The entry input
The input service: the device service of the PS/2 keyboard and mouse . It has the ports of the controller and its two interrupts, and nothing else. It sends input records to the compositor.
What it is for. It shows that a driver is a process, not a part of the kernel. This process is a device service: the root service gives it the five I/O ports of the PS/2 controller (0x60 to 0x64) and its two interrupts (1, the keyboard; 12, the mouse). The kernel turns each interrupt into an event of the process; it never reads a key itself.
What a reader sees. No window: the line input: ok, the mouse has a wheel (or no wheel, for a mouse with no wheel) on the log, once the controller is set up. Each key, each move of the mouse and each turn of its wheel then reaches the compositor as one record of its input ring, and the compositor sends a key to the window in front.
The records that it writes (display.Input):
Key: the scan code (withdisplay.KEY_EXTENDEDafter the prefix 0xE0), the character in the layout of the settings as a code point, 1 for a press or 0 for a release, and the modifiers (Shift, Control, the left Alt). After a dead key of the layout of France, one press can give two records: the accent alone, then the character of the key.Pointer: the motion in x and in y, in pixels of the mouse (y grows down, as on the screen), the three buttons, and the notches of the wheel (display.WHEEL_TOWARD_THE_ENDfor each notch toward the principal).
The wheel. A PS/2 mouse sends packets of 3 bytes and no wheel until it is asked for the IntelliMouse protocol: the sample rates 200, 100 and 80 in this order, then its identity (key_path.Mouse_Protocol). A mouse that answers MOUSE_IDENTITY_WHEEL sends packets of 4 bytes; the fourth byte is the notches, signed. A mouse that answers MOUSE_IDENTITY_WHEEL_AND_BUTTONS was left in the Explorer protocol by its firmware, which the default settings do not always leave: it sends packets of 4 bytes too, with the notches in the low 4 bits. The service reads both, with no reset of the mouse: a reset waits for a self test of the mouse, and the decoder needs only the identity. A mouse that answers another identity keeps packets of 3 bytes, and the system has no wheel.
How it starts. The root service starts it at each boot, before the compositor, with a context of its own: handle 0 is the input ring, which it shares with the compositor; handles 1 to 3 are the ports and the two interrupts. Its row of start_grant_sets has the grant System_Part only: no connection, and no service, so it cannot reach another process. The root service names these slots INPUT_GRANT_ too.
What it does not prove. It works with the PS/2 controller that QEMU emulates, with two keyboard layouts (src/library/internal/input/keyboard_layout); AltGr, the right Alt key, gives the third level of the layout of France. It has no USB.
input module with an entry
- Hash
b6a138e5d529f2f1589a6736d716dac082975545ee3302fdb55168812ae74cd3- Size
53248 bytes- Exports
0- Imports
0- Imported by
0- License
- MIT
The input service: the device service of the PS/2 keyboard and mouse
| Fact | Value |
|---|---|
| Kind | Modules with an entry |
| Source | src/modules/system/input |
| Boot image | yes: in the boot image, 53248 bytes in this build |
| Build settings | none: the defaults of the source |
| Imports | none |
| Imported by | none |
Neighbours
It imports no module, and no module imports it. The module graph shows it with the other modules that have no edge.
Exports
| Export | What it does |
|---|---|
entry() | sets up the PS/2 controller and then turns each byte of the controller into a record of the input ring, until the machine stops |
entry
entry()
entry sets up the PS/2 controller and then turns each byte of the controller into a record of the input ring, until the machine stops.
What it sets up: it opens the input ring (handle 0), drops the bytes that wait in the controller, enables the mouse port, turns on both interrupts and the clock of the mouse, gives the mouse its default settings, asks it for the wheel, sets its sample rate to 200 reports each second, and asks it to send its moves. It then writes input: ok, the mouse has a wheel (or no wheel).
The loop. It waits for an interrupt. It then reads each byte while the status port says that one waits: a byte of the mouse goes to mouse_byte, a byte of the keyboard to keyboard_byte.
A full input ring. The service never drops a record. It does not take a byte of the keyboard from the controller while the input ring has no room for its record: the byte stays in the controller, the keyboard holds the bytes after it, and the service waits until the compositor read half of the ring. The moves of the mouse that find the ring full become one move; a change of a button waits in order, and when 8 of them wait the bytes of the mouse stay in the controller too. The log has input: the input ring is full: the keyboard controller keeps its bytes when a wait begins, and input: the input ring has room again when it ends.
The stop: with no ring, it writes input: no ring and stops with Failed. With no PS/2 controller (a status port that reads all ones, or a drain that does not end), it writes input: no PS/2 controller: no keyboard and no mouse and stops with Failed; the compositor runs with no input. Else it never returns.
See: Architecture: The path of a key
- Form
- The entry of the module: one parameter, an address, fixed by the contract.
src/modules/system/input/main.odin:244
Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).
What the root service gives it
| What | Value | As the root service says |
|---|---|---|
| Grants | The ports and the two interrupts of the PS/2 controller (input_start). | |
| Other terms of its start grant set | none | |
| Budget that it asks for |
| The working memory: the rest of the pages that the root service gave it by its name, once the tool counts its module and its thread. |
The start grant set is read from start_grant_sets in src/modules/system/root/start_grant_sets.odin. The stated budget is read from the constant MODULE_BUDGET of the source of the module (its line); the build adds the counted parts and writes the sum in the module (tools/modustool/build/budget_count.odin); the root service accepts it up to the largest budget of a process, and adds the limits of processor time and of log records (src/modules/system/root/budgets.odin).
Input type of the package display
Input :: enum u32 {...}
The ring from the input service to the compositor.
KEY_EXTENDED constant of the package display
KEY_EXTENDED :: 0x100
The codes of the keys: the scan code of set 1 of the keyboard of the PC.
WHEEL_TOWARD_THE_END constant of the package display
WHEEL_TOWARD_THE_END :: 1
The sign of the wheel notches of a pointer record and of an Event: a.
start_grant_sets global variable of the package root
start_grant_sets := [?]Start_Grant_Set_Row {...}
The start grant set of each module of the boot image, with the reason of each.
mouse_byte procedure of the package input
mouse_byte :: proc "contextless" (value: u8)
mouse_byte gives one byte of the mouse to the decoder of its packets.
keyboard_byte procedure of the package input
keyboard_byte :: proc "contextless" (value: u8)
keyboard_byte turns one byte of the keyboard into a record Key.
