#include <agnix/agnix.h>#include <agnix/init.h>#include <agnix/ioport.h>#include <agnix/console.h>#include <agnix/terminal.h>#include <agnix/memory.h>#include <agnix/irq.h>#include <agnix/machine.h>Include dependency graph for keyboard.c:

Go to the source code of this file.
Defines | |
| #define | MOD_NAME "CHAR_KBD: \t" |
| #define | KBD_DTA_PORT 0x60 |
| #define | KBD_CMD_PORT 0x64 |
| #define | KBD_STS_PORT 0x64 |
| #define | KBD_DCMD_READID 0xF2 |
| #define | KBD_DCMD_SETDELAY 0xF3 |
| #define | KBD_DCMD_ENABLE 0xF4 |
| #define | KBD_DCMD_DISABLE 0xF5 |
| #define | KBD_DCMD_RESET 0xFF |
| #define | KBD_CCMD_WRITEMODE 0x60 |
| #define | KBD_CCMD_SELFTEST 0xAA |
| #define | KBD_CCMD_IFACETEST 0xAB |
| #define | KBD_CCMD_SETLEDS 0xED |
| #define | KBD_WAIT_LOOPS 10000000 |
| #define | KBD_STS_OBF 0x01 |
| #define | KBD_STS_IBF 0x02 |
| #define | KBD_STS_PERR 0x80 |
| #define | KBD_STS_GTMO 0x40 |
| #define | KBD_IRQ 1 |
| #define | SPECIAL 0 |
| #define | KBD_CODE_ESC 0x01 |
| #define | KBD_CODE_BACKSPACE 0x0E |
| #define | KBD_CODE_TAB 0x0F |
| #define | KBD_CODE_CTRL 0x1D |
| #define | KBD_CODE_SHIFTL 0x2A |
| #define | KBD_CODE_SHIFTR 0x36 |
| #define | KBD_CODE_PRINT 0x37 |
| #define | KBD_CODE_ALT 0x38 |
| #define | KBD_CODE_CAPS 0x3A |
| #define | KBD_CODE_SCROLL 0x45 |
| #define | KBD_CODE_NUM 0x46 |
| #define | KBD_CODE_F1 0x3B |
| #define | KBD_CODE_F2 0x3C |
| #define | KBD_CODE_F3 0x3D |
| #define | KBD_CODE_F4 0x3E |
| #define | KBD_CODE_F5 0x3F |
| #define | KBD_CODE_F6 0x40 |
| #define | KBD_CODE_F7 0x41 |
| #define | KBD_CODE_F8 0x42 |
| #define | KBD_CODE_F9 0x43 |
| #define | KBD_CODE_F10 0x44 |
| #define | ENTER 10 |
| #define | F1 'A' |
| #define | F2 'B' |
| #define | F3 'C' |
| #define | F4 'D' |
| #define | F5 'E' |
| #define | F6 'F' |
| #define | F7 'G' |
| #define | F8 'H' |
| #define | F9 'I' |
| #define | F10 'J' |
| #define | F11 'K' |
| #define | F12 'L' |
| #define | PAUSE 'P' |
| #define | KBD_LED_SCROLL 0x01 |
| #define | KBD_LED_NUM 0x02 |
| #define | KBD_LED_CAPS 0x04 |
| #define | KBD_FLG_SCROLL KBD_LED_SCROLL |
| #define | KBD_FLG_NUM KBD_LED_NUM |
| #define | KBD_FLG_CAPS KBD_LED_CAPS |
| #define | KBD_FLG_SHIFT 0x08 |
| #define | KBD_FLG_CNTRL 0x10 |
| #define | KBD_FLG_ALT 0x20 |
| #define | MAX_KBD_ACTIONS 16 |
Functions | |
| u8 | kbd_status_read (void) |
| int | kbd_wait_for_bf (u8 which_bf, int neg) |
| int | kbd_wait_for_notibf (void) |
| int | kbd_wait_for_obf (void) |
| void | kbd_data_write (u8 cmd) |
| char | kbd_data_read (void) |
| char | kbd_data_read_wait (void) |
| void | kbd_cmd_write (u8 cmd) |
| void | kbd_set_leds (u8 leds_mask) |
| int | kbd_change_led_flag (u8 led_flag) |
| void | kbd_irq_handler (u32 data) |
| int | kbd_screen_up (int scancode) |
| int | kbd_screen_down (int scancode) |
| int | cad_power_down (int scancode) |
| int | kbd_set_actions (void) |
| int | adi_chrdrv_kbd_init (void) |
Variables | |
| int | term_cur |
| terminal_s | term_sys [MAX_TERMINALS] |
| u8 | kbd_flags = 0 |
| int | kbd_action_count = 0 |
| kbd_action_s | kbd_action [MAX_KBD_ACTIONS] |
| char | scancode_to_ascii [0x100] |
| char | scancode_to_ascii_shift [0x100] |
| int | kbd_screen_scroll = 0 |
| irq_routine_s | kbd_irq_routine |
|
|
Definition at line 74 of file keyboard.c. |
|
|
Definition at line 75 of file keyboard.c. |
|
|
Definition at line 84 of file keyboard.c. |
|
|
Definition at line 85 of file keyboard.c. |
|
|
Definition at line 86 of file keyboard.c. |
|
|
Definition at line 76 of file keyboard.c. |
|
|
Definition at line 77 of file keyboard.c. |
|
|
Definition at line 78 of file keyboard.c. |
|
|
Definition at line 79 of file keyboard.c. |
|
|
Definition at line 80 of file keyboard.c. |
|
|
Definition at line 81 of file keyboard.c. |
|
|
Definition at line 82 of file keyboard.c. |
|
|
Definition at line 83 of file keyboard.c. |
|
|
Definition at line 37 of file keyboard.c. Referenced by adi_chrdrv_kbd_init(). |
|
|
Definition at line 36 of file keyboard.c. Referenced by adi_chrdrv_kbd_init(). |
|
|
Definition at line 38 of file keyboard.c. Referenced by kbd_set_leds(). |
|
|
Definition at line 35 of file keyboard.c. Referenced by adi_chrdrv_kbd_init(). |
|
|
Definition at line 26 of file keyboard.c. Referenced by kbd_cmd_write(). |
|
|
Definition at line 56 of file keyboard.c. Referenced by kbd_irq_handler(). |
|
|
Definition at line 50 of file keyboard.c. |
|
|
Definition at line 57 of file keyboard.c. Referenced by kbd_irq_handler(). |
|
|
Definition at line 52 of file keyboard.c. Referenced by kbd_irq_handler(). |
|
|
Definition at line 49 of file keyboard.c. |
|
|
Definition at line 61 of file keyboard.c. Referenced by kbd_irq_handler(). |
|
|
Definition at line 70 of file keyboard.c. Referenced by kbd_irq_handler(). |
|
|
Definition at line 62 of file keyboard.c. |
|
|
Definition at line 63 of file keyboard.c. |
|
|
Definition at line 64 of file keyboard.c. |
|
|
Definition at line 65 of file keyboard.c. |
|
|
Definition at line 66 of file keyboard.c. |
|
|
Definition at line 67 of file keyboard.c. |
|
|
Definition at line 68 of file keyboard.c. |
|
|
Definition at line 69 of file keyboard.c. |
|
|
Definition at line 59 of file keyboard.c. Referenced by kbd_irq_handler(). |
|
|
Definition at line 55 of file keyboard.c. |
|
|
Definition at line 58 of file keyboard.c. Referenced by kbd_irq_handler(). |
|
|
Definition at line 53 of file keyboard.c. Referenced by kbd_irq_handler(). |
|
|
Definition at line 54 of file keyboard.c. Referenced by kbd_irq_handler(). |
|
|
Definition at line 51 of file keyboard.c. |
|
|
Definition at line 32 of file keyboard.c. |
|
|
Definition at line 31 of file keyboard.c. Referenced by adi_chrdrv_kbd_init(). |
|
|
Definition at line 29 of file keyboard.c. |
|
|
Definition at line 33 of file keyboard.c. |
|
|
Definition at line 30 of file keyboard.c. |
|
|
Definition at line 25 of file keyboard.c. Referenced by kbd_data_read(), kbd_data_write(), and kbd_irq_handler(). |
|
|
Definition at line 98 of file keyboard.c. Referenced by kbd_irq_handler(), and kbd_set_actions(). |
|
|
Definition at line 95 of file keyboard.c. Referenced by kbd_irq_handler(). |
|
|
Definition at line 97 of file keyboard.c. Referenced by kbd_irq_handler(), and kbd_set_actions(). |
|
|
Definition at line 94 of file keyboard.c. Referenced by kbd_irq_handler(). |
|
|
Definition at line 93 of file keyboard.c. Referenced by kbd_irq_handler(). |
|
|
Definition at line 96 of file keyboard.c. Referenced by kbd_irq_handler(). |
|
|
Definition at line 46 of file keyboard.c. Referenced by adi_chrdrv_kbd_init(). |
|
|
Definition at line 91 of file keyboard.c. |
|
|
Definition at line 90 of file keyboard.c. |
|
|
Definition at line 89 of file keyboard.c. |
|
|
Definition at line 44 of file keyboard.c. Referenced by kbd_data_read(), and kbd_irq_handler(). |
|
|
Definition at line 42 of file keyboard.c. Referenced by kbd_wait_for_notibf(). |
|
|
Definition at line 41 of file keyboard.c. Referenced by kbd_data_read(), kbd_irq_handler(), and kbd_wait_for_obf(). |
|
|
Definition at line 43 of file keyboard.c. Referenced by kbd_data_read(), and kbd_irq_handler(). |
|
|
Definition at line 27 of file keyboard.c. Referenced by kbd_status_read(). |
|
|
Definition at line 40 of file keyboard.c. Referenced by kbd_wait_for_bf(). |
|
|
Definition at line 100 of file keyboard.c. |
|
|
Definition at line 23 of file keyboard.c. |
|
|
Definition at line 87 of file keyboard.c. |
|
|
Definition at line 48 of file keyboard.c. |
|
|
Definition at line 376 of file keyboard.c. References install_irq(), KBD_CCMD_IFACETEST, KBD_CCMD_SELFTEST, KBD_CCMD_WRITEMODE, kbd_cmd_write(), kbd_data_read_wait(), kbd_data_write(), KBD_DCMD_ENABLE, KBD_IRQ, kbd_irq_routine, kbd_set_actions(), kbd_set_leds(), MOD_NAME, and printk(). Referenced by adi_chrdrv_init(). 00377 {
00378 char data;
00379
00380 printk(MOD_NAME "PC keyboard ... ");
00381
00382 kbd_cmd_write(KBD_CCMD_SELFTEST);
00383 if ((data=kbd_data_read_wait()) != 0x55) {
00384 printk("Your keyboard is failed!\n");
00385 return -1;
00386 }
00387
00388 kbd_cmd_write(KBD_CCMD_IFACETEST);
00389 if (kbd_data_read_wait() != 0x00) {
00390 printk("Your keyboard is failed!\n");
00391 return -1;
00392 }
00393
00394 printk("ok\n");
00395
00396 kbd_cmd_write(KBD_CCMD_WRITEMODE);
00397 kbd_data_write(0x40 | 0x20 | 0x04 | 0x01);
00398
00399 // kbd_data_write(KBD_DCMD_RESET);
00400 kbd_data_write(KBD_DCMD_ENABLE);
00401
00402 kbd_set_leds(0x00);
00403
00404 kbd_set_actions();
00405
00406 install_irq(KBD_IRQ, &kbd_irq_routine);
00407
00408 return 0;
00409 }
Here is the call graph for this function: ![]() |
|
|
Definition at line 340 of file keyboard.c. References do_machine_reboot(). Referenced by kbd_set_actions(). 00341 {
00342 do_machine_reboot();
00343 // do_machine_powerdown();
00344
00345 return 0;
00346 }
Here is the call graph for this function: ![]() |
|
|
Definition at line 223 of file keyboard.c. References kbd_flags. Referenced by kbd_irq_handler(). 00224 {
00225 if (kbd_flags & led_flag)
00226 kbd_flags &= ~led_flag;
00227 else
00228 kbd_flags |= led_flag;
00229
00230 return 1;
00231 }
|
|
|
Definition at line 211 of file keyboard.c. References KBD_CMD_PORT, and kbd_wait_for_notibf(). Referenced by adi_chrdrv_kbd_init(). 00212 {
00213 kbd_wait_for_notibf();
00214 outb(cmd, KBD_CMD_PORT);
00215 }
Here is the call graph for this function: ![]() |
|
|
Definition at line 186 of file keyboard.c. References KBD_DTA_PORT, kbd_status_read(), KBD_STS_GTMO, KBD_STS_OBF, and KBD_STS_PERR. Referenced by kbd_data_read_wait(). 00187 {
00188 u8 status;
00189 char data = -1;
00190
00191 status = kbd_status_read();
00192
00193 if ((status & KBD_STS_OBF) && !(status & (KBD_STS_PERR | KBD_STS_GTMO))) {
00194
00195 data = inb(KBD_DTA_PORT);
00196 }
00197
00198 return data;
00199 }
Here is the call graph for this function: ![]() |
|
|
Definition at line 201 of file keyboard.c. References kbd_data_read(), and kbd_wait_for_obf(). Referenced by adi_chrdrv_kbd_init(). 00202 {
00203 char data = -1;
00204
00205 if (kbd_wait_for_obf())
00206 data = kbd_data_read();
00207
00208 return data;
00209 }
Here is the call graph for this function: ![]() |
|
|
Definition at line 180 of file keyboard.c. References KBD_DTA_PORT, and kbd_wait_for_notibf(). Referenced by adi_chrdrv_kbd_init(), and kbd_set_leds(). 00181 {
00182 kbd_wait_for_notibf();
00183 outb(cmd, KBD_DTA_PORT);
00184 }
Here is the call graph for this function: ![]() |
|
|
Definition at line 233 of file keyboard.c. References kbd_action_count, kbd_change_led_flag(), KBD_CODE_ALT, KBD_CODE_CAPS, KBD_CODE_CTRL, KBD_CODE_F1, KBD_CODE_F10, KBD_CODE_NUM, KBD_CODE_SCROLL, KBD_CODE_SHIFTL, KBD_CODE_SHIFTR, KBD_DTA_PORT, kbd_flags, KBD_FLG_ALT, KBD_FLG_CAPS, KBD_FLG_CNTRL, KBD_FLG_NUM, KBD_FLG_SCROLL, KBD_FLG_SHIFT, kbd_set_leds(), kbd_status_read(), KBD_STS_GTMO, KBD_STS_OBF, KBD_STS_PERR, printk(), scancode_to_ascii, scancode_to_ascii_shift, term_cur, term_sys, and terminal_switch(). 00234 {
00235 u8 status;
00236 u8 scancode;
00237 char asciicode;
00238 int leds_changed = 0;
00239 int i, k;
00240
00241 for (k = 0; k < 20000; k++) {
00242
00243 status = kbd_status_read();
00244 if ((status & KBD_STS_OBF) && !(status & (KBD_STS_PERR | KBD_STS_GTMO))) {
00245
00246 scancode = inb(KBD_DTA_PORT);
00247
00248 switch(scancode) {
00249 case KBD_CODE_CTRL:
00250 kbd_flags |= KBD_FLG_CNTRL;
00251 break;
00252 case KBD_CODE_CTRL+128:
00253 kbd_flags &= ~KBD_FLG_CNTRL;
00254 break;
00255 case KBD_CODE_ALT:
00256 kbd_flags |= KBD_FLG_ALT;
00257 break;
00258 case KBD_CODE_ALT+128:
00259 kbd_flags &= ~KBD_FLG_ALT;
00260 break;
00261 case KBD_CODE_CAPS:
00262 leds_changed = kbd_change_led_flag(KBD_FLG_CAPS);
00263 break;
00264 case KBD_CODE_SCROLL:
00265 leds_changed = kbd_change_led_flag(KBD_FLG_SCROLL);
00266 break;
00267 case KBD_CODE_NUM:
00268 leds_changed = kbd_change_led_flag(KBD_FLG_NUM);
00269 break;
00270 case KBD_CODE_SHIFTR:
00271 case KBD_CODE_SHIFTL:
00272 kbd_flags |= KBD_FLG_SHIFT;
00273 break;
00274 case KBD_CODE_SHIFTR+128:
00275 case KBD_CODE_SHIFTL+128:
00276 kbd_flags &= ~KBD_FLG_SHIFT;
00277 break;
00278 default:
00279
00280 if ((scancode >= KBD_CODE_F1) && (scancode <= KBD_CODE_F10) &&
00281 (kbd_flags & KBD_FLG_ALT)) {
00282 terminal_switch(scancode - KBD_CODE_F1);
00283 break;
00284 }
00285
00286 if (scancode < 128) {
00287
00288 if ((kbd_flags & KBD_FLG_SHIFT) || (kbd_flags & KBD_FLG_CAPS))
00289 asciicode = scancode_to_ascii_shift[scancode];
00290 else
00291 asciicode = scancode_to_ascii[scancode];
00292
00293 if (asciicode != 0) {
00294 if (term_sys[term_cur].ops && term_sys[term_cur].ops->write_char)
00295 term_sys[term_cur].ops->write_char(&term_sys[term_cur], asciicode);
00296 // printk("%c", asciicode);
00297 }
00298 }
00299 }
00300
00301 for (i = 0; i < kbd_action_count; i++) {
00302 if (((!kbd_action[i].scancode) || (kbd_action[i].scancode == scancode)) &&
00303 ((kbd_action[i].active_flags & kbd_flags) == kbd_action[i].active_flags)) {
00304 kbd_action[i].kbd_action_routine(scancode);
00305 }
00306 }
00307
00308 if (leds_changed)
00309 kbd_set_leds(kbd_flags & 0x07);
00310
00311 break;
00312 }
00313 }
00314
00315 if (k == 20000)
00316 printk("Keyboard interrupt error!\n");
00317 }
Here is the call graph for this function: ![]() |
|
|
Definition at line 330 of file keyboard.c. References kbd_screen_scroll, term_cur, and term_sys. Referenced by kbd_set_actions(). 00331 {
00332 if (kbd_screen_scroll > 0) {
00333 kbd_screen_scroll--;
00334 term_sys[term_cur].term_driver->ops->refresh(&term_sys[term_cur], kbd_screen_scroll);
00335 }
00336
00337 return 0;
00338 }
|
|
|
Definition at line 321 of file keyboard.c. References kbd_screen_scroll, term_cur, and term_sys. Referenced by kbd_set_actions(). 00322 {
00323 kbd_screen_scroll++;
00324
00325 term_sys[term_cur].term_driver->ops->refresh(&term_sys[term_cur], kbd_screen_scroll);
00326
00327 return 0;
00328 }
|
|
|
Definition at line 348 of file keyboard.c. References cad_power_down(), kbd_action_count, KBD_FLG_ALT, KBD_FLG_CNTRL, kbd_screen_down(), kbd_screen_up(), and memset(). Referenced by adi_chrdrv_kbd_init(). 00349 {
00350 memset(kbd_action, 0, sizeof(struct kbd_action_s) * MAX_KBD_ACTIONS);
00351
00352 kbd_action[0].active_flags = 0;
00353 kbd_action[0].passive_flags = 0;
00354 kbd_action[0].scancode = 73; /* PAGE_UP */
00355 kbd_action[0].kbd_action_routine = kbd_screen_up;
00356
00357 kbd_action[1].active_flags = 0;
00358 kbd_action[1].passive_flags = 0;
00359 kbd_action[1].scancode = 81; /* PAGE_DOWN */
00360 kbd_action[1].kbd_action_routine = kbd_screen_down;
00361
00362 kbd_action[2].active_flags = KBD_FLG_ALT | KBD_FLG_CNTRL;
00363 kbd_action[2].passive_flags = 0;
00364 kbd_action[2].scancode = 0x53; /* DEL */
00365 kbd_action[2].kbd_action_routine = cad_power_down;
00366
00367 kbd_action_count = 3;
00368
00369 return 0;
00370 }
Here is the call graph for this function: ![]() |
|
|
Definition at line 217 of file keyboard.c. References KBD_CCMD_SETLEDS, and kbd_data_write(). Referenced by adi_chrdrv_kbd_init(), and kbd_irq_handler(). 00218 {
00219 kbd_data_write(KBD_CCMD_SETLEDS);
00220 kbd_data_write(leds_mask);
00221 }
Here is the call graph for this function: ![]() |
|
|
Definition at line 140 of file keyboard.c. References KBD_STS_PORT. Referenced by kbd_data_read(), kbd_irq_handler(), and kbd_wait_for_bf(). 00141 {
00142 u8 status;
00143
00144 status = inb(KBD_STS_PORT);
00145
00146 return status;
00147 }
|
|
||||||||||||
|
Definition at line 149 of file keyboard.c. References kbd_status_read(), and KBD_WAIT_LOOPS. Referenced by kbd_wait_for_notibf(), and kbd_wait_for_obf(). 00150 {
00151 u8 status;
00152 int wait_loops = KBD_WAIT_LOOPS;
00153
00154 for (; wait_loops >= 0; wait_loops--) {
00155 status = kbd_status_read();
00156
00157 if (neg) {
00158 if (!(status & which_bf))
00159 return 1;
00160 }
00161 else {
00162 if (status & which_bf)
00163 return 1;
00164 }
00165 }
00166
00167 return 0;
00168 }
Here is the call graph for this function: ![]() |
|
|
Definition at line 170 of file keyboard.c. References KBD_STS_IBF, and kbd_wait_for_bf(). Referenced by kbd_cmd_write(), and kbd_data_write(). 00171 {
00172 return kbd_wait_for_bf(KBD_STS_IBF, 1);
00173 }
Here is the call graph for this function: ![]() |
|
|
Definition at line 175 of file keyboard.c. References KBD_STS_OBF, and kbd_wait_for_bf(). Referenced by kbd_data_read_wait(). 00176 {
00177 return kbd_wait_for_bf(KBD_STS_OBF, 0);
00178 }
Here is the call graph for this function: ![]() |
|
|
Definition at line 116 of file keyboard.c. |
|
|
Definition at line 107 of file keyboard.c. Referenced by kbd_irq_handler(), and kbd_set_actions(). |
|
|
Definition at line 105 of file keyboard.c. Referenced by kbd_change_led_flag(), and kbd_irq_handler(). |
|
|
Initial value: {
kbd_irq_handler, 0, IRQ_FLAG_RANDOM,
}
Definition at line 372 of file keyboard.c. Referenced by adi_chrdrv_kbd_init(). |
|
|
Definition at line 319 of file keyboard.c. Referenced by kbd_screen_down(), kbd_screen_up(), syscons_write(), and syscons_write_char(). |
|
|
Initial value: {
SPECIAL, SPECIAL,
'1','2','3','4','5','6','7','8','9','0','-','=',
SPECIAL, SPECIAL,
'q','w','e','r','t','y','u','i','o','p','[',']',ENTER,SPECIAL,
'a','s','d','f','g','h','j','k','l',';','\'',SPECIAL,'\\',
'<','z','x','c','v','b','n','m',',','.','/',SPECIAL,SPECIAL,SPECIAL,
' ',SPECIAL,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,PAUSE,SPECIAL,SPECIAL,
}
Definition at line 118 of file keyboard.c. Referenced by kbd_irq_handler(). |
|
|
Initial value: {
SPECIAL, SPECIAL,
'!','@','#','$','%','^','&','*','(',')','_','+',
SPECIAL, SPECIAL,
'Q','W','E','R','T','Y','U','I','O','P','{','}',ENTER,SPECIAL,
'A','S','D','F','G','H','J','K','L',':','"',SPECIAL,'|',
'>','Z','X','C','V','B','N','M','<','>','?',SPECIAL,SPECIAL,SPECIAL,
' ',SPECIAL,'~','~','~','~','~','~','~','~','~','~','~','~',PAUSE,SPECIAL,SPECIAL,
}
Definition at line 128 of file keyboard.c. Referenced by kbd_irq_handler(). |
|
|
|
|
|
|