Subversion Repositories HelenOS

Rev

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

Rev 1874 Rev 1938
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 kbdmips32 mips32
29
/** @addtogroup kbdmips32 mips32
30
 * @brief   HelenOS mips32 arch dependent parts of uspace keyboard handler.
30
 * @brief   HelenOS mips32 arch dependent parts of uspace keyboard handler.
31
 * @ingroup  kbd
31
 * @ingroup  kbd
32
 * @{
32
 * @{
33
 */
33
 */
34
/** @file
34
/** @file
35
 */
35
 */
36
#include <arch/kbd.h>
36
#include <arch/kbd.h>
37
#include <ipc/ipc.h>
37
#include <ipc/ipc.h>
38
#include <sysinfo.h>
38
#include <sysinfo.h>
39
#include <kbd.h>
39
#include <kbd.h>
40
#include <keys.h>
40
#include <keys.h>
41
 
41
 
42
#define MSIM_KEY_F1 0x504f1bL
42
#define MSIM_KEY_F1 0x504f1bL
43
#define MSIM_KEY_F2 0x514f1bL
43
#define MSIM_KEY_F2 0x514f1bL
44
#define MSIM_KEY_F3 0x524f1bL
44
#define MSIM_KEY_F3 0x524f1bL
45
#define MSIM_KEY_F4 0x534f1bL
45
#define MSIM_KEY_F4 0x534f1bL
46
#define MSIM_KEY_F5 0x35315b1bL
46
#define MSIM_KEY_F5 0x35315b1bL
47
#define MSIM_KEY_F6 0x37315b1bL
47
#define MSIM_KEY_F6 0x37315b1bL
48
#define MSIM_KEY_F7 0x38315b1bL
48
#define MSIM_KEY_F7 0x38315b1bL
49
#define MSIM_KEY_F8 0x39315b1bL
49
#define MSIM_KEY_F8 0x39315b1bL
50
#define MSIM_KEY_F9 0x30325b1bL
50
#define MSIM_KEY_F9 0x30325b1bL
51
#define MSIM_KEY_F10 0x31325b1bL
51
#define MSIM_KEY_F10 0x31325b1bL
52
#define MSIM_KEY_F11 0x33325b1bL
52
#define MSIM_KEY_F11 0x33325b1bL
53
#define MSIM_KEY_F12 0x34325b1bL
53
#define MSIM_KEY_F12 0x34325b1bL
54
 
54
 
55
#define GXEMUL_KEY_F1 0x504f5b1bL
55
#define GXEMUL_KEY_F1 0x504f5b1bL
56
#define GXEMUL_KEY_F2 0x514f5b1bL
56
#define GXEMUL_KEY_F2 0x514f5b1bL
57
#define GXEMUL_KEY_F3 0x524f5b1bL
57
#define GXEMUL_KEY_F3 0x524f5b1bL
58
#define GXEMUL_KEY_F4 0x534f5b1bL
58
#define GXEMUL_KEY_F4 0x534f5b1bL
59
#define GXEMUL_KEY_F5 0x35315b1bL
59
#define GXEMUL_KEY_F5 0x35315b1bL
60
#define GXEMUL_KEY_F6 0x37315b1bL
60
#define GXEMUL_KEY_F6 0x37315b1bL
61
#define GXEMUL_KEY_F7 0x38315b1bL
61
#define GXEMUL_KEY_F7 0x38315b1bL
62
#define GXEMUL_KEY_F8 0x39315b1bL
62
#define GXEMUL_KEY_F8 0x39315b1bL
63
#define GXEMUL_KEY_F9 0x38325b1bL
63
#define GXEMUL_KEY_F9 0x38325b1bL
64
#define GXEMUL_KEY_F10 0x39325b1bL
64
#define GXEMUL_KEY_F10 0x39325b1bL
65
#define GXEMUL_KEY_F11 0x33325b1bL
65
#define GXEMUL_KEY_F11 0x33325b1bL
66
#define GXEMUL_KEY_F12 0x34325b1bL
66
#define GXEMUL_KEY_F12 0x34325b1bL
67
 
67
 
68
#define FUNCTION_KEYS 0x100
68
#define FUNCTION_KEYS 0x100
69
 
69
 
70
irq_cmd_t msim_cmds[1] = {
70
irq_cmd_t msim_cmds[1] = {
71
    { CMD_MEM_READ_1, (void *)0xB0000000, 0, 2 }
71
    { CMD_MEM_READ_1, (void *) 0, 0, 2 }
72
};
72
};
73
 
73
 
74
irq_code_t msim_kbd = {
74
irq_code_t msim_kbd = {
75
    1,
75
    1,
76
    msim_cmds
76
    msim_cmds
77
};
77
};
78
 
78
 
79
static int msim,gxemul;
79
static int msim,gxemul;
80
static int fb_fb;
80
static int fb_fb;
81
 
81
 
82
 
82
 
83
int kbd_arch_init(void)
83
int kbd_arch_init(void)
84
{
84
{
85
    fb_fb = (sysinfo_value("fb.kind") == 1);
85
    fb_fb = (sysinfo_value("fb.kind") == 1);
-
 
86
    msim_cmds[0].addr = sysinfo_value("kbd.address.virtual");
86
    ipc_register_irq(2, &msim_kbd);
87
    ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &msim_kbd);
87
    return 0;
88
    return 0;
88
}
89
}
89
 
90
 
90
 
91
 
91
/*
92
/*
92
//*
93
//*
93
//* Please preserve this code (it can be used to determine scancodes)
94
//* Please preserve this code (it can be used to determine scancodes)
94
//*
95
//*
95
int to_hex(int v)
96
int to_hex(int v)
96
{
97
{
97
        return "0123456789ABCDEF"[v];
98
        return "0123456789ABCDEF"[v];
98
}
99
}
99
*/
100
*/
100
 
101
 
101
static int kbd_arch_process_no_fb(keybuffer_t *keybuffer, int scan_code)
102
static int kbd_arch_process_no_fb(keybuffer_t *keybuffer, int scan_code)
102
{
103
{
103
 
104
 
104
    static unsigned long buf = 0;
105
    static unsigned long buf = 0;
105
    static int count = 0;  
106
    static int count = 0;  
106
 
107
 
107
    /* Please preserve this code (it can be used to determine scancodes)
108
    /* Please preserve this code (it can be used to determine scancodes)
108
   
109
   
109
    keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf));
110
    keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf));
110
    keybuffer_push(keybuffer, to_hex(scan_code&0xf));
111
    keybuffer_push(keybuffer, to_hex(scan_code&0xf));
111
    keybuffer_push(keybuffer, ' ');
112
    keybuffer_push(keybuffer, ' ');
112
    keybuffer_push(keybuffer, ' ');
113
    keybuffer_push(keybuffer, ' ');
113
   
114
   
114
    return 1;
115
    return 1;
115
    */
116
    */
116
   
117
   
117
    if(scan_code == 0x7e) {
118
    if(scan_code == 0x7e) {
118
        switch (buf) {
119
        switch (buf) {
119
        case MSIM_KEY_F5:
120
        case MSIM_KEY_F5:
120
            keybuffer_push(keybuffer,FUNCTION_KEYS | 5);
121
            keybuffer_push(keybuffer,FUNCTION_KEYS | 5);
121
            buf = count = 0;
122
            buf = count = 0;
122
            return 1;
123
            return 1;
123
        case MSIM_KEY_F6:
124
        case MSIM_KEY_F6:
124
            keybuffer_push(keybuffer,FUNCTION_KEYS | 6);
125
            keybuffer_push(keybuffer,FUNCTION_KEYS | 6);
125
            buf = count = 0;
126
            buf = count = 0;
126
            return 1;
127
            return 1;
127
        case MSIM_KEY_F7:
128
        case MSIM_KEY_F7:
128
            keybuffer_push(keybuffer,FUNCTION_KEYS | 7);
129
            keybuffer_push(keybuffer,FUNCTION_KEYS | 7);
129
            buf = count = 0;
130
            buf = count = 0;
130
            return 1;
131
            return 1;
131
        case MSIM_KEY_F8:
132
        case MSIM_KEY_F8:
132
            keybuffer_push(keybuffer,FUNCTION_KEYS | 8);
133
            keybuffer_push(keybuffer,FUNCTION_KEYS | 8);
133
            buf = count = 0;
134
            buf = count = 0;
134
            return 1;
135
            return 1;
135
        case MSIM_KEY_F9:
136
        case MSIM_KEY_F9:
136
            keybuffer_push(keybuffer,FUNCTION_KEYS | 9);
137
            keybuffer_push(keybuffer,FUNCTION_KEYS | 9);
137
            buf = count = 0;
138
            buf = count = 0;
138
            return 1;
139
            return 1;
139
        case MSIM_KEY_F10:
140
        case MSIM_KEY_F10:
140
            keybuffer_push(keybuffer,FUNCTION_KEYS | 10);
141
            keybuffer_push(keybuffer,FUNCTION_KEYS | 10);
141
            buf = count = 0;
142
            buf = count = 0;
142
            return 1;
143
            return 1;
143
        case MSIM_KEY_F11:
144
        case MSIM_KEY_F11:
144
            keybuffer_push(keybuffer,FUNCTION_KEYS | 11);
145
            keybuffer_push(keybuffer,FUNCTION_KEYS | 11);
145
            buf = count = 0;
146
            buf = count = 0;
146
            return 1;
147
            return 1;
147
        case MSIM_KEY_F12:
148
        case MSIM_KEY_F12:
148
            keybuffer_push(keybuffer,FUNCTION_KEYS | 12);
149
            keybuffer_push(keybuffer,FUNCTION_KEYS | 12);
149
            buf = count = 0;
150
            buf = count = 0;
150
            return 1;
151
            return 1;
151
        default:
152
        default:
152
            keybuffer_push(keybuffer, buf & 0xff);
153
            keybuffer_push(keybuffer, buf & 0xff);
153
            keybuffer_push(keybuffer, (buf >> 8) &0xff);
154
            keybuffer_push(keybuffer, (buf >> 8) &0xff);
154
            keybuffer_push(keybuffer, (buf >> 16) &0xff);
155
            keybuffer_push(keybuffer, (buf >> 16) &0xff);
155
            keybuffer_push(keybuffer, (buf >> 24) &0xff);
156
            keybuffer_push(keybuffer, (buf >> 24) &0xff);
156
            keybuffer_push(keybuffer, scan_code);
157
            keybuffer_push(keybuffer, scan_code);
157
            buf = count = 0;
158
            buf = count = 0;
158
            return 1;
159
            return 1;
159
        }
160
        }
160
    }
161
    }
161
 
162
 
162
    buf |= ((unsigned long) scan_code)<<(8*(count++));
163
    buf |= ((unsigned long) scan_code)<<(8*(count++));
163
   
164
   
164
    if((buf & 0xff) != (MSIM_KEY_F1 & 0xff)) {
165
    if((buf & 0xff) != (MSIM_KEY_F1 & 0xff)) {
165
        keybuffer_push(keybuffer, buf);
166
        keybuffer_push(keybuffer, buf);
166
        buf = count = 0;
167
        buf = count = 0;
167
        return 1;
168
        return 1;
168
    }
169
    }
169
 
170
 
170
    if (count <= 1)
171
    if (count <= 1)
171
        return 1;
172
        return 1;
172
 
173
 
173
    if ((buf & 0xffff) != (MSIM_KEY_F1 & 0xffff)
174
    if ((buf & 0xffff) != (MSIM_KEY_F1 & 0xffff)
174
        && (buf & 0xffff) != (MSIM_KEY_F5 & 0xffff) ) {
175
        && (buf & 0xffff) != (MSIM_KEY_F5 & 0xffff) ) {
175
 
176
 
176
        keybuffer_push(keybuffer, buf & 0xff);
177
        keybuffer_push(keybuffer, buf & 0xff);
177
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
178
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
178
        buf = count = 0;
179
        buf = count = 0;
179
        return 1;
180
        return 1;
180
    }
181
    }
181
 
182
 
182
    if (count <= 2)
183
    if (count <= 2)
183
        return 1;
184
        return 1;
184
 
185
 
185
    switch (buf) {
186
    switch (buf) {
186
    case MSIM_KEY_F1:
187
    case MSIM_KEY_F1:
187
        keybuffer_push(keybuffer,FUNCTION_KEYS | 1);
188
        keybuffer_push(keybuffer,FUNCTION_KEYS | 1);
188
        buf = count = 0;
189
        buf = count = 0;
189
        return 1;
190
        return 1;
190
    case MSIM_KEY_F2:
191
    case MSIM_KEY_F2:
191
        keybuffer_push(keybuffer,FUNCTION_KEYS | 2);
192
        keybuffer_push(keybuffer,FUNCTION_KEYS | 2);
192
        buf = count = 0;
193
        buf = count = 0;
193
        return 1;
194
        return 1;
194
    case MSIM_KEY_F3:
195
    case MSIM_KEY_F3:
195
        keybuffer_push(keybuffer,FUNCTION_KEYS | 3);
196
        keybuffer_push(keybuffer,FUNCTION_KEYS | 3);
196
        buf = count = 0;
197
        buf = count = 0;
197
        return 1;
198
        return 1;
198
    case MSIM_KEY_F4:
199
    case MSIM_KEY_F4:
199
        keybuffer_push(keybuffer,FUNCTION_KEYS | 4);
200
        keybuffer_push(keybuffer,FUNCTION_KEYS | 4);
200
        buf = count = 0;
201
        buf = count = 0;
201
        return 1;
202
        return 1;
202
    }
203
    }
203
 
204
 
204
 
205
 
205
    if((buf & 0xffffff) != (MSIM_KEY_F5 & 0xffffff)
206
    if((buf & 0xffffff) != (MSIM_KEY_F5 & 0xffffff)
206
        && (buf & 0xffffff) != (MSIM_KEY_F9 & 0xffffff)) {
207
        && (buf & 0xffffff) != (MSIM_KEY_F9 & 0xffffff)) {
207
 
208
 
208
        keybuffer_push(keybuffer, buf & 0xff);
209
        keybuffer_push(keybuffer, buf & 0xff);
209
        keybuffer_push(keybuffer, (buf >> 8) & 0xff);
210
        keybuffer_push(keybuffer, (buf >> 8) & 0xff);
210
        keybuffer_push(keybuffer, (buf >> 16) & 0xff);
211
        keybuffer_push(keybuffer, (buf >> 16) & 0xff);
211
        buf=count=0;
212
        buf=count=0;
212
        return 1;
213
        return 1;
213
    }
214
    }
214
 
215
 
215
    if (count <= 3)
216
    if (count <= 3)
216
        return 1;
217
        return 1;
217
   
218
   
218
    switch (buf) {
219
    switch (buf) {
219
    case MSIM_KEY_F5:
220
    case MSIM_KEY_F5:
220
    case MSIM_KEY_F6:
221
    case MSIM_KEY_F6:
221
    case MSIM_KEY_F7:
222
    case MSIM_KEY_F7:
222
    case MSIM_KEY_F8:
223
    case MSIM_KEY_F8:
223
    case MSIM_KEY_F9:
224
    case MSIM_KEY_F9:
224
    case MSIM_KEY_F10:
225
    case MSIM_KEY_F10:
225
    case MSIM_KEY_F11:
226
    case MSIM_KEY_F11:
226
    case MSIM_KEY_F12:
227
    case MSIM_KEY_F12:
227
        return 1;
228
        return 1;
228
    default:
229
    default:
229
        keybuffer_push(keybuffer, buf & 0xff);
230
        keybuffer_push(keybuffer, buf & 0xff);
230
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
231
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
231
        keybuffer_push(keybuffer, (buf >> 16) &0xff);
232
        keybuffer_push(keybuffer, (buf >> 16) &0xff);
232
        keybuffer_push(keybuffer, (buf >> 24) &0xff);
233
        keybuffer_push(keybuffer, (buf >> 24) &0xff);
233
        buf = count = 0;
234
        buf = count = 0;
234
        return 1;
235
        return 1;
235
    }
236
    }
236
    return 1;
237
    return 1;
237
}
238
}
238
 
239
 
239
 
240
 
240
 
241
 
241
static int kbd_arch_process_fb(keybuffer_t *keybuffer, int scan_code)
242
static int kbd_arch_process_fb(keybuffer_t *keybuffer, int scan_code)
242
{
243
{
243
    static unsigned long buf = 0;
244
    static unsigned long buf = 0;
244
    static int count = 0;
245
    static int count = 0;
245
 
246
 
246
    /* Please preserve this code (it can be used to determine scancodes)
247
    /* Please preserve this code (it can be used to determine scancodes)
247
   
248
   
248
    keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf));
249
    keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf));
249
    keybuffer_push(keybuffer, to_hex(scan_code&0xf));
250
    keybuffer_push(keybuffer, to_hex(scan_code&0xf));
250
    keybuffer_push(keybuffer, ' ');
251
    keybuffer_push(keybuffer, ' ');
251
    keybuffer_push(keybuffer, ' ');
252
    keybuffer_push(keybuffer, ' ');
252
   
253
   
253
    return 1;
254
    return 1;
254
    */
255
    */
255
   
256
   
256
    if (scan_code == '\r')
257
    if (scan_code == '\r')
257
        scan_code = '\n';
258
        scan_code = '\n';
258
   
259
   
259
    buf |= ((unsigned long) scan_code)<<(8*(count++));
260
    buf |= ((unsigned long) scan_code)<<(8*(count++));
260
   
261
   
261
   
262
   
262
    if ((buf & 0xff) != (GXEMUL_KEY_F1 & 0xff)) {
263
    if ((buf & 0xff) != (GXEMUL_KEY_F1 & 0xff)) {
263
        keybuffer_push(keybuffer, buf);
264
        keybuffer_push(keybuffer, buf);
264
        buf = count = 0;
265
        buf = count = 0;
265
        return 1;
266
        return 1;
266
    }
267
    }
267
 
268
 
268
    if (count <= 1)
269
    if (count <= 1)
269
        return 1;
270
        return 1;
270
 
271
 
271
    if ((buf & 0xffff) != (GXEMUL_KEY_F1 & 0xffff)) {
272
    if ((buf & 0xffff) != (GXEMUL_KEY_F1 & 0xffff)) {
272
        keybuffer_push(keybuffer, buf & 0xff);
273
        keybuffer_push(keybuffer, buf & 0xff);
273
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
274
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
274
        buf = count = 0;
275
        buf = count = 0;
275
        return 1;
276
        return 1;
276
    }
277
    }
277
 
278
 
278
    if (count <= 2)
279
    if (count <= 2)
279
        return 1;
280
        return 1;
280
 
281
 
281
 
282
 
282
    if ((buf & 0xffffff) != (GXEMUL_KEY_F1 & 0xffffff)
283
    if ((buf & 0xffffff) != (GXEMUL_KEY_F1 & 0xffffff)
283
        && (buf & 0xffffff) != (GXEMUL_KEY_F5 & 0xffffff)
284
        && (buf & 0xffffff) != (GXEMUL_KEY_F5 & 0xffffff)
284
        && (buf & 0xffffff) != (GXEMUL_KEY_F9 & 0xffffff)) {
285
        && (buf & 0xffffff) != (GXEMUL_KEY_F9 & 0xffffff)) {
285
 
286
 
286
        keybuffer_push(keybuffer, buf & 0xff);
287
        keybuffer_push(keybuffer, buf & 0xff);
287
        keybuffer_push(keybuffer, (buf >> 8) & 0xff);
288
        keybuffer_push(keybuffer, (buf >> 8) & 0xff);
288
        keybuffer_push(keybuffer, (buf >> 16) & 0xff);
289
        keybuffer_push(keybuffer, (buf >> 16) & 0xff);
289
        buf = count = 0;
290
        buf = count = 0;
290
        return 1;
291
        return 1;
291
    }
292
    }
292
 
293
 
293
    if ( count <= 3 )
294
    if ( count <= 3 )
294
        return 1;
295
        return 1;
295
   
296
   
296
 
297
 
297
    switch (buf) {
298
    switch (buf) {
298
    case GXEMUL_KEY_F1:
299
    case GXEMUL_KEY_F1:
299
        keybuffer_push(keybuffer,FUNCTION_KEYS | 1 );
300
        keybuffer_push(keybuffer,FUNCTION_KEYS | 1 );
300
        buf=count=0;
301
        buf=count=0;
301
        return 1;
302
        return 1;
302
    case GXEMUL_KEY_F2:
303
    case GXEMUL_KEY_F2:
303
        keybuffer_push(keybuffer,FUNCTION_KEYS | 2 );
304
        keybuffer_push(keybuffer,FUNCTION_KEYS | 2 );
304
        buf=count=0;
305
        buf=count=0;
305
        return 1;
306
        return 1;
306
    case GXEMUL_KEY_F3:
307
    case GXEMUL_KEY_F3:
307
        keybuffer_push(keybuffer,FUNCTION_KEYS | 3 );
308
        keybuffer_push(keybuffer,FUNCTION_KEYS | 3 );
308
        buf=count=0;
309
        buf=count=0;
309
        return 1;
310
        return 1;
310
    case GXEMUL_KEY_F4:
311
    case GXEMUL_KEY_F4:
311
        keybuffer_push(keybuffer,FUNCTION_KEYS | 4 );
312
        keybuffer_push(keybuffer,FUNCTION_KEYS | 4 );
312
        buf=count=0;
313
        buf=count=0;
313
        return 1;
314
        return 1;
314
    case GXEMUL_KEY_F5:
315
    case GXEMUL_KEY_F5:
315
        keybuffer_push(keybuffer,FUNCTION_KEYS | 5 );
316
        keybuffer_push(keybuffer,FUNCTION_KEYS | 5 );
316
        buf=count=0;
317
        buf=count=0;
317
        return 1;
318
        return 1;
318
    case GXEMUL_KEY_F6:
319
    case GXEMUL_KEY_F6:
319
        keybuffer_push(keybuffer,FUNCTION_KEYS | 6 );
320
        keybuffer_push(keybuffer,FUNCTION_KEYS | 6 );
320
        buf=count=0;
321
        buf=count=0;
321
        return 1;
322
        return 1;
322
    case GXEMUL_KEY_F7:
323
    case GXEMUL_KEY_F7:
323
        keybuffer_push(keybuffer,FUNCTION_KEYS | 7 );
324
        keybuffer_push(keybuffer,FUNCTION_KEYS | 7 );
324
        buf=count=0;
325
        buf=count=0;
325
        return 1;
326
        return 1;
326
    case GXEMUL_KEY_F8:
327
    case GXEMUL_KEY_F8:
327
        keybuffer_push(keybuffer,FUNCTION_KEYS | 8 );
328
        keybuffer_push(keybuffer,FUNCTION_KEYS | 8 );
328
        buf=count=0;
329
        buf=count=0;
329
        return 1;
330
        return 1;
330
    case GXEMUL_KEY_F9:
331
    case GXEMUL_KEY_F9:
331
        keybuffer_push(keybuffer,FUNCTION_KEYS | 9 );
332
        keybuffer_push(keybuffer,FUNCTION_KEYS | 9 );
332
        buf=count=0;
333
        buf=count=0;
333
        return 1;
334
        return 1;
334
    case GXEMUL_KEY_F10:
335
    case GXEMUL_KEY_F10:
335
        keybuffer_push(keybuffer,FUNCTION_KEYS | 10 );
336
        keybuffer_push(keybuffer,FUNCTION_KEYS | 10 );
336
        buf=count=0;
337
        buf=count=0;
337
        return 1;
338
        return 1;
338
    case GXEMUL_KEY_F11:
339
    case GXEMUL_KEY_F11:
339
        keybuffer_push(keybuffer,FUNCTION_KEYS | 11 );
340
        keybuffer_push(keybuffer,FUNCTION_KEYS | 11 );
340
        buf=count=0;
341
        buf=count=0;
341
        return 1;
342
        return 1;
342
    case GXEMUL_KEY_F12:
343
    case GXEMUL_KEY_F12:
343
        keybuffer_push(keybuffer,FUNCTION_KEYS | 12 );
344
        keybuffer_push(keybuffer,FUNCTION_KEYS | 12 );
344
        buf=count=0;
345
        buf=count=0;
345
        return 1;
346
        return 1;
346
    default:
347
    default:
347
        keybuffer_push(keybuffer, buf & 0xff );
348
        keybuffer_push(keybuffer, buf & 0xff );
348
        keybuffer_push(keybuffer, (buf >> 8) &0xff );
349
        keybuffer_push(keybuffer, (buf >> 8) &0xff );
349
        keybuffer_push(keybuffer, (buf >> 16) &0xff );
350
        keybuffer_push(keybuffer, (buf >> 16) &0xff );
350
        keybuffer_push(keybuffer, (buf >> 24) &0xff );
351
        keybuffer_push(keybuffer, (buf >> 24) &0xff );
351
        buf=count=0;
352
        buf=count=0;
352
        return 1;
353
        return 1;
353
    }
354
    }
354
    return 1;
355
    return 1;
355
}
356
}
356
 
357
 
357
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call)
358
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call)
358
{
359
{
359
    int scan_code = IPC_GET_ARG2(*call);
360
    int scan_code = IPC_GET_ARG2(*call);
360
    static int esc_count=0;
361
    static int esc_count=0;
361
 
362
 
362
    if (scan_code == 0x1b) {
363
    if (scan_code == 0x1b) {
363
        esc_count++;
364
        esc_count++;
364
        if (esc_count == 3)
365
        if (esc_count == 3)
365
            __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE);
366
            __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE);
366
    } else {
367
    } else {
367
        esc_count=0;
368
        esc_count=0;
368
    }
369
    }
369
 
370
 
370
    if (fb_fb)
371
    if (fb_fb)
371
        return kbd_arch_process_fb(keybuffer, scan_code);
372
        return kbd_arch_process_fb(keybuffer, scan_code);
372
 
373
 
373
    return kbd_arch_process_no_fb(keybuffer, scan_code);
374
    return kbd_arch_process_no_fb(keybuffer, scan_code);
374
}
375
}
375
/** @}
376
/** @}
376
*/
377
*/
377
 
378