diff options
| -rw-r--r-- | asm/asm.h | 1 | ||||
| -rw-r--r-- | asm/int_mouse_handler.asm | 19 | ||||
| -rw-r--r-- | driver/mouse.h | 1 | ||||
| -rw-r--r-- | kernel/interrupts.c | 20 |
4 files changed, 26 insertions, 15 deletions
@@ -1,5 +1,6 @@ void pic_setup(); void int_kb_handler(); +void int_mouse_handler(); void int_default_handler(); void int_clock_handler(); void int_syscall_handler(); diff --git a/asm/int_mouse_handler.asm b/asm/int_mouse_handler.asm new file mode 100644 index 0000000..4e4882b --- /dev/null +++ b/asm/int_mouse_handler.asm @@ -0,0 +1,19 @@ +global int_mouse_handler +[extern mouse_handler] + +[bits 32] +int_mouse_handler: + + cli + pusha + + call mouse_handler + + mov al, 0x20 ;Port number AND command number to Acknowledge IRQ + out 0xa0, al ; came from slave + out 0x20, al ;Acknowledge IRQ, so we keep getting interrupts + + popa + sti + + iret ;Interrupt-Return diff --git a/driver/mouse.h b/driver/mouse.h new file mode 100644 index 0000000..dbf7393 --- /dev/null +++ b/driver/mouse.h @@ -0,0 +1 @@ +void mouse_handler(); diff --git a/kernel/interrupts.c b/kernel/interrupts.c index e19d816..74599c3 100644 --- a/kernel/interrupts.c +++ b/kernel/interrupts.c @@ -3,6 +3,7 @@ #include "lib/logger/log.h" // logger facilities #include "asm/asm.h" +#include "driver/mouse.h" #include "interrupts.h" #include "x86.h" @@ -21,7 +22,6 @@ void deflog(uint32_t eip, uint16_t cs, uint32_t flags) void int_install_ir(int irq, uint16_t flags, uint16_t sel, void *addr); //void mouse_handler(); - // the interrupt descriptor table static struct int_desc { @@ -52,7 +52,6 @@ void int_default() log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"default handler"); } - void show_error(uint32_t err) { log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"interrupt error code: 0x%08x",err); @@ -61,7 +60,6 @@ void show_error(uint32_t err) log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"Selector: %x",err&0b1111111111111000); } - void exception_handle_0(){ panic(FOOLOS_MODULE_NAME,"Divide by 0"); } void exception_handle_1(){ panic(FOOLOS_MODULE_NAME,"Single step (debugger)"); } void exception_handle_2(){ panic(FOOLOS_MODULE_NAME,"Non Maskable Interrupt"); } @@ -103,11 +101,9 @@ void exception_handle_16(){ panic(FOOLOS_MODULE_NAME,"Coprocessor error"); void exception_handle_17(){ panic(FOOLOS_MODULE_NAME,"Alignment Check"); } void exception_handle_18(){ panic(FOOLOS_MODULE_NAME,"Machine Check"); } - //set a handler for a specific interrupt void int_install_ir(int irq, uint16_t flags, uint16_t sel, void *addr) { - uint64_t base=(uint32_t)&(*(uint32_t*)addr); idt[irq].addrLo = base & 0xffff; @@ -115,27 +111,23 @@ void int_install_ir(int irq, uint16_t flags, uint16_t sel, void *addr) idt[irq].zeros=0; idt[irq].flags=flags; idt[irq].sel=sel; - } // 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; - for(i=0; i<INT_MAX; i++) + for(int i=0; i<INT_MAX; i++) { int_install_ir(i, 0b10001110, sel,&int_default_handler); } // 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); @@ -165,8 +157,8 @@ void int_init(uint16_t sel) // install keyboard interrupt handler (irq 1 => 33) int_install_ir(33, 0b10001110, 0x08,&int_kb_handler); - //mouse -// int_install_ir(44, 0b10001110, 0x08,&mouse_handler); + //mouse interrupt handler (irq 12 => 34) + int_install_ir(44, 0b10001110, 0x08,&int_mouse_handler); //system calls int_install_ir(0x80, 0b11101110, 0x08,&int_syscall_handler); @@ -174,9 +166,8 @@ void int_init(uint16_t sel) int_install(); // now we can enable interrupts back again - // x86_int_enable(); + // x86_int_enable(); x86_int_disable(); - } void int_install() @@ -190,4 +181,3 @@ void int_install() __asm__("lidt %0"::"m" (idtd)); } - |
