0001 .. include:: <isonum.txt>
0002
0003 ===================
0004 The userio Protocol
0005 ===================
0006
0007
0008 :Copyright: |copy| 2015 Stephen Chandler Paul <thatslyude@gmail.com>
0009
0010 Sponsored by Red Hat
0011
0012
0013 Introduction
0014 =============
0015
0016 This module is intended to try to make the lives of input driver developers
0017 easier by allowing them to test various serio devices (mainly the various
0018 touchpads found on laptops) without having to have the physical device in front
0019 of them. userio accomplishes this by allowing any privileged userspace program
0020 to directly interact with the kernel's serio driver and control a virtual serio
0021 port from there.
0022
0023 Usage overview
0024 ==============
0025
0026 In order to interact with the userio kernel module, one simply opens the
0027 /dev/userio character device in their applications. Commands are sent to the
0028 kernel module by writing to the device, and any data received from the serio
0029 driver is read as-is from the /dev/userio device. All of the structures and
0030 macros you need to interact with the device are defined in <linux/userio.h> and
0031 <linux/serio.h>.
0032
0033 Command Structure
0034 =================
0035
0036 The struct used for sending commands to /dev/userio is as follows::
0037
0038 struct userio_cmd {
0039 __u8 type;
0040 __u8 data;
0041 };
0042
0043 ``type`` describes the type of command that is being sent. This can be any one
0044 of the USERIO_CMD macros defined in <linux/userio.h>. ``data`` is the argument
0045 that goes along with the command. In the event that the command doesn't have an
0046 argument, this field can be left untouched and will be ignored by the kernel.
0047 Each command should be sent by writing the struct directly to the character
0048 device. In the event that the command you send is invalid, an error will be
0049 returned by the character device and a more descriptive error will be printed
0050 to the kernel log. Only one command can be sent at a time, any additional data
0051 written to the character device after the initial command will be ignored.
0052
0053 To close the virtual serio port, just close /dev/userio.
0054
0055 Commands
0056 ========
0057
0058 USERIO_CMD_REGISTER
0059 ~~~~~~~~~~~~~~~~~~~
0060
0061 Registers the port with the serio driver and begins transmitting data back and
0062 forth. Registration can only be performed once a port type is set with
0063 USERIO_CMD_SET_PORT_TYPE. Has no argument.
0064
0065 USERIO_CMD_SET_PORT_TYPE
0066 ~~~~~~~~~~~~~~~~~~~~~~~~
0067
0068 Sets the type of port we're emulating, where ``data`` is the port type being
0069 set. Can be any of the macros from <linux/serio.h>. For example: SERIO_8042
0070 would set the port type to be a normal PS/2 port.
0071
0072 USERIO_CMD_SEND_INTERRUPT
0073 ~~~~~~~~~~~~~~~~~~~~~~~~~
0074
0075 Sends an interrupt through the virtual serio port to the serio driver, where
0076 ``data`` is the interrupt data being sent.
0077
0078 Userspace tools
0079 ===============
0080
0081 The userio userspace tools are able to record PS/2 devices using some of the
0082 debugging information from i8042, and play back the devices on /dev/userio. The
0083 latest version of these tools can be found at:
0084
0085 https://github.com/Lyude/ps2emu