/[gxemul]/trunk/src/cpus/memory_arm.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/cpus/memory_arm.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 24 by dpavlin, Mon Oct 8 16:19:56 2007 UTC revision 28 by dpavlin, Mon Oct 8 16:20:26 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: memory_arm.c,v 1.34 2006/06/02 18:11:38 debug Exp $   *  $Id: memory_arm.c,v 1.36 2006/07/14 16:33:28 debug Exp $
29   *   *
30   *   *
31   *  TODO/NOTE:  The B and/or C bits could also cause the return value to   *  TODO/NOTE:  The B and/or C bits could also cause the return value to
# Line 48  extern int quiet_mode; Line 48  extern int quiet_mode;
48    
49    
50  /*  /*
51   *  arm_translate_address():   *  arm_translate_v2p():
52   *   *
53   *  Address translation with the MMU disabled.   *  Address translation with the MMU disabled. (Just treat the virtual address
54     *  as a physical address.)
55   */   */
56  int arm_translate_address(struct cpu *cpu, uint64_t vaddr64,  int arm_translate_v2p(struct cpu *cpu, uint64_t vaddr64,
57          uint64_t *return_addr, int flags)          uint64_t *return_paddr, int flags)
58  {  {
59          *return_addr = vaddr64 & 0xffffffff;          *return_paddr = vaddr64 & 0xffffffff;
60    
61          return 2;          return 2;
62  }  }
63    
# Line 101  static int arm_check_access(struct cpu * Line 103  static int arm_check_access(struct cpu *
103    
104    
105  /*  /*
106   *  arm_translate_address_mmu():   *  arm_translate_v2p_mmu():
107   *   *
108   *  Don't call this function is userland_emul is non-NULL, or cpu is NULL.   *  Don't call this function is userland_emul is non-NULL, or cpu is NULL.
109   *   *
# Line 113  static int arm_check_access(struct cpu * Line 115  static int arm_check_access(struct cpu *
115   *  If this is a 1KB page access, then the return value is ORed with   *  If this is a 1KB page access, then the return value is ORed with
116   *  MEMORY_NOT_FULL_PAGE.   *  MEMORY_NOT_FULL_PAGE.
117   */   */
118  int arm_translate_address_mmu(struct cpu *cpu, uint64_t vaddr64,  int arm_translate_v2p_mmu(struct cpu *cpu, uint64_t vaddr64,
119          uint64_t *return_addr, int flags)          uint64_t *return_paddr, int flags)
120  {  {
121          unsigned char *q;          unsigned char *q;
122          uint32_t addr, d=0, d2 = (uint32_t)(int32_t)-1, ptba, vaddr = vaddr64;          uint32_t addr, d=0, d2 = (uint32_t)(int32_t)-1, ptba, vaddr = vaddr64;
# Line 134  int arm_translate_address_mmu(struct cpu Line 136  int arm_translate_address_mmu(struct cpu
136    
137          if (cpu->cd.arm.translation_table == NULL ||          if (cpu->cd.arm.translation_table == NULL ||
138              cpu->cd.arm.ttb != cpu->cd.arm.last_ttb) {              cpu->cd.arm.ttb != cpu->cd.arm.last_ttb) {
                 uint32_t ofs;  
139                  cpu->cd.arm.translation_table = memory_paddr_to_hostaddr(                  cpu->cd.arm.translation_table = memory_paddr_to_hostaddr(
140                      cpu->mem, cpu->cd.arm.ttb & 0x0fffffff, 0);                      cpu->mem, cpu->cd.arm.ttb & 0x0fffffff, 0);
                 if (cpu->cd.arm.translation_table != NULL) {  
                         ofs = cpu->cd.arm.ttb & ((1 << BITS_PER_MEMBLOCK) - 1);  
                         cpu->cd.arm.translation_table += ofs;  
                 }  
141                  cpu->cd.arm.last_ttb = cpu->cd.arm.ttb;                  cpu->cd.arm.last_ttb = cpu->cd.arm.ttb;
142          }          }
143    
# Line 178  int arm_translate_address_mmu(struct cpu Line 175  int arm_translate_address_mmu(struct cpu
175                          printf("arm memory blah blah adfh asfg asdgasdg\n");                          printf("arm memory blah blah adfh asfg asdgasdg\n");
176                          exit(1);                          exit(1);
177                  }                  }
178                  d2 = *(uint32_t *)(q + (addr & ((1 << BITS_PER_MEMBLOCK) - 1)));                  d2 = *(uint32_t *)(q);
179  #ifdef HOST_LITTLE_ENDIAN  #ifdef HOST_LITTLE_ENDIAN
180                  if (cpu->byte_order == EMUL_BIG_ENDIAN)                  if (cpu->byte_order == EMUL_BIG_ENDIAN)
181  #else  #else
# Line 198  int arm_translate_address_mmu(struct cpu Line 195  int arm_translate_address_mmu(struct cpu
195                          case 0xc000:    ap >>= 6; break;                          case 0xc000:    ap >>= 6; break;
196                          }                          }
197                          ap &= 3;                          ap &= 3;
198                          *return_addr = (d2 & 0xffff0000) | (vaddr & 0x0000ffff);                          *return_paddr = (d2 & 0xffff0000)|(vaddr & 0x0000ffff);
199                          break;                          break;
200                  case 3: if (cpu->cd.arm.cpu_type.flags & ARM_XSCALE) {                  case 3: if (cpu->cd.arm.cpu_type.flags & ARM_XSCALE) {
201                                  /*  4KB page (Xscale)  */                                  /*  4KB page (Xscale)  */
# Line 207  int arm_translate_address_mmu(struct cpu Line 204  int arm_translate_address_mmu(struct cpu
204                                  /*  1KB page  */                                  /*  1KB page  */
205                                  subpage = 1;                                  subpage = 1;
206                                  ap = (d2 >> 4) & 3;                                  ap = (d2 >> 4) & 3;
207                                  *return_addr = (d2 & 0xfffffc00) |                                  *return_paddr = (d2 & 0xfffffc00) |
208                                      (vaddr & 0x000003ff);                                      (vaddr & 0x000003ff);
209                                  break;                                  break;
210                          }                          }
# Line 231  int arm_translate_address_mmu(struct cpu Line 228  int arm_translate_address_mmu(struct cpu
228                                  if (ap0 != ap1 || ap0 != ap2 || ap0 != ap3)                                  if (ap0 != ap1 || ap0 != ap2 || ap0 != ap3)
229                                          subpage = 1;                                          subpage = 1;
230                          }                          }
231                          *return_addr = (d2 & 0xfffff000) | (vaddr & 0x00000fff);                          *return_paddr = (d2 & 0xfffff000)|(vaddr & 0x00000fff);
232                          break;                          break;
233                  }                  }
234                  access = arm_check_access(cpu, ap, dav, user);                  access = arm_check_access(cpu, ap, dav, user);
# Line 245  int arm_translate_address_mmu(struct cpu Line 242  int arm_translate_address_mmu(struct cpu
242                          fs = FAULT_DOMAIN_S;                          fs = FAULT_DOMAIN_S;
243                          goto exception_return;                          goto exception_return;
244                  }                  }
245                  *return_addr = (d & 0xfff00000) | (vaddr & 0x000fffff);                  *return_paddr = (d & 0xfff00000) | (vaddr & 0x000fffff);
246                  ap = (d >> 10) & 3;                  ap = (d >> 10) & 3;
247                  access = arm_check_access(cpu, ap, dav, user);                  access = arm_check_access(cpu, ap, dav, user);
248                  if (access > writeflag)                  if (access > writeflag)

Legend:
Removed from v.24  
changed lines
  Added in v.28

  ViewVC Help
Powered by ViewVC 1.1.26