From 197ea3ca20879b29fca41a07cf43e5b04b9c5083 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Mon, 26 Oct 2020 16:36:40 +0100 Subject: Optimizations --- kernel/drivers/fpu.c | 2 +- kernel/drivers/ide.c | 2 +- kernel/drivers/interrupts.c | 17 +++++++++-------- kernel/drivers/timer.c | 4 +--- 4 files changed, 12 insertions(+), 13 deletions(-) (limited to 'kernel/drivers') diff --git a/kernel/drivers/fpu.c b/kernel/drivers/fpu.c index d8a2b79..f7eeceb 100644 --- a/kernel/drivers/fpu.c +++ b/kernel/drivers/fpu.c @@ -10,7 +10,7 @@ void set_fpu_cw(const u16 cw) void fpu_install() { __asm__ volatile("clts"); - u32 t; + u32 t = 0; __asm__ volatile("mov %%cr0, %0" : "=r"(t)); t &= ~(1 << 2); t |= (1 << 1); diff --git a/kernel/drivers/ide.c b/kernel/drivers/ide.c index c1c0227..1a94ae3 100644 --- a/kernel/drivers/ide.c +++ b/kernel/drivers/ide.c @@ -16,7 +16,7 @@ int ide_stat() void ide_wait() { - u8 stat; + u8 stat = 0; do stat = ide_stat(); while ((stat & IDE_BUSY) != 0); diff --git a/kernel/drivers/interrupts.c b/kernel/drivers/interrupts.c index 9088915..57b0ab5 100644 --- a/kernel/drivers/interrupts.c +++ b/kernel/drivers/interrupts.c @@ -6,6 +6,7 @@ #include #include #include +#include #include /** @@ -166,18 +167,18 @@ void isr_uninstall_handler(int isr) void isr_handler(struct regs *r) { - void (*handler)(struct regs * r); - // Execute fault handler if exists - handler = isr_routines[r->int_no]; + void (*handler)(struct regs * r) = isr_routines[r->int_no]; if (handler) { handler(r); } else if (r->int_no <= 32) { - cli(); - printf("\n%s Exception, halting!\n", isr_exceptions[r->int_no]); - printf("Error code: %d\n", r->err_code); - while (1) { - }; + printf("%s Exception, exiting!\n", isr_exceptions[r->int_no]); + struct proc *proc = proc_current(); + if (proc) + proc_exit(proc, 1); + else + __asm__ volatile("cli\nhlt"); + proc_yield(r); } } diff --git a/kernel/drivers/timer.c b/kernel/drivers/timer.c index 812bde7..3bc1811 100644 --- a/kernel/drivers/timer.c +++ b/kernel/drivers/timer.c @@ -31,9 +31,7 @@ void timer_handler() // "Delay" function with CPU sleep void timer_wait(u32 ticks) { - u32 eticks; - - eticks = timer_ticks + ticks; + u32 eticks = timer_ticks + ticks; while (timer_ticks < eticks) { __asm__ volatile("sti//hlt//cli"); } -- cgit v1.2.3