Added more tests for memblock_alloc()
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
#include <time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <socks/types.h>
|
||||
#include <socks/memblock.h>
|
||||
@@ -22,6 +24,7 @@ static void *system_memory = NULL;
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
srand(time(NULL));
|
||||
system_memory = mmap(
|
||||
NULL,
|
||||
MB_TO_BYTES(MEMORY_SIZE_MB),
|
||||
@@ -50,8 +53,13 @@ int main(int argc, const char **argv)
|
||||
memblock_reserve(0x30000, 0x40000);
|
||||
memblock_reserve(0x100000, 0x10000);
|
||||
|
||||
phys_addr_t alloc = memblock_alloc_phys(512);
|
||||
printf("allocated 512 bytes at 0x%" PRIxPTR "\n", alloc);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
int size = 512 + (rand() % 16384);
|
||||
|
||||
phys_addr_t alloc = memblock_alloc_phys(size);
|
||||
printf("allocated %d bytes at 0x%" PRIxPTR "\n", size, alloc);
|
||||
}
|
||||
|
||||
|
||||
printf("memory regions:\n");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user