2 .\" Copyright (c) 2014 John Baldwin <jhb@FreeBSD.org>
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .Nm devctl_clear_driver ,
41 .Nm devctl_set_driver ,
44 .Nd device control library
50 .Fn devctl_attach "const char *device"
52 .Fn devctl_clear_driver "const char *device" "bool force"
54 .Fn devctl_delete "const char *device" "bool force"
56 .Fn devctl_detach "const char *device" "bool force"
58 .Fn devctl_disable "const char *device" "bool force_detach"
60 .Fn devctl_enable "const char *device"
62 .Fn devctl_freeze "void"
64 .Fn devctl_rescan "const char *device"
66 .Fn devctl_resume "const char *device"
68 .Fn devctl_set_driver "const char *device" "const char *driver" "bool force"
70 .Fn devctl_suspend "const char *device"
72 .Fn devctl_thaw "void"
76 library adjusts the state of devices in the kernel's internal device
78 Each control operation accepts a
80 argument that identifies the device to adjust.
83 may be specified as either the name of an existing device or as a
85 The following bus-specific address formats are currently supported:
86 .Bl -tag -offset indent
87 .It Sy pci Ns Fa domain Ns : Ns Fa bus Ns : Ns Fa slot Ns : Ns Fa function
88 A PCI device with the specified
94 .It Sy pci Ns Fa bus Ns : Ns Fa slot Ns : Ns Fa function
95 A PCI device in domain zero with the specified
101 A device with an ACPI handle of
103 The handle must be specified as an absolute path and must begin with a
109 function probes a device and attaches a suitable device driver if one is
114 function detaches a device from its current device driver.
115 The device is left detached until either a new driver for its parent
116 bus is loaded or the device is explicitly probed via
121 the current device driver will be detached even if the device is busy.
125 function deletes a device from the device tree.
130 the device is deleted even if the device is physically present.
134 function disables a device.
135 If the device is currently attached to a device driver,
136 the device driver will be detached from the device,
137 but the device will retain its current name.
141 the current device driver will be detached even if the device is busy.
142 The device will remain disabled and detached until it is explicitly enabled
148 function re-enables a disabled device.
149 The device will probe and attach if a suitable device driver is found.
153 function suspends a device.
154 This may include placing the device in a reduced power state,
155 but any device driver currently attached to the device will remain attached.
159 function resumes a suspended device to a fully working state.
162 .Fn devctl_set_driver
163 function attaches a device driver named
166 If the device is already attached and
169 the request will fail.
170 If the device is already attached and
173 the device will be detached from its current device driver before it is
174 attached to the new device driver.
177 .Fn devctl_clear_driver
178 function resets a device so that it can be attached to any valid device
179 driver rather than only drivers with a previously specified name.
180 This function is used to undo a previous call to
181 .Fn devctl_set_driver .
182 If the device is already attached and
185 the request will fail.
186 If the device is already attached and
189 the device will be detached from its current device driver.
190 After the device's name is reset,
191 it is reprobed and attached to a suitable device driver if one is found.
195 function rescans a bus device checking for devices that have been added or
200 function freezes probe and attach processing initiated in response to
201 drivers being loaded.
205 function resumes (thaws the freeze) probe and attach processing
206 initiated in response to drivers being loaded.
208 .Rv -std devctl_attach devctl_clear_driver devctl_delete devctl_detach \
209 devctl_disable devctl_enable devctl_suspend devctl_rescan devctl_resume \
212 In addition to specific errors noted below,
215 functions may fail for any of the errors described in
220 The device name is too long.
222 No existing device matches the specified name or location.
224 The current process is not permitted to adjust the state of
230 function may fail if:
233 The device is already attached.
235 An internal memory allocation request failed.
237 The device is disabled.
239 No suitable driver for the device could be found,
240 or the driver failed to attach.
245 function may fail if:
248 The current device driver for
250 is busy and cannot detach at this time.
251 Note that some drivers may return this even if
255 The device is not attached to a driver.
257 The current device driver for
259 does not support detaching.
264 function may fail if:
267 The device is already enabled.
269 An internal memory allocation request failed.
271 No suitable driver for the device could be found,
272 or the driver failed to attach.
277 function may fail if:
280 The current device driver for
282 is busy and cannot detach at this time.
283 Note that some drivers may return this even if
287 The device is already disabled.
289 The current device driver for
291 does not support detaching.
296 function may fail if:
299 The device is already suspended.
301 The device to be suspended is the root bus device.
306 function may fail if:
309 The device is not suspended.
311 The device to be resumed is the root bus device.
315 .Fn devctl_set_driver
316 function may fail if:
319 The device is currently attached to a device driver and
323 The current device driver for
325 is busy and cannot detach at this time.
329 argument points outside the process' allocated address space.
331 No device driver with the requested name exists.
333 An internal memory allocation request failed.
335 The device is disabled.
337 The new device driver failed to attach.
341 .Fn devctl_clear_driver
342 function may fail if:
345 The device is currently attached to a device driver and
349 The current device driver for
351 is busy and cannot detach at this time.
353 The device is not configured for a specific device driver name.
355 The device driver chosen after reprobing failed to attach.
360 function may fail if:
363 The device is not attached to a driver.
365 The bus driver does not support rescanning.
370 function may fail if:
373 The device is physically present and
378 is the root device of the device tree.
387 library first appeared in
390 If a device is suspended individually via
392 and the entire machine is subsequently suspended,
393 the device will be resumed when the machine resumes.