diff options
Diffstat (limited to 'drivers/ps2.c')
| -rw-r--r-- | drivers/ps2.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/drivers/ps2.c b/drivers/ps2.c index b9a9b20..742b7ad 100644 --- a/drivers/ps2.c +++ b/drivers/ps2.c @@ -1,3 +1,4 @@ +/* this is both a PS/2 keyboard AND a PS/2 MOUSE driver */ #include <stdint.h> #include <stdio.h> #include "io.h" @@ -18,7 +19,7 @@ void ps2_set_leds(uint8_t status) outb(0x60, status); } -static void ps2_handler(struct regs_t regs) +static void key_handler(struct regs_t regs) { (void) regs; uint8_t scancode = inb(0x60); @@ -33,8 +34,33 @@ static void ps2_set_scancode_set(uint8_t set) outb(0x60, set); } -void ps2_init(void) +static void keyboard_init(void) { - set_interrupt_handler(IRQ(1), ps2_handler); + set_interrupt_handler(IRQ(1), key_handler); ps2_set_scancode_set(1); } + +static void mouse_handler(struct regs_t regs) +{ + printf("mouse action!\n"); +} + +static void mouse_init(void) +{ + /* enable IRQ12 */ + set_interrupt_handler(IRQ(12), mouse_handler); + /* make the ps/2 controller generate IRQ12 */ + outb(0x64, 0x20); + uint8_t status = inb(0x64); + /* set bit 1 and unset bit 5 */ + status |= (1 << 1); + status &= ~(1 << 5); + outb(0x64, 0x60); + outb(0x60, status); +} + +void ps2_init(void) +{ + keyboard_init(); + mouse_init(); +} |