From 835960fd85989ee961b5a932f467e6e4f545d201 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 5 Aug 2020 21:33:48 +0200 Subject: Added some cpu function wrappers --- src/drivers/cpu.c | 21 +++++++++++++++++++++ src/drivers/interrupts.c | 4 +--- 2 files changed, 22 insertions(+), 3 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/cpu.c b/src/drivers/cpu.c index ba8c66f..5c27c51 100644 --- a/src/drivers/cpu.c +++ b/src/drivers/cpu.c @@ -46,3 +46,24 @@ void outl(u16 port, u32 data) { __asm__ volatile("outl %0, %1" ::"a"(data), "Nd"(port)); } + +void cli() +{ + __asm__ volatile("cli"); +} + +void sti() +{ + __asm__ volatile("sti"); +} + +void hlt() +{ + __asm__ volatile("hlt"); +} + +void idle() +{ + while (1) + hlt(); +} diff --git a/src/drivers/interrupts.c b/src/drivers/interrupts.c index 9ad2529..0b94208 100644 --- a/src/drivers/interrupts.c +++ b/src/drivers/interrupts.c @@ -173,7 +173,7 @@ void isr_handler(struct regs *r) if (handler) { handler(r); } else if (r->int_no <= 32) { - __asm__("cli"); + cli(); printf("\n%s Exception, halting!\n", isr_exceptions[r->int_no]); printf("Error code: %d\n", r->err_code); while (1) { @@ -218,8 +218,6 @@ void isr_install() idt_set_gate(29, (u32)isr29, 0x08, 0x8E); idt_set_gate(30, (u32)isr30, 0x08, 0x8E); idt_set_gate(31, (u32)isr31, 0x08, 0x8E); - - idt_set_gate(0x80, (u32)isr128, 0x08, 0x8E); } /** -- cgit v1.2.3