4 * ARM7 Virtual Memory Manager
5 * - arch/arm7/mm_virt.c
18 Uint32 *gMM_KernelTable0 = (void*)MM_TABLE0KERN;
19 Uint32 *gMM_KernelTable1 = (void*)MM_TABLE1KERN;
22 int MM_InitialiseVirtual(void)
26 int MM_int_GetPageInfo(tVAddr VAddr, tMM_PageInfo *pi)
28 Uint32 *table0, table1;
31 if(VAddr & 0x80000000 ) {
32 table0 = MM_TABLE0KERN;
33 table1 = MM_TABLE1KERN;
36 table0 = MM_TABLE0USER;
37 table1 = MM_TABLE1USER;
41 desc = table0[ VAddr >> 20 ];
52 // 1: Coarse page table
54 // Domain from top level table
55 pi->Domain = (desc >> 5) & 7;
57 desc = table1[ VAddr >> 12 ];
64 // 1: Large Page (64KiB)
67 pi->PhysAddr = desc & 0xFFFF0000;
73 pi->PhysAddr = desc & 0xFFFFF000;
74 pi->bExecutable = desc & 1;
75 pi->bGlobal = !(desc >> 11);
76 pi->bSharec = (desc >> 10) & 1;
81 // 2: Section (or Supersection)
83 if( desc & (1 << 18) ) {
85 pi->PhysAddr = desc & 0xFF000000;
86 pi->PhysAddr |= ((desc >> 20) & 0xF) << 32;
87 pi->PhysAddr |= ((desc >> 5) & 0x7) << 36;
89 pi->Domain = 0; // Superpages default to zero
94 pi->PhysAddr = desc & 0xFFF80000;
96 pi->Domain = (desc >> 5) & 7;
99 // 3: Reserved (invalid)
109 tPAddr MM_GetPhysAddr(tVAddr VAddr)
112 if( MM_int_GetPageInfo(VAddr, &pi) )