Page allocator functionnal #67
This commit is contained in:
parent
2bec082b2d
commit
d13472712d
|
@ -37,6 +37,9 @@ typedef struct AllocatedPage_t{
|
||||||
struct AllocatedPage_t *next;
|
struct AllocatedPage_t *next;
|
||||||
} AllocatedPage_t;
|
} AllocatedPage_t;
|
||||||
|
|
||||||
|
#define CONTIGUOUS true
|
||||||
|
#define NORMAL false
|
||||||
|
|
||||||
//----------------------------------------------------------------------------//
|
//----------------------------------------------------------------------------//
|
||||||
|
|
||||||
ulong MmAllocPageFrame(void **frameListPtr, size_t *pageNumber, size_t size, bool contiguous);
|
ulong MmAllocPageFrame(void **frameListPtr, size_t *pageNumber, size_t size, bool contiguous);
|
||||||
|
|
|
@ -143,6 +143,9 @@ ulong MmAllocPageFrame(void **frameListPtr, size_t *pageNumber, size_t size, boo
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Frees a page frame by its id
|
||||||
|
//
|
||||||
void MmFreePageFrame(ulong id)
|
void MmFreePageFrame(ulong id)
|
||||||
{
|
{
|
||||||
AllocatedPage_t *busyPage = &busyPagesList;
|
AllocatedPage_t *busyPage = &busyPagesList;
|
||||||
|
@ -164,27 +167,27 @@ error_t MmTestBusyPage(void)
|
||||||
DebugLog("\nAlloc 6677 bytes\n");
|
DebugLog("\nAlloc 6677 bytes\n");
|
||||||
void **ptr = NULL;
|
void **ptr = NULL;
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
ulong id1 = MmAllocPageFrame (ptr, &n, 6677, false);
|
ulong id1 = MmAllocPageFrame (ptr, &n, 6677, NORMAL);
|
||||||
|
|
||||||
DebugLog("\nAlloc 9045 bytes\n");
|
DebugLog("\nAlloc 9045 bytes\n");
|
||||||
void **ptr2 = NULL;
|
void **ptr2 = NULL;
|
||||||
size_t n2 = 0;
|
size_t n2 = 0;
|
||||||
ulong id2 = MmAllocPageFrame (ptr2, &n2, 9045, false);
|
ulong id2 = MmAllocPageFrame (ptr2, &n2, 9045, NORMAL);
|
||||||
|
|
||||||
DebugLog("\nAlloc 1200 bytes\n");
|
DebugLog("\nAlloc 1200 bytes\n");
|
||||||
void **ptr3 = NULL;
|
void **ptr3 = NULL;
|
||||||
size_t n3 = 0;
|
size_t n3 = 0;
|
||||||
ulong id3 = MmAllocPageFrame (ptr3, &n3, 1200, false);
|
ulong id3 = MmAllocPageFrame (ptr3, &n3, 1200, NORMAL);
|
||||||
|
|
||||||
DebugLog("\nAlloc 4096 bytes\n");
|
DebugLog("\nAlloc 4096 bytes\n");
|
||||||
void **ptr4 = NULL;
|
void **ptr4 = NULL;
|
||||||
size_t n4 = 0;
|
size_t n4 = 0;
|
||||||
ulong id4 = MmAllocPageFrame (ptr3, &n3, 4096, false);
|
ulong id4 = MmAllocPageFrame (ptr3, &n3, 4096, NORMAL);
|
||||||
|
|
||||||
DebugLog("\nAlloc 4097 bytes\n");
|
DebugLog("\nAlloc 4097 bytes\n");
|
||||||
void **ptr5 = NULL;
|
void **ptr5 = NULL;
|
||||||
size_t n5 = 0;
|
size_t n5 = 0;
|
||||||
ulong id5 = MmAllocPageFrame (ptr3, &n3, 4097, false);
|
ulong id5 = MmAllocPageFrame (ptr3, &n3, 4097, NORMAL);
|
||||||
|
|
||||||
printBusyPages();
|
printBusyPages();
|
||||||
|
|
||||||
|
@ -195,7 +198,7 @@ error_t MmTestBusyPage(void)
|
||||||
DebugLog("\nAlloc 10000 bytes\n");
|
DebugLog("\nAlloc 10000 bytes\n");
|
||||||
void **ptr6 = NULL;
|
void **ptr6 = NULL;
|
||||||
size_t n6 = 0;
|
size_t n6 = 0;
|
||||||
ulong id6 = MmAllocPageFrame (ptr3, &n3, 10000, false);
|
ulong id6 = MmAllocPageFrame (ptr3, &n3, 10000, NORMAL);
|
||||||
|
|
||||||
printBusyPages();
|
printBusyPages();
|
||||||
|
|
||||||
|
@ -207,10 +210,9 @@ error_t MmTestBusyPage(void)
|
||||||
DebugLog("\nAlloc 10000 bytes contiguous\n");
|
DebugLog("\nAlloc 10000 bytes contiguous\n");
|
||||||
void **ptr7 = NULL;
|
void **ptr7 = NULL;
|
||||||
size_t n7 = 0;
|
size_t n7 = 0;
|
||||||
ulong id7 = MmAllocPageFrame (ptr3, &n3, 10000, true);
|
ulong id7 = MmAllocPageFrame (ptr3, &n3, 10000, CONTIGUOUS);
|
||||||
|
|
||||||
printBusyPages();
|
printBusyPages();
|
||||||
|
|
||||||
return EOK;
|
return EOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue