X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86%2Fmm_phys.c;h=c7de9beb8f5bc41fd6ff063fe71515ee17a3eaa6;hb=709179721ccc250f5d09f5bfc13f65df6cac6fed;hp=2727c018ab277fe71ebb0aea060659569f5ab6c0;hpb=3d261aba7f8108798d731d6cd85c445f46a41024;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86/mm_phys.c b/Kernel/arch/x86/mm_phys.c index 2727c018..c7de9beb 100644 --- a/Kernel/arch/x86/mm_phys.c +++ b/Kernel/arch/x86/mm_phys.c @@ -1,7 +1,7 @@ /* - AcessOS Microkernel Version - mm_phys.c -*/ + * Acess2 + * - Physical memory manager + */ #define DEBUG 1 #include #include @@ -13,9 +13,10 @@ extern void gKernelEnd; // === PROTOTYPES === -Uint32 MM_AllocPhys(); -void MM_RefPhys(Uint32 Addr); -void MM_DerefPhys(Uint32 Addr); +tPAddr MM_AllocPhys(); +tPAddr MM_AllocPhysRange(int Pages); +void MM_RefPhys(tPAddr Addr); +void MM_DerefPhys(tPAddr Addr); // === GLOBALS === int giPhysAlloc = 0; @@ -33,7 +34,7 @@ void MM_Install(tMBoot_Info *MBoot) // Initialise globals giPageCount = (MBoot->HighMem >> 2) + 256; // HighMem is a kByte value - LOG("giPageCount = %i", giPageCount); + //LOG("giPageCount = %i", giPageCount); // Get used page count kernelPages = (Uint)&gKernelEnd - KERNEL_BASE; @@ -66,12 +67,13 @@ void MM_Install(tMBoot_Info *MBoot) } // Allocate References - LOG("Reference Pages %i", (giPageCount*4+0xFFF)>>12); + //LOG("Reference Pages %i", (giPageCount*4+0xFFF)>>12); for(num = 0; num < (giPageCount*4+0xFFF)>>12; num++) { MM_Allocate( REFERENCE_BASE + (num<<12) ); } + //LOG("Filling"); // Fill references gaPageReferences = (void*)REFERENCE_BASE; memsetd(gaPageReferences, 1, kernelPages); @@ -89,7 +91,7 @@ tPAddr MM_AllocPhys() { int num = giPageCount / 32 / 32; int a, b, c; - Uint32 ret; + tPAddr ret; LOCK( &giPhysAlloc ); @@ -102,7 +104,6 @@ tPAddr MM_AllocPhys() } for(b=0;gaSuperBitmap[a]&(1<0;c++); // Mark page used if(gaPageReferences) @@ -117,8 +118,47 @@ tPAddr MM_AllocPhys() // Release Spinlock RELEASE( &giPhysAlloc ); - LOG("Allocated 0x%x\n", ret); - //LOG("ret = %x", ret); + + return ret; +} + +/** + * \fn tPAddr MM_AllocPhysRange(int Pages) + * \brief Allocate a range of physical pages + * \param Pages Number of pages to allocate + */ +tPAddr MM_AllocPhysRange(int Pages) +{ + int num = giPageCount / 32 / 32; + int a, b, c; + tPAddr ret; + + LOCK( &giPhysAlloc ); + + // Find free page + for(a=0;gaSuperBitmap[a]==-1&&a> 10 ] &= ~(1 << ((Addr >> 5)&31));