X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86%2Fmm_virt.c;h=f22de243a96a65213d1fab7bd945ff23897c3256;hb=37de13c0c8c88fa6edba679c20becec15547533e;hp=8c59ea0fba5d3c11cd65f7d8b646f91c822576af;hpb=de86ddb7cb10ee403732f9207aba756f267ef3de;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86/mm_virt.c b/Kernel/arch/x86/mm_virt.c index 8c59ea0f..f22de243 100644 --- a/Kernel/arch/x86/mm_virt.c +++ b/Kernel/arch/x86/mm_virt.c @@ -16,12 +16,7 @@ #include #include -#if USE_PAE -# define TAB 21 -# define DIR 30 -#else -# define TAB 22 -#endif +#define TAB 22 #define KERNEL_STACKS 0xF0000000 #define KERNEL_STACK_SIZE 0x00008000 @@ -61,11 +56,7 @@ #define INVLPG(addr) __asm__ __volatile__ ("invlpg (%0)"::"r"(addr)) -#if USE_PAE -typedef Uint64 tTabEnt; -#else typedef Uint32 tTabEnt; -#endif // === IMPORTS === extern void _UsertextEnd, _UsertextBase; @@ -101,6 +92,13 @@ tMutex glTempMappings; tMutex glTempFractal; Uint32 gWorkerStacks[(NUM_WORKER_STACKS+31)/32]; int giLastUsedWorker = 0; +struct sPageInfo { + void *Node; + tVAddr Base; + Uint64 Offset; + int Length; + int Flags; +} *gaMappedRegions; // sizeof = 24 bytes // === CODE === /** @@ -109,11 +107,7 @@ Uint32 gWorkerStacks[(NUM_WORKER_STACKS+31)/32]; */ void MM_PreinitVirtual(void) { - #if USE_PAE - gaInitPageDir[ ((PAGE_TABLE_ADDR >> TAB)-3*512+3)*2 ] = ((tTabEnt)&gaInitPageDir - KERNEL_BASE) | 3; - #else gaInitPageDir[ PAGE_TABLE_ADDR >> 22 ] = ((tTabEnt)&gaInitPageDir - KERNEL_BASE) | 3; - #endif INVLPG( PAGE_TABLE_ADDR ); } @@ -125,23 +119,6 @@ void MM_InstallVirtual(void) { int i; - #if USE_PAE - // --- Pre-Allocate kernel tables - for( i = KERNEL_BASE >> TAB; i < 1024*4; i ++ ) - { - if( gaPAE_PageDir[ i ] ) continue; - - // Skip stack tables, they are process unique - if( i > KERNEL_STACKS >> TAB && i < KERNEL_STACKS_END >> TAB) { - gaPAE_PageDir[ i ] = 0; - continue; - } - // Preallocate table - gaPAE_PageDir[ i ] = MM_AllocPhys() | 3; - INVLPG( &gaPAE_PageTable[i*512] ); - memset( &gaPAE_PageTable[i*512], 0, 0x1000 ); - } - #else // --- Pre-Allocate kernel tables for( i = KERNEL_BASE>>22; i < 1024; i ++ ) { @@ -156,7 +133,6 @@ void MM_InstallVirtual(void) INVLPG( &gaPageTable[i*1024] ); memset( &gaPageTable[i*1024], 0, 0x1000 ); } - #endif // Unset kernel on the User Text pages for( i = ((tVAddr)&_UsertextEnd-(tVAddr)&_UsertextBase+0xFFF)/4096; i--; ) { @@ -169,11 +145,7 @@ void MM_InstallVirtual(void) */ void MM_FinishVirtualInit(void) { - #if USE_PAE - gaInitPDPT[ 0 ] = 0; - #else gaInitPageDir[ 0 ] = 0; - #endif } /** @@ -185,8 +157,7 @@ void MM_PageFault(tVAddr Addr, Uint ErrorCode, tRegs *Regs) //ENTER("xAddr bErrorCode", Addr, ErrorCode); // -- Check for COW -- - if( gaPageDir [Addr>>22] & PF_PRESENT - && gaPageTable[Addr>>12] & PF_PRESENT + if( gaPageDir [Addr>>22] & PF_PRESENT && gaPageTable[Addr>>12] & PF_PRESENT && gaPageTable[Addr>>12] & PF_COW ) { tPAddr paddr; @@ -205,7 +176,6 @@ void MM_PageFault(tVAddr Addr, Uint ErrorCode, tRegs *Regs) } INVLPG( Addr & ~0xFFF ); - //LEAVE('-') return; } @@ -315,8 +285,7 @@ void MM_DumpTables(tVAddr Start, tVAddr End) (expected & PF_COW ? "C" : "-"), (expected & PF_GLOBAL ? "G" : "-"), (expected & PF_USER ? "U" : "-"), - (expected & PF_WRITE ? "W" : "-"), - gaPageTable[page] & MASK, expected + (expected & PF_WRITE ? "W" : "-") ); expected = 0; } @@ -356,19 +325,16 @@ tPAddr MM_Allocate(tVAddr VAddr) { // Allocate directory paddr = MM_AllocPhys(); - //LOG("paddr = 0x%llx (new table)", paddr); if( paddr == 0 ) { Warning("MM_Allocate - Out of Memory (Called by %p)", __builtin_return_address(0)); //LEAVE('i',0); return 0; } - // Map + // Map and mark as user (if needed) gaPageDir[ VAddr >> 22 ] = paddr | 3; - // Mark as user if(VAddr < MM_USER_MAX) gaPageDir[ VAddr >> 22 ] |= PF_USER; INVLPG( &gaPageDir[ VAddr >> 22 ] ); - //LOG("Clearing new table"); memsetd( &gaPageTable[ (VAddr >> 12) & ~0x3FF ], 0, 1024 ); } // Check if the page is already allocated @@ -502,7 +468,6 @@ tVAddr MM_ClearUser(void) { Uint i, j; - // Copy Directories for( i = 0; i < (MM_USER_MAX>>22); i ++ ) { // Check if directory is not allocated @@ -511,7 +476,7 @@ tVAddr MM_ClearUser(void) continue; } - + // Deallocate tables for( j = 0; j < 1024; j ++ ) { if( gaPageTable[i*1024+j] & 1 ) @@ -519,6 +484,7 @@ tVAddr MM_ClearUser(void) gaPageTable[i*1024+j] = 0; } + // Deallocate directory MM_DerefPhys( gaPageDir[i] & ~0xFFF ); gaPageDir[i] = 0; INVLPG( &gaPageTable[i*1024] ); @@ -1091,10 +1057,3 @@ void MM_UnmapHWPages(tVAddr VAddr, Uint Number) Mutex_Release( &glTempMappings ); } -// --- EXPORTS --- -EXPORT(MM_GetPhysAddr); -EXPORT(MM_Map); -//EXPORT(MM_Unmap); -EXPORT(MM_MapHWPages); -EXPORT(MM_AllocDMA); -EXPORT(MM_UnmapHWPages);