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

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