userio.txt 2.9 KB

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