Project

General

Profile

Revision 61

changes

View differences:

keyboard.c
12 12
    return (sys_irqsetpolicy(KBC_IRQ, IRQ_REENABLE | IRQ_EXCLUSIVE, interrupt_id));
13 13
}
14 14

  
15
int done = 1;
16
int sz = 1;
15 17
int got_error_keyboard = 0;
16
int two_byte_scancode = 0;
17 18

  
18 19
void (kbc_ih)(void) {
20
    if(done) sz = 1;
21
    else     sz++;
19 22
    uint8_t status = 0;
20 23
    got_error_keyboard = 0;
21

  
22 24
    if (util_sys_inb(STATUS_REG, &status)) {
23 25
        got_error_keyboard = 1;
24 26
        return;
25 27
    }
26

  
27 28
    if (status & (TIME_OUT_REC | PARITY_ERROR)) {
28 29
        got_error_keyboard = 1;
29 30
        return;
30 31
    }
31

  
32
    if ((status & OUT_BUF_FUL) == 0 || (status & AUX_MOUSE) != 0) {
33
        got_error_keyboard = 1;
34
        return;
35
    }
32 36
    uint8_t byte = 0;
33

  
34 37
    if (util_sys_inb(OUTPUT_BUF, &byte)) {
35 38
        got_error_keyboard = 1;
36 39
        return;
37 40
    }
38

  
39
    if (two_byte_scancode) {
40
        scancode[1] = byte;
41
        two_byte_scancode = 0;
42
    } else {
43
        scancode[0] = byte;
44
        two_byte_scancode = (byte == TWO_BYTE_CODE);
45
    }
46

  
41
    scancode[sz-1] = byte;
42
    done = !(TWO_BYTE_CODE == byte);
47 43
}
48 44

  
49 45
int (keyboard_poll)(uint8_t bytes[], uint8_t *size){

Also available in: Unified diff