Subversion Repositories HelenOS

Rev

Rev 3661 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3661 Rev 3662
1
/*
1
/*
2
 * Copyright (c) 2006 Josef Cejka
2
 * Copyright (c) 2006 Josef Cejka
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/** @addtogroup kbdia64 ia64
29
/** @addtogroup kbdia64 ia64
30
 * @brief   HelenOS ia64 arch dependent parts of uspace keyboard handler.
30
 * @brief   HelenOS ia64 arch dependent parts of uspace keyboard handler.
31
 * @ingroup  kbd
31
 * @ingroup  kbd
32
 * @{
32
 * @{
33
 */
33
 */
34
/** @file
34
/** @file
35
 */
35
 */
36
 
36
 
37
#include <arch/kbd.h>
37
#include <arch/kbd.h>
38
#include <ipc/ipc.h>
38
#include <ipc/ipc.h>
39
#include <sysinfo.h>
39
#include <sysinfo.h>
40
#include <kbd.h>
40
#include <kbd.h>
41
#include <keys.h>
41
#include <keys.h>
42
#include <stdio.h>
42
#include <stdio.h>
43
#include <stdlib.h>
43
#include <stdlib.h>
44
 
44
 
45
#include <unistd.h>
45
#include <unistd.h>
46
#include <align.h>
46
#include <align.h>
47
#include <async.h>
47
#include <async.h>
48
#include <ipc/ipc.h>
48
#include <ipc/ipc.h>
49
#include <errno.h>
49
#include <errno.h>
50
#include <stdio.h>
50
#include <stdio.h>
51
#include <ddi.h>
51
#include <ddi.h>
52
#include <sysinfo.h>
52
#include <sysinfo.h>
53
#include <as.h>
53
#include <as.h>
54
#include <ipc/fb.h>
54
#include <ipc/fb.h>
55
#include <ipc/ipc.h>
55
#include <ipc/ipc.h>
56
#include <ipc/ns.h>
56
#include <ipc/ns.h>
57
#include <ipc/services.h>
57
#include <ipc/services.h>
58
#include <libarch/ddi.h>
58
#include <libarch/ddi.h>
59
 
59
 
60
 
60
 
61
extern int lkbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call);
61
extern int lkbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call);
62
extern int lkbd_arch_init(void);
62
extern int lkbd_arch_init(void);
63
 
63
 
64
 
64
 
65
 
65
 
66
#define KEY_F1 0x504f1b
66
#define KEY_F1 0x504f1b
67
#define KEY_F2 0x514f1b
67
#define KEY_F2 0x514f1b
68
#define KEY_F3 0x524f1b
68
#define KEY_F3 0x524f1b
69
#define KEY_F4 0x534f1b
69
#define KEY_F4 0x534f1b
70
#define KEY_F5 0x7e35315b1b
70
#define KEY_F5 0x7e35315b1b
71
#define KEY_F6 0x7e37315b1b
71
#define KEY_F6 0x7e37315b1b
72
#define KEY_F7 0x7e38315b1b
72
#define KEY_F7 0x7e38315b1b
73
#define KEY_F8 0x7e39315b1b
73
#define KEY_F8 0x7e39315b1b
74
#define KEY_F9 0x7e30325b1b
74
#define KEY_F9 0x7e30325b1b
75
#define KEY_F10 0x7e31325b1b
75
#define KEY_F10 0x7e31325b1b
76
#define KEY_F11 0x7e33325b1b
76
#define KEY_F11 0x7e33325b1b
77
#define KEY_F12 0x7e34325b1b
77
#define KEY_F12 0x7e34325b1b
78
 
78
 
79
 
79
 
80
 
80
 
81
 
81
 
82
#define NSKEY_F1 0x415b5b1b
82
#define NSKEY_F1 0x415b5b1b
83
#define NSKEY_F2 0x425b5b1b
83
#define NSKEY_F2 0x425b5b1b
84
#define NSKEY_F3 0x435b5b1b
84
#define NSKEY_F3 0x435b5b1b
85
#define NSKEY_F4 0x445b5b1b
85
#define NSKEY_F4 0x445b5b1b
86
#define NSKEY_F5 0x455b5b1b
86
#define NSKEY_F5 0x455b5b1b
87
#define NSKEY_F6 0x37315b1b
87
#define NSKEY_F6 0x37315b1b
88
#define NSKEY_F7 0x38315b1b
88
#define NSKEY_F7 0x38315b1b
89
#define NSKEY_F8 0x39315b1b
89
#define NSKEY_F8 0x39315b1b
90
#define NSKEY_F9 0x30325b1b
90
#define NSKEY_F9 0x30325b1b
91
#define NSKEY_F10 0x31325b1b
91
#define NSKEY_F10 0x31325b1b
92
#define NSKEY_F11 0x33325b1b
92
#define NSKEY_F11 0x33325b1b
93
#define NSKEY_F12 0x34325b1b
93
#define NSKEY_F12 0x34325b1b
94
 
94
 
95
 
95
 
96
#define FUNCTION_KEYS 0x100
96
#define FUNCTION_KEYS 0x100
97
 
97
 
98
 
98
 
99
#define KBD_SKI 1
99
#define KBD_SKI 1
100
#define KBD_LEGACY 2
100
#define KBD_LEGACY 2
101
#define KBD_NS16550 3
101
#define KBD_NS16550 3
102
 
102
 
103
 
103
 
104
 
104
 
105
 
105
 
106
/* NS16550 registers */
106
/* NS16550 registers */
107
#define RBR_REG     0   /** Receiver Buffer Register. */
107
#define RBR_REG     0   /** Receiver Buffer Register. */
108
#define IER_REG     1   /** Interrupt Enable Register. */
108
#define IER_REG     1   /** Interrupt Enable Register. */
109
#define IIR_REG     2   /** Interrupt Ident Register (read). */
109
#define IIR_REG     2   /** Interrupt Ident Register (read). */
110
#define FCR_REG     2   /** FIFO control register (write). */
110
#define FCR_REG     2   /** FIFO control register (write). */
111
#define LCR_REG     3   /** Line Control register. */
111
#define LCR_REG     3   /** Line Control register. */
112
#define MCR_REG     4   /** Modem Control Register. */
112
#define MCR_REG     4   /** Modem Control Register. */
113
#define LSR_REG     5   /** Line Status Register. */
113
#define LSR_REG     5   /** Line Status Register. */
114
 
114
 
115
 
115
 
116
 
116
 
117
 
117
 
118
irq_cmd_t ski_cmds[1] = {
118
irq_cmd_t ski_cmds[1] = {
119
    { CMD_IA64_GETCHAR, 0, 0, 2 }
119
    { CMD_IA64_GETCHAR, 0, 0, 2 }
120
};
120
};
121
 
121
 
122
irq_code_t ski_kbd = {
122
irq_code_t ski_kbd = {
123
    1,
123
    1,
124
    ski_cmds
124
    ski_cmds
125
};
125
};
126
 
126
 
127
 
127
 
128
 
128
 
129
irq_cmd_t ns16550_cmds[1] = {
129
irq_cmd_t ns16550_cmds[1] = {
130
    { CMD_PORT_READ_1, 0, 0, 2 },
130
    { CMD_PORT_READ_1, 0, 0, 2 },
131
};
131
};
132
 
132
 
133
irq_code_t ns16550_kbd = {
133
irq_code_t ns16550_kbd = {
134
    1,
134
    1,
135
    ns16550_cmds
135
    ns16550_cmds
136
};
136
};
137
 
137
 
138
 
138
 
139
uint16_t ns16550_port;
139
uint16_t ns16550_port;
140
 
140
 
141
int kbd_type;
141
int kbd_type;
142
 
142
 
143
int kbd_arch_init(void)
143
int kbd_arch_init(void)
144
{
144
{
145
    if (sysinfo_value("kbd")) {
145
    if (sysinfo_value("kbd")) {
146
        kbd_type=sysinfo_value("kbd.type");
146
        kbd_type=sysinfo_value("kbd.type");
147
        if(kbd_type==KBD_SKI) ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &ski_kbd);
147
        if(kbd_type==KBD_SKI) ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &ski_kbd);
148
        if(kbd_type==KBD_LEGACY) return lkbd_arch_init();
148
        if(kbd_type==KBD_LEGACY) return lkbd_arch_init();
149
        if(kbd_type==KBD_NS16550) {
149
        if(kbd_type==KBD_NS16550) {
150
            ns16550_kbd.cmds[0].addr= (void *)  (sysinfo_value("kbd.port")+RBR_REG);
150
            ns16550_kbd.cmds[0].addr= (void *)  (sysinfo_value("kbd.port")+RBR_REG);
151
            ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &ns16550_kbd);
151
            ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &ns16550_kbd);
152
            iospace_enable(task_get_id(),ns16550_port=sysinfo_value("kbd.port"),8);
152
            iospace_enable(task_get_id(),ns16550_port=sysinfo_value("kbd.port"),8);
153
        }  
153
        }  
154
        return 0;
154
        return 0;
155
    }  
155
    }  
156
    return 1;
156
    return 1;
157
}
157
}
158
 
158
 
159
/*
159
/*
160
* Please preserve this code (it can be used to determine scancodes)
160
* Please preserve this code (it can be used to determine scancodes)
161
*
161
*
162
int to_hex(int v)
162
int to_hex(int v)
163
{
163
{
164
    return "0123456789ABCDEF"[v];
164
    return "0123456789ABCDEF"[v];
165
}
165
}
166
*/
166
*/
167
#define LSR_DATA_READY  0x01
167
#define LSR_DATA_READY  0x01
168
 
168
 
169
int kbd_ns16550_process(keybuffer_t *keybuffer, ipc_call_t *call)
169
int kbd_ns16550_process(keybuffer_t *keybuffer, ipc_call_t *call)
170
{
170
{
171
    static unsigned long buf = 0;
171
    static unsigned long buf = 0;
172
    static int count = 0, esc_count=0; 
172
    static int count = 0, esc_count=0; 
173
 
173
 
174
    int scan_code = IPC_GET_ARG2(*call);
174
    int scan_code = IPC_GET_ARG2(*call);
175
 
175
 
176
    if (scan_code == 0x1b) {
176
    if (scan_code == 0x1b) {
177
        esc_count++;
177
        esc_count++;
178
        if (esc_count == 3) {
178
        if (esc_count == 3) {
179
            __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE);
179
            __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE);
180
        }  
180
        }  
181
    } else {
181
    } else {
182
        esc_count = 0;
182
        esc_count = 0;
183
    }
183
    }
184
 
184
 
185
    if(scan_code==0x0d) return 1;   //Delete CR
185
    if(scan_code==0x0d) return 1;   //Delete CR
-
 
186
    if(scan_code==0x7f) scan_code='\b'; //Convert backspace
186
 
187
 
187
    if(scan_code == 0x7e) {
188
    if(scan_code == 0x7e) {
188
        switch (buf) {
189
        switch (buf) {
189
        case NSKEY_F6:
190
        case NSKEY_F6:
190
            keybuffer_push(keybuffer,FUNCTION_KEYS | 6);
191
            keybuffer_push(keybuffer,FUNCTION_KEYS | 6);
191
            buf = count = 0;
192
            buf = count = 0;
192
            return 1;
193
            return 1;
193
        case NSKEY_F7:
194
        case NSKEY_F7:
194
            keybuffer_push(keybuffer,FUNCTION_KEYS | 7);
195
            keybuffer_push(keybuffer,FUNCTION_KEYS | 7);
195
            buf = count = 0;
196
            buf = count = 0;
196
            return 1;
197
            return 1;
197
        case NSKEY_F8:
198
        case NSKEY_F8:
198
            keybuffer_push(keybuffer,FUNCTION_KEYS | 8);
199
            keybuffer_push(keybuffer,FUNCTION_KEYS | 8);
199
            buf = count = 0;
200
            buf = count = 0;
200
            return 1;
201
            return 1;
201
        case NSKEY_F9:
202
        case NSKEY_F9:
202
            keybuffer_push(keybuffer,FUNCTION_KEYS | 9);
203
            keybuffer_push(keybuffer,FUNCTION_KEYS | 9);
203
            buf = count = 0;
204
            buf = count = 0;
204
            return 1;
205
            return 1;
205
        case NSKEY_F10:
206
        case NSKEY_F10:
206
            keybuffer_push(keybuffer,FUNCTION_KEYS | 10);
207
            keybuffer_push(keybuffer,FUNCTION_KEYS | 10);
207
            buf = count = 0;
208
            buf = count = 0;
208
            return 1;
209
            return 1;
209
        case NSKEY_F11:
210
        case NSKEY_F11:
210
            keybuffer_push(keybuffer,FUNCTION_KEYS | 11);
211
            keybuffer_push(keybuffer,FUNCTION_KEYS | 11);
211
            buf = count = 0;
212
            buf = count = 0;
212
            return 1;
213
            return 1;
213
        case NSKEY_F12:
214
        case NSKEY_F12:
214
            keybuffer_push(keybuffer,FUNCTION_KEYS | 12);
215
            keybuffer_push(keybuffer,FUNCTION_KEYS | 12);
215
            buf = count = 0;
216
            buf = count = 0;
216
            return 1;
217
            return 1;
217
        default:
218
        default:
218
            keybuffer_push(keybuffer, buf & 0xff);
219
            keybuffer_push(keybuffer, buf & 0xff);
219
            keybuffer_push(keybuffer, (buf >> 8) &0xff);
220
            keybuffer_push(keybuffer, (buf >> 8) &0xff);
220
            keybuffer_push(keybuffer, (buf >> 16) &0xff);
221
            keybuffer_push(keybuffer, (buf >> 16) &0xff);
221
            keybuffer_push(keybuffer, (buf >> 24) &0xff);
222
            keybuffer_push(keybuffer, (buf >> 24) &0xff);
222
            keybuffer_push(keybuffer, scan_code);
223
            keybuffer_push(keybuffer, scan_code);
223
            buf = count = 0;
224
            buf = count = 0;
224
            return 1;
225
            return 1;
225
        }
226
        }
226
    }
227
    }
227
 
228
 
228
    buf |= ((unsigned long) scan_code)<<(8*(count++));
229
    buf |= ((unsigned long) scan_code)<<(8*(count++));
229
   
230
   
230
    if((buf & 0xff) != (NSKEY_F1 & 0xff)) {
231
    if((buf & 0xff) != (NSKEY_F1 & 0xff)) {
231
        keybuffer_push(keybuffer, buf);
232
        keybuffer_push(keybuffer, buf);
232
        buf = count = 0;
233
        buf = count = 0;
233
        return 1;
234
        return 1;
234
    }
235
    }
235
 
236
 
236
    if (count <= 1)
237
    if (count <= 1)
237
        return 1;
238
        return 1;
238
 
239
 
239
    if ((buf & 0xffff) != (NSKEY_F1 & 0xffff))  {
240
    if ((buf & 0xffff) != (NSKEY_F1 & 0xffff))  {
240
 
241
 
241
        keybuffer_push(keybuffer, buf & 0xff);
242
        keybuffer_push(keybuffer, buf & 0xff);
242
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
243
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
243
        buf = count = 0;
244
        buf = count = 0;
244
        return 1;
245
        return 1;
245
    }
246
    }
246
 
247
 
247
    if (count <= 2)
248
    if (count <= 2)
248
        return 1;
249
        return 1;
249
 
250
 
250
 
251
 
251
    if ((buf & 0xffffff) != (NSKEY_F1 & 0xffffff)
252
    if ((buf & 0xffffff) != (NSKEY_F1 & 0xffffff)
252
        && (buf & 0xffffff) != (NSKEY_F6 & 0xffffff)
253
        && (buf & 0xffffff) != (NSKEY_F6 & 0xffffff)
253
        && (buf & 0xffffff) != (NSKEY_F9 & 0xffffff) ) {
254
        && (buf & 0xffffff) != (NSKEY_F9 & 0xffffff) ) {
254
 
255
 
255
        keybuffer_push(keybuffer, buf & 0xff);
256
        keybuffer_push(keybuffer, buf & 0xff);
256
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
257
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
257
        keybuffer_push(keybuffer, (buf >> 16) &0xff);
258
        keybuffer_push(keybuffer, (buf >> 16) &0xff);
258
        buf = count = 0;
259
        buf = count = 0;
259
        return 1;
260
        return 1;
260
    }
261
    }
261
 
262
 
262
    if (count <= 3)
263
    if (count <= 3)
263
        return 1;
264
        return 1;
264
 
265
 
265
    switch (buf) {
266
    switch (buf) {
266
    case NSKEY_F1:
267
    case NSKEY_F1:
267
        keybuffer_push(keybuffer,FUNCTION_KEYS | 1);
268
        keybuffer_push(keybuffer,FUNCTION_KEYS | 1);
268
        buf = count = 0;
269
        buf = count = 0;
269
        return 1;
270
        return 1;
270
    case NSKEY_F2:
271
    case NSKEY_F2:
271
        keybuffer_push(keybuffer,FUNCTION_KEYS | 2);
272
        keybuffer_push(keybuffer,FUNCTION_KEYS | 2);
272
        buf = count = 0;
273
        buf = count = 0;
273
        return 1;
274
        return 1;
274
    case NSKEY_F3:
275
    case NSKEY_F3:
275
        keybuffer_push(keybuffer,FUNCTION_KEYS | 3);
276
        keybuffer_push(keybuffer,FUNCTION_KEYS | 3);
276
        buf = count = 0;
277
        buf = count = 0;
277
        return 1;
278
        return 1;
278
    case NSKEY_F4:
279
    case NSKEY_F4:
279
        keybuffer_push(keybuffer,FUNCTION_KEYS | 4);
280
        keybuffer_push(keybuffer,FUNCTION_KEYS | 4);
280
        buf = count = 0;
281
        buf = count = 0;
281
        return 1;
282
        return 1;
282
    case NSKEY_F5:
283
    case NSKEY_F5:
283
        keybuffer_push(keybuffer,FUNCTION_KEYS | 5);
284
        keybuffer_push(keybuffer,FUNCTION_KEYS | 5);
284
        buf = count = 0;
285
        buf = count = 0;
285
        return 1;
286
        return 1;
286
    }
287
    }
287
 
288
 
288
 
289
 
289
   
290
   
290
    switch (buf) {
291
    switch (buf) {
291
    case NSKEY_F6:
292
    case NSKEY_F6:
292
    case NSKEY_F7:
293
    case NSKEY_F7:
293
    case NSKEY_F8:
294
    case NSKEY_F8:
294
    case NSKEY_F9:
295
    case NSKEY_F9:
295
    case NSKEY_F10:
296
    case NSKEY_F10:
296
    case NSKEY_F11:
297
    case NSKEY_F11:
297
    case NSKEY_F12:
298
    case NSKEY_F12:
298
        return 1;
299
        return 1;
299
    default:
300
    default:
300
        keybuffer_push(keybuffer, buf & 0xff);
301
        keybuffer_push(keybuffer, buf & 0xff);
301
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
302
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
302
        keybuffer_push(keybuffer, (buf >> 16) &0xff);
303
        keybuffer_push(keybuffer, (buf >> 16) &0xff);
303
        keybuffer_push(keybuffer, (buf >> 24) &0xff);
304
        keybuffer_push(keybuffer, (buf >> 24) &0xff);
304
        buf = count = 0;
305
        buf = count = 0;
305
        return 1;
306
        return 1;
306
    }
307
    }
307
    return 1;
308
    return 1;
308
}
309
}
309
 
310
 
310
 
311
 
311
 
312
 
312
 
313
 
313
 
314
 
314
 
315
 
315
 
316
 
316
int kbd_ski_process(keybuffer_t *keybuffer, ipc_call_t *call)
317
int kbd_ski_process(keybuffer_t *keybuffer, ipc_call_t *call)
317
{
318
{
318
    static unsigned long long buf = 0;
319
    static unsigned long long buf = 0;
319
    static int count = 0;  
320
    static int count = 0;  
320
    static int esc_count = 0;
321
    static int esc_count = 0;
321
    int scan_code = IPC_GET_ARG2(*call);
322
    int scan_code = IPC_GET_ARG2(*call);
322
   
323
   
323
    /*
324
    /*
324
     * Please preserve this code (it can be used to determine scancodes)
325
     * Please preserve this code (it can be used to determine scancodes)
325
     */
326
     */
326
    //keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf));
327
    //keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf));
327
    //keybuffer_push(keybuffer, to_hex(scan_code&0xf));
328
    //keybuffer_push(keybuffer, to_hex(scan_code&0xf));
328
    //keybuffer_push(keybuffer, ' ');
329
    //keybuffer_push(keybuffer, ' ');
329
    //keybuffer_push(keybuffer, ' ');
330
    //keybuffer_push(keybuffer, ' ');
330
    //*/
331
    //*/
331
   
332
   
332
    if (scan_code) {
333
    if (scan_code) {
333
        buf |= (unsigned long long) scan_code<<(8*(count++));
334
        buf |= (unsigned long long) scan_code<<(8*(count++));
334
    } else {
335
    } else {
335
       
336
       
336
        if (buf == 0x1b) {
337
        if (buf == 0x1b) {
337
            esc_count++;
338
            esc_count++;
338
            if (esc_count == 3) {
339
            if (esc_count == 3) {
339
                __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE);
340
                __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE);
340
            }  
341
            }  
341
        } else {
342
        } else {
342
            esc_count = 0;
343
            esc_count = 0;
343
        }
344
        }
344
   
345
   
345
        if (!(buf & 0xff00)) {
346
        if (!(buf & 0xff00)) {
346
            keybuffer_push(keybuffer, buf);
347
            keybuffer_push(keybuffer, buf);
347
        } else {
348
        } else {
348
            switch (buf) {
349
            switch (buf) {
349
            case KEY_F1:
350
            case KEY_F1:
350
                keybuffer_push(keybuffer, FUNCTION_KEYS | 1);
351
                keybuffer_push(keybuffer, FUNCTION_KEYS | 1);
351
                break;
352
                break;
352
            case KEY_F2:
353
            case KEY_F2:
353
                keybuffer_push(keybuffer, FUNCTION_KEYS | 2);
354
                keybuffer_push(keybuffer, FUNCTION_KEYS | 2);
354
                break;
355
                break;
355
            case KEY_F3:
356
            case KEY_F3:
356
                keybuffer_push(keybuffer, FUNCTION_KEYS | 3);
357
                keybuffer_push(keybuffer, FUNCTION_KEYS | 3);
357
                break;
358
                break;
358
            case KEY_F4:
359
            case KEY_F4:
359
                keybuffer_push(keybuffer, FUNCTION_KEYS | 4);
360
                keybuffer_push(keybuffer, FUNCTION_KEYS | 4);
360
                break;
361
                break;
361
            case KEY_F5:
362
            case KEY_F5:
362
                keybuffer_push(keybuffer, FUNCTION_KEYS | 5);
363
                keybuffer_push(keybuffer, FUNCTION_KEYS | 5);
363
                break;
364
                break;
364
            case KEY_F6:
365
            case KEY_F6:
365
                keybuffer_push(keybuffer, FUNCTION_KEYS | 6);
366
                keybuffer_push(keybuffer, FUNCTION_KEYS | 6);
366
                break;
367
                break;
367
            case KEY_F7:
368
            case KEY_F7:
368
                keybuffer_push(keybuffer, FUNCTION_KEYS | 7);
369
                keybuffer_push(keybuffer, FUNCTION_KEYS | 7);
369
                break;
370
                break;
370
            case KEY_F8:
371
            case KEY_F8:
371
                keybuffer_push(keybuffer, FUNCTION_KEYS | 8);
372
                keybuffer_push(keybuffer, FUNCTION_KEYS | 8);
372
                break;
373
                break;
373
            case KEY_F9:
374
            case KEY_F9:
374
                keybuffer_push(keybuffer, FUNCTION_KEYS | 9);
375
                keybuffer_push(keybuffer, FUNCTION_KEYS | 9);
375
                break;
376
                break;
376
            case KEY_F10:
377
            case KEY_F10:
377
                keybuffer_push(keybuffer, FUNCTION_KEYS | 10);
378
                keybuffer_push(keybuffer, FUNCTION_KEYS | 10);
378
                break;
379
                break;
379
            case KEY_F11:
380
            case KEY_F11:
380
                keybuffer_push(keybuffer, FUNCTION_KEYS | 11);
381
                keybuffer_push(keybuffer, FUNCTION_KEYS | 11);
381
                break;
382
                break;
382
            case KEY_F12:
383
            case KEY_F12:
383
                keybuffer_push(keybuffer, FUNCTION_KEYS | 12);
384
                keybuffer_push(keybuffer, FUNCTION_KEYS | 12);
384
                break;
385
                break;
385
            }
386
            }
386
        }
387
        }
387
        buf = count = 0;
388
        buf = count = 0;
388
    }
389
    }
389
    return  1;
390
    return  1;
390
}
391
}
391
 
392
 
392
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call)
393
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call)
393
{
394
{
394
    printf("KBD Key pressed: %x(%c)\n",IPC_GET_ARG2(*call),IPC_GET_ARG2(*call));
395
    printf("KBD Key pressed: %x(%c)\n",IPC_GET_ARG2(*call),IPC_GET_ARG2(*call));
395
    if(kbd_type==KBD_SKI) return kbd_ski_process(keybuffer,call);
396
    if(kbd_type==KBD_SKI) return kbd_ski_process(keybuffer,call);
396
    if(kbd_type==KBD_NS16550) return kbd_ns16550_process(keybuffer,call);
397
    if(kbd_type==KBD_NS16550) return kbd_ns16550_process(keybuffer,call);
397
    if(kbd_type==KBD_LEGACY) return lkbd_arch_process(keybuffer,call);
398
    if(kbd_type==KBD_LEGACY) return lkbd_arch_process(keybuffer,call);
398
 
399
 
399
   
400
   
400
}
401
}
401
 
402
 
402
 
403
 
403
 
404
 
404
/**
405
/**
405
 * @}
406
 * @}
406
 */
407
 */
407
 
408