diff options
author | Alex Auvolat <alex@adnab.me> | 2015-03-09 17:04:04 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2015-03-09 17:04:04 +0100 |
commit | 3341e7a3a184b5bea17f0f678b40bc51c92d72a4 (patch) | |
tree | c77a940a371148b256676f7b59caaecc725a1f1d /src/kernel/core | |
parent | 436418e575b68fd7e85f7fdaf039e03874ec1cb9 (diff) | |
download | kogata-3341e7a3a184b5bea17f0f678b40bc51c92d72a4.tar.gz kogata-3341e7a3a184b5bea17f0f678b40bc51c92d72a4.zip |
Partial implement VFS pager (enough for ISO9660!)
Also add some debugging facilities (especially stack trace).
Diffstat (limited to 'src/kernel/core')
-rw-r--r-- | src/kernel/core/idt.c | 14 | ||||
-rw-r--r-- | src/kernel/core/kmalloc.c | 2 | ||||
-rw-r--r-- | src/kernel/core/paging.c | 3 | ||||
-rw-r--r-- | src/kernel/core/thread.c | 2 |
4 files changed, 17 insertions, 4 deletions
diff --git a/src/kernel/core/idt.c b/src/kernel/core/idt.c index 6bfe8b5..eef3ca6 100644 --- a/src/kernel/core/idt.c +++ b/src/kernel/core/idt.c @@ -275,7 +275,19 @@ void dbg_dump_registers(registers_t *regs) { dbg_printf("| EAX: 0x%p EBX: 0x%p ECX: 0x%p EDX: 0x%p\n", regs->eax, regs->ebx, regs->ecx, regs->edx); dbg_printf("| EDI: 0x%p ESI: 0x%p ESP: 0x%p EBP: 0x%p\n", regs->edi, regs->esi, regs->esp, regs->ebp); dbg_printf("| EIP: 0x%p CS : 0x%p DS : 0x%p SS : 0x%p\n", regs->eip, regs->cs, regs->ds, regs->ss); - dbg_printf("\\ EFl: 0x%p I# : 0x%p Err: 0x%p\n", regs->eflags, regs->int_no, regs->err_code); + dbg_printf("| EFl: 0x%p I# : 0x%p Err: 0x%p\n", regs->eflags, regs->int_no, regs->err_code); + dbg_printf("- Stack trace:\n"); + + uint32_t ebp = regs->ebp, eip = regs->eip; + int i = 0; + while (ebp >= K_HIGHHALF_ADDR && eip >= K_HIGHHALF_ADDR && i++ < 10) { + dbg_printf("| 0x%p EIP: 0x%p\n", ebp, eip); + uint32_t *d = (uint32_t*)ebp; + ebp = d[0]; + eip = d[1]; + } + + dbg_printf("\\\n"); } /* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/kernel/core/kmalloc.c b/src/kernel/core/kmalloc.c index a8b115b..85e6173 100644 --- a/src/kernel/core/kmalloc.c +++ b/src/kernel/core/kmalloc.c @@ -9,7 +9,7 @@ #include <freemem.h> static void* page_alloc_fun_for_kmalloc(size_t bytes) { - void* addr = region_alloc(bytes, "Core kernel heap", pf_handler_unexpected); + void* addr = region_alloc(bytes, "Core kernel heap", 0); if (addr == 0) return 0; // Map physical memory diff --git a/src/kernel/core/paging.c b/src/kernel/core/paging.c index 38e8407..f2289bd 100644 --- a/src/kernel/core/paging.c +++ b/src/kernel/core/paging.c @@ -66,6 +66,7 @@ void page_fault_handler(registers_t *regs) { if ((size_t)vaddr < PAGE_SIZE) { dbg_printf("Null pointer dereference in kernel code (0x%p)\n", vaddr); dbg_dump_registers(regs); + dbg_print_region_info(); PANIC("Null pointer dereference in kernel code."); } else if ((size_t)vaddr < K_HIGHHALF_ADDR) { if (pd->user_pfh == 0) { @@ -108,7 +109,7 @@ void page_fault_handler(registers_t *regs) { PANIC("Unhandled kernel space page fault"); } if (i->pf == 0) { - dbg_printf("Kernel pagefault in region with no handler at 0x%p\n", vaddr); + dbg_printf("Kernel pagefault in region with no handler at 0x%p (%s region)\n", vaddr, i->type); dbg_dump_registers(regs); dbg_print_region_info(); PANIC("Unhandled kernel space page fault"); diff --git a/src/kernel/core/thread.c b/src/kernel/core/thread.c index 58c92d3..74e5a30 100644 --- a/src/kernel/core/thread.c +++ b/src/kernel/core/thread.c @@ -157,7 +157,7 @@ thread_t *new_thread(entry_t entry, void* data) { thread_t *t = (thread_t*)malloc(sizeof(thread_t)); if (t == 0) return 0; - void* stack = region_alloc(KPROC_STACK_SIZE + PAGE_SIZE, "Stack", pf_handler_stackoverflow); + void* stack = region_alloc(KPROC_STACK_SIZE + PAGE_SIZE, "Stack", 0); if (stack == 0) { free(t); return 0; |