|
| #define | PS2_WAIT_TIMEOUT (CLOCKS_PER_SEC / 2) |
| | Wait timeout for PS/2 controller.
|
| |
| #define | PS2_SMALL_DELAY (CLOCKS_PER_SEC / 100) |
| | Small delay for various operations.
|
| |
| #define | PS2_LARGE_DELAY (CLOCKS_PER_SEC / 5) |
| | Large delay for various operations.
|
| |
| #define | PS2_COMMAND_RETRIES 3 |
| | Number of retries for commands.
|
| |
| #define | PS2_READ(data) |
| | Read data from PS/2 controller.
|
| |
| #define | PS2_WRITE(data) |
| | Write data to PS/2 controller.
|
| |
| #define | PS2_CMD(command) |
| | Send a command to the PS/2 controller without reading response.
|
| |
| #define | PS2_CMD_AND_READ(command, data) |
| | Send a command to the PS/2 controller and read response.
|
| |
| #define | PS2_CMD_AND_WRITE(command, data) |
| | Send a command to the PS/2 controller and write data.
|
| |
| #define | PS2_DEV_CMD(device, command) |
| | Send a command to a PS/2 device without reading response.
|
| |
| #define | PS2_DEV_CMD_AND_READ(device, command, data) |
| | Send a command to a PS/2 device and read response.
|
| |
| #define | PS2_DEV_SUB_CMD(device, command, subCommand) |
| | Send a command and a subcommand to a PS/2 device.
|
| |
| #define | PS2_WAIT_TIMEOUT (CLOCKS_PER_SEC / 2) |
| | Wait timeout for PS/2 controller.
|
| |
| #define | PS2_SMALL_DELAY (CLOCKS_PER_SEC / 100) |
| | Small delay for various operations.
|
| |
| #define | PS2_LARGE_DELAY (CLOCKS_PER_SEC / 5) |
| | Large delay for various operations.
|
| |
| #define | PS2_COMMAND_RETRIES 3 |
| | Number of retries for commands.
|
| |
| #define | PS2_READ(data) |
| | Read data from PS/2 controller.
|
| |
| #define | PS2_WRITE(data) |
| | Write data to PS/2 controller.
|
| |
| #define | PS2_CMD(command) |
| | Send a command to the PS/2 controller without reading response.
|
| |
| #define | PS2_CMD_AND_READ(command, data) |
| | Send a command to the PS/2 controller and read response.
|
| |
| #define | PS2_CMD_AND_WRITE(command, data) |
| | Send a command to the PS/2 controller and write data.
|
| |
| #define | PS2_DEV_CMD(device, command) |
| | Send a command to a PS/2 device without reading response.
|
| |
| #define | PS2_DEV_CMD_AND_READ(device, command, data) |
| | Send a command to a PS/2 device and read response.
|
| |
| #define | PS2_DEV_SUB_CMD(device, command, subCommand) |
| | Send a command and a subcommand to a PS/2 device.
|
| |
|
| enum | ps2_port_t {
PS2_PORT_DATA = 0x60
,
PS2_PORT_STATUS = 0x64
,
PS2_PORT_CMD = 0x64
} |
| | PS/2 controller I/O ports. More...
|
| |
| 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_UNKNOWN
,
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...
|
| |
| enum | ps2_port_t {
PS2_PORT_DATA = 0x60
,
PS2_PORT_STATUS = 0x64
,
PS2_PORT_CMD = 0x64
} |
| | PS/2 controller I/O ports. More...
|
| |
| 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_UNKNOWN
,
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...
|
| |
IBM Personal Computer/2 ports.
Patchwork attempts to implement a comprehensive PS/2 driver, even if certain details would be completely irrelevant on modern hardware. For example, most implementations assume that the first PS2 device is always a keyboard and the second a mouse, however this is, as far as I'm aware, just a very commonly agreed convention and not actually specified anywhere, even if all modern hardware appears to follow this convention, they technically don't have to.
The reason for this is because PS/2 appears to be frequently neglected in hobby projects, so I wish to create a publically available and easy to understand "proper" implementation. Even if its overkill and of course becouse its fun.
Note that in the future once proper device detection is implemented, this will need to be redone.