diff options
Diffstat (limited to 'kernel/interrupts.c')
| -rw-r--r-- | kernel/interrupts.c | 67 |
1 files changed, 36 insertions, 31 deletions
diff --git a/kernel/interrupts.c b/kernel/interrupts.c index ac200e5..f82c59c 100644 --- a/kernel/interrupts.c +++ b/kernel/interrupts.c @@ -2,15 +2,12 @@ #include "lib/logger/log.h" // logger facilities +#include "asm/asm.h" #include "interrupts.h" +#include "console.h" #include "x86.h" - -void int_clock_handler(); -void int_kb_handler(); -void int_syscall_handler(); void int_install_ir(int irq, uint16_t flags, uint16_t sel, void *addr); -void int_default_handler(); //void mouse_handler(); @@ -34,11 +31,16 @@ static struct idt_desc } idtd; +void exception_handle() +{ + panic(FOOLOS_MODULE_NAME,"exception interrupt"); +} void int_default() { - + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"default handler"); } +/* void show_error(uint32_t err) { @@ -48,7 +50,7 @@ void show_error(uint32_t err) log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"Selector: %x",err&0b1111111111111000); } -void int_irq0(){ X86_IRQ_BEGIN panic(FOOLOS_MODULE_NAME,"Divide by 0"); X86_IRQ_END } +//void int_irq0(){ X86_IRQ_BEGIN panic(FOOLOS_MODULE_NAME,"Divide by 0"); X86_IRQ_END } void int_irq1(){ X86_IRQ_BEGIN panic(FOOLOS_MODULE_NAME,"Single step (debugger)"); X86_IRQ_END } void int_irq2(){ X86_IRQ_BEGIN panic(FOOLOS_MODULE_NAME,"Non Maskable Interrupt"); X86_IRQ_END } void int_irq3(){ X86_IRQ_BEGIN panic(FOOLOS_MODULE_NAME,"Breakpoint (debugger)"); X86_IRQ_END } @@ -81,7 +83,7 @@ void int_irq15(){ X86_IRQ_BEGIN panic(FOOLOS_MODULE_NAME,"Unassigned"); X86_I void int_irq16(){ X86_IRQ_BEGIN panic(FOOLOS_MODULE_NAME,"Coprocessor error"); X86_IRQ_END } void int_irq17(){ X86_IRQ_BEGIN panic(FOOLOS_MODULE_NAME,"Alignment Check"); X86_IRQ_END } void int_irq18(){ X86_IRQ_BEGIN panic(FOOLOS_MODULE_NAME,"Machine Check"); X86_IRQ_END } - +*/ //set a handler for a specific interrupt void int_install_ir(int irq, uint16_t flags, uint16_t sel, void *addr) @@ -100,6 +102,11 @@ void int_install_ir(int irq, uint16_t flags, uint16_t sel, void *addr) // set default handler for all interrupts for a start void int_init(uint16_t sel) { + // + // Setup PIC + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"setting up PIC",&idt,&idtd); + pic_setup(); + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"initializing. IDT: 0x%08x, IDTD: 0x%08X",&idt,&idtd); int i; @@ -109,25 +116,28 @@ void int_init(uint16_t sel) } // exceptions + int_install_ir(0, 0b10001110, 0x08,&int_irq0); - int_install_ir(1, 0b10001110, 0x08,&int_irq1); - int_install_ir(2, 0b10001110, 0x08,&int_irq2); - int_install_ir(3, 0b10001110, 0x08,&int_irq3); - int_install_ir(4, 0b10001110, 0x08,&int_irq4); - int_install_ir(5, 0b10001110, 0x08,&int_irq5); - int_install_ir(6, 0b10001110, 0x08,&int_irq6); - int_install_ir(7, 0b10001110, 0x08,&int_irq7); - int_install_ir(8, 0b10001110, 0x08,&int_irq8); - int_install_ir(9, 0b10001110, 0x08,&int_irq9); - int_install_ir(10, 0b10001110, 0x08,&int_irq10); - int_install_ir(11, 0b10001110, 0x08,&int_irq11); - int_install_ir(12, 0b10001110, 0x08,&int_irq12); - int_install_ir(13, 0b10001110, 0x08,&int_irq13); - int_install_ir(14, 0b10001110, 0x08,&int_irq14); - int_install_ir(15, 0b10001110, 0x08,&int_irq15); - int_install_ir(16, 0b10001110, 0x08,&int_irq16); - int_install_ir(17, 0b10001110, 0x08,&int_irq17); - int_install_ir(18, 0b10001110, 0x08,&int_irq18); + int_install_ir(1, 0b10001110, 0x08,&int_irq0); + int_install_ir(2, 0b10001110, 0x08,&int_irq0); + int_install_ir(3, 0b10001110, 0x08,&int_irq0); + int_install_ir(4, 0b10001110, 0x08,&int_irq0); + int_install_ir(5, 0b10001110, 0x08,&int_irq0); + int_install_ir(6, 0b10001110, 0x08,&int_irq0); + int_install_ir(7, 0b10001110, 0x08,&int_irq0); + int_install_ir(8, 0b10001110, 0x08,&int_irq0); + int_install_ir(9, 0b10001110, 0x08,&int_irq0); + int_install_ir(10, 0b10001110, 0x08,&int_irq0); + int_install_ir(11, 0b10001110, 0x08,&int_irq0); + int_install_ir(12, 0b10001110, 0x08,&int_irq0); + int_install_ir(13, 0b10001110, 0x08,&int_irq0); + int_install_ir(14, 0b10001110, 0x08,&int_irq0); + int_install_ir(15, 0b10001110, 0x08,&int_irq0); + int_install_ir(16, 0b10001110, 0x08,&int_irq0); + int_install_ir(17, 0b10001110, 0x08,&int_irq0); + int_install_ir(18, 0b10001110, 0x08,&int_irq0); + + // setup some custom interrupts // remember that we shifted all interrupts with the pic by 32 @@ -138,11 +148,6 @@ void int_init(uint16_t sel) // install keyboard interrupt handler (irq 1 => 33) int_install_ir(33, 0b10001110, 0x08,&int_kb_handler); - #ifdef FOOLOS_COMPILE_FLOPPY - // install floppy interrupt handler (irq 6 => 38) - int_install_ir(38, 0b10001110, 0x08,&int_floppy_handler); - #endif - //mouse // int_install_ir(44, 0b10001110, 0x08,&mouse_handler); |
