hos/mm.c

41 lines
911 B
C

// mm.c
// 09/01/03 Josh Holtrop
// 0x368000 is first available byte (this is right after the kernel @ 1mb and the initrd @ 2mb, 1440kb.
pageblock *first_pageblock = (pageblock *) 0;
dword totalmem = 0;
void mm_init()
{
dword *memmap_entries = (dword *) 0x9040A;
memmap_entry *maps = (memmap_entry *) 0x92000;
dword a;
for (a=0;a<(*memmap_entries);a++)
{
if (maps[a].attributes == 1) // (1) mem free to OS
{
if ((maps[a].base.lowdword + maps[a].limit.lowdword) > (FREERAM_START+4096)) //goes past where we start freeram
{
if (first_pageblock == 0) //no pageblock page set up yet
{
if (maps[a].base.lowdword < (FREERAM_START+4096))
{
first_pageblock = (pageblock *) FREERAM_START;
}
}
else
{
}
}
totalmem += maps[a].limit.lowdword;
}
}
printf("Total memory available to OS: %x", totalmem);
}