21#include <aquila/errno.h>
30#define STATUS_PORT 0x04
31#define COMMAND_PORT 0x04
33#define STATUS_OBUF_FULL 0x01
34#define STATUS_IBUF_FULL 0x02
35#define STATUS_SYSTEM 0x04
36#define STATUS_COMMAND 0x08
37#define STATUS_TOUT 0x40
38#define STATUS_PARITY 0x80
77 if (port == 1 || port == 2)
85 for (
int i = 0; i < 100000; ++i)
133 for (
int i = 0; i < 100000; ++i)
140#define CMD_READ_CONFIG 0x20
141#define CMD_WRITE_CONFIG 0x60
142#define CMD_AUX_ENABLE 0xA8
143#define CONFIG_AUX_IRQ 0x02
195 printk(
"i8042: controller not found\n");
199 printk(
"i8042: skipping check\n");
207 printk(
"i8042: the second port didn't come on\n");
210 for (
int i = 0; i < 10; ++i)
213 for (
int i = 0; i < pd->
nirq && i < 2; ++i)
static uint8_t io_in8(struct ioaddr *io, uintptr_t off)
Reads an 8-, 16- or 32-bit register.
static void io_out8(struct ioaddr *io, uintptr_t off, uint8_t val)
Writes an 8-, 16- or 32-bit register.
static char * ioaddr_type_str(struct ioaddr *io)
static int aux_enable(void)
Turns the second port on, and its interrupt (a bit of the controller's configuration byte).
static uint8_t read_status(void)
Returns the controller's status register.
void i8042_handler_register(int port, void(*fun)(int))
Registers the function that gets each byte a port receives.
static void(* port_handler[2])(int)
int i8042_aux_write(uint8_t byte)
Sends a byte to the device on the second port (the mouse).
static int read_wait(void)
Waits for the controller's reply to a command.
static int has_byte(void)
Returns whether the controller has a byte for us (its output buffer is full).
void i8042_reboot(void)
Resets the CPU, through the controller's output line: this reboots the PC.
static void i8042_irq(void *arg)
Handles a port's interrupt: its byte goes to the port's handler.
static int write_wait(void)
Waits until the controller can take a byte.
static int i8042_init(void)
Finds the platform's i8042, turns the mouse's port on, and installs the ports' interrupt handlers.
static struct ioaddr i8042_ioaddr
int kargs_get(const char *key, const char **value)
Looks up an argument of the kernel's command line.
#define MODULE_INIT(name, i, f)
int printk(const char *fmt,...)
Writes a kernel message, to the message buffer and the consoles.
An installed handler, on its interrupt's list.
Where a device's registers are.