IBM Personal Computer/2 ports.
More...
IBM Personal Computer/2 ports.
- See also
- https://wiki.osdev.org/I8042_PS/2_Controller
-
https://www-ug.eecg.toronto.edu/msl/nios_devices/datasheets/PS2%20Keyboard%20Protocol.htm
|
| enum | ps2_cmd_t {
PS2_CMD_CFG_READ = 0x20
, PS2_CMD_CFG_WRITE = 0x60
, PS2_CMD_SECOND_DISABLE = 0xA7
, PS2_CMD_SECOND_ENABLE = 0xA8
,
PS2_CMD_FIRST_DISABLE = 0xAD
, PS2_CMD_FIRST_ENABLE = 0xAE
, PS2_CMD_SECOND_TEST = 0xA9
, PS2_CMD_SELF_TEST = 0xAA
,
PS2_CMD_FIRST_TEST = 0xAB
, PS2_CMD_DUMP = 0xAC
, PS2_CMD_SECOND_WRITE = 0xD4
} |
| | PS/2 controller commands. More...
|
| |
| enum | ps2_status_bits_t {
PS2_STATUS_OUT_FULL = (1 << 0)
, PS2_STATUS_IN_FULL = (1 << 1)
, PS2_STATUS_SYSTEM_FLAG = (1 << 2)
, PS2_STATUS_CMD_DATA = (1 << 3)
,
PS2_STATUS_TIMEOUT_ERROR = (1 << 6)
, PS2_STATUS_PARITY_ERROR = (1 << 7)
} |
| | PS/2 controller status register bits. More...
|
| |
| enum | ps2_config_bits_t {
PS2_CFG_FIRST_IRQ = (1 << 0)
, PS2_CFG_SECOND_IRQ = (1 << 1)
, PS2_CFG_SYSTEM_FLAG = (1 << 2)
, PS2_CFG_RESERVED_3 = (1 << 3)
,
PS2_CFG_FIRST_CLOCK_DISABLE = (1 << 4)
, PS2_CFG_SECOND_CLOCK_DISABLE = (1 << 5)
, PS2_CFG_FIRST_TRANSLATION = (1 << 6)
, PS2_CFG_RESERVED_7 = (1 << 7)
} |
| | PS/2 controller configuration bits. More...
|
| |
| enum | ps2_device_cmd_t {
PS2_DEV_CMD_ECHO = 0xEE
, PS2_DEV_CMD_SET_LEDS = 0xED
, PS2_DEV_CMD_SET_SCANCODE_SET = 0xF0
, PS2_DEV_CMD_IDENTIFY = 0xF2
,
PS2_DEV_CMD_SET_TYPEMATIC = 0xF3
, PS2_DEV_CMD_ENABLE_SCANNING = 0xF4
, PS2_DEV_CMD_DISABLE_SCANNING = 0xF5
, PS2_DEV_CMD_SET_DEFAULTS = 0xF6
,
PS2_DEV_CMD_RESEND = 0xFE
, PS2_DEV_CMD_RESET = 0xFF
} |
| | PS/2 device commands. More...
|
| |
| enum | ps2_device_t { PS2_DEV_NONE = -1
, PS2_DEV_FIRST = 0
, PS2_DEV_SECOND = 1
, PS2_DEV_COUNT = 2
} |
| | PS/2 device identifiers. More...
|
| |
| enum | ps2_device_type_t {
PS2_DEV_TYPE_NONE
, PS2_DEV_TYPE_KEYBOARD
, PS2_DEV_TYPE_MOUSE_STANDARD
, PS2_DEV_TYPE_MOUSE_SCROLL
,
PS2_DEV_TYPE_MOUSE_5BUTTON
} |
| | PS/2 device types. More...
|
| |
| enum | ps2_self_test_response_t { PS2_SELF_TEST_PASS = 0x55
, PS2_SELF_TEST_FAIL = 0xFC
} |
| | PS/2 controller self-test responses. More...
|
| |
| enum | ps2_device_test_response_t {
PS2_DEV_TEST_PASS = 0x00
, PS2_DEV_TEST_CLOCK_STUCK_LOW = 0x01
, PS2_DEV_TEST_CLOCK_STUCK_HIGH = 0x02
, PS2_DEV_TEST_DATA_STUCK_LOW = 0x03
,
PS2_DEV_TEST_DATA_STUCK_HIGH = 0x04
} |
| | PS/2 device test responses. More...
|
| |
| enum | ps2_device_response_t {
PS2_DEV_RESPONSE_ACK = 0xFA
, PS2_DEV_RESPONSE_RESEND = 0xFE
, PS2_DEV_RESPONSE_BAT_OK = 0xAA
, PS2_DEV_RESPONSE_KBD_EXTENDED = 0xE0
,
PS2_DEV_RESPONSE_KBD_RELEASE = 0xF0
} |
| | PS/2 device command responses. More...
|
| |
◆ PS2_WAIT_TIMEOUT
Wait timeout for PS/2 controller.
Definition at line 22 of file ps2.h.
◆ PS2_SMALL_DELAY
Small delay for various operations.
Definition at line 27 of file ps2.h.
◆ PS2_LARGE_DELAY
Large delay for various operations.
Definition at line 32 of file ps2.h.
◆ PS2_COMMAND_RETRIES
| #define PS2_COMMAND_RETRIES 10 |
Number of retries for commands.
Definition at line 37 of file ps2.h.
◆ PS2_KEYBOARD_PNP_IDS
| #define PS2_KEYBOARD_PNP_IDS |
◆ PS2_MOUSE_PNP_IDS
| #define PS2_MOUSE_PNP_IDS |
Value: "PNP0F00;PNP0F01;PNP0F02;PNP0F03;PNP0F04;PNP0F05;PNP0F06;PNP0F07;PNP0F08;PNP0F09;PNP0F0A;PNP0F0B;PNP0F0C;PNP0F0D;" \
"PNP0F0E;PNP0F0F;PNP0F10;PNP0F11;PNP0F12;PNP0F13;PNP0F14;PNP0F15;PNP0F16;PNP0F17;PNP0F18;PNP0F19;PNP0F1A;PNP0F1B;" \
"PNP0F1C;PNP0F1D;PNP0F1E;PNP0F1F;PNP0F20;PNP0F21;PNP0F22;PNP0F23;PNP0FFC;PNP0FFF"
All known PS/2 mouse PNP IDs.
- See also
- https://uefi.org/sites/default/files/resources/devids%20%285%29.txt
Definition at line 53 of file ps2.h.
◆ ps2_cmd_t
PS/2 controller commands.
| Enumerator |
|---|
| PS2_CMD_CFG_READ | |
| PS2_CMD_CFG_WRITE | |
| PS2_CMD_SECOND_DISABLE | |
| PS2_CMD_SECOND_ENABLE | |
| PS2_CMD_FIRST_DISABLE | |
| PS2_CMD_FIRST_ENABLE | |
| PS2_CMD_SECOND_TEST | |
| PS2_CMD_SELF_TEST | |
| PS2_CMD_FIRST_TEST | |
| PS2_CMD_DUMP | |
| PS2_CMD_SECOND_WRITE | |
Definition at line 62 of file ps2.h.
◆ ps2_status_bits_t
PS/2 controller status register bits.
| Enumerator |
|---|
| PS2_STATUS_OUT_FULL | Output buffer status (0 = empty, 1 = full)
|
| PS2_STATUS_IN_FULL | Input buffer status (0 = empty, 1 = full)
|
| PS2_STATUS_SYSTEM_FLAG | |
| PS2_STATUS_CMD_DATA | Command(1) or Data(0)
|
| PS2_STATUS_TIMEOUT_ERROR | |
| PS2_STATUS_PARITY_ERROR | |
Definition at line 81 of file ps2.h.
◆ ps2_config_bits_t
PS/2 controller configuration bits.
| Enumerator |
|---|
| PS2_CFG_FIRST_IRQ | First PS/2 port interrupt enable.
|
| PS2_CFG_SECOND_IRQ | Second PS/2 port interrupt enable.
|
| PS2_CFG_SYSTEM_FLAG | System flag (POST passed)
|
| PS2_CFG_RESERVED_3 | Should be zero.
|
| PS2_CFG_FIRST_CLOCK_DISABLE | First PS/2 port clock disable.
|
| PS2_CFG_SECOND_CLOCK_DISABLE | Second PS/2 port clock disable.
|
| PS2_CFG_FIRST_TRANSLATION | First PS/2 port translation enable.
|
| PS2_CFG_RESERVED_7 | Should be zero.
|
Definition at line 96 of file ps2.h.
◆ ps2_device_cmd_t
PS/2 device commands.
| Enumerator |
|---|
| PS2_DEV_CMD_ECHO | |
| PS2_DEV_CMD_SET_LEDS | |
| PS2_DEV_CMD_SET_SCANCODE_SET | |
| PS2_DEV_CMD_IDENTIFY | |
| PS2_DEV_CMD_SET_TYPEMATIC | |
| PS2_DEV_CMD_ENABLE_SCANNING | |
| PS2_DEV_CMD_DISABLE_SCANNING | |
| PS2_DEV_CMD_SET_DEFAULTS | |
| PS2_DEV_CMD_RESEND | |
| PS2_DEV_CMD_RESET | |
Definition at line 112 of file ps2.h.
◆ ps2_device_t
PS/2 device identifiers.
| Enumerator |
|---|
| PS2_DEV_NONE | |
| PS2_DEV_FIRST | |
| PS2_DEV_SECOND | |
| PS2_DEV_COUNT | |
Definition at line 130 of file ps2.h.
◆ ps2_device_type_t
PS/2 device types.
| Enumerator |
|---|
| PS2_DEV_TYPE_NONE | |
| PS2_DEV_TYPE_KEYBOARD | |
| PS2_DEV_TYPE_MOUSE_STANDARD | |
| PS2_DEV_TYPE_MOUSE_SCROLL | |
| PS2_DEV_TYPE_MOUSE_5BUTTON | |
Definition at line 142 of file ps2.h.
◆ ps2_self_test_response_t
PS/2 controller self-test responses.
| Enumerator |
|---|
| PS2_SELF_TEST_PASS | |
| PS2_SELF_TEST_FAIL | |
Definition at line 155 of file ps2.h.
◆ ps2_device_test_response_t
PS/2 device test responses.
| Enumerator |
|---|
| PS2_DEV_TEST_PASS | |
| PS2_DEV_TEST_CLOCK_STUCK_LOW | |
| PS2_DEV_TEST_CLOCK_STUCK_HIGH | |
| PS2_DEV_TEST_DATA_STUCK_LOW | |
| PS2_DEV_TEST_DATA_STUCK_HIGH | |
Definition at line 165 of file ps2.h.
◆ ps2_device_response_t
PS/2 device command responses.
| Enumerator |
|---|
| PS2_DEV_RESPONSE_ACK | |
| PS2_DEV_RESPONSE_RESEND | |
| PS2_DEV_RESPONSE_BAT_OK | |
| PS2_DEV_RESPONSE_KBD_EXTENDED | Indicates that the following byte is an extended scancode.
|
| PS2_DEV_RESPONSE_KBD_RELEASE | Indicates that the following byte is a key release code.
|
Definition at line 178 of file ps2.h.
◆ ps2_drain()
Drain the PS/2 output buffer.
Reads and discards any data in the PS/2 output buffer.
Definition at line 325 of file ps2.c.
◆ ps2_wait_until_set()
Wait until status bit(s) are set.
- Parameters
-
| status | Status bit(s) to wait for. |
- Returns
- On success,
0. On timeout, ERR.
Definition at line 335 of file ps2.c.
◆ ps2_wait_until_clear()
Wait until status bit(s) are clear.
- Parameters
-
| status | Status bit(s) to wait for. |
- Returns
- On success,
0. On timeout, ERR.
Definition at line 350 of file ps2.c.
◆ ps2_read()
Read from the PS/2 controllers data port.
Waits for the output buffer to be full, then reads a byte from the data port.
- Returns
- On success, the response byte. On failure,
ERR and errno is set to:
ETIMEOUT: Timeout occurred while waiting for data.
Definition at line 365 of file ps2.c.
◆ ps2_read_no_wait()
Read from the PS/2 controllers data port without waiting.
- Returns
- On success, the response byte. On failure,
ERR and errno is set to:
EAGAIN: No data available to read.
Definition at line 375 of file ps2.c.
◆ ps2_write()
Write to the PS/2 controllers data port.
Waits for the input buffer to be empty, then writes a byte to the data port.
- Parameters
-
- Returns
- On success,
0. On failure, ERR and errno is set to:
ETIMEOUT: Timeout occurred while waiting to write.
Definition at line 386 of file ps2.c.
◆ ps2_cmd()
Send a command to the PS/2 controller without reading response.
- Parameters
-
- Returns
- On success,
0. On failure, ERR and errno is set to:
ETIMEOUT: Timeout occurred while waiting to send command.
Definition at line 397 of file ps2.c.
◆ ps2_cmd_and_read()
Send a command to the PS/2 controller and read response.
- Parameters
-
- Returns
- On success, the response byte. On failure,
ERR and errno is set to:
ETIMEOUT: Timeout occurred while waiting to send command or read data.
Definition at line 408 of file ps2.c.
◆ ps2_cmd_and_write()
Send a command to the PS/2 controller and write data.
- Parameters
-
| command | Command to send. |
| data | Data to write. |
- Returns
- On success,
0. On failure, ERR and errno is set to:
ETIMEOUT: Timeout occurred while waiting to send command or write data.
Definition at line 417 of file ps2.c.
◆ ps2_device_cmd()
Send a command to a PS/2 device without reading response.
- Parameters
-
| device | Device to send command to. |
| command | Command to send. |
- Returns
- On success,
0. On failure, ERR and errno is set to:
ETIMEOUT: Timeout occurred while waiting to send command.
Definition at line 488 of file ps2.c.
◆ ps2_device_cmd_and_read()
Send a command to a PS/2 device and read response.
- Parameters
-
| device | Device to send command to, specified by its port. |
| command | Command to send. |
- Returns
- On success,
0. On failure, ERR and errno is set to:
ETIMEOUT: Timeout occurred while waiting to send command or read data.
Definition at line 530 of file ps2.c.
◆ ps2_device_sub_cmd()
Send a command and a subcommand to a PS/2 device.
- Parameters
-
| device | Device to send command to, specified by its port. |
| command | Command to send. |
| subCommand | Subcommand to send. |
- Returns
- On success,
0. On failure, ERR and errno is set to:
ETIMEOUT: Timeout occurred while waiting to send command or subcommand.
Definition at line 539 of file ps2.c.