diff options
Diffstat (limited to 'devices/i8042.c')
-rw-r--r-- | devices/i8042.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/devices/i8042.c b/devices/i8042.c index c612e6d..4805529 100644 --- a/devices/i8042.c +++ b/devices/i8042.c @@ -8,8 +8,8 @@ #include <stdio.h> #include <sys/io.h> -// r status register -// w command register +/* r status register */ +/* w command register */ #define comm_port 0x64 #define comm_enable_first_ps2 0xae #define comm_enable_second_ps2 0xa8 @@ -19,13 +19,15 @@ #define data_port 0x60 #define data_enable_scanning 0xf4 -// TODO: All output to port 0x60 or 0x64 must be preceded by waiting for bit 1 (value=2) of port 0x64 to become clear. -// TODO: Similarly, bytes cannot be read from port 0x60 until bit 0 (value=1) of port 0x64 is set. +/* TODO: All output to port 0x60 or 0x64 must be preceded by waiting for bit 1 (value=2) of port 0x64 to become clear. + * TODO: Similarly, bytes cannot be read from port 0x60 until bit 0 (value=1) of port 0x64 is set. */ void ps2_ctrl_init() { - // eat all previous keystrikes + int i; + + /* eat all previous keystrikes */ while (inb(comm_port) & 0x1) inb(data_port); uint8_t test; @@ -39,30 +41,30 @@ ps2_ctrl_init() test = inb(data_port); printf("i8042: port2 test 0xa9:%x %s\n", test, test == 0x00 ? "ok" : "failed"); - // printf("8042: init keyboard\n"); + /* printf("8042: init keyboard\n"); */ outb(comm_enable_first_ps2, comm_port); outb(comm_enable_second_ps2, comm_port); - // resets the cpu - // outb(0xfe, 0x64); + /* resets the cpu */ + /* outb(0xfe, 0x64); */ outb(0xf2, 0x60); printf("i8042: id port1: "); while ((inb(0x64) & 0x01) == 0) {} - for (int i = 0; i < 3; ++i) printf("%x ", inb(0x60)); + for (i = 0; i < 3; ++i) printf("%x ", inb(0x60)); printf("\n"); outb(0xd4, 0x64); outb(0xf2, 0x60); printf("i8042: id port2: "); while ((inb(0x64) & 0x01) == 0) {} - for (int i = 0; i < 3; ++i) printf("%x ", inb(0x60)); + for (i = 0; i < 3; ++i) printf("%x ", inb(0x60)); printf("\n"); outb(comm_read_ctrl_config, comm_port); uint8_t conf = (inb(data_port) | 1) & ~0x10; - conf |= 0x22; // mouse + conf |= 0x22; /* mouse */ outb(comm_write_ctrl_config, comm_port); outb(conf, data_port); @@ -81,7 +83,6 @@ ps2_read_port1() unsigned char ps2_read_port2() { - outb(0xd4, 0x64); return inb(0x60); } |