Rev 509 | Rev 512 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 509 | Rev 511 | ||
---|---|---|---|
Line 33... | Line 33... | ||
33 | #include <arch/asm.h> |
33 | #include <arch/asm.h> |
34 | #include <arch.h> |
34 | #include <arch.h> |
35 | #include <print.h> |
35 | #include <print.h> |
36 | #include <synch/spinlock.h> |
36 | #include <synch/spinlock.h> |
37 | #include <typedefs.h> |
37 | #include <typedefs.h> |
- | 38 | #include <console/chardev.h> |
|
- | 39 | #include <console/console.h> |
|
38 | 40 | ||
39 | /** |
41 | /** |
40 | * i8042 processor driver. |
42 | * i8042 processor driver. |
41 | * It takes care of low-level keyboard functions. |
43 | * It takes care of low-level keyboard functions. |
42 | */ |
44 | */ |
Line 53... | Line 55... | ||
53 | 55 | ||
54 | static spinlock_t keylock; /**< keylock protects keyflags and lockflags. */ |
56 | static spinlock_t keylock; /**< keylock protects keyflags and lockflags. */ |
55 | static volatile int keyflags; /**< Tracking of multiple keypresses. */ |
57 | static volatile int keyflags; /**< Tracking of multiple keypresses. */ |
56 | static volatile int lockflags; /**< Tracking of multiple keys lockings. */ |
58 | static volatile int lockflags; /**< Tracking of multiple keys lockings. */ |
57 | 59 | ||
- | 60 | static void i8042_suspend(void); |
|
- | 61 | static void i8042_resume(void); |
|
- | 62 | ||
- | 63 | static chardev_t kbrd; |
|
- | 64 | static chardev_operations_t ops = { |
|
- | 65 | .suspend = i8042_suspend, |
|
- | 66 | .resume = i8042_resume |
|
- | 67 | }; |
|
- | 68 | ||
58 | /** Primary meaning of scancodes. */ |
69 | /** Primary meaning of scancodes. */ |
59 | static char sc_primary_map[] = { |
70 | static char sc_primary_map[] = { |
60 | SPECIAL, /* 0x00 */ |
71 | SPECIAL, /* 0x00 */ |
61 | SPECIAL, /* 0x01 - Esc */ |
72 | SPECIAL, /* 0x01 - Esc */ |
62 | '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', |
73 | '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', |
Line 218... | Line 229... | ||
218 | /** Initialize i8042. */ |
229 | /** Initialize i8042. */ |
219 | void i8042_init(void) |
230 | void i8042_init(void) |
220 | { |
231 | { |
221 | trap_register(VECTOR_KBD, i8042_interrupt); |
232 | trap_register(VECTOR_KBD, i8042_interrupt); |
222 | spinlock_initialize(&keylock); |
233 | spinlock_initialize(&keylock); |
- | 234 | chardev_initialize(&kbrd, &ops); |
|
- | 235 | stdin = &kbrd; |
|
223 | } |
236 | } |
224 | 237 | ||
225 | /** Process i8042 interrupt. |
238 | /** Process i8042 interrupt. |
226 | * |
239 | * |
227 | * @param n Interrupt vector. |
240 | * @param n Interrupt vector. |
Line 290... | Line 303... | ||
290 | shift = keyflags & PRESSED_SHIFT; |
303 | shift = keyflags & PRESSED_SHIFT; |
291 | if (letter && capslock) |
304 | if (letter && capslock) |
292 | shift = !shift; |
305 | shift = !shift; |
293 | if (shift) |
306 | if (shift) |
294 | map = sc_secondary_map; |
307 | map = sc_secondary_map; |
295 | putchar(map[sc]); |
308 | chardev_push_character(&kbrd, map[sc]); |
296 | break; |
309 | break; |
297 | } |
310 | } |
298 | spinlock_unlock(&keylock); |
311 | spinlock_unlock(&keylock); |
299 | } |
312 | } |
- | 313 | ||
- | 314 | /* Called from getc(). */ |
|
- | 315 | void i8042_resume(void) |
|
- | 316 | { |
|
- | 317 | } |
|
- | 318 | ||
- | 319 | /* Called from getc(). */ |
|
- | 320 | void i8042_suspend(void) |
|
- | 321 | { |
|
- | 322 | } |