X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86%2Fmm_phys.c;h=1b79650bd6e75ac47b1a0ed55a37524669e483de;hb=1e7db40300bc594cf708bb6082a6e05a268da946;hp=de30a9318ad4251d22f2106b379d7fbc4011f9da;hpb=60672c2c2c3add9d0c4c498ee79b3475c7b1afef;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86/mm_phys.c b/Kernel/arch/x86/mm_phys.c index de30a931..1b79650b 100644 --- a/Kernel/arch/x86/mm_phys.c +++ b/Kernel/arch/x86/mm_phys.c @@ -1,7 +1,8 @@ /* - AcessOS Microkernel Version - mm_phys.c -*/ + * Acess2 + * - Physical memory manager + */ +#define DEBUG 1 #include #include #include @@ -32,7 +33,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; @@ -65,7 +66,7 @@ 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) ); @@ -76,11 +77,7 @@ void MM_Install(tMBoot_Info *MBoot) memsetd(gaPageReferences, 1, kernelPages); for( num = kernelPages; num < giPageCount; num++ ) { - //if(gaPageBitmap[ num2 / 32 ] == 0) { - // memsetd(&gaPageReferences[num2], 0, 31-(num2&31)); - // num2 = (num2 + 32) & ~31; - //} else - gaPageReferences[num] = (gaPageBitmap[ num / 32 ] >> (num&31)) & 1; + gaPageReferences[num] = (gaPageBitmap[ num / 32 ] >> (num&31)) & 1; } } @@ -100,12 +97,11 @@ tPAddr MM_AllocPhys() for(a=0;gaSuperBitmap[a]==-1&&a0;c++); // Mark page used if(gaPageReferences) @@ -120,7 +116,47 @@ tPAddr MM_AllocPhys() // Release Spinlock RELEASE( &giPhysAlloc ); - //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; + Uint32 ret; + + LOCK( &giPhysAlloc ); + + // Find free page + for(a=0;gaSuperBitmap[a]==-1&&a> 10 ] &= ~(1 << ((Addr >> 5)&31));