wip: debug memory pages persistency
This commit is contained in:
parent
8c936f6323
commit
4337bc11c8
24
src/kernel.c
24
src/kernel.c
@ -1,4 +1,5 @@
|
|||||||
#include "alloc.h"
|
#include "alloc.h"
|
||||||
|
#include "debug.h"
|
||||||
#include "drivers.h"
|
#include "drivers.h"
|
||||||
#include "gdt.h"
|
#include "gdt.h"
|
||||||
#include "idt.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 "
|
"I see no way to confuse an array of 256 seg:off pairs with a "
|
||||||
"complex 8*unknown quantity -byte descriptor table. -- Troy "
|
"complex 8*unknown quantity -byte descriptor table. -- Troy "
|
||||||
"Martin 03:50, 22 March 2009 (UTC)\n");
|
"Martin 03:50, 22 March 2009 (UTC)\n");
|
||||||
/* kprintf("%p\n", vmalloc(10)); */
|
/* char *str = vmalloc(10); */
|
||||||
int i = 0;
|
/* strcpy(str, "hello"); */
|
||||||
while (vmalloc(10))
|
/* int i = 0; */
|
||||||
if (i++ > 11000)
|
/* while (vmalloc(10)) */
|
||||||
kprintf("%d\n", i++);
|
/* 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();
|
shell_init();
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ void kpanic(const char *format, ...)
|
|||||||
kprintf("fault at address: %p\n", faulting_address);
|
kprintf("fault at address: %p\n", faulting_address);
|
||||||
/* for (int i = 16; i < 32; i++) */
|
/* for (int i = 16; i < 32; i++) */
|
||||||
/* kprintf("%p\n", page_table1[i]); */
|
/* kprintf("%p\n", page_table1[i]); */
|
||||||
show_valloc_mem();
|
/* show_valloc_mem(); */
|
||||||
/* kprintf("\n\n"); */
|
/* kprintf("\n\n"); */
|
||||||
/* print_stack(); */
|
/* print_stack(); */
|
||||||
/* kprintf("\n\n"); */
|
/* kprintf("\n\n"); */
|
||||||
|
@ -16,5 +16,5 @@ void init_memory(void)
|
|||||||
page_directory[i] = 0x02;
|
page_directory[i] = 0x02;
|
||||||
for (int16_t i = 0; i < 1024; i++)
|
for (int16_t i = 0; i < 1024; i++)
|
||||||
page_table1[i] = (i << 12) | 0x03;
|
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;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ void *alloc_pages(size_t size)
|
|||||||
/* assert(page_table1[i] >> 12 == i); */
|
/* assert(page_table1[i] >> 12 == i); */
|
||||||
page_table1[i] = ((uint32_t)frame & PAGE_MASK) | INIT_FLAGS;
|
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);
|
return (void *)(index * PAGE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ static Block *find_block(Zone *head, uint32_t size)
|
|||||||
block_it = block_it->next_free) {
|
block_it = block_it->next_free) {
|
||||||
assert(block_it);
|
assert(block_it);
|
||||||
if (block_it->in_use) {
|
if (block_it->in_use) {
|
||||||
PRINT_PTR(block_it);
|
/* PRINT_PTR(block_it); */
|
||||||
PRINT_PTR(block_it->zone);
|
/* PRINT_PTR(block_it->zone); */
|
||||||
}
|
}
|
||||||
assert(!block_it->in_use);
|
assert(!block_it->in_use);
|
||||||
if (size <= block_it->size) {
|
if (size <= block_it->size) {
|
||||||
|
Loading…
Reference in New Issue
Block a user