"8042" PS/2 Controller: Difference between revisions

[unchecked revision][unchecked revision]
Content deleted Content added
m Polling works fine in QEMU
m Bot: Replace deprecated source tag with syntaxhighlight
 
(8 intermediate revisions by 7 users not shown)
Line 1:
The PS/2 Controller (often called a “Keyboard controller”) is located on the mainboard. In the early days the controller was a single chip ('''Intel 8042'''). As of today it is part of the [[Advanced Integrated Peripheral]].
== Overview ==
 
The PS/2 Controller (often called a “Keyboard controller”) is located on the mainboard. In the early days the controller was a single chip (8042). As of today it is part of the [[Advanced Integrated Peripheral]].
 
The name is misleading because the controller does more than controlling communication with PS/2 devices.
Line 384 ⟶ 382:
* Wait for the device to send "ACK" back (0xFA)
* Wait for the device to send up to 2 bytes of reply, with a time-out to determine when it's finished (e.g. in case it only sends 1 byte)
* Send the "enable scanning" command 0xF4 to the device
 
A partial list of responses includes:
Line 389 ⟶ 388:
{| {{wikitable}}
|-
! Bytes (Normal)
! Byte/s
! Bytes (Translated*)
! Device Type
|-
| None
| None
| Ancient AT keyboard with translation enabled in the PS/Controller (not possible for the second PS/2 port)
| MF2Ancient AT keyboard
|-
| 0x00
| n/a
| Standard PS/2 mouse
|-
| 0x03
| n/a
| Mouse with scroll wheel
|-
| 0x04
| n/a
| 5-button mouse
|-
| 0xAB, 0x41 or 0xAB, 0xC1
| MF2 keyboard with translation enabled in the PS/Controller (not possible for the second PS/2 port)
|-
| 0xAB, 0x83
| 0xAB, 0x41 or 0xAB, 0xC1
| MF2 keyboard
| rowspan="2" | MF2 keybaord
|-
| 0xAB, 0xC1
| 0xAB, 0xC1
|-
| 0xAB, 0x84
| 0xAB, 0x54
| IBM ThinkPads, Spacesaver keyboards, many other "short" keyboards
|-
| rowspan="2" | 0xAB, 0x85
| rowspan="2" | 0xAB, 0x85
| NCD N-97 keyboard
|-
| 122-Key Host Connect(ed) Keyboard
|-
| 0xAB, 0x86
| 0xAB, 0x86
| 122-key keyboards
|-
| 0xAB, 0x90
| 0xAB, 0x90
| Japanese "G" keyboards
|-
| 0xAB, 0x91
| 0xAB, 0x91
| Japanese "P" keyboards
|-
| 0xAB, 0x92
| 0xAB, 0x92
| Japanese "A" keyboards
|-
| 0xAC, 0xA1
| 0xAC, 0xA1
| NCD Sun layout keyboard
|}
 
<nowiki>*</nowiki> Translation is not possible for the second PS/2 port
Note: If anyone sees any other responses please add to the list above!
 
Notes:
Once your PS/2 Controller driver knows what types of PS/2 devices are present, it can start suitable device drivers for those devices. Don't forget that we've left devices in a "scanning disabled" state.
Note:* If anyone sees any other responses please add to the list above!
* Translated IDs are provided in the table above for completeness, but it's arguably better to disable translation in the controller prior to pulling a device ID to avoid potential confusion.
 
Once your PS/2 Controller driver knows what types of PS/2 devices are present, it can start suitable device drivers for those devices. Don't forget that we've left devices in a "scanning disabled" state.
 
== Hot Plug PS/2 Devices ==
Line 475 ⟶ 513:
== CPU Reset ==
To trigger a CPU Reset, regardless of what state the CPU is in, write the value 0xFE to the Output port.
<sourcesyntaxhighlight lang="asm">
;Wait for a empty Input Buffer
wait1:
Line 485 ⟶ 523:
mov al, 0xFE
out 0x64, al
</syntaxhighlight>
</source>
 
==See Also==
Line 495 ⟶ 533:
*[[Post:69151|PS/2 controller initialisation]]
===External Links===
* [http://web.archive.org/web/20210417040153/http://www.diakom.ru/el/elfirms/datashts/Smsc/42w11.pdf SMS "8042" Datasheet]
 
[[Category:X86]]