|
AquilaOS documentation
How it works, and its code
|
The PS/2 mouse driver: /dev/mouse (character device 10, 1). More...
#include <core/system.h>#include <core/module.h>#include <core/arch.h>#include <cpu/cpu.h>#include <dev/i8042.h>#include <sys/proc.h>#include <sys/sched.h>#include <dev/dev.h>#include <fs/devfs.h>#include <fs/posix.h>#include <ds/ringbuf.h>#include <ds/queue.h>#include <aquila/errno.h>Go to the source code of this file.
Macros | |
| #define | USE_DEFAULTS 0xF6 |
| #define | ENABLE_MOUSE 0xF4 |
| #define | RESET 0xFF |
| #define | BUF_SIZE 1024 |
Functions | |
| void | ps2mouse_handler (int byte) |
| Takes a byte from the mouse, which the i8042 driver received: it goes to the readers, unless it is a reply to the reset done at open. | |
| void | ps2mouse_register (void) |
| Has the i8042 driver send the bytes of its second port, the mouse's, to this driver. | |
| static ssize_t | ps2mouse_read (struct devid *dd, off_t offset, struct iobuf *io) |
| Reads the bytes received from the mouse. | |
| static ssize_t | ps2mouse_write (struct devid *dd, off_t offset, struct iobuf *io) |
| Sends what is written to the mouse, a byte at a time: commands, which it replies to (an ACK to each byte, and more to some). | |
| int | ps2mouse_probe () |
| Sets the mouse up at boot (its default settings, and reporting on) and registers /dev/mouse. | |
| static int | ps2mouse_file_open (struct file *file) |
| Opens /dev/mouse, which one process at a time may have open (EACCES otherwise), and resets the mouse. | |
| static int | ps2mouse_file_can_read (struct file *file, size_t size) |
| Returns whether there are bytes to read. | |
| static int | ps2mouse_file_close (struct file *file) |
| Closes /dev/mouse: another process may open it now. | |
Variables | |
| struct dev | ps2mousedev |
| static struct ringbuf * | mouse_ring = RINGBUF_NEW(BUF_SIZE) |
| static struct proc * | proc = NULL |
| static struct waitq * | mouse_read_queue = &(struct waitq){0} |
| static int | skip = 0 |
The PS/2 mouse driver: /dev/mouse (character device 10, 1).
As Linux's /dev/psaux, reading it gives the mouse's bytes as they come: its movement packets (3 bytes, or 4 with a wheel), and its replies (an ACK, its ID) to the commands written to it, which go to the mouse. A reader finds where packets start by bit 3 of their first byte. Opening it resets the mouse to a plain PS/2 mouse, so the first byte read starts a packet. The mouse is on the second port of the i8042 controller (dev/input/i8042.c).
Definition in file ps2mouse.c.
| #define BUF_SIZE 1024 |
Definition at line 40 of file ps2mouse.c.
Referenced by e1000_transmit(), rx_init(), and tx_init().
| #define ENABLE_MOUSE 0xF4 |
Definition at line 37 of file ps2mouse.c.
Referenced by ps2mouse_file_open(), and ps2mouse_probe().
| #define RESET 0xFF |
Definition at line 38 of file ps2mouse.c.
Referenced by ps2mouse_file_open().
| #define USE_DEFAULTS 0xF6 |
Definition at line 36 of file ps2mouse.c.
Referenced by ps2mouse_probe().
Returns whether there are bytes to read.
Definition at line 149 of file ps2mouse.c.
References mouse_ring, and ps2mouse_file_can_read().
Referenced by ps2mouse_file_can_read().
|
static |
Closes /dev/mouse: another process may open it now.
Definition at line 156 of file ps2mouse.c.
References NULL, posix_file_close(), and ps2mouse_file_close().
Referenced by ps2mouse_file_close().
|
static |
Opens /dev/mouse, which one process at a time may have open (EACCES otherwise), and resets the mouse.
Definition at line 127 of file ps2mouse.c.
References curproc, ENABLE_MOUSE, i8042_aux_write(), mouse_read_queue, mouse_ring, posix_file_open(), ps2mouse_file_open(), RESET, and skip.
Referenced by ps2mouse_file_open().
| void ps2mouse_handler | ( | int | byte | ) |
Takes a byte from the mouse, which the i8042 driver received: it goes to the readers, unless it is a reply to the reset done at open.
| byte | the byte |
Definition at line 56 of file ps2mouse.c.
References mouse_read_queue, mouse_ring, ps2mouse_handler(), skip, and waitq_wakeup().
Referenced by ps2mouse_handler(), and ps2mouse_register().
| int ps2mouse_probe | ( | ) |
Sets the mouse up at boot (its default settings, and reporting on) and registers /dev/mouse.
The i8042 driver turned the controller's second port on. The mouse's replies come before anyone reads, and opening the device sets the mouse up again anyway.
Definition at line 114 of file ps2mouse.c.
References ENABLE_MOUSE, i8042_aux_write(), kdev_chrdev_register(), ps2mouse_probe(), ps2mouse_register(), ps2mousedev, and USE_DEFAULTS.
Referenced by ps2mouse_probe().
Reads the bytes received from the mouse.
Definition at line 81 of file ps2mouse.c.
References mouse_ring, ps2mouse_read(), and iobuf::resid.
Referenced by ps2mouse_read().
| void ps2mouse_register | ( | void | ) |
Has the i8042 driver send the bytes of its second port, the mouse's, to this driver.
Definition at line 75 of file ps2mouse.c.
References i8042_handler_register(), ps2mouse_handler(), and ps2mouse_register().
Referenced by ps2mouse_probe(), and ps2mouse_register().
Sends what is written to the mouse, a byte at a time: commands, which it replies to (an ACK to each byte, and more to some).
Definition at line 88 of file ps2mouse.c.
References i8042_aux_write(), iobuf_in(), ps2mouse_write(), and iobuf::resid.
Referenced by ps2mouse_write().
Definition at line 44 of file ps2mouse.c.
Referenced by ps2mouse_file_open(), and ps2mouse_handler().
|
static |
Definition at line 42 of file ps2mouse.c.
Referenced by ps2mouse_file_can_read(), ps2mouse_file_open(), ps2mouse_handler(), and ps2mouse_read().
|
static |
Definition at line 43 of file ps2mouse.c.
| struct dev ps2mousedev |
Definition at line 34 of file ps2mouse.c.
Referenced by ps2mouse_probe().
|
static |
Definition at line 48 of file ps2mouse.c.
Referenced by ooo_drain(), ps2mouse_file_open(), ps2mouse_handler(), segment_input(), vt_keyboard_reset(), and vt_scancode().