add: memory test

This commit is contained in:
Starnakin 2024-11-26 14:31:17 +01:00
parent 9944f79b2e
commit 295c513f2d

View File

@ -68,24 +68,26 @@ void kernel_main(multiboot_info_t *mbd, uint32_t magic)
"Martin 03:50, 22 March 2009 (UTC)\n"); "Martin 03:50, 22 March 2009 (UTC)\n");
// PRINT_PTR(alloc_frame()); // PRINT_PTR(alloc_frame());
if (false) { if (true) {
void *start = alloc_pages(1); void *start = alloc_pages(1);
int *ptr; int *ptr;
uint32_t i; uint32_t i;
for (i = 1; (ptr = alloc_pages(PAGE_SIZE)); i++) { for (i = 1; (ptr = alloc_pages(PAGE_SIZE)); i++) {
memset(ptr, ~0, PAGE_SIZE);
*ptr = i; *ptr = i;
if (i == 4096) if (i == 4096 && false)
break; break;
} }
PRINT_UINT(i); // 32573
uint16_t bozo = 0; uint16_t bozo = 0;
for (uint32_t j = 1; j < i - 1; j++) { for (uint32_t j = 1; j < i - 1; j++) {
ptr = start + j * PAGE_SIZE; ptr = start + j * PAGE_SIZE;
kprintf("j=%d %p: %d\n", j, ptr, *ptr);
if (*ptr != j) { if (*ptr != j) {
bozo++; bozo++;
if (bozo == 12) if (bozo == 12)
break; break;
} }
kprintf("j=%d %p: %d\n", j, ptr, *ptr);
} }
} else { } else {