From 773f55466e0da51690f271779b2e4cf90c790903 Mon Sep 17 00:00:00 2001 From: Starnakin Date: Tue, 26 Nov 2024 14:16:46 +0100 Subject: [PATCH] add: memory test --- src/kernel.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/kernel.c b/src/kernel.c index bb0c6fc..61b2b6f 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -69,11 +69,25 @@ void kernel_main(multiboot_info_t *mbd, uint32_t magic) // PRINT_PTR(alloc_frame()); if (false) { - void *ptr; - while ((ptr = alloc_pages(PAGE_SIZE * 1))) { - if (ptr) - memset(ptr, ~0, PAGE_SIZE * 1); + void *start = alloc_pages(1); + int *ptr; + uint32_t i; + for (i = 1; (ptr = alloc_pages(PAGE_SIZE)); i++) { + *ptr = i; + if (i == 4096) + break; } + uint16_t bozo = 0; + for (uint32_t j = 1; j < i - 1; j++) { + ptr = start + j * PAGE_SIZE; + if (*ptr != j) { + bozo++; + if (bozo == 12) + break; + } + kprintf("j=%d %p: %d\n", j, ptr, *ptr); + } + } else { while (vmalloc(10)) ;