"8042" PS/2 Controller: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content deleted Content added
m A little more "translation" info |
Added command bytes |
||
Line 48: | Line 48: | ||
== PS/2 Controller Commands == |
== PS/2 Controller Commands == |
||
The PS/2 Controller accepts some commands and performs them. These commands should not be confused with bytes sent to a PS/2 device (e.g. keyboard, mouse). |
|||
'''TODO''' Note: this is ''Controller'' commands and NOT ''Device'' commands |
|||
To send a command to the controller, write the command byte to IO port 0x64. If there is a "next byte" (the command is 2 bytes) then the next byte needs to be written to IO Port 0x60. If there is a response byte, then the response byte needs to be read from IO Port 0x60. |
|||
{| {{wikitable}} |
|||
|- |
|||
! Command Byte |
|||
! Meaning |
|||
! Response Byte |
|||
|- |
|||
|0x20 |
|||
|Read "byte 0" from internal RAM |
|||
|Controller Configuration Byte (see below) |
|||
|- |
|||
|0x21 to 0x3F |
|||
|Read "byte N" from internal RAM (where 'N' is the command byte & 0x1F) |
|||
|Unknown (only the first byte of internal RAM has a standard purpose) |
|||
|- |
|||
|0x60 |
|||
|Write next byte to "byte 0" of internal RAM (Controller Configuration Byte, see below) |
|||
|None |
|||
|- |
|||
|0x61 to 0x7F |
|||
|Write next byte to "byte N" of internal RAM (where 'N' is the command byte & 0x1F) |
|||
|None |
|||
|- |
|||
|0xA7 |
|||
|Disable second PS/2 port (only if 2 PS/2 ports supported) |
|||
|None |
|||
|- |
|||
|0xA8 |
|||
|Enable second PS/2 port (only if 2 PS/2 ports supported) |
|||
|None |
|||
|- |
|||
|0xA9 |
|||
|Test second PS/2 port (only if 2 PS/2 ports supported) |
|||
|0x00 test passed |
|||
0x01 clock line stuck low |
|||
0x02 clock line stuck high |
|||
0x03 data line stuck low |
|||
0x04 data line stuck high |
|||
|- |
|||
|0xAA |
|||
|Test PS/2 Controller |
|||
|0x55 test passed |
|||
0xFC test failed |
|||
|- |
|||
|0xAB |
|||
|Test first PS/2 port |
|||
|0x00 test passed |
|||
0x01 clock line stuck low |
|||
0x02 clock line stuck high |
|||
0x03 data line stuck low |
|||
0x04 data line stuck high |
|||
|- |
|||
|0xAC |
|||
|Diagnostic dump (real all bytes of internal RAM) |
|||
|Unknown |
|||
|- |
|||
|0xAD |
|||
|Disable first PS/2 port |
|||
|None |
|||
|- |
|||
|0xAE |
|||
|Enable first PS/2 port |
|||
|None |
|||
|- |
|||
|0xC0 |
|||
|Read controller input port |
|||
|Unknown (none of these bits have a standard/defined purpose) |
|||
|- |
|||
|0xC1 |
|||
|Copy bits 0 to 3 of input port to status bits 4 to 7 |
|||
|None |
|||
|- |
|||
|0xC2 |
|||
|Copy bits 4 to 6 of input port to status bits 4 to 7 |
|||
|None |
|||
|- |
|||
|0xD0 |
|||
|Read Controller Output Port |
|||
|Controller Output Port (see below) |
|||
|- |
|||
|0xD1 |
|||
|Write next byte to Controller Output Port (see below) |
|||
Note: Check if output buffer is empty first |
|||
|None |
|||
|- |
|||
|0xD2 |
|||
|Write next byte to first PS/2 port output buffer (only if 2 PS/2 ports supported) |
|||
(makes it look like the byte written was received from the first PS/2 port) |
|||
|None |
|||
|- |
|||
|0xD3 |
|||
|Write next byte to second PS/2 port output buffer (only if 2 PS/2 ports supported) |
|||
(makes it look like the byte written was received from the second PS/2 port) |
|||
|None |
|||
|- |
|||
|0xD4 |
|||
|Write next byte to second PS/2 port input buffer (only if 2 PS/2 ports supported) |
|||
(sends next byte to the second PS/2 port) |
|||
|None |
|||
|- |
|||
|0xF0 |
|||
|Pulse output line low for 6 ms. Bits 0 to 3 are used as a mask (0 = pulse line, 1 = don't pulse line) and correspond to 4 different output lines. |
|||
Note: Bit 0 corresponds to the "reset" line. The other output lines don't have a standard/defined purpose. |
|||
|None |
|||
|} |
|||
=== PS/2 Controller Configuration Byte === |
|||
Commands 0x20 and 0x60 let you read and write the PS/2 Controller Configuration Byte. This configuration byte has the following format: |
|||
{| {{wikitable}} |
|||
|- |
|||
! Bit |
|||
! Meaning |
|||
|- |
|||
| 0 |
|||
| First PS/2 port interrupt (1 = enabled, 0 = disabled) |
|||
|- |
|||
| 1 |
|||
| Second PS/2 port interrupt (1 = enabled, 0 = disabled, only if 2 PS/2 ports supported) |
|||
|- |
|||
| 2 |
|||
| Unknown |
|||
|- |
|||
| 3 |
|||
| Should be zero |
|||
|- |
|||
| 4 |
|||
| First PS/2 port clock (1 = disabled, 0 = enabled) |
|||
|- |
|||
| 5 |
|||
| Second PS/2 port clock (1 = disabled, 0 = enabled, only if 2 PS/2 ports supported) |
|||
|- |
|||
| 6 |
|||
| First PS/2 port translation (1 = enabled, 0 = disabled) |
|||
|- |
|||
| 7 |
|||
| Must be zero |
|||
|- |
|||
|} |
|||
=== PS/2 Controller Output Port === |
|||
Commands 0xD0 and 0xD1 let you read and write the PS/2 Controller Output Port. This output port has the following format: |
|||
{| {{wikitable}} |
|||
|- |
|||
! Bit |
|||
! Meaning |
|||
|- |
|||
| 0 |
|||
| System reset (output) |
|||
'''WARNING''' always set to '1'. You need to pulse the reset line (e.g. using command 0xFE), and setting this bit to '0' can lock the computer up ("reset forever"). |
|||
|- |
|||
| 1 |
|||
| A20 gate (output) |
|||
|- |
|||
| 2 |
|||
| Second PS/2 port clock (output, only if 2 PS/2 ports supported) |
|||
|- |
|||
| 3 |
|||
| Second PS/2 port data (output, only if 2 PS/2 ports supported) |
|||
|- |
|||
| 4 |
|||
| Output buffer full with byte from first PS/2 port (connected to IRQ1) |
|||
|- |
|||
| 5 |
|||
| Output buffer full with byte from second PS/2 port (connected to IRQ12, only if 2 PS/2 ports supported) |
|||
|- |
|||
| 6 |
|||
| First PS/2 port clock (output) |
|||
|- |
|||
| 7 |
|||
| First PS/2 port data (output) |
|||
|- |
|||
|} |
|||