32#define PS2_WAIT_TIMEOUT (CLOCKS_PER_SEC / 2)
37#define PS2_SMALL_DELAY (CLOCKS_PER_SEC / 100)
42#define PS2_LARGE_DELAY (CLOCKS_PER_SEC / 5)
47#define PS2_COMMAND_RETRIES 3
198#define PS2_READ(data) \
200 uint64_t result = ps2_wait_until_set(PS2_STATUS_OUT_FULL); \
203 *(data) = port_inb(PS2_PORT_DATA); \
216#define PS2_WRITE(data) \
218 uint64_t result = ps2_wait_until_clear(PS2_STATUS_IN_FULL); \
221 port_outb(PS2_PORT_DATA, data); \
232#define PS2_CMD(command) \
234 uint64_t result = ps2_send_cmd(command); \
245#define PS2_CMD_AND_READ(command, data) \
247 uint64_t result = ps2_send_cmd(command); \
250 result = PS2_READ(data); \
262#define PS2_CMD_AND_WRITE(command, data) \
264 uint64_t result = ps2_send_cmd(command); \
267 result = PS2_WRITE(data); \
279#define PS2_DEV_CMD(device, command) \
281 uint64_t result = ps2_send_device_cmd(device, command); \
293#define PS2_DEV_CMD_AND_READ(device, command, data) \
295 uint64_t result = ps2_send_device_cmd(device, command); \
298 result = PS2_READ(data); \
311#define PS2_DEV_SUB_CMD(device, command, subCommand) \
313 uint64_t result = PS2_DEV_CMD(device, command); \
316 result = PS2_DEV_CMD(device, subCommand); \
ps2_device_t
PS/2 device identifiers.
ps2_status_bits_t
PS/2 controller status register bits.
ps2_device_test_response_t
PS/2 device test responses.
ps2_cmd_t
PS/2 controller commands.
ps2_config_bits_t
PS/2 controller configuration bits.
uint64_t ps2_wait_until_set(ps2_status_bits_t status)
Wait until status bit(s) is set.
uint64_t ps2_send_device_cmd(ps2_device_t device, ps2_device_cmd_t command)
Send a command to a PS/2 device.
ps2_self_test_response_t
PS/2 controller self-test responses.
ps2_device_type_t
PS/2 device types.
uint64_t ps2_send_cmd(ps2_cmd_t command)
Send a command to the PS/2 controller.
void ps2_drain(void)
Drain the PS/2 output buffer.
ps2_port_t
PS/2 controller I/O ports.
uint64_t ps2_wait_until_clear(ps2_status_bits_t status)
Wait until status bit(s) is clear.
ps2_device_cmd_t
PS/2 device commands.
ps2_device_response_t
PS/2 device command responses.
void ps2_init(void)
Initialize the PS/2 controller.
@ PS2_DEV_COUNT
Total number of ports.
@ PS2_DEV_SECOND
Second PS/2 port.
@ PS2_DEV_FIRST
First PS/2 port.
@ PS2_STATUS_TIMEOUT_ERROR
@ PS2_STATUS_PARITY_ERROR
@ PS2_STATUS_IN_FULL
Input buffer status (0 = empty, 1 = full)
@ PS2_STATUS_OUT_FULL
Output buffer status (0 = empty, 1 = full)
@ PS2_STATUS_CMD_DATA
Command(1) or Data(0)
@ PS2_DEV_TEST_DATA_STUCK_LOW
@ PS2_DEV_TEST_DATA_STUCK_HIGH
@ PS2_DEV_TEST_CLOCK_STUCK_HIGH
@ PS2_DEV_TEST_CLOCK_STUCK_LOW
@ PS2_CFG_SECOND_IRQ
Second PS/2 port interrupt enable.
@ PS2_CFG_FIRST_IRQ
First PS/2 port interrupt enable.
@ PS2_CFG_RESERVED_7
Should be zero.
@ PS2_CFG_SYSTEM_FLAG
System flag (POST passed)
@ PS2_CFG_RESERVED_3
Should be zero.
@ PS2_CFG_SECOND_CLOCK_DISABLE
Second PS/2 port clock disable.
@ PS2_CFG_FIRST_CLOCK_DISABLE
First PS/2 port clock disable.
@ PS2_CFG_FIRST_TRANSLATION
First PS/2 port translation enable.
@ PS2_DEV_TYPE_MOUSE_5BUTTON
@ PS2_DEV_TYPE_MOUSE_STANDARD
@ PS2_DEV_TYPE_MOUSE_SCROLL
@ PS2_DEV_CMD_SET_DEFAULTS
@ PS2_DEV_CMD_DISABLE_SCANNING
@ PS2_DEV_CMD_SET_TYPEMATIC
@ PS2_DEV_CMD_ENABLE_SCANNING
@ PS2_DEV_CMD_SET_SCANCODE_SET
@ 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.
PS/2 device information structure.