← Documents Documentation/input/userio.rst GitHub 원문 ↗

Linux 6.18.37 · Input

The userio Protocol

권한 있는 사용자 공간 program이 가상 serio port를 구성하고 interrupt data를 교환하는 userio protocol을 설명합니다.

Source pathDocumentation/input/userio.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

userio.rst:1-85

`/dev/userio`는 실제 PS/2·serio hardware 없이 input driver를 시험할 수 있는 privileged interface입니다. 두 byte command로 port type을 정하고 등록한 뒤 interrupt를 전달하며, device를 닫으면 가상 port도 닫힙니다.

userio protocol 요약
`SET_PORT_TYPE``REGISTER``SEND_INTERRUPT`raw serio data 읽기device 닫기

설정과 등록 순서를 지키는 것이 핵심입니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

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

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

목적과 사용 개요

1-31

이 문서는 2015년 Stephen Chandler Paul이 작성했으며 Red Hat의 후원을 받았습니다.

`userio` module은 input driver 개발자가 실제 serio 장치를 앞에 두지 않고도 여러 serio 장치, 특히 laptop touchpad를 시험할 수 있게 하여 개발을 쉽게 만드는 것이 목적입니다. 권한 있는 사용자 공간 program이 kernel의 serio driver와 직접 상호 작용하고 가상 serio port를 제어하도록 합니다.

application은 `/dev/userio` character device를 열어 module과 상호 작용합니다. device에 기록한 command는 kernel module로 전달되고, serio driver에서 받은 data는 변환하지 않은 그대로 `/dev/userio`에서 읽습니다. 필요한 구조체와 macro는 `<linux/userio.h>`와 `<linux/serio.h>`에 정의되어 있습니다.

userio data 방향
동작방향내용
`write()`사용자 공간 → kernel`struct userio_cmd` command
`read()`kernel serio driver → 사용자 공간driver가 보낸 raw data
`close()`사용자 공간 → kernel가상 serio port 닫기

같은 character device에서 command와 serio data의 방향이 나뉩니다.

userio 사용 흐름
`/dev/userio` 열기`USERIO_CMD_SET_PORT_TYPE` 전송`USERIO_CMD_REGISTER` 전송interrupt data 송신 또는 serio data 수신`/dev/userio` 닫아 virtual port 종료

가상 port type을 정한 뒤 등록하고 interrupt data를 교환합니다.

.. include:: <isonum.txt>

===================
The userio Protocol
===================


:Copyright: |copy| 2015 Stephen Chandler Paul <thatslyude@gmail.com>

Sponsored by Red Hat


Introduction
=============

This module is intended to try to make the lives of input driver developers
easier by allowing them to test various serio devices (mainly the various
touchpads found on laptops) without having to have the physical device in front
of them. userio accomplishes this by allowing any privileged userspace program
to directly interact with the kernel's serio driver and control a virtual serio
port from there.

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 the
kernel module by writing to the device, and any data received from the serio
driver is read as-is from the /dev/userio device. All of the structures and
macros you need to interact with the device are defined in <linux/userio.h> and
<linux/serio.h>.

명령 구조와 전송 규칙

32-53

`/dev/userio`에 command를 보낼 때는 아래 `struct userio_cmd`를 사용합니다. `type`은 `<linux/userio.h>`에 정의된 `USERIO_CMD_*` macro 중 하나이며, `data`는 그 command의 argument입니다. argument가 없는 command에서는 `data`를 건드리지 않아도 kernel이 무시합니다.

`struct userio_cmd`
FieldType의미
`type``__u8`전송할 `USERIO_CMD_*` 종류
`data``__u8`command argument 또는 무시되는 값

command는 두 개의 8-bit field로 이루어집니다.

각 command는 구조체를 character device에 직접 기록하여 한 번에 하나씩 보내야 합니다. 잘못된 command를 보내면 character device가 error를 반환하고 kernel log에는 더 구체적인 error가 기록됩니다. 첫 command 뒤에 함께 기록한 추가 data는 무시됩니다.

command 전송 제약
상황kernel 동작
유효한 구조체 하나 기록해당 command 처리
잘못된 commandcharacter device error 반환과 kernel log 기록
한 write에 추가 data 포함첫 command 뒤의 data 무시
argument 없는 command`data` field 무시
device 닫기virtual serio port 종료

write 단위와 오류 처리 규칙입니다.


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 one
of the USERIO_CMD macros defined in <linux/userio.h>. ``data`` is the argument
that goes along with the command. In the event that the command doesn't have an
argument, 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 character
device. In the event that the command you send is invalid, an error will be
returned by the character device and a more descriptive error will be printed
to the kernel log. Only one command can be sent at a time, any additional data
written to the character device after the initial command will be ignored.

To close the virtual serio port, just close /dev/userio.

지원 명령과 사용자 공간 도구

54-85

`USERIO_CMD_REGISTER`는 port를 serio driver에 등록하고 양방향 data 전송을 시작합니다. 이 command는 `USERIO_CMD_SET_PORT_TYPE`으로 port type을 먼저 설정한 뒤 한 번만 수행할 수 있으며 argument는 없습니다.

`USERIO_CMD_SET_PORT_TYPE`은 흉내 낼 port type을 설정합니다. `data`에는 `<linux/serio.h>`의 macro 중 하나를 넣습니다. 예를 들어 `SERIO_8042`는 일반 PS/2 port를 뜻합니다.

`USERIO_CMD_SEND_INTERRUPT`는 가상 serio port를 통해 serio driver로 interrupt를 보냅니다. 전송할 interrupt data는 `data` field에 둡니다.

userio command
CommandArgument효과
`USERIO_CMD_SET_PORT_TYPE`serio port type가상 port 종류 설정
`USERIO_CMD_REGISTER`없음설정된 port를 serio driver에 한 번 등록
`USERIO_CMD_SEND_INTERRUPT`interrupt data가상 port에서 driver로 interrupt 전달

세 command의 선행 조건과 argument를 비교합니다.

등록 순서
serio type 선택`SET_PORT_TYPE` 전송`REGISTER` 한 번 전송`SEND_INTERRUPT`로 data 전달

`REGISTER`보다 port type 설정이 먼저 와야 합니다.

userio 사용자 공간 tool은 i8042의 일부 debugging 정보를 사용해 PS/2 장치를 기록하고 `/dev/userio`에서 재생할 수 있습니다. 최신 version은 `https://github.com/Lyude/ps2emu`에서 제공됩니다.


Commands
========

USERIO_CMD_REGISTER
~~~~~~~~~~~~~~~~~~~

Registers the port with the serio driver and begins transmitting data back and
forth. Registration can only be performed once a port type is set with
USERIO_CMD_SET_PORT_TYPE. Has no argument.

USERIO_CMD_SET_PORT_TYPE
~~~~~~~~~~~~~~~~~~~~~~~~

Sets the type of port we're emulating, where ``data`` is the port type being
set. Can be any of the macros from <linux/serio.h>. For example: SERIO_8042
would set the port type to be a normal PS/2 port.

USERIO_CMD_SEND_INTERRUPT
~~~~~~~~~~~~~~~~~~~~~~~~~

Sends an interrupt through the virtual serio port to the serio driver, where
``data`` is the interrupt data being sent.

Userspace tools
===============

The userio userspace tools are able to record PS/2 devices using some of the
debugging information from i8042, and play back the devices on /dev/userio. The
latest version of these tools can be found at:

        https://github.com/Lyude/ps2emu