Code: Select all
UInt32 i = multibootHeader->mmap_addr;
while (i < multibootHeader->mmap_addr + multibootHeader->mmap_length)
{
struct MultibootMMapEntry *me = (struct MultibootMMapEntry*)i;
// Does this entry specify usable RAM?
if (me->type == 1)
{
// For every page in this entry, add to the free page stack.
for (UInt32 j = (me->base_addr_low & 0xFFFFF000) + 0x1000; j <= me->base_addr_low + me->length_low - 0x1000; j += 0x1000)
FreeFrame(j);
}
i += me->size + sizeof(UInt32);
}
Code: Select all
unsigned int *frameStackTop = 0;
void FreeFrame(unsigned int frame)
{
frame &= 0xFFFFF000;
*(unsigned int*)frame = (unsigned int)frameStackTop;
frameStackTop = (unsigned int*)frame;
}
Is there anything simple I'm overlooking here?