Changeset 30ab05f in mainline for genarch/src/i8042/i8042.c
- Timestamp:
- 2006-02-27T20:33:36Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d87c3f3
- Parents:
- 02f441c0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
genarch/src/i8042/i8042.c
r02f441c0 r30ab05f 53 53 /* 54 54 * 60 Write 8042 Command Byte: next data byte written to port 60h is 55 * placed in 8042 command register. Format:55 * placed in 8042 command register. Format: 56 56 * 57 57 * |7|6|5|4|3|2|1|0|8042 Command Byte … … 74 74 #define SPECIAL '?' 75 75 #define KEY_RELEASE 0x80 76 77 /** 78 * These codes read from i8042 data register are silently ignored. 79 */ 80 #define IGNORE_CODE 0x7f 76 81 77 82 static void key_released(__u8 sc); … … 262 267 263 268 static void i8042_interrupt(int n, void *stack); 269 static void i8042_wait(void); 264 270 265 271 /** Initialize i8042. */ … … 267 273 { 268 274 exc_register(VECTOR_KBD, "i8042_interrupt", i8042_interrupt); 269 while (i8042_status_read() & i8042_WAIT_MASK) { 270 /* wait */ 271 } 275 i8042_wait(); 272 276 i8042_command_write(i8042_SET_COMMAND); 273 while (i8042_status_read() & i8042_WAIT_MASK) { 274 /* wait */ 275 } 277 i8042_wait(); 276 278 i8042_data_write(i8042_COMMAND); 279 i8042_wait(); 277 280 278 281 trap_virtual_enable_irqs(1<<IRQ_KBD); … … 296 299 else 297 300 key_pressed(x); 301 } 302 303 /** Wait until the controller reads its data. */ 304 void i8042_wait(void) { 305 while (i8042_status_read() & i8042_WAIT_MASK) { 306 /* wait */ 307 } 298 308 } 299 309 … … 503 513 ; 504 514 x = i8042_data_read(); 505 if (x & KEY_RELEASE) 506 key_released(x ^ KEY_RELEASE); 507 else 508 active_read_key_pressed(x); 515 if (x != IGNORE_CODE) { 516 if (x & KEY_RELEASE) 517 key_released(x ^ KEY_RELEASE); 518 else 519 active_read_key_pressed(x); 520 } 509 521 } 510 522 return ch; 511 523 } 524 525 /** Poll for key press and release events. 526 * 527 * This function can be used to implement keyboard polling. 528 */ 529 void i8042_poll(void) 530 { 531 __u8 x; 532 533 while (((x = i8042_status_read() & i8042_BUFFER_FULL_MASK))) { 534 x = i8042_data_read(); 535 if (x != IGNORE_CODE) { 536 if (x & KEY_RELEASE) 537 key_released(x ^ KEY_RELEASE); 538 else 539 key_pressed(x); 540 } 541 } 542 }
Note:
See TracChangeset
for help on using the changeset viewer.