diff options
author | Alex AUVOLAT <alexis211@gmail.com> | 2013-07-10 21:17:50 +0200 |
---|---|---|
committer | Alex AUVOLAT <alexis211@gmail.com> | 2013-07-10 21:17:50 +0200 |
commit | 78d7ffce4861dea5624ff29ceb39f1643dff8235 (patch) | |
tree | 6b41c052e48398f7520013622f0b1b9b9190259a /src/kernel/task | |
parent | fadf399405ca5d918dd5e1182fadc3d82f6bc900 (diff) | |
download | TCE-78d7ffce4861dea5624ff29ceb39f1643dff8235.tar.gz TCE-78d7ffce4861dea5624ff29ceb39f1643dff8235.zip |
Serial port used for writing kernel output.
Project: give total control to userland over display/input devices.
Diffstat (limited to 'src/kernel/task')
-rw-r--r-- | src/kernel/task/idt.cpp | 4 | ||||
-rw-r--r-- | src/kernel/task/syscall.cpp | 2 | ||||
-rw-r--r-- | src/kernel/task/task.cpp | 26 |
3 files changed, 13 insertions, 19 deletions
diff --git a/src/kernel/task/idt.cpp b/src/kernel/task/idt.cpp index 94a31b7..782bbd6 100644 --- a/src/kernel/task/idt.cpp +++ b/src/kernel/task/idt.cpp @@ -80,9 +80,7 @@ static struct irq_waiter { extern "C" void idt_isrHandler(registers regs) { if (regs.int_no != 14 || paging_fault(®s)) { if (tasking_handleException(®s) == 0) { - *ke_vt << "\nREALLY BAD THIS TIME\t\tUnhandled exception\t#"; - *ke_vt << regs.int_no; - *ke_vt << "\t@" << regs.eip; + dbg_printf("REALLY BAD THIS TIME: Unhandled exception #%d @%p\n", regs.int_no, regs.eip); PANIC("Unhandled Exception"); } } diff --git a/src/kernel/task/syscall.cpp b/src/kernel/task/syscall.cpp index 9e7c089..a3074b8 100644 --- a/src/kernel/task/syscall.cpp +++ b/src/kernel/task/syscall.cpp @@ -33,7 +33,7 @@ CALL2(process_waitpid, waitpid_sc); CALL1V(close, close_sc); static void printk_sc(registers *r) { - ke_vt->writeStr((char*)r->ebx); + dbg_printf("%s", (char*)r->ebx); } static void thread_new_sc(registers* r) { diff --git a/src/kernel/task/task.cpp b/src/kernel/task/task.cpp index 2af0441..2ad5447 100644 --- a/src/kernel/task/task.cpp +++ b/src/kernel/task/task.cpp @@ -104,40 +104,36 @@ void schedule() { /* Called when an exception happens. Provides a stack trace if it was in kernel land. Ends the thread for most exceptions, ends the whole process for page faults. */ uint32_t tasking_handleException(registers *regs) { - node *n = current_thread->process->fd.at(0); - vt *vt = (n && n->as_vt() ? n->as_vt() : ke_vt); - if (current_thread == 0) return 0; //No tasking yet - vt->writeStr("\n"); - vt->writeStr("[ke:"); vt->writeStr(__FILE__); vt->writeStr(":"); - vt->writeDec(__LINE__); vt->writeStr("] "); - vt->writeStr("Exception: "); + dbg_printf("[ke:%s:%d] Exception: ", __FILE__, __LINE__); char *exception_messages[] = {"Division By Zero","Debug","Non Maskable Interrupt","Breakpoint", "Into Detected Overflow","Out of Bounds","Invalid Opcode","No Coprocessor", "Double Fault", "Coprocessor Segment Overrun","Bad TSS","Segment Not Present","Stack Fault","General Protection Fault", "Page Fault","Unknown Interrupt","Coprocessor Fault","Alignment Check","Machine Check"}; - *vt << exception_messages[regs->int_no];; - *vt << "\n\tPID: " << (int)current_thread->process->pid; - *vt << "\n\teip: " << regs->eip; + + dbg_printf("%s\n", exception_messages[regs->int_no]); + dbg_printf("\tPID: %d\n", current_thread->process->pid); + dbg_printf("\teip: %p\n", regs->eip); + if (regs->eip >= K_HIGHHALF_ADDR) { - *vt << "\n\tException in kernel."; + dbg_printf("\tException in kernel\n"); stack_trace(regs->ebp); // useless } - *vt << "\n\tTrace:"; + dbg_printf("\tTrace:\n"); uint32_t *stack = (uint32_t*)regs->ebp, i; for (i = 0; i < 7 && (size_t)stack < (regs->ebp + 0x4000) && (size_t) stack >= regs->ebp; i++) { - *vt << "\n\t " << (size_t)stack << " next: " << stack[0] << " ret: " << stack[1]; + dbg_printf("\t%p\tnext: %p\tret: %p\n", stack, stack[0], stack[1]); stack = (uint32_t*)stack[0]; } if (regs->int_no == 14) { - *vt << "\n\tKilling process.\n"; + dbg_printf("\tKilling process.\n"); thread_exit_stackJmp(EX_PAGEFAULT); } else { - *vt << "\n\tKilling thread.\n"; + dbg_printf("\tKilling thread.\n"); thread_exit_stackJmp(EX_EXCEPTION); } PANIC("This should never have happened. Please report this."); |