Subversion Repositories HelenOS

Rev

Rev 1841 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1841 Rev 1842
Line 34... Line 34...
34
 * @brief   i8042 processor driver.
34
 * @brief   i8042 processor driver.
35
 *
35
 *
36
 * It takes care of low-level keyboard functions.
36
 * It takes care of low-level keyboard functions.
37
 */
37
 */
38
 
38
 
39
#include <genarch/i8042/i8042.h>
39
#include <genarch/kbd/i8042.h>
-
 
40
#include <genarch/kbd/scanc.h>
-
 
41
#include <genarch/kbd/scanc_pc.h>
40
#include <arch/drivers/i8042.h>
42
#include <arch/drivers/i8042.h>
41
#include <arch/interrupt.h>
43
#include <arch/interrupt.h>
42
#include <cpu.h>
44
#include <cpu.h>
43
#include <arch/asm.h>
45
#include <arch/asm.h>
44
#include <arch.h>
46
#include <arch.h>
Line 76... Line 78...
76
#define i8042_WAIT_MASK     0x02
78
#define i8042_WAIT_MASK     0x02
77
#define i8042_MOUSE_DATA        0x20
79
#define i8042_MOUSE_DATA        0x20
78
 
80
 
79
#define KEY_RELEASE 0x80
81
#define KEY_RELEASE 0x80
80
 
82
 
81
/**
-
 
82
 * These codes read from i8042 data register are silently ignored.
-
 
83
 */
-
 
84
#define IGNORE_CODE 0x7f
-
 
85
 
-
 
86
static void key_released(uint8_t sc);
83
static void key_released(uint8_t sc);
87
static void key_pressed(uint8_t sc);
84
static void key_pressed(uint8_t sc);
88
static char key_read(chardev_t *d);
85
static char key_read(chardev_t *d);
89
 
86
 
90
#define PRESSED_SHIFT       (1<<0)
87
#define PRESSED_SHIFT       (1<<0)
Line 388... Line 385...
388
    while(!(ch = active_read_buff_read())) {
385
    while(!(ch = active_read_buff_read())) {
389
        uint8_t x;
386
        uint8_t x;
390
        while (!(i8042_status_read() & i8042_BUFFER_FULL_MASK))
387
        while (!(i8042_status_read() & i8042_BUFFER_FULL_MASK))
391
            ;
388
            ;
392
        x = i8042_data_read();
389
        x = i8042_data_read();
393
        if (x != IGNORE_CODE) {
-
 
394
            if (x & KEY_RELEASE)
390
        if (x & KEY_RELEASE)
395
                key_released(x ^ KEY_RELEASE);
391
            key_released(x ^ KEY_RELEASE);
396
            else
392
        else
397
                active_read_key_pressed(x);
393
            active_read_key_pressed(x);
398
        }
-
 
399
    }
394
    }
400
    return ch;
395
    return ch;
401
}
396
}
402
 
397
 
403
/** Poll for key press and release events.
398
/** Poll for key press and release events.
Line 408... Line 403...
408
{
403
{
409
    uint8_t x;
404
    uint8_t x;
410
 
405
 
411
    while (((x = i8042_status_read() & i8042_BUFFER_FULL_MASK))) {
406
    while (((x = i8042_status_read() & i8042_BUFFER_FULL_MASK))) {
412
        x = i8042_data_read();
407
        x = i8042_data_read();
413
        if (x != IGNORE_CODE) {
-
 
414
            if (x & KEY_RELEASE)
408
        if (x & KEY_RELEASE)
415
                key_released(x ^ KEY_RELEASE);
409
            key_released(x ^ KEY_RELEASE);
416
            else
410
        else
417
                key_pressed(x);
411
            key_pressed(x);
418
        }
-
 
419
    }
412
    }
420
}
413
}
421
 
414
 
422
/** @}
415
/** @}
423
 */
416
 */
424
 
-