wip: debug memory pages persistency

This commit is contained in:
0x35c 2024-10-21 13:36:42 +02:00
parent 8c936f6323
commit 4337bc11c8
5 changed files with 24 additions and 10 deletions

View File

@ -1,4 +1,5 @@
#include "alloc.h"
#include "debug.h"
#include "drivers.h"
#include "gdt.h"
#include "idt.h"
@ -35,10 +36,23 @@ void kernel_main(void)
"I see no way to confuse an array of 256 seg:off pairs with a "
"complex 8*unknown quantity -byte descriptor table. -- Troy "
"Martin 03:50, 22 March 2009 (UTC)\n");
/* kprintf("%p\n", vmalloc(10)); */
int i = 0;
while (vmalloc(10))
if (i++ > 11000)
kprintf("%d\n", i++);
/* char *str = vmalloc(10); */
/* strcpy(str, "hello"); */
/* int i = 0; */
/* while (vmalloc(10)) */
/* if (i++ > 11000) */
/* kprintf("str: %s at %d\n", str, i); */
void *tab[1024];
for (int i = 0; i < 1024; i++) {
tab[i] = alloc_pages(1);
/* PRINT_INT(i); */
/* PRINT_PTR(tab[i]); */
if (tab[i])
memset(tab[i], i, 4096);
}
/* PRINT_UINT(((uint8_t *)tab[0])[0]); */
for (int i = 0; i < 10; i++)
PRINT_PTR(tab[i]);
/* PRINT_UINT(((uint8_t *)tab[i])[0]); */
shell_init();
}

View File

@ -22,7 +22,7 @@ void kpanic(const char *format, ...)
kprintf("fault at address: %p\n", faulting_address);
/* for (int i = 16; i < 32; i++) */
/* kprintf("%p\n", page_table1[i]); */
show_valloc_mem();
/* show_valloc_mem(); */
/* kprintf("\n\n"); */
/* print_stack(); */
/* kprintf("\n\n"); */

View File

@ -16,5 +16,5 @@ void init_memory(void)
page_directory[i] = 0x02;
for (int16_t i = 0; i < 1024; i++)
page_table1[i] = (i << 12) | 0x03;
page_directory[0] = ((uint32_t)page_table1 - HEAP_END) | 0x03;
page_directory[342] = ((uint32_t)page_table1 - HEAP_END) | 0x03;
}

View File

@ -46,7 +46,7 @@ void *alloc_pages(size_t size)
/* assert(page_table1[i] >> 12 == i); */
page_table1[i] = ((uint32_t)frame & PAGE_MASK) | INIT_FLAGS;
}
PRINT_PTR(page_table1[index]);
/* PRINT_PTR(page_table1[index]); */
return (void *)(index * PAGE_SIZE);
}

View File

@ -17,8 +17,8 @@ static Block *find_block(Zone *head, uint32_t size)
block_it = block_it->next_free) {
assert(block_it);
if (block_it->in_use) {
PRINT_PTR(block_it);
PRINT_PTR(block_it->zone);
/* PRINT_PTR(block_it); */
/* PRINT_PTR(block_it->zone); */
}
assert(!block_it->in_use);
if (size <= block_it->size) {