Rev 511 | Rev 517 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 511 | Rev 512 | ||
---|---|---|---|
Line 41... | Line 41... | ||
41 | /** |
41 | /** |
42 | * i8042 processor driver. |
42 | * i8042 processor driver. |
43 | * It takes care of low-level keyboard functions. |
43 | * It takes care of low-level keyboard functions. |
44 | */ |
44 | */ |
45 | 45 | ||
- | 46 | #define i8042_DATA 0x60 |
|
- | 47 | #define i8042_STATUS 0x64 |
|
- | 48 | ||
- | 49 | /** Keyboard commands. */ |
|
- | 50 | #define KBD_ENABLE 0xf4 |
|
- | 51 | #define KBD_DISABLE 0xf5 |
|
- | 52 | #define KBD_ACK 0xfa |
|
- | 53 | ||
46 | #define SPECIAL '?' |
54 | #define SPECIAL '?' |
47 | #define KEY_RELEASE 0x80 |
55 | #define KEY_RELEASE 0x80 |
48 | 56 | ||
49 | static void key_released(__u8 sc); |
57 | static void key_released(__u8 sc); |
50 | static void key_pressed(__u8 sc); |
58 | static void key_pressed(__u8 sc); |
Line 228... | Line 236... | ||
228 | 236 | ||
229 | /** Initialize i8042. */ |
237 | /** Initialize i8042. */ |
230 | void i8042_init(void) |
238 | void i8042_init(void) |
231 | { |
239 | { |
232 | trap_register(VECTOR_KBD, i8042_interrupt); |
240 | trap_register(VECTOR_KBD, i8042_interrupt); |
- | 241 | trap_virtual_enable_irqs(1<<IRQ_KBD); |
|
233 | spinlock_initialize(&keylock); |
242 | spinlock_initialize(&keylock); |
234 | chardev_initialize(&kbrd, &ops); |
243 | chardev_initialize(&kbrd, &ops); |
235 | stdin = &kbrd; |
244 | stdin = &kbrd; |
236 | } |
245 | } |
237 | 246 | ||
Line 243... | Line 252... | ||
243 | void i8042_interrupt(__u8 n, __native stack[]) |
252 | void i8042_interrupt(__u8 n, __native stack[]) |
244 | { |
253 | { |
245 | __u8 x; |
254 | __u8 x; |
246 | 255 | ||
247 | trap_virtual_eoi(); |
256 | trap_virtual_eoi(); |
248 | x = inb(0x60); |
257 | x = inb(i8042_DATA); |
249 | if (x & KEY_RELEASE) |
258 | if (x & KEY_RELEASE) |
250 | key_released(x ^ KEY_RELEASE); |
259 | key_released(x ^ KEY_RELEASE); |
251 | else |
260 | else |
252 | key_pressed(x); |
261 | key_pressed(x); |
253 | } |
262 | } |