From 916c21af52dc2230d689e1075457c4c29b4b262c Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 15 May 2020 20:28:44 +0200 Subject: Added test-case for malloc --- src/kernel/memory/paging.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/kernel/memory/paging.c') diff --git a/src/kernel/memory/paging.c b/src/kernel/memory/paging.c index edaa82e..516f0f1 100644 --- a/src/kernel/memory/paging.c +++ b/src/kernel/memory/paging.c @@ -7,9 +7,9 @@ int paging_enabled = 0; u32 tmp[1024][1024] __attribute__((aligned(4096))); -struct page_directory *paging_kernel_directory = (struct page_directory *)tmp; - -struct page_directory *paging_directory; // Current +struct page_directory *paging_kernel_directory __attribute__((aligned(4096))) = + (struct page_directory *)tmp; +struct page_directory *paging_directory __attribute__((aligned(4096))); // Current void paging_init(struct page_directory *dir, int user) { @@ -47,6 +47,14 @@ void paging_install(u32 multiboot_address) log("Enabling"); paging_enable(); log("Installed paging"); + + u32 a = (u32)malloc(4096); + u32 b = (u32)malloc(4096); + free((void *)b); + free((void *)a); + u32 c = (u32)malloc(2048); + assert(a == c); + info("kmalloc test succeeded!"); } void paging_disable() @@ -189,4 +197,4 @@ u32 paging_get_used_pages() } } return n; -} +} \ No newline at end of file -- cgit v1.2.3