home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / programming / misc_programming / 8042.doc < prev    next >
Text File  |  1990-01-04  |  31KB  |  632 lines

  1.                       KB controller
  2.                       -------------
  3.  
  4.     8742/8741 programming scheme:
  5.  
  6. 1. 8742 STRUCTURE
  7.  
  8.              DATA                             PROGRAM
  9.       MEMORY MAP                 MEMORY MAP
  10.  
  11.      127┌─────────────┐               2047┌─────────────┐
  12.        │          │           8042           │         │    Page 7
  13.        │  8742 RAM   │           8742           │  8742 ROM   │       │
  14.        │          │         │             │         │    Page 4
  15.       64├─────────────┤        ───────────       1024├─────────────┤
  16.        │  8741 RAM   │         │             │             │    Page 3
  17.       32├─────────────┤           8041A           │  8741 ROM   │       │  
  18.        │   Bank 1    │           8741A           │             │    Page 1
  19.        │     R7      │         &        256├─────────────┤    ────── 
  20.        │     ..      │           8042           │             │       │
  21.        │     R1      │           8742           │             │       │
  22.     │     R0      │                   ├─────────────┤       │
  23.       24├─────────────┤                  7│  TIMER INT. │       │
  24.     │   8 level   │                   ├─────────────┤
  25.     │    STACK    │                   │             │    Page 0
  26.        8├─────────────┤                   ├─────────────┤
  27.        │   Bank 0    │                  3│   IBF INT.  │       │
  28.        │     R7      │                   ├─────────────┤       │
  29.        │     ..      │                   │             │       │
  30.        │     R1      │                   ├─────────────┤       │
  31.     │     R0      │                  0│    RESET    │       │
  32.        0└─────────────┘                   └─────────────┘    ──────
  33.                                     
  34.  
  35.     (1) PC - Program Counter Stack
  36.         10-bit counter starting from data memory address 8 to 
  37.             low nibble of address 9.   
  38.     (2) PSW - Program Status Word
  39.         8-bit register used to store general information about 
  40.         program execution.
  41.         bit 0 - 2 : Stack Pointer Bits S0, S1, S2 
  42.         bit 3 : Not used
  43.         bit 4 : Working Register Bank
  44.         bit 5 : User flag(F0)
  45.         bit 6 : Auxiliary Carry(AC)
  46.         bit 7 : Carry(CY)
  47.     (3) Location 0 - Reset vector
  48.         Following a RESET* input to the processor, the next instruction
  49.         is automatically fetched from location 0.
  50.  
  51.     (4) Location 3 - IBF inerrupt vector
  52.         An interrupt generated by an Input Buffer Full(IBF) condition 
  53.         (with EN I instruction) causes the next instruction to be        
  54.         fetched from location 3.
  55.     (5) Location 7 - Timer interrupt vector
  56.         A timer overflow interrupt(with EN TCNTI instruction) will
  57.         cause the next instruction to be fetched from location 7.
  58.     (6) Instruction Cycle -    1/(X MHz/15) = Y microseconds 
  59.     (7) Timer - 1/[X MHz/(15*32)] = Z microseconds
  60.         The STRT T instruction enable the counter.
  61.         The STOP T instruction disable the counter.
  62.         
  63.  
  64. 2. 8741/8742 FEATURE  
  65.     (1) 8-bit CPU 
  66.     (2) 8-bit data bus interface registers
  67.     (3) 1K(2K) by 8 bit EPROM for 8741/8742
  68.     (4) 64(128) by 8 bit RAM memory for 8741/8742
  69.     (5) Interval timer/event counter
  70.     (6) Two 8-bit TTL compatible I/O ports
  71.     (7) Resident clock oscillator
  72.     (8) 12M Hz operation for 8041AH, 8742, 8042
  73.  
  74. 3. DBBOUT, DBBIN and STATUS registers
  75.     (1) DBBOUT - Data Bus Buffer OUTput
  76.         The host processor(system) may read data from DBBOUT.         
  77.     (2) DBBIN - Data Bus Buffer INput
  78.         The host processor(system) may write command or data to DBBIN.
  79.     (3) STATUS   
  80.         The status of DBBOUT, DBBIN and user_defined status is 
  81.         provided in the STATUS.
  82.  
  83.  
  84.  
  85.  
  86.         This SPECIFICATION of 8042/8041 include 
  87.  
  88. 1. PORT definition
  89.  
  90. 2. COMMAND
  91.  
  92. 3. Timing of TRANSMITTING(error conditions included)
  93.  
  94. 4. Timing of RECEIVING(error conditions included)
  95.  
  96. 5. Timing of RECEIVE XT KB data
  97.  
  98.  
  99.  
  100.  
  101.            The DETAILS of the above
  102.  
  103.             PORT DEFINITION
  104. ┌───────────────────────────────────────────────────────────────────────────┐
  105. │ Port 60h         Input/Output Buffer for Keyboard and Auxiliary Device    │
  106. │                  (8042 only)                                              │
  107. │                                                                           │
  108. │       * The output buffer is an 8-bit READ ONLY register at Port 60h.     │
  109. │         When the output buffer is read, the 8042 uses it to send informa- │
  110. │         tion to the system microprocessor.                                │
  111. │         THE INFORMATION CAN BE SCAN CODES RECEIVED FROM KEYBOARD, DATA    │
  112. │         FROM AN AUXILIARY DEVICE, or DATA BYTES THAT RESULT FROM A COMMAND│
  113. │         FROM THE SYSTEM MICROPROCESSOR.                                   │
  114. │                                                                           │
  115. │       * The input buffer is an 8-bit WRITE ONLY register at Port 60h.     │
  116. │         When the input buffer is written, a flag is set that indicates a  │
  117. │         data write.DATA WRITTEN TO PORT 60H IS SENT TO THE KEYBOARD UNLESS│
  118. │         THE 8042 IS EXPECTING A DATA BYTE FOLLOWING A 8042 COMMAND. Data  │
  119. │         should be written to the 8042 input buffer only if the input      │
  120. │         buffer full bit (bit 1) of Status Port 64h = 0.                   │
  121. │                                                                           │
  122. │ Port 64h         8042 Command Port (WRITE)                                │
  123. │                                                                           │
  124. │       * 8042 commands written through port 64h :                          │
  125. │                                        │
  126. │    # common command                            │
  127. │    @ 8041 command                                    │
  128. │      8042 command                                    │
  129. │                                        │
  130. │         . 21-3F  read 8042 RAM                                            │
  131. │       # . 20     read 8042 command byte                                   │
  132. │         . 61-7F  write 8042 RAM                                           │
  133. │       # . 60     write 8042 command byte                                  │
  134. │         . A4     test password installed                                  │
  135. │         . A5     load security                                            │
  136. │         . A6     enable security                                          │
  137. │         . A7     disable auxiliary device interface                       │
  138. │         . A8     enable auxiliary device interface                        │
  139. │         . A9     interface test for auxiliary device 'clock'              │
  140. │                  and 'data' line                                          │
  141. │       # . AA     self test                                                │
  142. │       # . AB     interface test for keyboard 'clock'& 'data' line         │
  143. │       @ . AC     diagonstic dump                                         │
  144. │         . AC     reserved                            │
  145. │       # . AD     disable keyboard interface                               │
  146. │       # . AE     enable keyboard interface                                │
  147. │       # . C0     read input port                                          │
  148. │         . C1     poll input port low - port 1 bit 0-3,                    │
  149. │                  in status bits 4-7                                       │
  150.  
  151. │         . C2     poll input port low - port 1 bit 4-7,                    │
  152. │                  in status bits 4-7                                       │
  153. │         . C3     light panel LED                              │
  154. │       # . D0     read output port                                         │
  155. │       # . D1     write output port                                        │
  156. │                  NOTE: Bit 0 of output port is connected to               │
  157. │                          system reset. This bit should not be             │
  158. │                          written low                                      │
  159. │         . D2     write keyboard output buffer                             │
  160. │         . D3     write auxiliary device output buffer                     │
  161. │         . D4     write auxiliary device                                   │
  162. │       # . E0     read test inputs                                         │
  163. │       # . F0-FF  pulse output port                                        │
  164. │                                                                           │
  165. │ Note:                                     │
  166. │       (1) Definitions of the command byte (for command 20h & 60h):        │
  167. │           Bit     For 8042                    |  For 8041                 │
  168. │           ------------------------------------+---------------------------│
  169. │            7     Reserved = 0                 | the same as 8042          │
  170. │                                               |                           │
  171. │            6     IBM translate mode           | the same as 8042          │
  172. │                  = 1, 8042 translates the     |                           │
  173. │                    incoming scan code to scan |                           │
  174. │                    code set 1.                |                           │
  175. │                  = 0, 8042 passes the         |                           │
  176. │                    keyboard scan codes        |                           │
  177. │                    without translation.       |                           │
  178. │                                               |                           │
  179. │            5     Disable auxiliary device     | IBM PC mode               │
  180. │                  interface                    | = 1, PC keyboard interface│
  181. │                  = 1, disable                 | = 0, PC/AT keyboard       │
  182. │                  = 0, enable                  |      interface            │
  183. │                                               |                           │
  184. │            4     Disable keyboard             | the same as 8042          │
  185. │                  interface                    |                           │
  186. │                  = 1, disable                 |                           │
  187. │                  = 0, enable                  |                           │
  188. │                                               |                           │
  189. │            3     Reserved = 0                 | Disable inhibit switch    │
  190. │                                               | = 1, disable              │
  191. │                                               | = 0, enable               │
  192. │                                               |                           │
  193. │            2     System flag                  | the same as 8042          │
  194. │                                               |                           │
  195. │            1     Enable auxiliary interrupt   | Reserved = 0              │
  196. │                  = 1, enable                  |                           │
  197. │                                               |                           │
  198. │            0     Enable keyboard interrupt    | the same as 8042          │
  199. │                  = 1, enable                  |                           │
  200. │                                                                           │
  201.  
  202. │       (2) An interrupt occurs if the interrupt is enabled in the          │
  203. │           command byte.                                                   │
  204. │                                                                           │
  205. │       (3) Enable inhibit switch causes the KEY LOCK funtion to fail.         │
  206. │                                                                           │
  207. │                                                                           │
  208. │ Port 64h         8042 Status Port (READ)                                  │
  209. │                                                                           │
  210. │     Bit   For 8042                    |  For 8041                         │
  211. │     ----------------------------------+---------------------------        │
  212. │      7   Parity error                 | the same as 8042                  │
  213. │      6   General time out             | Receive time out                  │
  214. │      5   Auxiliary output buffer full | Transmit time out                 │
  215. │      4   Inhibit switch               | the same as 8042                  │
  216. │      3   Command/data                 |        "                          │
  217. │      2   System flag                  |        "                          │
  218. │      1   Input buffer full            |        "                          │
  219. │      0   Output buffer full           |        "                          │
  220. │     ----------------------------------+---------------------------        │
  221. │                                                                           │
  222. │       * PROGRAMMING CONSIDERATION                                         │
  223. │                                                                           │
  224. │         . port 64h (status register) can be read at any time              │
  225. │         . port 60h should be READ ONLY when the output buffer full        │
  226. │           bit in the status register is a 1                               │
  227. │         . the auxiliary output buffer full bit in the status register     │
  228. │           indicates that the data in port 60h came from the auxiliary     │
  229. │           device. this bit is VALID ONLY when the output buffer full      │
  230. │           bit is a 1                                                      │
  231. │         . port 60h and 64h should be written only when the status register│
  232. │           input buffer full bit is 0                                      │
  233. │         . the devices connected to the 8042 should be disabled before     │
  234. │           initiating a command that generates output. if output is        │
  235. │           generated, any value in the output buffer is overwritten        │
  236. │         . an external latch is used to hold the level sensitive IRQ until │
  237. │           an I/O read from address 60h is executed by the system          │
  238. │                                                                           │
  239. └───────────────────────────────────────────────────────────────────────────┘
  240.  
  241.  
  242.  
  243.  
  244.                    COMMAND         
  245. ┌─────────────────────────────────────────────────────────────────┐
  246. │#20    read 8042 command byte -                                  │
  247. │    Read command byte and put it into output buffer.      │
  248. │                                  │
  249. │21-3F  read 8042 RAM -                                           │  
  250. │    Read 8042 RAM address 21h to 3fh and put it into        │
  251. │    output buffer.                          │
  252. │                                  │
  253. │#60    write 8042 command byte -                                 │
  254. │    The next byte written to port 60h will update the command │
  255. │    byte.                              │
  256. │                                  │
  257. │61-7F  write 8042 RAM -                                          │
  258. │    The next byte written to port 60h will update content of  │
  259. │    8042 RAM address 21h to 3fh accordingly.          │
  260. │                                  │
  261. │A4     test password installed -                                 │
  262. │    Test if there is a password installed in the 8042 RAM,    │
  263. │    if installed, place FAh into output buffer, else       │
  264. │    place F1h into output buffer.                  │
  265. │                                  │
  266. │A5     load security -                                           │
  267. │    Load password into 8042 RAM, the password must be written │
  268. │    to port 60h in scan code set 1 format, and will be        │
  269. │    terminated until a null(0) is written to port 60h.        │
  270. │                                  │
  271. │A6     enable security -                                         │
  272. │    Enable the 8042 security feature, this command is VALID   │
  273. │    ONLY when a password is currently stored in 8042 RAM.        │
  274. │    When the security is enabled, the status byte(64h) bit 4  │
  275. │    (inhibit switch) will become 0.                   │
  276. │                                  │
  277. │A7     disable auxiliary device interface -                      │
  278. │    Set bit 5 of the 8042 command byte, this disable the      │
  279. │    auxiliary device interface by driving the CLOCK line low, │
  280. │    data is not sent(received) to(from) auxiliary device.      │
  281. │                                  │
  282. │A8     enable auxiliary device interface -                       │
  283. │    Clear bit 5 of the 8042 command byte, this release the      │
  284. │    auxiliary device interface.                               │
  285. │                                  │
  286. │A9     interface test -                                          │
  287. │    Test auxiliary device clock and data line, and place test │
  288. │    result in output buffer.                  │
  289.  
  290. │      ╔═══════════════════════════════════════╗                 │
  291. │      ║ Test Result      Meaning        ║          │
  292. │      ║                            ║          │
  293. │      ║     0            No error        ║          │
  294. │      ║     1            AUX clock stuck low    ║          │
  295. │      ║     2            AUX clock stuck high    ║          │
  296. │      ║     3            AUX data stuck low    ║          │
  297. │      ║     4            AUX data stuck high    ║          │
  298. │      ╚═══════════════════════════════════════╝                 │
  299. │                                  │
  300. │#AA    self test -                                               │
  301. │    Perform 8042 internal diagnostic tests. 55h will be put   │
  302. │    into output buffer if no errors are detected.          │
  303. │                                  │
  304. │#AB    interface test -                                          │
  305. │    Test KB clock and data line, and place test result in       │
  306. │       output buffer.                             │
  307. │      ╔═══════════════════════════════════════╗                 │
  308. │      ║ Test Result      Meaning        ║          │
  309. │      ║                            ║          │
  310. │      ║     0            No error        ║          │
  311. │      ║     1            KB clock stuck low    ║          │
  312. │      ║     2            KB clock stuck high    ║          │
  313. │      ║     3            KB data stuck low    ║          │
  314. │      ║     4            KB data stuck high    ║          │
  315. │      ╚═══════════════════════════════════════╝                 │
  316. │                                  │
  317. │@AC    diagonstic dump -                                      │
  318. │    Send content of 8042 RAM address 0 to 0fh,           │
  319. │    current state of input port(P1),              │
  320. │    current state of output port(P2),              │
  321. │    8041 program status word(PSW) to system sequentially.     │
  322. │                                  │
  323. │AC     reserved                                                  │
  324. │                                  │
  325. │#AD    disable keyboard interface -                              │
  326. │    Set bit 4 of the 8042 command byte, this disable the      │
  327. │    KB interface by driving the CLOCK line low,            │
  328. │    data is not sent(received) to(from) KB.                    │
  329. │                                  │
  330. │#AE    enable keyboard interface -                               │
  331. │    Clear bit 4 of the 8042 command byte, this release the      │
  332. │    KB interface.                                       │
  333. │                                  │
  334. │#C0    read input port -                                         │
  335. │    Read input port(P1), and place the data in output buffer. │
  336. │    This command should be used ONLY IF the output buffer is  │
  337. │    EMPTY.                              │
  338. │                                  │
  339. │    NOTE: (1) 8042 input port(P1) definition:          │
  340.  
  341. │            ╔═════════════════════════════╗                 │
  342. │            ║ Bit       General Definition   ║          │
  343. │            ║                               ║          │
  344. │            ║  7        Reserved             ║          │
  345. │            ║  6        "                 ║          │
  346. │            ║  5        "                 ║          │
  347. │            ║  4        "                 ║          │
  348. │            ║  3        "                 ║          │
  349. │            ║  2     5V                   ║          │
  350. │            ║  1     PD data              ║          │
  351. │            ║  0     KB data              ║          │
  352. │            ╚═════════════════════════════╝                 │
  353. │                                  │
  354. │              8041 output port(P2) definition:          │
  355. │            ╔═════════════════════════════╗                 │
  356. │            ║ Bit       General Definition   ║          │
  357. │            ║                               ║          │
  358. │            ║  7        KEY LOCK -> 0:lock   ║          │
  359. │            ║  6     Reserved             ║          │
  360. │            ║  5        "                 ║          │
  361. │            ║  4        "                 ║          │
  362. │            ║  3        "                 ║          │
  363. │            ║  2        "                 ║          │
  364. │            ║  1        "                 ║          │
  365. │            ║  0        "                 ║          │
  366. │            ╚═════════════════════════════╝                 │
  367. │          * indicate conjugate of that signal          │
  368. │                                  │
  369. │C1     poll input port low -                                     │
  370. │    Place input port(P1) bits 0-3 in STATUS bits 4-7.      │
  371. │                                  │
  372. │C2     poll input port high -                                    │
  373. │    Place input port(P1) bits 4-7 in STATUS bits 4-7.      │
  374. │                                  │
  375. │C3     light panel LED -                             │
  376. │       The next byte written to port 60h is defined as:          │
  377. │       set to high speed : data = 1                  │
  378. │       set to low speed  : data = 0                  │
  379. │                                  │
  380. │#D0    read output port -                                        │
  381. │    Read output port(P2), and place the data in output buffer.│
  382. │    This command should be used ONLY IF the output buffer is  │
  383. │    EMPTY.                              │
  384. │                                  │
  385. │#D1    write output port -                                       │
  386. │    The next byte written to port 60h will be output to       │
  387. │    output port(P2).                      │
  388. │                                  │
  389.  
  390. │       NOTE: (1) Bit 0 of output port is connected to            │
  391. │                 system reset. This bit should not be            │
  392. │                 written low                                     │
  393. │                                  │
  394. │          (2) For AT model with PS2 mouse, i.e., 915V, 1100SX,│
  395. │           ONLY bit 0 and 1 can be modified.          │
  396. │                                  │
  397. │          (3) 8042 output port(P2) definition:          │
  398. │            ╔═════════════════════════════╗                 │
  399. │            ║ Bit       General Definition   ║          │
  400. │            ║                               ║          │
  401. │            ║  7        KB data*             ║          │
  402. │            ║  6     KB clock*            ║          │
  403. │            ║  5     IRQ 12               ║          │
  404. │            ║  4     IRQ 1                ║          │
  405. │            ║  3     PD data*             ║          │
  406. │            ║  2     PD clock*            ║          │
  407. │            ║  1     Gate A20             ║          │
  408. │            ║  0     Reset                ║          │
  409. │            ╚═════════════════════════════╝                 │
  410. │                                  │
  411. │              8041 output port(P2) definition:          │
  412. │            ╔═════════════════════════════╗                 │
  413. │            ║ Bit       General Definition   ║          │
  414. │            ║                               ║          │
  415. │            ║  7        KB data              ║          │
  416. │            ║  6     KB clock*            ║          │
  417. │            ║  5     Reserved             ║          │
  418. │            ║  4     IRQ 1                ║          │
  419. │            ║  3     Reserved             ║          │
  420. │            ║  2     Reserved             ║          │
  421. │            ║  1     Gate A20             ║          │
  422. │            ║  0     Reset                ║          │
  423. │            ╚═════════════════════════════╝                 │
  424. │          * indicate conjugate of that signal          │
  425. │                                  │
  426. │D2     write keyboard output buffer -                            │
  427. │    The next byte written to port 60h is written to output    │
  428. │    buffer as if initiated by KB.                             │
  429. │                                  │
  430. │D3     write auxiliary device output buffer -                    │
  431. │    The next byte written to port 60h is written to output    │
  432. │    buffer as if initiated by PD.                         │
  433. │                                  │
  434. │D4     write auxiliary device -                                  │
  435. │    The next byte written to port 60h is transmitted to PD.      │
  436. │                                  │
  437.  
  438. │#E0    read test inputs -                                        │
  439. │    Read T0 and T1, place in data bit 0 and 1 respectively,      │
  440. │    and place data byte in output buffer.              │
  441. │                                  │
  442. │#F0-FF pulse output port -                                       │
  443. │       Bit 0 - 3 of the 8042 output port(P2) may be pulsed low   │
  444. │       for approximately 6 microseconds.                         │
  445. │       Bit 0 - 3 of this command indicate which bits are to be   │
  446. │       pulsed. A 0 indicates that the bit should be pulsed, a 1  │
  447. │    indicates that the bit should not be modified.          │
  448. └─────────────────────────────────────────────────────────────────┘
  449.  
  450.  
  451.  
  452.  
  453.                        TIMING OF TRANSMITTING
  454.  
  455. NOTE : The clock is provided by KB.
  456.  
  457.         The KB controller shall communicate with the AT KB using 
  458.         synchronous serial protocol. The following figure shows the 
  459.         function of each bit and timing.
  460.  
  461.                  bit 10 -- stop (high)
  462.                  bit  9 -- parity (odd)
  463.                  bit  8 -- data bit7 (MSB)                 
  464.                  bit  7 -- data bit6 
  465.                  bit  6 -- data bit5
  466.                  bit  5 -- data bit4
  467.                  bit  4 -- data bit3
  468.                  bit  3 -- data bit2
  469.                  bit  2 -- data bit1
  470.                  bit  1 -- data bit0 (LSB)
  471.                  bit  0 -- start (low)
  472.  
  473.                 Figure 1-1 : function of each bit
  474.  
  475.  
  476.          (code ED)    
  477.                  ┌───┐   ┌───────┐   ┌─────────────────┐   ┌──────── 
  478.     data ────────┘   └───┘       └───┘                 └───┘
  479.             ┌───┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─────────
  480.     clock───┘   └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ └─┘
  481.              start  0   1   2   3   4   5   6   7 parity stop     
  482.  
  483.                 Figure 1-2 : Sending data to AT KB timing
  484.  
  485.       . If the AT KB does not start clocking the data out of KB controller 
  486.         within 15 milliseconds or complect that clocking within 2 
  487.         milliseconds, the resend code(0feh) will be sent to system, and sets 
  488.         the transmit time-out bit in status byte. 
  489.       . The AT KB is resquired to response for all transmission data.
  490.         If the AT KB doesn't complete to response data within 25 milli-
  491.         seconds, place hexFE in KB controller's output buffer, and sets
  492.         the transmit time-out and receive time-out bits of status byte. 
  493.       . When the KB controller received the response data from the AT KB, 
  494.         and found the KB parrity error,a hexFE is placed in KB controller's 
  495.         output buffer, and parity error and transmit time-out bits of 
  496.         status byte will be set. 
  497.          
  498.  
  499.  
  500. The follwings are steps and notes of KB controller sending data to KB.
  501.  
  502.       . Set KB data and clock inactive, when KB controller start to 
  503.         communicate with AT KB.
  504.       . Set KB clock active, then wait KB pull clock low within 15 ms.
  505.       . Send data to KB from LSB to MSB synchronously during inactive 
  506.         period of clock(data bit 0 to data bit 7). Each bit(data bit 0 to
  507.         data bit 7, parity bit and stop bit) must be complete sending 
  508.         within 0.3 ms. Else timer overflow.
  509.       . Send parity bit with respect to ODD parity.
  510.       . Pull KB data active, wait KB data transfer from low to high,
  511.         then STOP CTNT, this end the transmission process.  
  512.                              
  513.  
  514. NOTE :
  515.         (1) For 8742, all the transmit time-out or receive time-out in 8741
  516.             must be replaced by timeout error. 
  517.         (2) For 8742, the KB timing protocal is the same as 8741 KB.
  518.         (3) For 8742, the auxiliary device timing protocal is similar to
  519.             8742 KB protocal.
  520.          
  521.  
  522.  
  523.  
  524.                        TIMING OF RECEIVING
  525.  
  526.         The following figure are AT keyboared synchronous serial 
  527.         protocol.  
  528.  
  529.          (code AA)
  530.          ──┐       ┌───┐   ┌───┐   ┌───┐   ┌────────────────────────                      
  531.     data   └───────┘   └───┘   └───┘   └───┘     
  532.          ───┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐         ┌─────
  533.     clock   └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ └─────────┘
  534.          start  0   1   2   3   4   5   6   7 parity stop
  535.       
  536.              Figure 1-3 : AT keyboard timing  
  537.  
  538.       . KB controller shall pull KB clock and data high when there is no
  539.         data in DBBIN and DBBOUT and KB interface is enabled.
  540.       . If KB controller cannot complect receiving KB data within 2
  541.         millisecond, a hexFF is placed in the DBBOUT, and set receive
  542.         time-out bit of status byte.           
  543.  
  544.       . If KB controller check the AT KB parity error occurs, then send        
  545.         a hexFE to KB, and wait for KB respond within 25 ms.
  546.       . If the AT KB cannot complect response within 25 millisecond,
  547.         a hexFE is placed in the DBBOUT, and set receive and transmit 
  548.         time-out bits of status byte. 
  549.       . If parity error occurs again, a hexFE is placed in the DBBOUT,
  550.         and set parity error, receive time-out bits of status byte.
  551.  
  552.  
  553. The follwings are steps and notes of KB controller receiving data from KB.
  554.         
  555.       . Wait for KB clock change from high to low, then check if data 
  556.         is low; if it is, then continue, else ignore this noise.
  557.       . Wait KB clock active, then receive the data bit 0 at the first
  558.         falling edge of clock.
  559.       . Receive data bit 1 to data bit 7 and parity bit at falling edge 
  560.         of the successive clock.
  561.       . Check if there is parity error, if parity error, then set parity 
  562.         error flag.
  563.       . If parity OK, then wait for falling edge of stop bit and
  564.         STOP CTNT.
  565.       . Inhibit KB(pull KB clock low), send data from KB to system.
  566.  
  567. NOTE : The data from AT KB belong to scan code set 2 format, 
  568.        KB controller must translate it to scan code set 1 accoring 
  569.        to command byte bit 6.  
  570.        Example: receive 0eh  (make code)  -> send 29h to system 
  571.                        0f0h ┐
  572.                         0eh ┘(break code) ->      0a9h
  573.                 └───────────────────────┘         └──┘
  574.                     scan code set 2          scan code set 1
  575.  
  576.                  RECEIVE XT KEYBOARD DATA
  577.  
  578.         The following figure are XT KB synchronous serial 
  579.         protocol.  
  580.  
  581.                 bit  8 -- data bit7 (MSB)         
  582.                 bit  7 -- data bit6 
  583.                 bit  6 -- data bit5
  584.                 bit  5 -- data bit4
  585.                 bit  4 -- data bit3
  586.                 bit  3 -- data bit2
  587.                 bit  2 -- data bit1
  588.                 bit  1 -- data bit0 (LSB)
  589.                 bit  0 -- start (high)
  590.  
  591.                Figure 1-4 : function of each bit
  592.  
  593.          (code 15)     
  594.              ┌──────────┐    ┌────┐    ┌────┐   
  595.     data ────┘          └────┘    └────┘    └──────────────────      
  596.          ───┐  ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐ ┌──┐┌───
  597.     clock   └──┘  └─┘  └─┘  └─┘  └─┘  └─┘  └─┘  └─┘  └─┘  └┘
  598.               start 0    1    2    3    4    5    6    7 
  599.  
  600.              Figure 1-5 : XT keyboard timing  
  601.               
  602. The follwing are steps and notes of KB controller receiving data from XT KB.
  603.         
  604.       . Receive XT KB data within 15 ms.
  605.       . If timer overflow, then place hexFF in DBBOUT, and set receive
  606.         time-out of status byte.
  607.         
  608.       . Wait KB clock inactive, then check if KB data is active.
  609.         If it is inactive, then ignore this noise, else continue.
  610.       . Receive start bit at the first rising edge of KB clock.
  611.       . Receive data bit 0 to data bit 7 at rising edge of the 
  612.         successive clock.
  613.       . Inhibit KB(pull KB data low), send data from KB to system.
  614.  
  615. NOTE : 
  616.         (1) The data from XT KB belong to scan code set 1.
  617.         (2) The reset KB command must pull KB clock low at least 12.5 ms,
  618.             then pull KB clock high.
  619.         (3) The KB controller places a hexEE in DBBOUT if system issues
  620.             an echo(eeh) command to KB.
  621.         (4) KB controller places a hexFA in DBBOUT for all the command 
  622.             to KB except RESET and ECHO.
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.