xref: /freebsd/share/man/man4/devctl.4 (revision ca6a6373bdaed010d6cbfb27f7249ae96009409d)
1.\"
2.\" Copyright (c) 2002 M. Warner Losh <imp@FreeBSD.org>
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. The name of the author may not be used to endorse or promote products
10.\"    derived from this software without specific prior written permission.
11.\"
12.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22.\" SUCH DAMAGE.
23.\"
24.Dd September 21, 2020
25.Dt DEVCTL 4
26.Os
27.Sh NAME
28.Nm devctl
29.Nd "device event reporting and device control interface"
30.Sh SYNOPSIS
31The
32.Nm
33driver is automatically included in the kernel.
34.Sh DESCRIPTION
35The
36.Nm
37device is used to report device events from the kernel.
38Future versions will allow for some device control as well.
39.Sh IMPLEMENTATION NOTES
40This design allows only one reader for
41.Pa /dev/devctl .
42This is not desirable
43in the long run, but will get a lot of hair out of this implementation.
44Maybe we should make this device a clonable device.
45.Pp
46Also note: we specifically do not attach a device to the
47.Vt device_t
48tree
49to avoid potential chicken and egg problems.
50One could argue that all of this belongs to the root node.
51One could also further argue that the
52.Xr sysctl 3
53interface that we have now might more properly be an
54.Xr ioctl 2
55interface.
56.Pp
57.Dv SIGIO
58support is included in the driver.
59However, the author is not sure that the
60.Dv SIGIO
61support is done correctly.
62It was copied from a driver that had
63.Dv SIGIO
64support that likely has not been
65tested since
66.Fx 3.4
67or
68.Fx 2.2.8 !
69.Pp
70The read channel for this device is used to report changes to
71userland in realtime.
72We return one record at a time.
73If you try to read this device a character at a time, you will lose
74the rest of the data.
75Listening programs are expected to cope.
76.Pp
77The sysctl
78.Va hw.bus.devctl_queue
79can be used to control queue length.
80It is set to 0 to disable
81.Nm
82when no
83.Xr devd 8
84is running.
85.Sh PROTOCOL
86The
87.Nm
88device
89uses an
90.Tn ASCII
91protocol.
92The driver returns one record at a time to its readers.
93Each record is terminated with a newline.
94The first character of the record is the event type.
95.Pp
96.Bl -column -compact "Type" "Description"
97.Em "Type	Description"
98!	A notify event, such as a link state change.
99+	Device node in tree attached.
100-	Device node in tree detached.
101?	Unknown device detected.
102.El
103.Ss Message Formats
104Except for the first character in the record, attach and detach
105messages have the same format.
106.Pp
107.D1 Ar T Ns Ar dev Li at Ar parent Li on Ar location
108.Pp
109.Bl -column -compact "location" "Description"
110.Em "Part	Description"
111.It Ar T Ta "+ or -"
112.It Ar dev Ta "The device name that was attached/detached."
113.It Ar parent Ta "The device name of the parent bus that attached the device."
114.It Ar location Ta "Bus specific location information."
115.El
116.Pp
117The nomatch messages can be used to load devices driver.
118If you load a device driver, then one of two things can happen.
119If the device driver attaches to something, you will get a device
120attached message.
121If it does not, then nothing will happen.
122.Pp
123The attach and detach messages arrive after the event.
124This means one cannot use the attach message to load an alternate
125driver.
126The attach message driver has already claimed this device.
127One cannot use the detach messages to flush data to the device.
128The device is already gone.
129.Pp
130All values passed back are of the form
131.Sq key=value
132or
133.Sq key="value" .
134When the latter, the string
135.Dq value
136must have any internal backslashes doubled.
137It must also have any internal double quote characters
138.Sq "
139preceded by a backslash.
140All other characters should be passed through.
141.Sh SEE ALSO
142.Xr devd 8
143