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
34 .Nm devctl_clear_driver ,
41 .Nm devctl_set_driver ,
43 .Nd device control library
49 .Fn devctl_attach "const char *device"
51 .Fn devctl_clear_driver "const char *device" "bool force"
53 .Fn devctl_delete "const char *device" "bool force"
55 .Fn devctl_detach "const char *device" "bool force"
57 .Fn devctl_disable "const char *device" "bool force_detach"
59 .Fn devctl_enable "const char *device"
61 .Fn devctl_rescan "const char *device"
63 .Fn devctl_resume "const char *device"
65 .Fn devctl_set_driver "const char *device" "const char *driver" "bool force"
67 .Fn devctl_suspend "const char *device"
71 library adjusts the state of devices in the kernel's internal device
73 Each control operation accepts a
75 argument that identifies the device to adjust.
78 may be specified as either the name of an existing device or as a
80 The following bus-specific address formats are currently supported:
81 .Bl -tag -offset indent
82 .It Sy pci Ns Fa domain Ns : Ns Fa bus Ns : Ns Fa slot Ns : Ns Fa function
83 A PCI device with the specified
89 .It Sy pci Ns Fa bus Ns : Ns Fa slot Ns : Ns Fa function
90 A PCI device in domain zero with the specified
96 A device with an ACPI handle of
98 The handle must be specified as an absolute path and must begin with a
104 function probes a device and attaches a suitable device driver if one is
109 function detaches a device from its current device driver.
110 The device is left detached until either a new driver for its parent
111 bus is loaded or the device is explicitly probed via
116 the current device driver will be detached even if the device is busy.
120 function deletes a device from the device tree.
125 the device is deleted even if the device is physically present.
129 function disables a device.
130 If the device is currently attached to a device driver,
131 the device driver will be detached from the device,
132 but the device will retain its current name.
136 the current device driver will be detached even if the device is busy.
137 The device will remain disabled and detached until it is explicitly enabled
143 function re-enables a disabled device.
144 The device will probe and attach if a suitable device driver is found.
148 function suspends a device.
149 This may include placing the device in a reduced power state,
150 but any device driver currently attached to the device will remain attached.
154 function resumes a suspended device to a fully working state.
157 .Fn devctl_set_driver
158 function attaches a device driver named
161 If the device is already attached and
164 the request will fail.
165 If the device is already attached and
168 the device will be detached from its current device driver before it is
169 attached to the new device driver.
172 .Fn devctl_clear_driver
173 function resets a device so that it can be attached to any valid device
174 driver rather than only drivers with a previously specified name.
175 This function is used to undo a previous call to
176 .Fn devctl_set_driver .
177 If the device is already attached and
180 the request will fail.
181 If the device is already attached and
184 the device will be detached from its current device driver.
185 After the device's name is reset,
186 it is reprobed and attached to a suitable device driver if one is found.
190 function rescans a bus device checking for devices that have been added or
193 .Rv -std devctl_attach devctl_clear_driver devctl_delete devctl_detach \
194 devctl_disable devctl_enable devctl_suspend devctl_rescan devctl_resume \
197 In addition to specific errors noted below,
200 functions may fail for any of the errors described in
205 The device name is too long.
207 No existing device matches the specified name or location.
209 The current process is not permitted to adjust the state of
215 function may fail if:
218 The device is already attached.
220 An internal memory allocation request failed.
222 The device is disabled.
224 No suitable driver for the device could be found,
225 or the driver failed to attach.
230 function may fail if:
233 The current device driver for
235 is busy and cannot detach at this time.
236 Note that some drivers may return this even if
240 The device is not attached to a driver.
242 The current device driver for
244 does not support detaching.
249 function may fail if:
252 The device is already enabled.
254 An internal memory allocation request failed.
256 No suitable driver for the device could be found,
257 or the driver failed to attach.
262 function may fail if:
265 The current device driver for
267 is busy and cannot detach at this time.
268 Note that some drivers may return this even if
272 The device is already disabled.
274 The current device driver for
276 does not support detaching.
281 function may fail if:
284 The device is already suspended.
286 The device to be suspended is the root bus device.
291 function may fail if:
294 The device is not suspended.
296 The device to be resumed is the root bus device.
300 .Fn devctl_set_driver
301 function may fail if:
304 The device is currently attached to a device driver and
308 The current device driver for
310 is busy and cannot detach at this time.
314 argument points outside the process' allocated address space.
316 No device driver with the requested name exists.
318 An internal memory allocation request failed.
320 The device is disabled.
322 The new device driver failed to attach.
326 .Fn devctl_clear_driver
327 function may fail if:
330 The device is currently attached to a device driver and
334 The current device driver for
336 is busy and cannot detach at this time.
338 The device is not configured for a specific device driver name.
340 The device driver chosen after reprobing failed to attach.
345 function may fail if:
348 The device is not attached to a driver.
350 The bus driver does not support rescanning.
355 function may fail if:
358 The device is physically present and
363 is the root device of the device tree.
372 library first appeared in
375 If a device is suspended individually via
377 and the entire machine is subsequently suspended,
378 the device will be resumed when the machine resumes.