xref: /freebsd/share/man/man4/devctl.4 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
1b279e597SWarner Losh.\"
2f86e6000SWarner Losh.\" Copyright (c) 2002 M. Warner Losh <imp@FreeBSD.org>
3b279e597SWarner Losh.\"
4b279e597SWarner Losh.\" Redistribution and use in source and binary forms, with or without
5b279e597SWarner Losh.\" modification, are permitted provided that the following conditions
6b279e597SWarner Losh.\" are met:
7b279e597SWarner Losh.\" 1. Redistributions of source code must retain the above copyright
8b279e597SWarner Losh.\"    notice, this list of conditions and the following disclaimer.
9b279e597SWarner Losh.\" 2. The name of the author may not be used to endorse or promote products
10b279e597SWarner Losh.\"    derived from this software without specific prior written permission.
11b279e597SWarner Losh.\"
12b279e597SWarner Losh.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13b279e597SWarner Losh.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14b279e597SWarner Losh.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15b279e597SWarner Losh.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16b279e597SWarner Losh.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17b279e597SWarner Losh.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18b279e597SWarner Losh.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19b279e597SWarner Losh.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20b279e597SWarner Losh.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21b279e597SWarner Losh.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22b279e597SWarner Losh.\" SUCH DAMAGE.
23b279e597SWarner Losh.\"
24*a5dca7c7SWarner Losh.Dd September 21, 2020
25b279e597SWarner Losh.Dt DEVCTL 4
26b279e597SWarner Losh.Os
27b279e597SWarner Losh.Sh NAME
28b279e597SWarner Losh.Nm devctl
29ace5be68SRuslan Ermilov.Nd "device event reporting and device control interface"
30*a5dca7c7SWarner Losh.Sh SYNOPSIS
31*a5dca7c7SWarner LoshThe
32*a5dca7c7SWarner Losh.Nm
33*a5dca7c7SWarner Loshdriver is automatically included in the kernel.
34b279e597SWarner Losh.Sh DESCRIPTION
357f511526SWarner LoshThe
367f511526SWarner Losh.Nm
377f511526SWarner Loshdevice is used to report device events from the kernel.
387f511526SWarner LoshFuture versions will allow for some device control as well.
397f511526SWarner Losh.Sh IMPLEMENTATION NOTES
40ace5be68SRuslan ErmilovThis design allows only one reader for
41ace5be68SRuslan Ermilov.Pa /dev/devctl .
427f511526SWarner LoshThis is not desirable
437f511526SWarner Loshin the long run, but will get a lot of hair out of this implementation.
447f511526SWarner LoshMaybe we should make this device a clonable device.
457f511526SWarner Losh.Pp
46ace5be68SRuslan ErmilovAlso note: we specifically do not attach a device to the
47ace5be68SRuslan Ermilov.Vt device_t
48ace5be68SRuslan Ermilovtree
497f511526SWarner Loshto avoid potential chicken and egg problems.
507f511526SWarner LoshOne could argue that all of this belongs to the root node.
51ace5be68SRuslan ErmilovOne could also further argue that the
52ace5be68SRuslan Ermilov.Xr sysctl 3
53ace5be68SRuslan Ermilovinterface that we have now might more properly be an
54ace5be68SRuslan Ermilov.Xr ioctl 2
55ace5be68SRuslan Ermilovinterface.
567f511526SWarner Losh.Pp
57ace5be68SRuslan Ermilov.Dv SIGIO
58ace5be68SRuslan Ermilovsupport is included in the driver.
59ace5be68SRuslan ErmilovHowever, the author is not sure that the
60ace5be68SRuslan Ermilov.Dv SIGIO
61ace5be68SRuslan Ermilovsupport is done correctly.
62ace5be68SRuslan ErmilovIt was copied from a driver that had
63ace5be68SRuslan Ermilov.Dv SIGIO
64ace5be68SRuslan Ermilovsupport that likely has not been
65ace5be68SRuslan Ermilovtested since
66ace5be68SRuslan Ermilov.Fx 3.4
67ace5be68SRuslan Ermilovor
68ace5be68SRuslan Ermilov.Fx 2.2.8 !
697f511526SWarner Losh.Pp
707f511526SWarner LoshThe read channel for this device is used to report changes to
717f511526SWarner Loshuserland in realtime.
727f511526SWarner LoshWe return one record at a time.
73776fc0e9SYaroslav TykhiyIf you try to read this device a character at a time, you will lose
747f511526SWarner Loshthe rest of the data.
757f511526SWarner LoshListening programs are expected to cope.
767f511526SWarner Losh.Pp
77ee38f2e0SMateusz GuzikThe sysctl
78ee38f2e0SMateusz Guzik.Va hw.bus.devctl_queue
7925972509SEdward Tomasz Napieralacan be used to control queue length.
8025972509SEdward Tomasz NapieralaIt is set to 0 to disable
817f511526SWarner Losh.Nm
82ace5be68SRuslan Ermilovwhen no
83ace5be68SRuslan Ermilov.Xr devd 8
84ace5be68SRuslan Ermilovis running.
857f511526SWarner Losh.Sh PROTOCOL
86ace5be68SRuslan ErmilovThe
877f511526SWarner Losh.Nm
88ace5be68SRuslan Ermilovdevice
89ace5be68SRuslan Ermilovuses an
90ace5be68SRuslan Ermilov.Tn ASCII
91ace5be68SRuslan Ermilovprotocol.
927f511526SWarner LoshThe driver returns one record at a time to its readers.
937f511526SWarner LoshEach record is terminated with a newline.
947f511526SWarner LoshThe first character of the record is the event type.
957f511526SWarner Losh.Pp
967f511526SWarner Losh.Bl -column -compact "Type" "Description"
977f511526SWarner Losh.Em "Type	Description"
9847aeac77SCeri Davies!	A notify event, such as a link state change.
99ace5be68SRuslan Ermilov+	Device node in tree attached.
100ace5be68SRuslan Ermilov-	Device node in tree detached.
101ace5be68SRuslan Ermilov?	Unknown device detected.
1027f511526SWarner Losh.El
103ace5be68SRuslan Ermilov.Ss Message Formats
1047f511526SWarner LoshExcept for the first character in the record, attach and detach
1057f511526SWarner Loshmessages have the same format.
106ace5be68SRuslan Ermilov.Pp
107ace5be68SRuslan Ermilov.D1 Ar T Ns Ar dev Li at Ar parent Li on Ar location
108ace5be68SRuslan Ermilov.Pp
109ace5be68SRuslan Ermilov.Bl -column -compact "location" "Description"
1107f511526SWarner Losh.Em "Part	Description"
111ace5be68SRuslan Ermilov.It Ar T Ta "+ or -"
112ace5be68SRuslan Ermilov.It Ar dev Ta "The device name that was attached/detached."
113ace5be68SRuslan Ermilov.It Ar parent Ta "The device name of the parent bus that attached the device."
114ace5be68SRuslan Ermilov.It Ar location Ta "Bus specific location information."
1157f511526SWarner Losh.El
1167f511526SWarner Losh.Pp
1177f511526SWarner LoshThe nomatch messages can be used to load devices driver.
1187f511526SWarner LoshIf you load a device driver, then one of two things can happen.
119ace5be68SRuslan ErmilovIf the device driver attaches to something, you will get a device
1207f511526SWarner Loshattached message.
121ace5be68SRuslan ErmilovIf it does not, then nothing will happen.
1227f511526SWarner Losh.Pp
1237f511526SWarner LoshThe attach and detach messages arrive after the event.
1247f511526SWarner LoshThis means one cannot use the attach message to load an alternate
1257f511526SWarner Loshdriver.
1267f511526SWarner LoshThe attach message driver has already claimed this device.
1277f511526SWarner LoshOne cannot use the detach messages to flush data to the device.
1287f511526SWarner LoshThe device is already gone.
129*a5dca7c7SWarner Losh.Pp
130*a5dca7c7SWarner LoshAll values passed back are of the form
131*a5dca7c7SWarner Losh.Sq key=value
132*a5dca7c7SWarner Loshor
133*a5dca7c7SWarner Losh.Sq key="value" .
134*a5dca7c7SWarner LoshWhen the latter, the string
135*a5dca7c7SWarner Losh.Dq value
136*a5dca7c7SWarner Loshmust have any internal backslashes doubled.
137*a5dca7c7SWarner LoshIt must also have any internal double quote characters
138*a5dca7c7SWarner Losh.Sq "
139*a5dca7c7SWarner Loshpreceded by a backslash.
140*a5dca7c7SWarner LoshAll other characters should be passed through.
141b279e597SWarner Losh.Sh SEE ALSO
1427f511526SWarner Losh.Xr devd 8
143