aboutsummaryrefslogtreecommitdiff
path: root/drivers/ps2.c
diff options
context:
space:
mode:
authorFranklin Wei <frankhwei536@gmail.com>2015-02-18 12:49:58 -0500
committerFranklin Wei <frankhwei536@gmail.com>2015-02-18 12:49:58 -0500
commit9defae4d6f7b30d844447549fadffea4eab5a0dd (patch)
tree2c44f6fb193d9b3f7487714e7dfa3903bedb932d /drivers/ps2.c
parent1d3537f33d793e2cabe53e72f0e0ead911fcc870 (diff)
downloadkappa-9defae4d6f7b30d844447549fadffea4eab5a0dd.zip
kappa-9defae4d6f7b30d844447549fadffea4eab5a0dd.tar.gz
kappa-9defae4d6f7b30d844447549fadffea4eab5a0dd.tar.bz2
kappa-9defae4d6f7b30d844447549fadffea4eab5a0dd.tar.xz
support keyboard io
Diffstat (limited to 'drivers/ps2.c')
-rw-r--r--drivers/ps2.c71
1 files changed, 0 insertions, 71 deletions
diff --git a/drivers/ps2.c b/drivers/ps2.c
deleted file mode 100644
index 9da026d..0000000
--- a/drivers/ps2.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/* this is both a PS/2 keyboard AND a PS/2 MOUSE driver */
-#include <stdint.h>
-#include <stdio.h>
-#include "io.h"
-#include "isr.h"
-#include "ps2.h"
-#include "ps2_keymaps.h"
-
-static void ps2_wait(void)
-{
- /* wait for the keyboard */
- while(1)
- if ((inb(0x64) & 2) == 0) break;
-}
-
-void ps2_set_leds(uint8_t status)
-{
- ps2_wait();
- outb(0x60, 0xED);
- outb(0x60, status);
-}
-
-static uint8_t keyboard_state[16];
-
-static void key_handler(struct regs_t *regs)
-{
- (void) regs;
- uint8_t scancode = inb(0x60);
- (void) scancode;
- /* TODO: handle scancode */
- /*printf("key %x\n", scancode);*/
-}
-
-static void ps2_set_scancode_set(uint8_t set)
-{
- ps2_wait();
- outb(0x60, 0xF0);
- outb(0x60, set);
-}
-
-static void keyboard_init(void)
-{
- set_interrupt_handler(IRQ(1), key_handler);
- ps2_set_scancode_set(1);
-}
-
-static void mouse_handler(struct regs_t *regs)
-{
- (void) 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();
-}