From 0dc446980d8ede518a356ab2c2f165cb08ce444a Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sat, 7 Feb 2015 19:03:47 -0500 Subject: implement text in graphics mode --- drivers/ps2.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'drivers/ps2.c') 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 #include #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(); +} -- cgit v1.1