iwn.4: Miscellaneous adjustments.
[dragonfly.git] / share / man / man4 / hotplug.4
1 .\"     $OpenBSD: hotplug.4,v 1.3 2007/05/31 19:19:50 jmc Exp $
2 .\"
3 .\" Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org>
4 .\"
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
8 .\"
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 .\"
17 .Dd December 5, 2009
18 .Dt HOTPLUG 4
19 .Os
20 .Sh NAME
21 .Nm hotplug
22 .Nd devices hot plugging
23 .Sh SYNOPSIS
24 .Cd "pseudo-device hotplug 1"
25 .Pp
26 .In sys/types.h
27 .In sys/device.h
28 .In sys/hotplug.h
29 .Sh DESCRIPTION
30 The
31 .Nm
32 pseudo-device passes device attachment and detachment events to
33 userland.
34 When a device attaches or detaches, the corresponding event is queued.
35 The events can then be obtained from the queue through the
36 .Xr read 2
37 call on the
38 .Pa /dev/hotplug
39 device file.
40 Once an event has been read, it's deleted from the queue.
41 The event queue has a limited size and if it's full all new events will be
42 dropped.
43 Each event is described with the following structure declared in the
44 .In sys/hotplug.h
45 header file:
46 .Bd -literal -offset indent
47 struct hotplug_event {
48         int             he_type;        /* event type           */
49         enum devclass   he_devclass;    /* device class         */
50         char            he_devname[16]; /* device name          */
51 };
52
53 .Ed
54 The
55 .Va he_type
56 field describes the event type and can be either
57 .Dv HOTPLUG_DEVAT
58 for device attachment or
59 .Dv HOTPLUG_DEVDT
60 for detachment.
61 The
62 .Va he_devclass
63 field describes the device class.
64 All device classes can be found in the
65 .In sys/device.h
66 header file:
67 .Bd -literal -offset indent
68 enum devclass {
69         DV_DULL,        /* generic, no special info */
70         DV_CPU,         /* CPU (carries resource utilization) */
71         DV_DISK,        /* disk drive (label, etc) */
72         DV_IFNET,       /* network interface */
73         DV_TAPE,        /* tape device */
74         DV_TTY          /* serial line interface */
75 };
76
77 .Ed
78 The
79 .Va he_devname
80 is a device name including unit number, e.g.\&
81 .Pa sd1 .
82 .Pp
83 Only one structure can be read per call.
84 If there are no events in the queue, the
85 .Xr read 2
86 call will block until an event appears.
87 .Sh DIAGNOSTICS
88 .Bl -diag
89 .It "hotplug: event lost, queue full"
90 New events will be dropped until all pending events have been read.
91 .El
92 .Sh SEE ALSO
93 .Xr read 2 ,
94 .Xr hotplugd 8
95 .Sh HISTORY
96 The
97 .Nm
98 device first appeared in
99 .Ox 3.6 .
100 The
101 .Nm
102 driver was imported to
103 .Dx 2.5 .
104 .Sh AUTHORS
105 The
106 .Nm
107 driver was written by
108 .An Alexander Yurchenko Aq grange@openbsd.org .