keyboard.S
Upload User: qyj398
Upload Date: 2008-02-19
Package Size: 71k
Code Size: 17k
Development Platform:

Unix_Linux

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