diff --git a/kernel/arch/x86_64/idt.c b/kernel/arch/x86_64/idt.c index efda2cb..ebca808 100644 --- a/kernel/arch/x86_64/idt.c +++ b/kernel/arch/x86_64/idt.c @@ -15,6 +15,9 @@ #include #include +#undef DEBUG_FAULTS +#define LOUD_SEGFAULTS + static struct idt_pointer idtp; static idt_entry_t idt[256]; @@ -213,6 +216,10 @@ struct regs * isr_handler(struct regs * r) { spin_unlock(fault_lock); arch_fatal(); #else +# ifdef LOUD_SEGFAULTS + printf("Page fault in pid=%d (%s; cpu=%d) at %#zx\n", (int)this_core->current_process->id, this_core->current_process->name, this_core->cpu_id, faulting_address); + dump_regs(r); +# endif send_signal(this_core->current_process->id, SIGSEGV, 1); #endif break; @@ -230,6 +237,10 @@ struct regs * isr_handler(struct regs * r) { spin_unlock(fault_lock); arch_fatal(); #else +# ifdef LOUD_SEGFAULTS + printf("GPF in userspace on CPU %d\n", this_core->cpu_id); + dump_regs(r); +# endif send_signal(this_core->current_process->id, SIGSEGV, 1); #endif break; diff --git a/kernel/misc/fbterm.c b/kernel/misc/fbterm.c index beea7db..a2ff70f 100644 --- a/kernel/misc/fbterm.c +++ b/kernel/misc/fbterm.c @@ -221,11 +221,14 @@ static void process_char(char ch) { invert_at(x,y); } +static size_t (*previous_writer)(size_t,uint8_t*) = NULL; + size_t fbterm_write(size_t size, uint8_t *buffer) { if (!buffer) return 0; for (unsigned int i = 0; i < size; ++i) { process_char(buffer[i]); } + if (previous_writer) previous_writer(size,buffer); return size; } @@ -234,5 +237,6 @@ void fbterm_initialize(void) { fbterm_width = (lfb_resolution_x - LEFT_PAD) / char_width; fbterm_height = (lfb_resolution_y) / char_height; + previous_writer = printf_output; printf_output = fbterm_write; }