Implemented memblock_alloc()
This commit is contained in:
@@ -35,32 +35,36 @@ int main(int argc, const char **argv)
|
||||
|
||||
memblock_add(0, MB_TO_BYTES(MEMORY_SIZE_MB));
|
||||
|
||||
memblock_reserve(0x10000, 0x40000);
|
||||
memblock_reserve(0x00000, 0x40000);
|
||||
memblock_reserve(0x60000, 0x20000);
|
||||
memblock_reserve(0x30000, 0x40000);
|
||||
memblock_reserve(0x100000, 0x10000);
|
||||
|
||||
phys_addr_t alloc = memblock_alloc(512);
|
||||
printf("allocated 512 bytes at 0x%" PRIxPTR "\n", alloc);
|
||||
|
||||
printf("memory regions:\n");
|
||||
|
||||
memblock_iter_t it;
|
||||
for_each_mem_range(&it, 0, 0x100000) {
|
||||
printf("\t%08" PRIxPTR "-%08" PRIxPTR "\n",
|
||||
it.base,
|
||||
it.limit);
|
||||
it.it_base,
|
||||
it.it_limit);
|
||||
}
|
||||
|
||||
printf("reserved regions:\n");
|
||||
for_each_reserved_mem_range(&it, 0, 0x100000) {
|
||||
printf("\t%08" PRIxPTR "-%08" PRIxPTR "\n",
|
||||
it.base,
|
||||
it.limit);
|
||||
printf("\t%08" PRIxPTR "-%08" PRIxPTR " (%s)\n",
|
||||
it.it_base,
|
||||
it.it_limit,
|
||||
it.it_status == MEMBLOCK_ALLOC ? "allocated" : "reserved");
|
||||
}
|
||||
|
||||
printf("free regions:\n");
|
||||
for_each_free_mem_range(&it, 0, ULLONG_MAX) {
|
||||
printf("\t%08" PRIxPTR "-%08" PRIxPTR "\n",
|
||||
it.base,
|
||||
it.limit);
|
||||
it.it_base,
|
||||
it.it_limit);
|
||||
}
|
||||
|
||||
munmap(system_memory, MB_TO_BYTES(MEMORY_SIZE_MB));
|
||||
|
||||
Reference in New Issue
Block a user