root/kernel/chr_drv/keyboard.S

/* [previous][next][first][last][top][bottom][index][help] */
   1 /*
   2  *  linux/kernel/keyboard.S
   3  *
   4  *  (C) 1991  Linus Torvalds
   5  */
   6 
   7 /*
   8  * NOTE! This file no longer contains the low-level keyboard interrupt:
   9  * that is now in kernel/sys_call.S. The reason is that the low-level
  10  * interrupt must keep track of stack frames for signals etc.
  11  *
  12  * Thus it should be very easy to rewrite this in C - I just haven't
  13  * bothered.
  14  */
  15 
  16 /*
  17  *      Thanks to Alfred Leung for US keyboard patches
  18  *              Wolfgang Thiel for German keyboard patches
  19  *              Marc Corsini for the French keyboard
  20  *              LeBlanc@mcc.ac.uk for the UK keyboard
  21  *              Tommy Thorn (tthorn@daimi.aau.dk) for Danish keyboard
  22  */
  23 
  24 /* KBD_FINNISH for Finnish keyboards
  25  * KBD_US for US-type
  26  * KBD_GR for German keyboards
  27  * KBD_FR for Frech keyboard
  28  * KBD_UK for British extended keyboard
  29  * KBD_DK for Danish keyboard
  30  */
  31 
  32 .text
  33 .globl _hard_reset_now
  34 .globl _do_keyboard_interrupt
  35 .globl _do_keyboard
  36 .globl _kapplic
  37 .globl _kmode
  38 .globl _kleds
  39 .globl _set_leds
  40 .globl _kraw
  41 .globl _ke0
  42 
  43 /*
  44  * these are for the keyboard read functions
  45  */
  46 size    = 2048          /* must be a power of two ! And MUST be the same
  47                            as in tty_io.c !!!! */
  48 head = 4
  49 tail = 8
  50 proc_list = 12
  51 buf = 16
  52 
  53 _kapplic:       .byte 0
  54 _kmode: .byte 0         /* caps, alt, ctrl and shift mode */
  55 _kleds: .byte 2         /* num-lock, caps, scroll-lock mode (nom-lock on) */
  56 _ke0:   .byte 0
  57 _kraw:  .byte 0
  58 
  59 /*
  60  *  do_keyboard is the real interrupt routine that reads the
  61  *  keyboard scan-code and converts it into the appropriate
  62  *  ascii character(s).
  63  */
  64 _do_keyboard:
  65         xorl %eax,%eax          /* %eax is scan code */
  66         inb $0x60,%al
  67         pushl %eax
  68         inb $0x61,%al
  69         jmp 1f
  70 1:      jmp 1f
  71 1:      orb $0x80,%al
  72         jmp 1f
  73 1:      jmp 1f
  74 1:      outb %al,$0x61
  75         jmp 1f
  76 1:      jmp 1f
  77 1:      andb $0x7F,%al
  78         outb %al,$0x61
  79         jmp 1f
  80 1:      jmp 1f
  81 1:      movb $0x20,%al
  82         outb %al,$0x20
  83         cmpb $0,_kraw
  84         je 1f
  85         xorl %ebx,%ebx          /* if raw kbd, just put scancode */
  86         popl %eax
  87         sti
  88         call put_queue
  89         jmp postkey
  90 1:      popl %eax
  91         movl $1,%ebx
  92         cmpb $0xE0,%al
  93         je end_intr
  94         movl $2,%ebx
  95         cmpb $0xE1,%al
  96         je end_intr
  97         sti
  98         call key_table(,%eax,4)
  99 postkey:
 100         call _do_keyboard_interrupt
 101         movl $0,%ebx
 102 end_intr:
 103         movb %bl,_ke0
 104         ret
 105 
 106 /*
 107  * This routine fills the buffer with max 8 bytes, taken from
 108  * %ebx:%eax. (%edx is high). The bytes are written in the
 109  * order %al,%ah,%eal,%eah,%bl,%bh ... until %eax is zero.
 110  */
 111 put_queue:
 112         pushl %ecx
 113         pushl %edx
 114         movl _table_list,%edx           # read-queue for console
 115         movl head(%edx),%ecx
 116 1:      movb %al,buf(%edx,%ecx)
 117         incl %ecx
 118         andl $size-1,%ecx
 119         cmpl tail(%edx),%ecx            # buffer full - discard everything
 120         je 3f
 121         shrdl $8,%ebx,%eax
 122         je 2f
 123         shrl $8,%ebx
 124         jmp 1b
 125 2:      movl %ecx,head(%edx)
 126         movl proc_list(%edx),%ecx
 127         testl %ecx,%ecx
 128         je 3f
 129         movl $0,(%ecx)
 130 3:      popl %edx
 131         popl %ecx
 132         ret
 133 
 134 ctrl:   movb $0x04,%al
 135         jmp 1f
 136 alt:    movb $0x10,%al
 137 1:      cmpb $0,_ke0
 138         je 2f
 139         addb %al,%al
 140 2:      orb %al,_kmode
 141         ret
 142 unctrl: movb $0x04,%al
 143         jmp 1f
 144 unalt:  movb $0x10,%al
 145 1:      cmpb $0,_ke0
 146         je 2f
 147         addb %al,%al
 148 2:      notb %al
 149         andb %al,_kmode
 150         ret
 151 
 152 lshift:
 153         orb $0x01,_kmode
 154         ret
 155 unlshift:
 156         andb $0xfe,_kmode
 157         ret
 158 rshift:
 159         orb $0x02,_kmode
 160         ret
 161 unrshift:
 162         andb $0xfd,_kmode
 163         ret
 164 
 165 old_leds:
 166         .byte 2
 167 
 168 caps:   testb $0x80,_kmode
 169         jne 1f
 170         xorb $4,_kleds
 171         xorb $0x40,_kmode
 172         orb $0x80,_kmode
 173 _set_leds:
 174         movb _kleds,%al
 175         cmpb old_leds,%al
 176         je 1f
 177         movb %al,old_leds
 178         call kb_wait
 179         movb $0xed,%al          /* set leds command */
 180         outb %al,$0x60
 181         call kb_wait
 182         movb _kleds,%al
 183         outb %al,$0x60
 184 1:      ret
 185 uncaps: andb $0x7f,_kmode
 186         ret
 187 scroll:
 188         testb $0x03,_kmode
 189         je 1f
 190         call _show_mem
 191         jmp 2f
 192 1:      call _show_state
 193 2:      xorb $1,_kleds
 194         jmp _set_leds
 195         
 196 num:    cmpb $0x01,_kapplic
 197         jne notappl
 198         movw $0x0050,%ax
 199 applkey:
 200         shll $16,%eax
 201         movw $0x4f1b,%ax
 202         xorl %ebx,%ebx
 203         jmp put_queue
 204  
 205 notappl:
 206         xorb $2,_kleds
 207         jmp _set_leds
 208 
 209 /*
 210  *  cursor-key/numeric keypad cursor keys are handled here.
 211  *  checking for numeric keypad etc.
 212  */
 213 cursor:
 214         subb $0x47,%al
 215         jb 1f
 216         cmpb $12,%al
 217         ja 1f
 218         jne cur2                /* check for ctrl-alt-del */
 219         testb $0x0c,_kmode
 220         je cur2
 221         testb $0x30,_kmode
 222         jne _ctrl_alt_del
 223 cur2:   cmpb $0x01,_ke0         /* _ke0 forces cursor movement */
 224         je cur
 225         testb $0x03,_kmode      /* shift forces cursor */
 226         jne cur
 227         cmpb $0x01,_kapplic
 228         jne notcappl
 229         movb appl_table(%eax),%al
 230         jmp applkey
 231 notcappl:
 232         testb $0x02,_kleds      /* not num-lock forces cursor */
 233         je cur
 234         xorl %ebx,%ebx
 235         movb num_table(%eax),%al
 236         jmp put_queue
 237 1:      ret
 238 
 239 /*
 240  * cursor keys send ^[ [ x if normal, ^[ O x if application mode
 241  */
 242 cur:    movb cur_table(%eax),%al
 243         cmpb $'9,%al
 244         ja ok_cur
 245         movb $'~,%ah
 246 ok_cur: shll $16,%eax
 247         movw $0x5b1b,%ax
 248         xorl %ebx,%ebx
 249         cmpb $0x01,_kapplic
 250         jne put_queue
 251         movb $0x4f,%ah
 252         jmp put_queue
 253 
 254 #if defined(KBD_FR) /* || defined(KBD_DK) correct, but .. */
 255 num_table:
 256         .ascii "789-456+1230."
 257 #else
 258 num_table:
 259         .ascii "789-456+1230,"
 260 #endif
 261 cur_table:
 262         .ascii "HA5-DGC+YB623"
 263         
 264 /*      
 265     Keypad /                    35      B7      Q
 266     Keypad *  (PrtSc)           37      B7      R
 267     Keypad NumLock              45      ??      P
 268     Keypad 7  (Home)            47      C7      w
 269     Keypad 8  (Up arrow)        48      C8      x
 270     Keypad 9  (PgUp)            49      C9      y
 271     Keypad -                    4A      CA      S
 272     Keypad 4  (Left arrow)      4B      CB      t
 273     Keypad 5                    4C      CC      u
 274     Keypad 6  (Right arrow)     4D      CD      v
 275     Keypad +                    4E      CE      l
 276     Keypad 1  (End)             4F      CF      q
 277     Keypad 2  (Down arrow)      50      D0      r
 278     Keypad 3  (PgDn)            51      D1      s
 279     Keypad 0  (Ins)             52      D2      p
 280     Keypad .  (Del)             53      D3      n
 281 */    
 282  
 283 appl_table:
 284         .ascii "wxyStuvlqrspn"
 285 
 286 /*
 287  * this routine handles function keys
 288  */
 289 func:
 290         subb $0x3B,%al
 291         jb end_func
 292         cmpb $9,%al
 293         jbe ok_func
 294         subb $18,%al
 295         cmpb $10,%al
 296         jb end_func
 297         cmpb $11,%al
 298         ja end_func
 299 ok_func:
 300         testb $0x10,_kmode
 301         jne alt_func
 302         cmpl $4,%ecx            /* check that there is enough room */
 303         jl end_func
 304         movl func_table(,%eax,4),%eax
 305         xorl %ebx,%ebx
 306         jmp put_queue
 307 alt_func:
 308         pushl %eax
 309         call _change_console
 310         popl %eax
 311 end_func:
 312         ret
 313 
 314 /*
 315  * function keys send F1:'esc [ [ A' F2:'esc [ [ B' etc.
 316  */
 317 func_table:
 318         .long 0x415b5b1b,0x425b5b1b,0x435b5b1b,0x445b5b1b
 319         .long 0x455b5b1b,0x465b5b1b,0x475b5b1b,0x485b5b1b
 320         .long 0x495b5b1b,0x4a5b5b1b,0x4b5b5b1b,0x4c5b5b1b
 321 
 322 #if     defined(KBD_FINNISH)
 323 key_map:
 324         .byte 0,27
 325         .ascii "1234567890+'"
 326         .byte 127,9
 327         .ascii "qwertyuiop}"
 328         .byte 0,13,0
 329         .ascii "asdfghjkl|{"
 330         .byte 0,0
 331         .ascii "'zxcvbnm,.-"
 332         .byte 0,'*,0,32         /* 36-39 */
 333         .fill 16,1,0            /* 3A-49 */
 334         .byte '-,0,0,0,'+       /* 4A-4E */
 335         .byte 0,0,0,0,0,0,0     /* 4F-55 */
 336         .byte '<
 337         .fill 10,1,0
 338 
 339 shift_map:
 340         .byte 0,27
 341         .ascii "!\"#$%&/()=?`"
 342         .byte 127,9
 343         .ascii "QWERTYUIOP]^"
 344         .byte 13,0
 345         .ascii "ASDFGHJKL\\["
 346         .byte 0,0
 347         .ascii "*ZXCVBNM;:_"
 348         .byte 0,'*,0,32         /* 36-39 */
 349         .fill 16,1,0            /* 3A-49 */
 350         .byte '-,0,0,0,'+       /* 4A-4E */
 351         .byte 0,0,0,0,0,0,0     /* 4F-55 */
 352         .byte '>
 353         .fill 10,1,0
 354 
 355 alt_map:
 356         .byte 0,0
 357         .ascii "\0@\243$\0\0{[]}\\\0"
 358         .byte 0,0
 359         .byte 0,0,0,0,0,0,0,0,0,0,0
 360         .byte '~,13,0
 361         .byte 0,0,0,0,0,0,0,0,0,0,0
 362         .byte 0,0
 363         .byte 0,0,0,0,0,0,0,0,0,0,0
 364         .byte 0,0,0,0           /* 36-39 */
 365         .fill 16,1,0            /* 3A-49 */
 366         .byte 0,0,0,0,0         /* 4A-4E */
 367         .byte 0,0,0,0,0,0,0     /* 4F-55 */
 368         .byte '|
 369         .fill 10,1,0
 370 
 371 #elif defined(KBD_US)
 372 
 373 key_map:
 374         .byte 0,27
 375         .ascii "1234567890-="
 376         .byte 127,9
 377         .ascii "qwertyuiop[]"
 378         .byte 13,0
 379         .ascii "asdfghjkl;'"
 380         .byte '`,0
 381         .ascii "\\zxcvbnm,./"
 382         .byte 0,'*,0,32         /* 36-39 */
 383         .fill 16,1,0            /* 3A-49 */
 384         .byte '-,0,0,0,'+       /* 4A-4E */
 385         .byte 0,0,0,0,0,0,0     /* 4F-55 */
 386         .byte '<
 387         .fill 10,1,0
 388 
 389 shift_map:
 390         .byte 0,27
 391         .ascii "!@#$%^&*()_+"
 392         .byte 127,9
 393         .ascii "QWERTYUIOP{}"
 394         .byte 13,0
 395         .ascii "ASDFGHJKL:\""
 396         .byte '~,0
 397         .ascii "|ZXCVBNM<>?"
 398         .byte 0,'*,0,32         /* 36-39 */
 399         .fill 16,1,0            /* 3A-49 */
 400         .byte '-,0,0,0,'+       /* 4A-4E */
 401         .byte 0,0,0,0,0,0,0     /* 4F-55 */
 402         .byte '>
 403         .fill 10,1,0
 404 
 405 alt_map:
 406         .byte 0,0
 407         .ascii "\0@\0$\0\0{[]}\\\0"
 408         .byte 0,0
 409         .byte 0,0,0,0,0,0,0,0,0,0,0
 410         .byte '~,13,0
 411         .byte 0,0,0,0,0,0,0,0,0,0,0
 412         .byte 0,0
 413         .byte 0,0,0,0,0,0,0,0,0,0,0
 414         .byte 0,0,0,0           /* 36-39 */
 415         .fill 16,1,0            /* 3A-49 */
 416         .byte 0,0,0,0,0         /* 4A-4E */
 417         .byte 0,0,0,0,0,0,0     /* 4F-55 */
 418         .byte '|
 419         .fill 10,1,0
 420 
 421 #elif defined(KBD_UK)
 422 
 423 key_map:
 424         .byte 0,27
 425         .ascii "1234567890-="
 426         .byte 127,9
 427         .ascii "qwertyuiop[]"
 428         .byte 13,0
 429         .ascii "asdfghjkl;'"
 430         .byte '`,0
 431         .ascii "#zxcvbnm,./"
 432         .byte 0,'*,0,32         /* 36-39 */
 433         .fill 16,1,0            /* 3A-49 */
 434         .byte '-,0,0,0,'+       /* 4A-4E */
 435         .byte 0,0,0,0,0,0,0     /* 4F-55 */
 436         .ascii "\\"
 437         .fill 10,1,0
 438 
 439 shift_map:
 440         .byte 0,27
 441         .ascii "!\"\243$%^&*()_+"
 442         .byte 127,9
 443         .ascii "QWERTYUIOP{}"
 444         .byte 13,0
 445         .ascii "ASDFGHJKL:@"
 446         .byte '~,0
 447         .ascii "~ZXCVBNM<>?"
 448         .byte 0,'*,0,32         /* 36-39 */
 449         .fill 16,1,0            /* 3A-49 */
 450         .byte '-,0,0,0,'+       /* 4A-4E */
 451         .byte 0,0,0,0,0,0,0     /* 4F-55 */
 452         .byte '|
 453         .fill 10,1,0
 454 
 455 alt_map:
 456         .byte 0,0
 457         .ascii "\0@\0$\0\0{[]}\\\0"
 458         .byte 0,0
 459         .byte 0,0,0,0,0,0,0,0,0,0,0
 460         .byte '~,13,0
 461         .byte 0,0,0,0,0,0,0,0,0,0,0
 462         .byte 0,0
 463         .byte 0,0,0,0,0,0,0,0,0,0,0
 464         .byte 0,0,0,0           /* 36-39 */
 465         .fill 16,1,0            /* 3A-49 */
 466         .byte 0,0,0,0,0         /* 4A-4E */
 467         .byte 0,0,0,0,0,0,0     /* 4F-55 */
 468         .byte '|
 469         .fill 10,1,0
 470 
 471 #elif defined(KBD_GR)
 472 
 473 key_map:
 474         .byte 0,27
 475         .ascii "1234567890\\'"
 476         .byte 127,9
 477         .ascii "qwertzuiop@+"
 478         .byte 13,0
 479         .ascii "asdfghjkl[]^"
 480         .byte 0,'#
 481         .ascii "yxcvbnm,.-"
 482         .byte 0,'*,0,32         /* 36-39 */
 483         .fill 16,1,0            /* 3A-49 */
 484         .byte '-,0,0,0,'+       /* 4A-4E */
 485         .byte 0,0,0,0,0,0,0     /* 4F-55 */
 486         .byte '<
 487         .fill 10,1,0
 488 
 489 shift_map:
 490         .byte 0,27
 491         .ascii "!\"#$%&/()=?`"
 492         .byte 127,9
 493         .ascii "QWERTZUIOP\\*"
 494         .byte 13,0
 495         .ascii "ASDFGHJKL{}~"
 496         .byte 0,''
 497         .ascii "YXCVBNM;:_"
 498         .byte 0,'*,0,32         /* 36-39 */
 499         .fill 16,1,0            /* 3A-49 */
 500         .byte '-,0,0,0,'+       /* 4A-4E */
 501         .byte 0,0,0,0,0,0,0     /* 4F-55 */
 502         .byte '>
 503         .fill 10,1,0
 504 
 505 alt_map:
 506         .byte 0,0
 507         .ascii "\0@\0$\0\0{[]}\\\0"
 508         .byte 0,0
 509         .byte '@,0,0,0,0,0,0,0,0,0,0
 510         .byte '~,13,0
 511         .byte 0,0,0,0,0,0,0,0,0,0,0
 512         .byte 0,0
 513         .byte 0,0,0,0,0,0,0,0,0,0,0
 514         .byte 0,0,0,0           /* 36-39 */
 515         .fill 16,1,0            /* 3A-49 */
 516         .byte 0,0,0,0,0         /* 4A-4E */
 517         .byte 0,0,0,0,0,0,0     /* 4F-55 */
 518         .byte '|
 519         .fill 10,1,0
 520 
 521 #elif defined(KBD_FR)
 522 
 523 key_map:
 524         .byte 0,27
 525         .ascii "&{\"'(-}_/@)="
 526         .byte 127,9
 527         .ascii "azertyuiop^$"
 528         .byte 13,0
 529         .ascii "qsdfghjklm|"
 530         .byte '`,0,42           /* coin sup gauche, don't know, [*|mu] */
 531         .ascii "wxcvbn,;:!"
 532         .byte 0,'*,0,32         /* 36-39 */
 533         .fill 16,1,0            /* 3A-49 */
 534         .byte '-,0,0,0,'+       /* 4A-4E */
 535         .byte 0,0,0,0,0,0,0     /* 4F-55 */
 536         .byte '<
 537         .fill 10,1,0
 538 
 539 shift_map:
 540         .byte 0,27
 541         .ascii "1234567890]+"
 542         .byte 127,9
 543         .ascii "AZERTYUIOP<>"
 544         .byte 13,0
 545         .ascii "QSDFGHJKLM%"
 546         .byte '~,0,'#
 547         .ascii "WXCVBN?./\\"
 548         .byte 0,'*,0,32         /* 36-39 */
 549         .fill 16,1,0            /* 3A-49 */
 550         .byte '-,0,0,0,'+       /* 4A-4E */
 551         .byte 0,0,0,0,0,0,0     /* 4F-55 */
 552         .byte '>
 553         .fill 10,1,0
 554 
 555 alt_map:
 556         .byte 0,0
 557         .ascii "\0~#{[|`\\^@]}"
 558         .byte 0,0
 559         .byte '@,0,0,0,0,0,0,0,0,0,0
 560         .byte '~,13,0
 561         .byte 0,0,0,0,0,0,0,0,0,0,0
 562         .byte 0,0
 563         .byte 0,0,0,0,0,0,0,0,0,0,0
 564         .byte 0,0,0,0           /* 36-39 */
 565         .fill 16,1,0            /* 3A-49 */
 566         .byte 0,0,0,0,0         /* 4A-4E */
 567         .byte 0,0,0,0,0,0,0     /* 4F-55 */
 568         .byte '|
 569         .fill 10,1,0
 570 
 571 #elif defined(KBD_DK)
 572 
 573 key_map:
 574         .byte 0,27
 575         .ascii "1234567890+'"
 576         .byte 127,9
 577         .ascii "qwertyuiop"
 578         .byte 134,0,13,0        /* This is IBM-PC, change it to latin-1 */
 579         .ascii "asdfghjkl"
 580         .byte 145,155,0,0
 581         .ascii "'zxcvbnm,.-"
 582         .byte 0,'*,0,32         /* 36-39 */
 583         .fill 16,1,0            /* 3A-49 */
 584         .byte '-,0,0,0,'+       /* 4A-4E */
 585         .byte 0,0,0,0,0,0,0     /* 4F-55 */
 586         .byte '<
 587         .fill 10,1,0
 588 
 589 shift_map:
 590         .byte 0,27
 591         .ascii "!\"#$%&/()=?`"
 592         .byte 127,9
 593         .ascii "QWERTYUIOP"
 594         .byte 143,94,13,0
 595         .ascii "ASDFGHJKL"
 596         .byte 146,157,0,0
 597         .ascii "*ZXCVBNM;:_"
 598         .byte 0,'*,0,32         /* 36-39 */
 599         .fill 16,1,0            /* 3A-49 */
 600         .byte '-,0,0,0,'+       /* 4A-4E */
 601         .byte 0,0,0,0,0,0,0     /* 4F-55 */
 602         .byte '>
 603         .fill 10,1,0
 604 
 605 alt_map:
 606         .byte 0,0
 607         .ascii "\0@\0$\0\0{[]}\0"
 608         .byte '|,0,0
 609         .byte 0,0,0,0,0,0,0,0,0,0,0
 610         .byte '~,13,0
 611         .byte 0,0,0,0,0,0,0,0,0,0,0
 612         .byte 0,0
 613         .byte 0,0,0,0,0,0,0,0,0,0,0
 614         .byte 0,0,0,0           /* 36-39 */
 615         .fill 16,1,0            /* 3A-49 */
 616         .byte 0,0,0,0,0         /* 4A-4E */
 617         .byte 0,0,0,0,0,0,0     /* 4F-55 */
 618         .ascii "\\"
 619         .fill 10,1,0
 620 
 621 #else
 622 #error "KBD-type not defined"
 623 #endif
 624 /*
 625  * do_self handles "normal" keys, ie keys that don't change meaning
 626  * and which have just one character returns.
 627  */
 628 do_self:
 629         lea alt_map,%ebx
 630         testb $0x20,_kmode              /* alt-gr */
 631         jne 1f
 632         lea shift_map,%ebx
 633         testb $0x0f,_kmode
 634         jne 1f
 635         lea key_map,%ebx
 636 1:      movb (%ebx,%eax),%al
 637         orb %al,%al
 638         je none
 639         testb $0x4c,_kmode              /* ctrl or caps */
 640         je 2f
 641         cmpb $'a,%al
 642         jb 2f
 643         cmpb $'},%al
 644         ja 2f
 645         subb $32,%al
 646 2:      testb $0x0c,_kmode              /* ctrl */
 647         je 3f
 648         andb $0x1f,%al
 649 3:      testb $0x10,_kmode              /* left alt */
 650         je 4f
 651         orb $0x80,%al
 652 4:      andl $0xff,%eax
 653         xorl %ebx,%ebx
 654         call put_queue
 655 none:   ret
 656 
 657 /*
 658  * slash and star have routines of their own, as a 'E0h' before
 659  * the scan code for slash means that the numeric keypad
 660  * slash was pushed.
 661  */
 662 slash:  cmpb $1,_ke0
 663         jne do_self
 664         cmpb $1,_kapplic
 665         jne notmapplic
 666         movw $'Q,%ax
 667         jmp applkey
 668         
 669 notmapplic:
 670         movl $'/,%eax
 671         xorl %ebx,%ebx
 672         jmp put_queue
 673 
 674 star:   cmpb $1,_kapplic
 675         jne do_self
 676         movw $'R,%ax
 677         jmp applkey
 678         
 679 notsapplic:
 680         movl $'*,%eax
 681         xorl %ebx,%ebx
 682         jmp put_queue
 683 
 684 enter:  cmpb $1,_ke0
 685         jne do_self
 686         cmpb $1,_kapplic
 687         jne do_self
 688         movw $'M,%ax
 689         jmp applkey
 690         
 691 minus:  cmpb $1,_kapplic
 692         jne do_self
 693         movw $'S,%ax
 694         jmp applkey
 695         
 696 plus:   cmpb $1,_kapplic
 697         jne do_self
 698         movw $'l,%ax
 699         jmp applkey
 700         
 701 /*
 702  * This table decides which routine to call when a scan-code has been
 703  * gotten. Most routines just call do_self, or none, depending if
 704  * they are make or break.
 705  */
 706 key_table:
 707         .long none,do_self,do_self,do_self      /* 00-03 s0 esc 1 2 */
 708         .long do_self,do_self,do_self,do_self   /* 04-07 3 4 5 6 */
 709         .long do_self,do_self,do_self,do_self   /* 08-0B 7 8 9 0 */
 710         .long do_self,do_self,do_self,do_self   /* 0C-0F + ' bs tab */
 711         .long do_self,do_self,do_self,do_self   /* 10-13 q w e r */
 712         .long do_self,do_self,do_self,do_self   /* 14-17 t y u i */
 713         .long do_self,do_self,do_self,do_self   /* 18-1B o p } ^ */
 714         .long enter,ctrl,do_self,do_self        /* 1C-1F enter ctrl a s */
 715         .long do_self,do_self,do_self,do_self   /* 20-23 d f g h */
 716         .long do_self,do_self,do_self,do_self   /* 24-27 j k l | */
 717         .long do_self,do_self,lshift,do_self    /* 28-2B { para lshift , */
 718         .long do_self,do_self,do_self,do_self   /* 2C-2F z x c v */
 719         .long do_self,do_self,do_self,do_self   /* 30-33 b n m , */
 720         .long do_self,slash,rshift,star         /* 34-37 . - rshift * */
 721         .long alt,do_self,caps,func             /* 38-3B alt sp caps f1 */
 722         .long func,func,func,func               /* 3C-3F f2 f3 f4 f5 */
 723         .long func,func,func,func               /* 40-43 f6 f7 f8 f9 */
 724         .long func,num,scroll,cursor            /* 44-47 f10 num scr home */
 725         .long cursor,cursor,minus,cursor        /* 48-4B up pgup - left */
 726         .long cursor,cursor,plus,cursor         /* 4C-4F n5 right + end */
 727         .long cursor,cursor,cursor,cursor       /* 50-53 dn pgdn ins del */
 728         .long none,none,do_self,func            /* 54-57 sysreq ? < f11 */
 729         .long func,none,none,none               /* 58-5B f12 ? ? ? */
 730         .long none,none,none,none               /* 5C-5F ? ? ? ? */
 731         .long none,none,none,none               /* 60-63 ? ? ? ? */
 732         .long none,none,none,none               /* 64-67 ? ? ? ? */
 733         .long none,none,none,none               /* 68-6B ? ? ? ? */
 734         .long none,none,none,none               /* 6C-6F ? ? ? ? */
 735         .long none,none,none,none               /* 70-73 ? ? ? ? */
 736         .long none,none,none,none               /* 74-77 ? ? ? ? */
 737         .long none,none,none,none               /* 78-7B ? ? ? ? */
 738         .long none,none,none,none               /* 7C-7F ? ? ? ? */
 739         .long none,none,none,none               /* 80-83 ? br br br */
 740         .long none,none,none,none               /* 84-87 br br br br */
 741         .long none,none,none,none               /* 88-8B br br br br */
 742         .long none,none,none,none               /* 8C-8F br br br br */
 743         .long none,none,none,none               /* 90-93 br br br br */
 744         .long none,none,none,none               /* 94-97 br br br br */
 745         .long none,none,none,none               /* 98-9B br br br br */
 746         .long none,unctrl,none,none             /* 9C-9F br unctrl br br */
 747         .long none,none,none,none               /* A0-A3 br br br br */
 748         .long none,none,none,none               /* A4-A7 br br br br */
 749         .long none,none,unlshift,none           /* A8-AB br br unlshift br */
 750         .long none,none,none,none               /* AC-AF br br br br */
 751         .long none,none,none,none               /* B0-B3 br br br br */
 752         .long none,none,unrshift,none           /* B4-B7 br br unrshift br */
 753         .long unalt,none,uncaps,none            /* B8-BB unalt br uncaps br */
 754         .long none,none,none,none               /* BC-BF br br br br */
 755         .long none,none,none,none               /* C0-C3 br br br br */
 756         .long none,none,none,none               /* C4-C7 br br br br */
 757         .long none,none,none,none               /* C8-CB br br br br */
 758         .long none,none,none,none               /* CC-CF br br br br */
 759         .long none,none,none,none               /* D0-D3 br br br br */
 760         .long none,none,none,none               /* D4-D7 br br br br */
 761         .long none,none,none,none               /* D8-DB br ? ? ? */
 762         .long none,none,none,none               /* DC-DF ? ? ? ? */
 763         .long none,none,none,none               /* E0-E3 e0 e1 ? ? */
 764         .long none,none,none,none               /* E4-E7 ? ? ? ? */
 765         .long none,none,none,none               /* E8-EB ? ? ? ? */
 766         .long none,none,none,none               /* EC-EF ? ? ? ? */
 767         .long none,none,none,none               /* F0-F3 ? ? ? ? */
 768         .long none,none,none,none               /* F4-F7 ? ? ? ? */
 769         .long none,none,none,none               /* F8-FB ? ? ? ? */
 770         .long none,none,none,none               /* FC-FF ? ? ? ? */
 771 
 772 /*
 773  * kb_wait waits for the keyboard controller buffer to empty.
 774  */
 775 kb_wait:
 776         pushl %eax
 777         pushl %ebx
 778         movl $10000,%ebx
 779 1:      inb $0x64,%al
 780         testb $0x02,%al
 781         je 2f
 782         decl %ebx
 783         jne 1b
 784 2:      popl %ebx
 785         popl %eax
 786         ret
 787 
 788 no_idt:
 789         .long 0,0
 790 /*
 791  * This routine reboots the machine by asking the keyboard
 792  * controller to pulse the reset-line low. We try that for a while,
 793  * and if it doesn't work, we do some other stupid things.
 794  */
 795 _hard_reset_now:
 796         sti
 797         movl $100,%ebx
 798 1:      call kb_wait
 799         movw $0x1234,0x472      /* don't do memory check */
 800         movb $0xfe,%al          /* pulse reset low */
 801         outb %al,$0x64
 802         decl %ebx
 803         jne 1b
 804         lidt no_idt             /* zero-length idt: should triple-fault */
 805         jmp _hard_reset_now

/* [previous][next][first][last][top][bottom][index][help] */