Rev 1194 | Rev 1196 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1194 | Rev 1195 | ||
---|---|---|---|
Line 269... | Line 269... | ||
269 | static void i8042_wait(void); |
269 | static void i8042_wait(void); |
270 | 270 | ||
271 | /** Initialize i8042. */ |
271 | /** Initialize i8042. */ |
272 | void i8042_init(void) |
272 | void i8042_init(void) |
273 | { |
273 | { |
- | 274 | int i; |
|
- | 275 | ||
274 | exc_register(VECTOR_KBD, "i8042_interrupt", (iroutine) i8042_interrupt); |
276 | exc_register(VECTOR_KBD, "i8042_interrupt", (iroutine) i8042_interrupt); |
275 | i8042_wait(); |
277 | i8042_wait(); |
276 | i8042_command_write(i8042_SET_COMMAND); |
278 | i8042_command_write(i8042_SET_COMMAND); |
277 | i8042_wait(); |
279 | i8042_wait(); |
278 | i8042_data_write(i8042_COMMAND); |
280 | i8042_data_write(i8042_COMMAND); |
279 | i8042_wait(); |
281 | i8042_wait(); |
280 | 282 | ||
281 | trap_virtual_enable_irqs(1<<IRQ_KBD); |
283 | trap_virtual_enable_irqs(1<<IRQ_KBD); |
282 | chardev_initialize("i8042_kbd", &kbrd, &ops); |
284 | chardev_initialize("i8042_kbd", &kbrd, &ops); |
283 | stdin = &kbrd; |
285 | stdin = &kbrd; |
- | 286 | ||
284 | /* |
287 | /* |
285 | * Clear input buffer |
288 | * Clear input buffer. |
- | 289 | * Number of iterations is limited to prevent infinite looping. |
|
286 | */ |
290 | */ |
287 | { |
- | |
288 | int a=0; |
- | |
289 | while((i8042_status_read()&i8042_BUFFER_FULL_MASK)&&(a<20)) { |
291 | for (i = 0; (i8042_status_read() & i8042_BUFFER_FULL_MASK) && i < 100; i++) { |
290 | i8042_data_read(); |
292 | i8042_data_read(); |
291 | a++; |
- | |
292 | } |
293 | } |
293 | } |
- | |
294 | } |
294 | } |
295 | 295 | ||
296 | /** Process i8042 interrupt. |
296 | /** Process i8042 interrupt. |
297 | * |
297 | * |
298 | * @param n Interrupt vector. |
298 | * @param n Interrupt vector. |