mirror of
https://gitlab.os-k.eu/os-k-team/os-k.git
synced 2023-08-25 14:03:10 +02:00
Page allocator functionnal #67
This commit is contained in:
parent
2df15a1488
commit
2bec082b2d
@ -39,7 +39,9 @@ typedef struct AllocatedPage_t{
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
error_t MmGetFreePageFrame(void **framePtr, size_t *pageNumber, size_t size);
|
||||
ulong MmAllocPageFrame(void **frameListPtr, size_t *pageNumber, size_t size, bool contiguous);
|
||||
void MmFreePageFrame(ulong id);
|
||||
|
||||
error_t MmTestBusyPage(void);
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
@ -100,9 +100,9 @@ static void removePageFromBusyList(void *phyPageAddr)
|
||||
}
|
||||
|
||||
//
|
||||
// Returns an id to identify a page frame allocated
|
||||
// Returns an id to identify a page frame allocated (kernel)
|
||||
//
|
||||
ulong MmAllocKernelPageFrame(void **frameListPtr, size_t *pageNumber, size_t size, bool contiguous)
|
||||
ulong MmAllocPageFrame(void **frameListPtr, size_t *pageNumber, size_t size, bool contiguous)
|
||||
{
|
||||
static ulong id = 0;
|
||||
*pageNumber = (((ulong)size - 1) / KPAGESIZE) + 1;
|
||||
@ -143,7 +143,7 @@ ulong MmAllocKernelPageFrame(void **frameListPtr, size_t *pageNumber, size_t siz
|
||||
return id;
|
||||
}
|
||||
|
||||
void MmFreeKernelPageFrame(ulong id)
|
||||
void MmFreePageFrame(ulong id)
|
||||
{
|
||||
AllocatedPage_t *busyPage = &busyPagesList;
|
||||
|
||||
@ -164,50 +164,50 @@ error_t MmTestBusyPage(void)
|
||||
DebugLog("\nAlloc 6677 bytes\n");
|
||||
void **ptr = NULL;
|
||||
size_t n = 0;
|
||||
ulong id1 = MmAllocKernelPageFrame (ptr, &n, 6677, false);
|
||||
ulong id1 = MmAllocPageFrame (ptr, &n, 6677, false);
|
||||
|
||||
DebugLog("\nAlloc 9045 bytes\n");
|
||||
void **ptr2 = NULL;
|
||||
size_t n2 = 0;
|
||||
ulong id2 = MmAllocKernelPageFrame (ptr2, &n2, 9045, false);
|
||||
ulong id2 = MmAllocPageFrame (ptr2, &n2, 9045, false);
|
||||
|
||||
DebugLog("\nAlloc 1200 bytes\n");
|
||||
void **ptr3 = NULL;
|
||||
size_t n3 = 0;
|
||||
ulong id3 = MmAllocKernelPageFrame (ptr3, &n3, 1200, false);
|
||||
ulong id3 = MmAllocPageFrame (ptr3, &n3, 1200, false);
|
||||
|
||||
DebugLog("\nAlloc 4096 bytes\n");
|
||||
void **ptr4 = NULL;
|
||||
size_t n4 = 0;
|
||||
ulong id4 = MmAllocKernelPageFrame (ptr3, &n3, 4096, false);
|
||||
ulong id4 = MmAllocPageFrame (ptr3, &n3, 4096, false);
|
||||
|
||||
DebugLog("\nAlloc 4097 bytes\n");
|
||||
void **ptr5 = NULL;
|
||||
size_t n5 = 0;
|
||||
ulong id5 = MmAllocKernelPageFrame (ptr3, &n3, 4097, false);
|
||||
ulong id5 = MmAllocPageFrame (ptr3, &n3, 4097, false);
|
||||
|
||||
printBusyPages();
|
||||
|
||||
DebugLog("\nFree 6677 and 1200 bytes\n");
|
||||
MmFreeKernelPageFrame(id1);
|
||||
MmFreeKernelPageFrame(id3);
|
||||
MmFreePageFrame(id1);
|
||||
MmFreePageFrame(id3);
|
||||
|
||||
DebugLog("\nAlloc 10000 bytes\n");
|
||||
void **ptr6 = NULL;
|
||||
size_t n6 = 0;
|
||||
ulong id6 = MmAllocKernelPageFrame (ptr3, &n3, 10000, false);
|
||||
ulong id6 = MmAllocPageFrame (ptr3, &n3, 10000, false);
|
||||
|
||||
printBusyPages();
|
||||
|
||||
DebugLog("\nFree 10000 bytes\n");
|
||||
MmFreeKernelPageFrame(id6);
|
||||
MmFreePageFrame(id6);
|
||||
|
||||
printBusyPages();
|
||||
|
||||
DebugLog("\nAlloc 10000 bytes contiguous\n");
|
||||
void **ptr7 = NULL;
|
||||
size_t n7 = 0;
|
||||
ulong id7 = MmAllocKernelPageFrame (ptr3, &n3, 10000, true);
|
||||
ulong id7 = MmAllocPageFrame (ptr3, &n3, 10000, true);
|
||||
|
||||
printBusyPages();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user