Changeset 30ab05f in mainline for genarch/src/i8042/i8042.c


Ignore:
Timestamp:
2006-02-27T20:33:36Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d87c3f3
Parents:
02f441c0
Message:

sparc64 work.
Very raw and fragile preliminary standalone keyboard support - polling mode only.
Because of a workaround in Simics, the scan codes are the same as on ia32.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • genarch/src/i8042/i8042.c

    r02f441c0 r30ab05f  
    5353/*
    5454 * 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:
    5656 *
    5757 *    |7|6|5|4|3|2|1|0|8042 Command Byte
     
    7474#define SPECIAL         '?'
    7575#define KEY_RELEASE     0x80
     76
     77/**
     78 * These codes read from i8042 data register are silently ignored.
     79 */
     80#define IGNORE_CODE     0x7f
    7681
    7782static void key_released(__u8 sc);
     
    262267
    263268static void i8042_interrupt(int n, void *stack);
     269static void i8042_wait(void);
    264270
    265271/** Initialize i8042. */
     
    267273{
    268274        exc_register(VECTOR_KBD, "i8042_interrupt", i8042_interrupt);
    269         while (i8042_status_read() & i8042_WAIT_MASK) {
    270                 /* wait */
    271         }
     275        i8042_wait();
    272276        i8042_command_write(i8042_SET_COMMAND);
    273         while (i8042_status_read() & i8042_WAIT_MASK) {
    274                 /* wait */
    275         }
     277        i8042_wait();
    276278        i8042_data_write(i8042_COMMAND);
     279        i8042_wait();
    277280
    278281        trap_virtual_enable_irqs(1<<IRQ_KBD);
     
    296299        else
    297300                key_pressed(x);
     301}
     302
     303/** Wait until the controller reads its data. */
     304void i8042_wait(void) {
     305        while (i8042_status_read() & i8042_WAIT_MASK) {
     306                /* wait */
     307        }
    298308}
    299309
     
    503513                        ;
    504514                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                }
    509521        }
    510522        return ch;
    511523}
     524
     525/** Poll for key press and release events.
     526 *
     527 * This function can be used to implement keyboard polling.
     528 */
     529void 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.