PS/2
This page or section is a stub. You can help the wiki by accurately contributing to it. |
PS/2 is a type of serial communication, typically used for user input devices (keyboard, mouse, bar code scanner, etc). It involves a controller (e.g. "8042 chip" on PC compatible systems), the mechanical and electrical details of the communication itself, and a device.
History
Originally (1981) IBM used a different type of serial communication for XT keyboards. The older interface was not bi-directional - the device could talk to the controller, but the controller couldn't talk to the device.
Later (1984) IBM replaced the older serial interface with a newer bi-directional interface for AT keyboards. This allowed the host to send commands to the device.
Later still (1987) IBM extended the "AT" standard to create the "PS/2" standard. The PS/2 standard is electrically identical to the older AT standard (it only uses a different plug/connector).
Eventually the PS/2 was superseded by USB, however it is still fairly common (and for compatibility, some system have emulation layers that make USB devices appear as PS/2 devices).
Protocol
A diagram of the PS2 connector is below.
The serial communication typically runs at a baud rate of 10 KHz to 16.7 KHz. Each byte sent by a device to a controller is transmitted as a packet containing 11 bits. The "device to host" packet has the following bits:
- 1 start bit (always 0)
- 8 data bits (least significant bit first)
- 1 parity bit (odd parity)
- 1 stop bit (always 1)
Each byte sent by a controller to a device is transmitted as a packet containing 12 bits. The "host to device" packet has the following bits:
- 1 start bit (always 0)
- 8 data bits (least significant bit first)
- 1 parity bit (odd parity)
- 1 stop bit (always 1)
- 1 acknowledgement bit
Driver Model
There are various types of PS/2 port controllers; including "bit banging" general purpose IO, special support built into the system's chipset and add-on PCI cards. There are also various types of PS/2 devices (keyboard, mouse, touch-pad, bar code scanner, magnetic card/stripe reader, fingerprint reader, etc).
Obviously you don't want to duplicate the code for every type of PS/2 device within each different PS/2 controller driver. You want to separate them, so that any driver for a PS/2 device can talk to any PS/2 controller driver (and so that the PS/2 device's code can be ported to different architectures without any changes). This is relatively simple to do - PS/2 controller drivers only need to be able to send and receive bytes (there's no baud rate control or anything) and a simple "byte stream" approach suffices.