Subversion Repositories HelenOS

Rev

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

Rev 1874 Rev 1939
Line 40... Line 40...
40
#include <ipc/ipc.h>
40
#include <ipc/ipc.h>
41
#include <unistd.h>
41
#include <unistd.h>
42
#include <kbd.h>
42
#include <kbd.h>
43
#include <keys.h>
43
#include <keys.h>
44
#include <genarch/kbd.h>
44
#include <genarch/kbd.h>
-
 
45
#include <sysinfo.h>
45
 
46
 
46
/* Interesting bits for status register */
47
/* Interesting bits for status register */
47
#define i8042_OUTPUT_FULL  0x1
48
#define i8042_OUTPUT_FULL  0x1
48
#define i8042_INPUT_FULL   0x2
49
#define i8042_INPUT_FULL   0x2
49
#define i8042_MOUSE_DATA   0x20
50
#define i8042_MOUSE_DATA   0x20
Line 67... Line 68...
67
 
68
 
68
static volatile int keyflags;       /**< Tracking of multiple keypresses. */
69
static volatile int keyflags;       /**< Tracking of multiple keypresses. */
69
static volatile int lockflags;      /**< Tracking of multiple keys lockings. */
70
static volatile int lockflags;      /**< Tracking of multiple keys lockings. */
70
 
71
 
71
irq_cmd_t i8042_cmds[2] = {
72
irq_cmd_t i8042_cmds[2] = {
72
    { CMD_PORT_READ_1, (void *)0x64, 0, 1 },
73
    { CMD_PORT_READ_1, (void *) 0x64, 0, 1 },
73
    { CMD_PORT_READ_1, (void *)0x60, 0, 2 }
74
    { CMD_PORT_READ_1, (void *) 0x60, 0, 2 }
74
};
75
};
75
 
76
 
76
irq_code_t i8042_kbd = {
77
irq_code_t i8042_kbd = {
77
    2,
78
    2,
78
    i8042_cmds
79
    i8042_cmds
Line 89... Line 90...
89
int kbd_arch_init(void)
90
int kbd_arch_init(void)
90
{
91
{
91
    int i;
92
    int i;
92
    int mouseenabled = 0;
93
    int mouseenabled = 0;
93
 
94
 
94
    iospace_enable(task_get_id(),(void *)i8042_DATA, 5);
95
    iospace_enable(task_get_id(), (void *) i8042_DATA, 5);
95
    /* Disable kbd, enable mouse */
96
    /* Disable kbd, enable mouse */
96
    i8042_command_write(i8042_CMD_KBD);
97
    i8042_command_write(i8042_CMD_KBD);
97
    wait_ready();
98
    wait_ready();
98
    i8042_command_write(i8042_CMD_KBD);
99
    i8042_command_write(i8042_CMD_KBD);
99
    wait_ready();
100
    wait_ready();
Line 122... Line 123...
122
        usleep(1000);
123
        usleep(1000);
123
    }
124
    }
124
    if (mouseanswer == MOUSE_ACK) {
125
    if (mouseanswer == MOUSE_ACK) {
125
        /* enable mouse */
126
        /* enable mouse */
126
        mouseenabled = 1;
127
        mouseenabled = 1;
127
 
128
       
128
        ipc_register_irq(MOUSE_IRQ, &i8042_kbd);
129
        ipc_register_irq(sysinfo_value("mouse.inr"), sysinfo_value("mouse.devno"), 0, &i8042_kbd);
129
    }
130
    }
130
    /* Enable kbd */
131
    /* Enable kbd */
131
    ipc_register_irq(KBD_IRQ, &i8042_kbd);
132
    ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &i8042_kbd);
132
    /* Register for irq restart */
-
 
133
    ipc_register_irq(IPC_IRQ_KBDRESTART, NULL);
-
 
134
 
133
 
135
    int newcontrol = i8042_KBD_IE | i8042_KBD_TRANSLATE;
134
    int newcontrol = i8042_KBD_IE | i8042_KBD_TRANSLATE;
136
    if (mouseenabled)
135
    if (mouseenabled)
137
        newcontrol |= i8042_MOUSE_IE;
136
        newcontrol |= i8042_MOUSE_IE;
138
   
137
   
Line 147... Line 146...
147
/** Process keyboard & mouse events */
146
/** Process keyboard & mouse events */
148
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call)
147
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call)
149
{
148
{
150
    int status = IPC_GET_ARG1(*call);
149
    int status = IPC_GET_ARG1(*call);
151
 
150
 
152
    if (IPC_GET_METHOD(*call) == IPC_IRQ_KBDRESTART) {
-
 
153
        kbd_arch_init();
-
 
154
        return 1;
-
 
155
    }
-
 
156
 
-
 
157
    if ((status & i8042_MOUSE_DATA))
151
    if ((status & i8042_MOUSE_DATA))
158
        return 0;
152
        return 0;
159
   
153
   
160
    int scan_code = IPC_GET_ARG2(*call);
154
    int scan_code = IPC_GET_ARG2(*call);
161
   
155