2 .\" Copyright (c) 2014 John Baldwin <jhb@FreeBSD.org>
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 .Nd device control library
44 .Fn devctl_attach "const char *device"
46 .Fn devctl_detach "const char *device" "bool force"
48 .Fn devctl_disable "const char *device" "bool force_detach"
50 .Fn devctl_enable "const char *device"
52 .Fn devctl_set_driver "const char *device" "const char *driver" "bool force"
56 library adjusts the state of devices in the kernel's internal device
58 Each control operation accepts a
60 argument that identifies the device to adjust.
63 may be specified as either the name of an existing device or as a
65 The following bus-specific address formats are currently supported:
66 .Bl -tag -offset indent
67 .It Sy pci Ns Fa domain Ns : Ns Fa bus Ns : Ns Fa slot Ns : Ns Fa function
68 A PCI device with the specified
74 .It Sy pci Ns Fa bus Ns : Ns Fa slot Ns : Ns Fa function
75 A PCI device in domain zero with the specified
81 A device with an ACPI handle of
83 The handle must be specified as an absolute path and must begin with a
89 function probes a device and attaches a suitable device driver if one is
94 function detaches a device from its current device driver.
95 The device is left detached until either a new driver for its parent
96 bus is loaded or the device is explicitly probed via
101 the current device driver will be detached even if the device is busy.
105 function disables a device.
106 If the device is currently attached to a device driver,
107 the device driver will be detached from the device,
108 but the device will retain its current name.
112 the current device driver will be detached even if the device is busy.
113 The device will remain disabled and detached until it is explicitly enabled
119 function re-enables a disabled device.
120 The device will probe and attach if a suitable device driver is found.
123 .Fn devctl_set_driver
124 function attaches a device driver named
127 If the device is already attached and
130 the request will fail.
131 If the device is already attached and
134 the device will be detached from its current device driver before it is
135 attached to the new device driver.
137 .Rv -std devctl_attach devctl_detach devctl_disable devctl_enable \
140 In addition to specific errors noted below,
143 functions may fail for any of the errors described in
148 The device name is too long.
150 No existing device matches the specified name or location.
152 The current process is not permitted to adjust the state of
158 function may fail if:
161 The device is already attached.
163 An internal memory allocation request failed.
165 The device is disabled.
167 No suitable driver for the device could be found,
168 or the driver failed to attach.
173 function may fail if:
176 The current device driver for
178 is busy and cannot detach at this time.
179 Note that some drivers may return this even if
183 The device is not attached to a driver.
185 The current device driver for
187 does not support detaching.
192 function may fail if:
195 The device is already enabled.
197 An internal memory allocation request failed.
199 No suitable driver for the device could be found,
200 or the driver failed to attach.
205 function may fail if:
208 The current device driver for
210 is busy and cannot detach at this time.
211 Note that some drivers may return this even if
215 The device is already disabled.
217 The current device driver for
219 does not support detaching.
223 .Fn devctl_set_driver
224 function may fail if:
227 The device is currently attached to a device driver and
231 The current device driver for
233 is busy and cannot detach at this time.
237 argument points outside the process' allocated address space.
239 No device driver with the requested name exists.
241 An internal memory allocation request failed.
243 The device is disabled.
245 The new device driver failed to attach.
254 library first appeared in