low-level physmem memory free function

alentours-dev
q3k 2012-10-30 11:53:21 +01:00
parent 22000db5e9
commit 338f5b1a83
2 changed files with 14 additions and 0 deletions

View File

@ -14,4 +14,7 @@ u64 physmem_physical_to_page(u64 Physical);
// Read physical data
void physmem_read(u64 Base, u64 Size, void *Destination);
// Return how much memory is free (including not reserved by system)
u64 physmem_get_free(void);
#endif

View File

@ -82,3 +82,14 @@ void physmem_read(u64 Base, u64 Size, void *Destination)
OffsetInSource++;
}
}
u64 physmem_get_free(void)
{
u64 Accumulator = 0;
for (u64 i = g_TopFrame; i <= g_MemorySize; i += PHYSMEM_PAGE_SIZE)
{
if (system_memory_available(i, PHYSMEM_PAGE_SIZE))
Accumulator += PHYSMEM_PAGE_SIZE;
}
return Accumulator;
}