/[gxemul]/trunk/src/cpus/memory_ppc.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_ppc.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 26 by dpavlin, Mon Oct 8 16:20:10 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: memory_ppc.c,v 1.23 2006/03/30 19:41:51 debug Exp $   *  $Id: memory_ppc.c,v 1.24 2006/06/24 21:47:23 debug Exp $
29   *   *
30   *  Included from cpu_ppc.c.   *  Included from cpu_ppc.c.
31   */   */
# Line 41  Line 41 
41   *  BAT translation. Returns -1 if there was no BAT hit, >= 0 for a hit.   *  BAT translation. Returns -1 if there was no BAT hit, >= 0 for a hit.
42   *  (0 for access denied, 1 for read-only, and 2 for read-write access allowed.)   *  (0 for access denied, 1 for read-only, and 2 for read-write access allowed.)
43   */   */
44  int ppc_bat(struct cpu *cpu, uint64_t vaddr, uint64_t *return_addr, int flags,  int ppc_bat(struct cpu *cpu, uint64_t vaddr, uint64_t *return_paddr, int flags,
45          int user)          int user)
46  {  {
47          int i, istart = 0, iend = 8, pp;          int i, istart = 0, iend = 8, pp;
# Line 78  int ppc_bat(struct cpu *cpu, uint64_t va Line 78  int ppc_bat(struct cpu *cpu, uint64_t va
78                  if ((vaddr & ~mask) != (ebs & ~mask))                  if ((vaddr & ~mask) != (ebs & ~mask))
79                          continue;                          continue;
80    
81                  *return_addr = (vaddr & mask) | (phys & ~mask);                  *return_paddr = (vaddr & mask) | (phys & ~mask);
82    
83                  pp = lower & BAT_PP;                  pp = lower & BAT_PP;
84                  switch (pp) {                  switch (pp) {
# Line 139  static int get_pte_low(struct cpu *cpu, Line 139  static int get_pte_low(struct cpu *cpu,
139   *  a permission violation. *resp is set to 0 for no access, 1 for read-only   *  a permission violation. *resp is set to 0 for no access, 1 for read-only
140   *  access, or 2 for read/write access.   *  access, or 2 for read/write access.
141   */   */
142  static int ppc_vtp32(struct cpu *cpu, uint32_t vaddr, uint64_t *return_addr,  static int ppc_vtp32(struct cpu *cpu, uint32_t vaddr, uint64_t *return_paddr,
143          int *resp, uint64_t msr, int writeflag, int instr)          int *resp, uint64_t msr, int writeflag, int instr)
144  {  {
145          int srn = (vaddr >> 28) & 15, api = (vaddr >> 22) & PTE_API;          int srn = (vaddr >> 28) & 15, api = (vaddr >> 22) & PTE_API;
# Line 186  static int ppc_vtp32(struct cpu *cpu, ui Line 186  static int ppc_vtp32(struct cpu *cpu, ui
186                  return 1;                  return 1;
187    
188          access = lower_pte & PTE_PP;          access = lower_pte & PTE_PP;
189          *return_addr = (lower_pte & PTE_RPGN) | (vaddr & ~PTE_RPGN);          *return_paddr = (lower_pte & PTE_RPGN) | (vaddr & ~PTE_RPGN);
190    
191          key = (cpu->cd.ppc.sr[srn] & SR_PRKEY && msr & PPC_MSR_PR) ||          key = (cpu->cd.ppc.sr[srn] & SR_PRKEY && msr & PPC_MSR_PR) ||
192              (cpu->cd.ppc.sr[srn] & SR_SUKEY && !(msr & PPC_MSR_PR));              (cpu->cd.ppc.sr[srn] & SR_SUKEY && !(msr & PPC_MSR_PR));
# Line 212  static int ppc_vtp32(struct cpu *cpu, ui Line 212  static int ppc_vtp32(struct cpu *cpu, ui
212    
213    
214  /*  /*
215   *  ppc_translate_address():   *  ppc_translate_v2p():
216   *   *
217   *  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.
218   *   *
# Line 221  static int ppc_vtp32(struct cpu *cpu, ui Line 221  static int ppc_vtp32(struct cpu *cpu, ui
221   *      1  Success, the page is readable only   *      1  Success, the page is readable only
222   *      2  Success, the page is read/write   *      2  Success, the page is read/write
223   */   */
224  int ppc_translate_address(struct cpu *cpu, uint64_t vaddr,  int ppc_translate_v2p(struct cpu *cpu, uint64_t vaddr,
225          uint64_t *return_addr, int flags)          uint64_t *return_paddr, int flags)
226  {  {
227          int instr = flags & FLAG_INSTR, res = 0, match, user;          int instr = flags & FLAG_INSTR, res = 0, match, user;
228          int writeflag = flags & FLAG_WRITEFLAG? 1 : 0;          int writeflag = flags & FLAG_WRITEFLAG? 1 : 0;
# Line 235  int ppc_translate_address(struct cpu *cp Line 235  int ppc_translate_address(struct cpu *cp
235                  vaddr &= 0xffffffff;                  vaddr &= 0xffffffff;
236    
237          if ((instr && !(msr & PPC_MSR_IR)) || (!instr && !(msr & PPC_MSR_DR))) {          if ((instr && !(msr & PPC_MSR_IR)) || (!instr && !(msr & PPC_MSR_DR))) {
238                  *return_addr = vaddr;                  *return_paddr = vaddr;
239                  return 2;                  return 2;
240          }          }
241    
242          if (cpu->cd.ppc.cpu_type.flags & PPC_601) {          if (cpu->cd.ppc.cpu_type.flags & PPC_601) {
243                  fatal("ppc_translate_address(): TODO: 601\n");                  fatal("ppc_translate_v2p(): TODO: 601\n");
244                  exit(1);                  exit(1);
245          }          }
246    
247          /*  Try the BATs first:  */          /*  Try the BATs first:  */
248          if (cpu->cd.ppc.bits == 32) {          if (cpu->cd.ppc.bits == 32) {
249                  res = ppc_bat(cpu, vaddr, return_addr, flags, user);                  res = ppc_bat(cpu, vaddr, return_paddr, flags, user);
250                  if (res > 0)                  if (res > 0)
251                          return res;                          return res;
252                  if (res == 0) {                  if (res == 0) {
# Line 257  int ppc_translate_address(struct cpu *cp Line 257  int ppc_translate_address(struct cpu *cp
257    
258          /*  Virtual to physical translation:  */          /*  Virtual to physical translation:  */
259          if (cpu->cd.ppc.bits == 32) {          if (cpu->cd.ppc.bits == 32) {
260                  match = ppc_vtp32(cpu, vaddr, return_addr, &res, msr,                  match = ppc_vtp32(cpu, vaddr, return_paddr, &res, msr,
261                      writeflag, instr);                      writeflag, instr);
262                  if (match && res > 0)                  if (match && res > 0)
263                          return res;                          return res;

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

  ViewVC Help
Powered by ViewVC 1.1.26