Rev 666 | Rev 826 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
519 | mauro | 1 | /* |
2 | * Project: S.Ha.R.K. |
||
3 | * |
||
4 | * Coordinators: |
||
5 | * Giorgio Buttazzo <giorgio@sssup.it> |
||
6 | * Paolo Gai <pj@gandalf.sssup.it> |
||
7 | * |
||
8 | * Authors : |
||
9 | * Paolo Gai <pj@gandalf.sssup.it> |
||
10 | * Massimiliano Giorgi <massy@gandalf.sssup.it> |
||
11 | * Luca Abeni <luca@gandalf.sssup.it> |
||
12 | * Mauro Marinoni <mauro.marinoni@unipv.it> |
||
13 | * (see the web pages for full authors list) |
||
14 | * |
||
15 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
16 | * |
||
17 | * http://www.sssup.it |
||
18 | * http://retis.sssup.it |
||
19 | * http://shark.sssup.it |
||
20 | */ |
||
21 | |||
22 | //#define __KEYB_DEBUG__ |
||
523 | mauro | 23 | #define KEYB_TASK |
519 | mauro | 24 | |
25 | #include <kernel/kern.h> |
||
26 | #include <signal.h> |
||
27 | #include <modules/hartport.h> |
||
28 | |||
29 | #include "../include/drivers/shark_input26.h" |
||
30 | #include "../include/drivers/shark_keyb26.h" |
||
31 | |||
32 | /* Devices */ |
||
33 | extern int atkbd_init(void); |
||
34 | extern int atkbd_exit(void); |
||
35 | |||
36 | /* Handlers */ |
||
37 | extern int kbd_init(void); |
||
38 | extern int kbd_exit(void); |
||
39 | |||
523 | mauro | 40 | /* Functions */ |
519 | mauro | 41 | extern int kbd_enable(void); |
42 | extern int kbd_disable(void); |
||
43 | extern int kbd_get(unsigned int *data, BYTE access); |
||
44 | extern void kbd_setleds(unsigned int led); |
||
45 | extern int kbd_rate(unsigned int *delay, unsigned int *period); |
||
46 | extern void kbd_mksound(unsigned int hz, unsigned int ticks); |
||
47 | |||
48 | /* |
||
49 | * The following tables contains the ascii code corresponding to the |
||
50 | * scan codes, with shift & no shift... |
||
51 | */ |
||
52 | char keyTable [TABLE_KEY_SIZE]; |
||
53 | char keyShiftTable[TABLE_KEY_SIZE]; |
||
54 | char keyAltGrTable[TABLE_KEY_SIZE]; |
||
55 | |||
56 | BYTE useAltGr = FALSE; |
||
57 | |||
58 | /* Status variables */ |
||
59 | static BYTE shift = FALSE; |
||
60 | static BYTE ctrl = FALSE; |
||
61 | static BYTE alt = FALSE; |
||
62 | static BYTE altgr = FALSE; |
||
63 | |||
64 | static BYTE capslock = FALSE; |
||
65 | static BYTE numlock = TRUE; |
||
66 | static BYTE scrolllock = FALSE; |
||
67 | |||
68 | /* Keyboard Flags (if shift, alt or control are pressed...); */ |
||
69 | static BYTE keyFlag = 0x00; |
||
70 | static BYTE status; |
||
71 | |||
72 | /* Keyboard driver currently installed */ |
||
73 | static int keyb_installed = FALSE; |
||
74 | |||
75 | |||
76 | #define MAX_KEY_EXC 50 |
||
77 | |||
78 | static struct keyexctable |
||
79 | { |
||
80 | KEY_EVT evt; |
||
81 | void (*func) (KEY_EVT * k); |
||
82 | unsigned char lock; |
||
83 | } keyExcTable[MAX_KEY_EXC]; |
||
84 | |||
85 | static int lastExc; |
||
86 | |||
87 | /* Communication port between the extern process & the user */ |
||
88 | static PORT pkeyPort, ukeyPort; |
||
89 | |||
522 | mauro | 90 | #ifdef KEYB_TASK |
519 | mauro | 91 | /* keyboard task PID */ |
92 | static PID keybpid; |
||
522 | mauro | 93 | #else |
523 | mauro | 94 | static void keyProc(void); |
522 | mauro | 95 | #endif |
519 | mauro | 96 | |
97 | /* |
||
522 | mauro | 98 | * Start keyProc Task or exec it as function |
519 | mauro | 99 | */ |
522 | mauro | 100 | void shark_kbd_exec(void) |
519 | mauro | 101 | { |
522 | mauro | 102 | #ifdef KEYB_TASK |
519 | mauro | 103 | task_activate(keybpid); |
522 | mauro | 104 | #else |
105 | keyProc(); |
||
106 | #endif |
||
519 | mauro | 107 | } |
108 | |||
109 | /* |
||
110 | * This function get a scan code, return an ascii code and set |
||
111 | * the status vars in order to handle the special keys of the AT keyboard |
||
112 | */ |
||
113 | WORD scanCode(unsigned int c, int d) |
||
114 | { |
||
115 | //printk("scanCode: c (%x) - d (%d)\n", c, d); |
||
116 | |||
117 | /* KEY_EVT status setting */ |
||
749 | mauro | 118 | status = 1 << d; |
519 | mauro | 119 | |
120 | switch (c) { |
||
121 | /* CapsLock pressed*/ |
||
122 | case KEY_CPSLOCK: |
||
123 | if (d == KEY_PRESSED) { |
||
124 | capslock = capslock ? FALSE : TRUE; |
||
125 | /* light the caps lock led */ |
||
126 | kbd_setleds(scrolllock + (numlock << 1) + (capslock << 2)); |
||
127 | } |
||
128 | return 0; |
||
129 | /* NumLock pressed */ |
||
130 | case PAD_NUMLOCK: |
||
131 | if (d == KEY_PRESSED) { |
||
132 | numlock = numlock ? FALSE : TRUE; |
||
133 | /* light the num lock led */ |
||
134 | kbd_setleds(scrolllock + (numlock << 1) + (capslock << 2)); |
||
135 | } |
||
136 | return 0; |
||
137 | /* ScrollLock pressed*/ |
||
138 | case EXT_SCRLOCK: |
||
139 | if (d == KEY_PRESSED) { |
||
140 | scrolllock = scrolllock ? FALSE : TRUE; |
||
141 | /* light the scroll lock led */ |
||
142 | kbd_setleds(scrolllock + (numlock << 1) + (capslock << 2)); |
||
143 | } |
||
144 | return 0; |
||
145 | /* Shift pressed or released */ |
||
146 | case KEY_SHL: |
||
147 | if (d) { |
||
148 | shift = TRUE; |
||
149 | if (c == KEY_SHL) |
||
150 | keyFlag |= SHFL_BIT; |
||
151 | } else { |
||
152 | keyFlag &= (!SHFL_BIT); |
||
153 | if (!(keyFlag & SHFR_BIT)) |
||
154 | shift = FALSE; |
||
155 | } |
||
156 | return 0; |
||
157 | /* Shift pressed or released */ |
||
158 | case KEY_SHR: |
||
159 | if (d) { |
||
160 | shift = TRUE; |
||
161 | if (c == KEY_SHR) |
||
162 | keyFlag |= SHFR_BIT; |
||
163 | } else { |
||
164 | keyFlag &= (!SHFR_BIT); |
||
165 | if (!(keyFlag & SHFL_BIT)) |
||
166 | shift = FALSE; |
||
167 | } |
||
168 | return 0; |
||
169 | /* Control pressed or released */ |
||
170 | case KEY_CTRLL: |
||
171 | if (d) { |
||
172 | ctrl = TRUE; |
||
173 | keyFlag |= CNTL_BIT; |
||
174 | } else { |
||
175 | keyFlag &= (!CNTL_BIT); |
||
176 | if (!(keyFlag & CNTR_BIT)) |
||
177 | ctrl = FALSE; |
||
178 | } |
||
179 | return 0; |
||
180 | /* Control pressed or released */ |
||
181 | case KEY_CTRLR: |
||
182 | if (d) { |
||
183 | ctrl = TRUE; |
||
184 | keyFlag |= CNTR_BIT; |
||
185 | } else { |
||
186 | keyFlag &= (!CNTR_BIT); |
||
187 | if (!(keyFlag & CNTL_BIT)) |
||
188 | ctrl = FALSE; |
||
189 | } |
||
190 | return 0; |
||
191 | /* Alt Left pressed */ |
||
192 | case KEY_ALTL: |
||
193 | if (d) { |
||
194 | alt = TRUE; |
||
195 | keyFlag |= ALTL_BIT; |
||
196 | } else { |
||
197 | alt = FALSE; |
||
198 | keyFlag &= (!ALTL_BIT); |
||
199 | } |
||
200 | return 0; |
||
201 | /* Alt Right (AltGr) pressed */ |
||
202 | case KEY_ALTR: |
||
203 | if (d) { |
||
204 | altgr = TRUE; |
||
205 | keyFlag |= ALTR_BIT; |
||
206 | } else { |
||
207 | altgr = FALSE; |
||
208 | keyFlag &= (!ALTR_BIT); |
||
209 | if ((!useAltGr) && (!(keyFlag & ALTL_BIT))) |
||
210 | alt = FALSE; |
||
211 | } |
||
212 | return 0; |
||
213 | /* Delete */ |
||
214 | case EXT_DEL: |
||
215 | return DELETE; |
||
216 | case PAD_DEL: |
||
217 | if (numlock || shift) |
||
218 | return 0x18; |
||
219 | else |
||
220 | break; |
||
221 | /* Pad Enter */ |
||
222 | case PAD_ENT: |
||
223 | return 0x0d; |
||
224 | /* Pad Add */ |
||
225 | case PAD_PLUS: |
||
226 | return 0x2b; |
||
227 | /* Pad Sub */ |
||
228 | case PAD_SUB: |
||
229 | return 0x2d; |
||
230 | /* Pad Slash */ |
||
231 | case PAD_SLH: |
||
232 | return 0x2f; |
||
233 | /* Numbers & simbols */ |
||
234 | case KEY_1: case KEY_2: case KEY_3: case KEY_4: case KEY_5: |
||
235 | case KEY_6: case KEY_7: case KEY_8: case KEY_9: case KEY_0: |
||
236 | case KEY_SUB: case KEY_PLUS: case KEY_BRL: case KEY_BRR: |
||
237 | case KEY_COL: case KEY_API: case KEY_TIL: case KEY_BSL: |
||
238 | case KEY_LT: case KEY_GT: case KEY_SLH: |
||
239 | /* AlrGR enabled & pressed */ |
||
240 | if (altgr && useAltGr) { |
||
241 | return keyAltGrTable[c]; |
||
242 | } |
||
243 | /* Control Shift status */ |
||
244 | if (shift) |
||
245 | return keyShiftTable[c]; |
||
246 | else |
||
247 | return keyTable[c]; |
||
248 | } |
||
249 | |||
250 | /* Pad Keys */ |
||
251 | if (numlock || shift) |
||
252 | switch (c) { |
||
253 | case PAD_DEL: |
||
254 | return 0x18; |
||
255 | case PAD_INS: |
||
256 | return 0x30; |
||
257 | case PAD_END: |
||
258 | return 0x31; |
||
259 | case PAD_DOWN: |
||
260 | return 0x32; |
||
261 | case PAD_PGDW: |
||
262 | return 0x33; |
||
263 | case PAD_RIGHT: |
||
264 | return 0x34; |
||
265 | case PAD_5: |
||
266 | return 0x35; |
||
267 | case PAD_LEFT: |
||
268 | return 0x36; |
||
269 | case PAD_HOME: |
||
270 | return 0x37; |
||
271 | case PAD_UP: |
||
272 | return 0x38; |
||
273 | case PAD_PGUP: |
||
274 | return 0x39; |
||
275 | } |
||
276 | |||
277 | /* Characters keys */ |
||
278 | if (((c >= KEY_Q) && (c <= KEY_P)) || |
||
279 | ((c >= KEY_A) && (c <= KEY_L)) || |
||
280 | ((c >= KEY_Z) && (c <= KEY_M))) { |
||
281 | /* AlrGR enabled & pressed */ |
||
282 | if (altgr && useAltGr) { |
||
283 | return keyAltGrTable[c]; |
||
284 | } |
||
285 | /* Control CapsLock & Shift status */ |
||
286 | if (capslock) { |
||
287 | if (shift) |
||
288 | return keyTable[c]; |
||
289 | else |
||
290 | return keyShiftTable[c]; |
||
291 | } else { |
||
292 | if (shift) |
||
293 | return keyShiftTable[c]; |
||
294 | else |
||
295 | return keyTable[c]; |
||
296 | } |
||
297 | } |
||
298 | |||
299 | /* Remaining keys */ |
||
300 | if (c < TABLE_KEY_SIZE) |
||
301 | /* Left 'low' keys (Esc, BackSpace, Space, ...) */ |
||
302 | return keyTable[c]; |
||
303 | else |
||
304 | /* Default - Return as keycode */ |
||
305 | return (0xff00 | c); |
||
306 | } |
||
307 | |||
522 | mauro | 308 | #ifdef KEYB_TASK |
519 | mauro | 309 | TASK keyProc(void) |
522 | mauro | 310 | #else |
523 | mauro | 311 | static void keyProc(void) |
522 | mauro | 312 | #endif |
519 | mauro | 313 | { |
314 | WORD code; |
||
315 | BYTE found; |
||
316 | KEY_EVT dt; |
||
317 | int i, res; |
||
318 | unsigned int dato; |
||
319 | |||
522 | mauro | 320 | #ifdef KEYB_TASK |
519 | mauro | 321 | while (1) { |
522 | mauro | 322 | #endif |
519 | mauro | 323 | res = kbd_get(&dato, NON_BLOCK); |
324 | if (res >= 0) { |
||
325 | code = scanCode(dato, res); |
||
326 | if (code != 0) { |
||
327 | if (code & 0xff00) |
||
328 | /* It's a scan code, set the right bit */ |
||
329 | dt.flag = (keyFlag | SCAN_BIT); |
||
330 | else |
||
331 | /* Simply send the keyFlag status */ |
||
332 | dt.flag = keyFlag; |
||
333 | dt.status = status; |
||
334 | dt.ascii = (BYTE) (code & 0x00FF); |
||
335 | dt.scan = dato; |
||
336 | #ifdef __KEYB_DEBUG__ |
||
337 | printk("shark_keyb.c: KEY_EVT ( %2x - %c - %2x - %1d)\n", dt.scan, dt.ascii, dt.flag, dt.status); |
||
338 | #endif |
||
339 | found = FALSE; |
||
340 | for (i = 0; i < lastExc; i++) |
||
666 | mauro | 341 | if (((keyExcTable[i].evt.flag & ~SCAN_BIT) == (dt.flag & ~SCAN_BIT)) && |
749 | mauro | 342 | ((keyExcTable[i].evt.status & dt.status) != 0)) { |
666 | mauro | 343 | if ( ((keyExcTable[i].evt.scan == dt.scan) || (keyExcTable[i].evt.scan == 0)) && |
344 | ((keyExcTable[i].evt.ascii == dt.ascii) || (keyExcTable[i].evt.ascii == 0)) ){ |
||
519 | mauro | 345 | #ifdef __KEYB_DEBUG__ |
666 | mauro | 346 | printk("shark_keyb.c: Key_Hook ( %2x - %2x - %1d) -> ( %2x - %2x - %1d)\n", |
347 | dt.scan, dt.ascii, dt.flag, dt.status, |
||
348 | keyExcTable[i].evt.scan, keyExcTable[i].evt.ascii, keyExcTable[i].evt.flag, keyExcTable[i].evt.status); |
||
519 | mauro | 349 | #endif |
666 | mauro | 350 | keyExcTable[i].func(&dt); |
351 | if (keyExcTable[i].lock == TRUE) |
||
352 | found = TRUE; |
||
353 | } |
||
523 | mauro | 354 | } |
519 | mauro | 355 | /* when the port is full, data is lost */ |
356 | if (!found) |
||
357 | port_send(pkeyPort, (BYTE *) (&dt), NON_BLOCK); |
||
358 | } |
||
359 | } |
||
522 | mauro | 360 | #ifdef KEYB_TASK |
519 | mauro | 361 | task_endcycle(); |
362 | } |
||
522 | mauro | 363 | #endif |
519 | mauro | 364 | } |
365 | |||
366 | /* default function called on ctrl-c */ |
||
367 | void default_ctrlChandler(KEY_EVT * k) { |
||
368 | set_active_page(0); |
||
369 | set_visual_page(0); |
||
523 | mauro | 370 | //cputs("Ctrl-C pressed!\n"); |
519 | mauro | 371 | sys_end(); |
372 | } |
||
373 | |||
374 | /**** Start User Functions ****/ |
||
375 | |||
376 | /* Function that returns the ascii code */ |
||
377 | BYTE keyb_getch(BYTE wait) |
||
378 | { |
||
523 | mauro | 379 | KEY_EVT ev; |
519 | mauro | 380 | BYTE fl; |
381 | |||
523 | mauro | 382 | fl = port_receive (ukeyPort, &ev, wait); |
383 | if (fl) { |
||
384 | #ifdef __KEYB_DEBUG__ |
||
385 | printk("shark_keyb.c: GetChar ( %2x - %c - %2x - %1d)\n", ev.scan, ev.ascii, ev.flag, ev.status); |
||
386 | #endif |
||
387 | if (!isScanCode(ev) && !isReleased(ev)) |
||
388 | return (ev.ascii); |
||
389 | else |
||
390 | return 0; |
||
391 | } else |
||
519 | mauro | 392 | return 0; |
393 | } |
||
394 | |||
395 | /* |
||
396 | * Function that returns a structure containing the flags status, the ascii |
||
397 | * code, and the scan code |
||
398 | */ |
||
399 | int keyb_getcode(KEY_EVT * k, BYTE wait) |
||
400 | { |
||
401 | return (port_receive (ukeyPort, (BYTE *) (k), wait)); |
||
402 | } |
||
403 | |||
404 | void keyb_hook(KEY_EVT k, void (*f) (KEY_EVT * k), unsigned char l) |
||
405 | { |
||
406 | if (lastExc >= MAX_KEY_EXC) |
||
407 | return; |
||
408 | keyExcTable[lastExc].evt = k; |
||
409 | keyExcTable[lastExc].func = f; |
||
410 | keyExcTable[lastExc++].lock = l; |
||
411 | |||
412 | return; |
||
413 | } |
||
414 | |||
523 | mauro | 415 | /* This function disable the keyboard */ |
519 | mauro | 416 | int keyb_disable(void) |
417 | { |
||
418 | kbd_disable(); |
||
419 | return 0; |
||
420 | } |
||
421 | |||
523 | mauro | 422 | /* This function enable the keyboard */ |
519 | mauro | 423 | int keyb_enable(void) |
424 | { |
||
425 | kbd_enable(); |
||
426 | return 0; |
||
427 | } |
||
428 | |||
523 | mauro | 429 | /**** End User Functions ****/ |
549 | mauro | 430 | int KEYB26_installed(void) |
431 | { |
||
432 | return keyb_installed; |
||
433 | } |
||
519 | mauro | 434 | |
435 | int KEYB26_init(KEYB_PARMS *s) |
||
436 | { |
||
437 | KEYB_PARMS kparms = BASE_KEYB; |
||
438 | WORD i; |
||
439 | int status = 0; |
||
440 | |||
522 | mauro | 441 | #ifdef KEYB_TASK |
519 | mauro | 442 | SOFT_TASK_MODEL base_m; |
443 | TASK_MODEL *m; |
||
522 | mauro | 444 | #endif |
519 | mauro | 445 | |
446 | if (keyb_installed == TRUE) return 0; |
||
447 | |||
448 | /* if a NULL is passed */ |
||
449 | if (s == NULL) |
||
450 | s = &kparms; |
||
451 | |||
452 | for (i = 0; i < TABLE_KEY_SIZE; i++) { |
||
453 | keyTable[i] = 0; |
||
454 | keyShiftTable[i] = 0; |
||
455 | keyAltGrTable[i] = 0; |
||
456 | } |
||
457 | |||
458 | /* keymap */ |
||
459 | if (s->keymap == (unsigned char)KEYB_DEFAULT) s->keymap = KEYMAP_US; |
||
460 | keyb_set_map(s->keymap); |
||
461 | |||
523 | mauro | 462 | pkeyPort = port_create ("KeybPort", sizeof(KEY_EVT), 20, STREAM, WRITE); |
519 | mauro | 463 | if (pkeyPort == -1) |
464 | return -2; |
||
523 | mauro | 465 | ukeyPort = port_connect ("KeybPort", sizeof(KEY_EVT), STREAM, READ); |
519 | mauro | 466 | if (ukeyPort == -1) { |
467 | port_delete (pkeyPort); |
||
468 | return -3; |
||
469 | } |
||
470 | |||
471 | /* remove all key pressed handlers */ |
||
472 | lastExc = 0; |
||
473 | |||
474 | /* and add a ctrl-c handler if requested */ |
||
475 | if (s->ctrlcfunc == (void *) KEYB_DEFAULT) |
||
476 | s->ctrlcfunc = (void *) default_ctrlChandler; |
||
477 | if (s->ctrlcfunc != NULL) { |
||
478 | KEY_EVT emerg; |
||
523 | mauro | 479 | emerg.ascii = 'c'; |
480 | emerg.scan = KEY_C; |
||
481 | emerg.status = KEY_PRESSED; |
||
482 | emerg.flag = CNTL_BIT; |
||
519 | mauro | 483 | keyb_hook (emerg, s->ctrlcfunc, TRUE); |
523 | mauro | 484 | emerg.flag = CNTR_BIT; |
519 | mauro | 485 | keyb_hook (emerg, s->ctrlcfunc, TRUE); |
486 | } |
||
487 | |||
522 | mauro | 488 | #ifdef KEYB_TASK |
519 | mauro | 489 | /* keyb task */ |
490 | if (s->tm == (TASK_MODEL *) KEYB_DEFAULT) { |
||
491 | soft_task_default_model (base_m); |
||
492 | soft_task_def_wcet (base_m, 2000); |
||
493 | soft_task_def_met (base_m, 800); |
||
494 | soft_task_def_period (base_m, 25000); |
||
495 | soft_task_def_system (base_m); |
||
496 | soft_task_def_aperiodic (base_m); |
||
497 | m = (TASK_MODEL *) & base_m; |
||
498 | } else |
||
499 | m = s->tm; |
||
500 | |||
501 | #ifdef __KEYB_DEBUG__ |
||
502 | //printk(KERN_DEBUG "keyb task: %li %li %li %li\n", (long)s->pclass, (long)APERIODIC, (long)s->dline, (long)s->wcet); |
||
503 | #endif |
||
504 | |||
505 | keybpid = task_create ("KeyTask", keyProc, m, NULL); |
||
506 | if (keybpid == -1) { |
||
507 | port_delete (pkeyPort); |
||
508 | port_delete (ukeyPort); |
||
509 | return -1; |
||
510 | } |
||
522 | mauro | 511 | #endif |
519 | mauro | 512 | |
549 | mauro | 513 | if (INPUT26_installed() == FALSE) |
519 | mauro | 514 | if (INPUT26_init()) { |
515 | printk(KERN_ERR "shark_keyb.c: Unable to open Input SubSystem.\n"); |
||
516 | port_delete (pkeyPort); |
||
517 | port_delete (ukeyPort); |
||
544 | giacomo | 518 | #ifdef KEYB_TASK |
523 | mauro | 519 | task_kill (keybpid); |
544 | giacomo | 520 | #endif |
519 | mauro | 521 | return -1; |
522 | } |
||
523 | |||
549 | mauro | 524 | status = kbd_init(); |
519 | mauro | 525 | if (status) { |
549 | mauro | 526 | printk(KERN_ERR "shark_keyb.c: Kbd_Init return: %d\n", status); |
519 | mauro | 527 | port_delete (pkeyPort); |
528 | port_delete (ukeyPort); |
||
544 | giacomo | 529 | #ifdef KEYB_TASK |
523 | mauro | 530 | task_kill (keybpid); |
544 | giacomo | 531 | #endif |
519 | mauro | 532 | return -1; |
533 | } |
||
549 | mauro | 534 | |
535 | status = atkbd_init(); |
||
519 | mauro | 536 | if (status) { |
549 | mauro | 537 | printk(KERN_ERR "shark_keyb.c: AtKbd_Init return: %d\n", status); |
519 | mauro | 538 | port_delete (pkeyPort); |
539 | port_delete (ukeyPort); |
||
544 | giacomo | 540 | #ifdef KEYB_TASK |
523 | mauro | 541 | task_kill (keybpid); |
544 | giacomo | 542 | #endif |
519 | mauro | 543 | return -1; |
544 | } |
||
545 | |||
546 | kbd_setleds(scrolllock + (numlock << 1) + (capslock << 2)); |
||
547 | kbd_enable(); |
||
548 | |||
549 | keyb_installed = TRUE; |
||
550 | return status; |
||
551 | } |
||
552 | |||
553 | /* |
||
554 | * KEYB module cleanup |
||
555 | * (must be called if it's needed to re-call keyb_init() with other parameters) |
||
556 | * -1 -> ERROR |
||
557 | */ |
||
558 | int KEYB26_close(void) |
||
559 | { |
||
522 | mauro | 560 | #ifdef KEYB_TASK |
519 | mauro | 561 | int free; |
562 | SYS_FLAGS f; |
||
522 | mauro | 563 | #endif |
519 | mauro | 564 | |
565 | if (!keyb_installed) |
||
566 | return -1; |
||
549 | mauro | 567 | |
519 | mauro | 568 | kbd_disable(); |
549 | mauro | 569 | |
570 | atkbd_exit(); |
||
519 | mauro | 571 | kbd_exit(); |
572 | |||
522 | mauro | 573 | #ifdef KEYB_TASK |
519 | mauro | 574 | f = kern_fsave(); |
575 | free = (proc_table[keybpid].status == FREE); |
||
576 | kern_frestore(f); |
||
577 | #ifdef __KEYB_DEBUG__ |
||
578 | printk(KERN_DEBUG "shark_keyb.c: KeyTask is %s.\n", free ? "killed" : "alive"); |
||
579 | #endif |
||
580 | if (free) |
||
581 | task_kill (keybpid); |
||
522 | mauro | 582 | #endif |
519 | mauro | 583 | |
584 | /*port_delete (pkeyPort); |
||
585 | port_delete (ukeyPort);*/ |
||
586 | |||
587 | keyb_installed = FALSE; |
||
588 | |||
589 | return 0; |
||
590 | } |