/[gxemul]/trunk/src/cpus/memory_alpha.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_alpha.c

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

revision 26 by dpavlin, Mon Oct 8 16:20:10 2007 UTC revision 32 by dpavlin, Mon Oct 8 16:20:58 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: memory_alpha.c,v 1.3 2006/06/24 21:47:23 debug Exp $   *  $Id: memory_alpha.c,v 1.7 2006/10/08 02:28:58 debug Exp $
29   */   */
30    
31  #include <stdio.h>  #include <stdio.h>
# Line 37  Line 37 
37  #include "memory.h"  #include "memory.h"
38  #include "misc.h"  #include "misc.h"
39    
40    #include "alpha_rpb.h"
41    
42    
43  /*  /*
44   *  alpha_translate_v2p():   *  alpha_translate_v2p():
# Line 44  Line 46 
46  int alpha_translate_v2p(struct cpu *cpu, uint64_t vaddr,  int alpha_translate_v2p(struct cpu *cpu, uint64_t vaddr,
47          uint64_t *return_paddr, int flags)          uint64_t *return_paddr, int flags)
48  {  {
49          *return_paddr = vaddr & 0x000003ffffffffffULL;          uint64_t base = cpu->cd.alpha.pcb.apcb_ptbr << ALPHA_PAGESHIFT;
50            uint64_t addr, pte1, pte2, pte3;
51            int i1, i2, i3;
52            unsigned char *pt_entry_ptr;
53    
54            /*  Kernel direct-mapped space:  */
55            if ((vaddr & ~0x1ffffffffffULL) == 0xfffffc0000000000ULL) {
56                    *return_paddr = vaddr & 0x000003ffffffffffULL;
57                    return 2;
58            }
59    
60            i1 = (vaddr >> 33) & 0x3ff;
61            i2 = (vaddr >> 23) & 0x3ff;
62            i3 = (vaddr >> 13) & 0x3ff;
63    
64            debug("base = 0x%016"PRIx64"\n", base);
65            debug("i1=0x%x i2=0x%x i3=0x%x\n", i1, i2, i3);
66    
67            addr = base + i1 * sizeof(uint64_t);
68    
69            pt_entry_ptr = memory_paddr_to_hostaddr(cpu->mem, addr, 0);
70            if (pt_entry_ptr == NULL)
71                    goto not_found;
72    
73            pte1 = *(uint64_t *)(pt_entry_ptr);
74            pte1 = LE64_TO_HOST(pte1);
75    
76            debug("pte1 = 0x%016"PRIx64"\n", pte1);
77    
78            addr = ((pte1 >> 32) << ALPHA_PAGESHIFT) + (i2 * sizeof(uint64_t));
79    
80            pt_entry_ptr = memory_paddr_to_hostaddr(cpu->mem, addr, 0);
81            if (pt_entry_ptr == NULL)
82                    goto not_found;
83    
84            pte2 = *(uint64_t *)(pt_entry_ptr);
85            pte2 = LE64_TO_HOST(pte2);
86    
87            debug("pte2 = 0x%016"PRIx64"\n", pte2);
88    
89            addr = ((pte2 >> 32) << ALPHA_PAGESHIFT) + (i3 * sizeof(uint64_t));
90    
91            pt_entry_ptr = memory_paddr_to_hostaddr(cpu->mem, addr, 0);
92            if (pt_entry_ptr == NULL)
93                    goto not_found;
94    
95            pte3 = *(uint64_t *)(pt_entry_ptr);
96            pte3 = LE64_TO_HOST(pte3);
97    
98            debug("pte3 = 0x%016"PRIx64"\n", pte3);
99    
100    not_found:
101            /*  No match.  */
102            debug("[ alpha_translate_v2p: 0x%016"PRIx64" wasn't found ]\n", vaddr);
103    
104    #if 1
105          /*  UGLY hack for now:  */          /*  UGLY hack for now:  */
106          /*  TODO: Real virtual memory support.  */          /*  TODO: Real virtual memory support.  */
107            *return_paddr = vaddr & 0x000003ffffffffffULL;
108    
109            if ((vaddr & ~0x7fff) == 0x0000000010000000ULL)
110                    *return_paddr = (vaddr & 0x7fff) + HWRPB_PADDR;
111    
112          if ((vaddr & ~0xffff) == 0xfffffc0010000000ULL ||          if ((vaddr & ~0xffffff) == 0xfffffe0000000000ULL)
113              (vaddr & ~0xffff) == 0x0000000010000000ULL)                  *return_paddr = 0x7efa000 + (vaddr & 0xffffff);
                 *return_paddr = (vaddr & 0x0fffffff) +  
                     (cpu->machine->physical_ram_in_mb-1) * 1048576;  
   
         /*  At 0x20000000, NetBSD stores temp prom data  */  
         if ((vaddr & ~0x1fff) == 0xfffffc0020000000ULL ||  
             (vaddr & ~0x1fff) == 0x0000000020000000ULL)  
                 *return_paddr = (vaddr & 0x0fffffff) + 512*1024 +  
                     (cpu->machine->physical_ram_in_mb-1) * 1048576;  
114    
115          /*  printf("yo %016"PRIx64" %016"PRIx64"\n", vaddr, *return_paddr);  */          /*  At 0x20000000, NetBSD stores 8KB temp prom data  */
116            if ((vaddr & ~0x1fff) == 0x0000000020000000ULL)
117                    *return_paddr = (vaddr & 0x1fff) + PROM_ARGSPACE_PADDR;
118    
119          return 2;          return 2;
120    #else
121            return 0;
122    #endif
123  }  }
124    

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

  ViewVC Help
Powered by ViewVC 1.1.26