8. The userio Protocol¶
| Copyright: | © 2015 Stephen Chandler Paul <thatslyude@gmail.com> |
|---|
Sponsored by Red Hat
8.1. Introduction¶
This module is intended to try to make the lives of input driver developerseasier by allowing them to test various serio devices (mainly the varioustouchpads found on laptops) without having to have the physical device in frontof them. userio accomplishes this by allowing any privileged userspace programto directly interact with the kernel’s serio driver and control a virtual serioport from there.
8.2. Usage overview¶
In order to interact with the userio kernel module, one simply opens the/dev/userio character device in their applications. Commands are sent to thekernel module by writing to the device, and any data received from the seriodriver is read as-is from the /dev/userio device. All of the structures andmacros you need to interact with the device are defined in <linux/userio.h> and<linux/serio.h>.
8.3. Command Structure¶
The struct used for sending commands to /dev/userio is as follows:
struct userio_cmd { __u8 type; __u8 data;};type describes the type of command that is being sent. This can be any oneof the USERIO_CMD macros defined in <linux/userio.h>.data is the argumentthat goes along with the command. In the event that the command doesn’t have anargument, this field can be left untouched and will be ignored by the kernel.Each command should be sent by writing the struct directly to the characterdevice. In the event that the command you send is invalid, an error will bereturned by the character device and a more descriptive error will be printedto the kernel log. Only one command can be sent at a time, any additional datawritten to the character device after the initial command will be ignored.
To close the virtual serio port, just close /dev/userio.
8.4. Commands¶
8.4.1. USERIO_CMD_REGISTER¶
Registers the port with the serio driver and begins transmitting data back andforth. Registration can only be performed once a port type is set withUSERIO_CMD_SET_PORT_TYPE. Has no argument.
8.4.2. USERIO_CMD_SET_PORT_TYPE¶
Sets the type of port we’re emulating, wheredata is the port type beingset. Can be any of the macros from <linux/serio.h>. For example: SERIO_8042would set the port type to be a normal PS/2 port.
8.4.3. USERIO_CMD_SEND_INTERRUPT¶
Sends an interrupt through the virtual serio port to the serio driver, wheredata is the interrupt data being sent.
8.5. Userspace tools¶
The userio userspace tools are able to record PS/2 devices using some of thedebugging information from i8042, and play back the devices on /dev/userio. Thelatest version of these tools can be found at: