1 The userio Protocol 2 (c) 2015 Stephen Chandler Paul <thatslyude@gmail.com> 3 Sponsored by Red Hat 4-------------------------------------------------------------------------------- 5 61. Introduction 7~~~~~~~~~~~~~~~ 8 This module is intended to try to make the lives of input driver developers 9easier by allowing them to test various serio devices (mainly the various 10touchpads found on laptops) without having to have the physical device in front 11of them. userio accomplishes this by allowing any privileged userspace program 12to directly interact with the kernel's serio driver and control a virtual serio 13port from there. 14 152. Usage overview 16~~~~~~~~~~~~~~~~~ 17 In order to interact with the userio kernel module, one simply opens the 18/dev/userio character device in their applications. Commands are sent to the 19kernel module by writing to the device, and any data received from the serio 20driver is read as-is from the /dev/userio device. All of the structures and 21macros you need to interact with the device are defined in <linux/userio.h> and 22<linux/serio.h>. 23 243. Command Structure 25~~~~~~~~~~~~~~~~~~~~ 26 The struct used for sending commands to /dev/userio is as follows: 27 28 struct userio_cmd { 29 __u8 type; 30 __u8 data; 31 }; 32 33 "type" describes the type of command that is being sent. This can be any one 34of the USERIO_CMD macros defined in <linux/userio.h>. "data" is the argument 35that goes along with the command. In the event that the command doesn't have an 36argument, this field can be left untouched and will be ignored by the kernel. 37Each command should be sent by writing the struct directly to the character 38device. In the event that the command you send is invalid, an error will be 39returned by the character device and a more descriptive error will be printed 40to the kernel log. Only one command can be sent at a time, any additional data 41written to the character device after the initial command will be ignored. 42 To close the virtual serio port, just close /dev/userio. 43 444. Commands 45~~~~~~~~~~~ 46 474.1 USERIO_CMD_REGISTER 48~~~~~~~~~~~~~~~~~~~~~~~ 49 Registers the port with the serio driver and begins transmitting data back and 50forth. Registration can only be performed once a port type is set with 51USERIO_CMD_SET_PORT_TYPE. Has no argument. 52 534.2 USERIO_CMD_SET_PORT_TYPE 54~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 55 Sets the type of port we're emulating, where "data" is the port type being 56set. Can be any of the macros from <linux/serio.h>. For example: SERIO_8042 57would set the port type to be a normal PS/2 port. 58 594.3 USERIO_CMD_SEND_INTERRUPT 60~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 61 Sends an interrupt through the virtual serio port to the serio driver, where 62"data" is the interrupt data being sent. 63 645. Userspace tools 65~~~~~~~~~~~~~~~~~~ 66 The userio userspace tools are able to record PS/2 devices using some of the 67debugging information from i8042, and play back the devices on /dev/userio. The 68latest version of these tools can be found at: 69 70 https://github.com/Lyude/ps2emu 71