KBC Ram

Keyboard Controller Internal RAM

The Intel 8042 keyboard controller which is directly accessible via ports 0x60 and 0x64 has a number of bytes of internal memory. Depending on the controller you can either access all bytes or just seven of them.

Type 1 controller All RAM locations
Type 2 controller 0x00 (command byte), 0x13, 0x14, 0x16, 0x17, 0x1D, 0x1F (kadc)

The most important byte, the command byte, is documented here.

0x00 The Command Byte

At location 0x00 in the controller's RAM is what is known as the command byte. This is not to be confused with commands sent to the device. Rather, the so-called command byte maintains internal flags for certain important controller functions. The bits have meanings as set out below.

Bit Meaning in ISA & EISA Systems Meaning in MCA & PS/2 Systems with a Type 1 Controller Meaning in MCA & PS/2 Systems with a Type 2 Controller
7 Unused, set to 0 (upc) As ISA As ISA
6 0 = do not convert scan codes (upc)
1 (normal) = convert scan codes to those used on a PC (upc)
As ISA Must be zero (upc) (see notes)
5 0 (normal) = check parity from keyboard and allow scan conversion (upc)
1 = ignore parity from keyboard and do not convert scan codes (upc)
Writing a 1 to this bit sets the original PC mode. In this mode the controller neither checks parity nor converts scan codes (atrm)
0 = enable mouse (upc)
1 = disable mouse by forcing the mouse clock line low (upc)
0 = enable mouse (upc)
1 = disable mouse by forcing the mouse clock line low (upc)
4 0 = enable keyboard (upc)
1 = disable keyboard by forcing the keyboard clock line low (upc)
As ISA As ISA
3 0 (normal) = don't override keyboard inhibit (upc)
1 = override keyboard inhibit ignoring the keyboard lockout switch (upc)
Unused, set to 0 (upc) Unused, set to 0 (upc)
2 0 = System flag status bit indicates reset by power on (upc)
1 = System flag status bit after successful controller self test (upc)
As ISA As ISA
1 Unused, set to 0 (upc) 0 = No interrupt on mouse input (upc)
1 = Raise IRQ12 on mouse input (upc)
0 = No interrupt on mouse input (upc)
1 = Raise IRQ12 on mouse input (upc)
0 0 = No interrupt on keyboard input (upc)
1 = Raise IRQ1 on keyboard input (upc)
As ISA As ISA

Notes

  • Bit 6 cannot be set to 1 on a Type 2 controller. On an MCA machine this can be used to detect the type of controller. (upc)
  • Writing bit 6 as a 1 (one) and reading it as a 0 (zero) indicates a Type 2 controller. (kadc)
  • Although a Type 2 controller cannot translate scan codes the keyboard can be instructed to supply a different scan code set. (upc)
  • To perform translation on a Type 2 controller instruct the keyboard with command 0xF0. (kadc)
  • For Type 1 controllers bit 6 should be set to 0 (zero) while asking the keyboard for its scan set. This prevents the controller from translating the bytes of the response. (kadc)

Sources

The sources for the information above are

  • (atrm) - IBM Technical Reference - Personal Computer/AT
  • (kadc) - IBM PS/2 Reference Manual: Keyboard and Auxiliary Device Controller
  • (upc) - The Undocumented PC, second edition - Frank van Gilluwe
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License