mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Test TO_PAGES and FROM_PAGES macros
This commit is contained in:
parent
d136f9fd42
commit
a09790e4f2
@ -379,12 +379,12 @@ namespace Memory
|
||||
for (uint64_t i = 0; i < Info->Memory.Entries; i++)
|
||||
{
|
||||
if (Info->Memory.Entry[i].Type != Usable)
|
||||
this->ReservePages((void *)Info->Memory.Entry[i].BaseAddress, Info->Memory.Entry[i].Length / PAGE_SIZE + 1);
|
||||
this->ReservePages(Info->Memory.Entry[i].BaseAddress, TO_PAGES(Info->Memory.Entry[i].Length));
|
||||
}
|
||||
|
||||
trace("Locking bitmap pages...");
|
||||
this->ReservePages(0, 0x100);
|
||||
this->LockPages(PageBitmap.Buffer, PageBitmap.Size / PAGE_SIZE + 1);
|
||||
this->LockPages(PageBitmap.Buffer, TO_PAGES(PageBitmap.Size));
|
||||
}
|
||||
|
||||
Physical::Physical() {}
|
||||
|
59
Tests/Marco.cpp
Normal file
59
Tests/Marco.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
#include <types.h>
|
||||
#include <memory.hpp>
|
||||
#include <debug.h>
|
||||
|
||||
__constructor void TestMacros()
|
||||
{
|
||||
{
|
||||
int a = TO_PAGES(4096);
|
||||
int b = FROM_PAGES(2);
|
||||
|
||||
debug("a: 4096 -> %d", a);
|
||||
debug("b: a -> %d", b);
|
||||
|
||||
if (a != 2)
|
||||
{
|
||||
error("TO_PAGES is not equal to 2");
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
if (b != 8192)
|
||||
{
|
||||
error("FROM_PAGES is not equal to 8192");
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
debug("-------------------------");
|
||||
|
||||
{
|
||||
uintptr_t actual = PAGE_SIZE;
|
||||
int expected = 1;
|
||||
|
||||
for (int i = 0; i < 128; i++)
|
||||
{
|
||||
int a = TO_PAGES(actual);
|
||||
uintptr_t b = FROM_PAGES(expected);
|
||||
|
||||
/* TODO: This is a workaround for now. */
|
||||
if (a != expected + 1)
|
||||
{
|
||||
error("TO_PAGES is not equal to %d (actual: %d)", expected, a);
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
if (b != actual)
|
||||
{
|
||||
error("FROM_PAGES is not equal to %d (actual: %d)", actual, b);
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
actual += PAGE_SIZE;
|
||||
expected++;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user