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 .Nm devctl_set_driver ,
40 .Nd device control library
46 .Fn devctl_attach "const char *device"
48 .Fn devctl_detach "const char *device" "bool force"
50 .Fn devctl_disable "const char *device" "bool force_detach"
52 .Fn devctl_enable "const char *device"
54 .Fn devctl_resume "const char *device"
56 .Fn devctl_set_driver "const char *device" "const char *driver" "bool force"
58 .Fn devctl_suspend "const char *device"
62 library adjusts the state of devices in the kernel's internal device
64 Each control operation accepts a
66 argument that identifies the device to adjust.
69 may be specified as either the name of an existing device or as a
71 The following bus-specific address formats are currently supported:
72 .Bl -tag -offset indent
73 .It Sy pci Ns Fa domain Ns : Ns Fa bus Ns : Ns Fa slot Ns : Ns Fa function
74 A PCI device with the specified
80 .It Sy pci Ns Fa bus Ns : Ns Fa slot Ns : Ns Fa function
81 A PCI device in domain zero with the specified
87 A device with an ACPI handle of
89 The handle must be specified as an absolute path and must begin with a
95 function probes a device and attaches a suitable device driver if one is
100 function detaches a device from its current device driver.
101 The device is left detached until either a new driver for its parent
102 bus is loaded or the device is explicitly probed via
107 the current device driver will be detached even if the device is busy.
111 function disables a device.
112 If the device is currently attached to a device driver,
113 the device driver will be detached from the device,
114 but the device will retain its current name.
118 the current device driver will be detached even if the device is busy.
119 The device will remain disabled and detached until it is explicitly enabled
125 function re-enables a disabled device.
126 The device will probe and attach if a suitable device driver is found.
130 function suspends a device.
131 This may include placing the device in a reduced power state,
132 but any device driver currently attached to the device will remain attached.
136 function resumes a suspended device to a fully working state.
139 .Fn devctl_set_driver
140 function attaches a device driver named
143 If the device is already attached and
146 the request will fail.
147 If the device is already attached and
150 the device will be detached from its current device driver before it is
151 attached to the new device driver.
153 .Rv -std devctl_attach devctl_detach devctl_disable devctl_enable \
154 devctl_suspend devctl_resume devctl_set_driver
156 In addition to specific errors noted below,
159 functions may fail for any of the errors described in
164 The device name is too long.
166 No existing device matches the specified name or location.
168 The current process is not permitted to adjust the state of
174 function may fail if:
177 The device is already attached.
179 An internal memory allocation request failed.
181 The device is disabled.
183 No suitable driver for the device could be found,
184 or the driver failed to attach.
189 function may fail if:
192 The current device driver for
194 is busy and cannot detach at this time.
195 Note that some drivers may return this even if
199 The device is not attached to a driver.
201 The current device driver for
203 does not support detaching.
208 function may fail if:
211 The device is already enabled.
213 An internal memory allocation request failed.
215 No suitable driver for the device could be found,
216 or the driver failed to attach.
221 function may fail if:
224 The current device driver for
226 is busy and cannot detach at this time.
227 Note that some drivers may return this even if
231 The device is already disabled.
233 The current device driver for
235 does not support detaching.
240 function may fail if:
243 The device is already suspended.
245 The device to be suspended is the root bus device.
250 function may fail if:
253 The device is not suspended.
255 The device to be resumed is the root bus device.
259 .Fn devctl_set_driver
260 function may fail if:
263 The device is currently attached to a device driver and
267 The current device driver for
269 is busy and cannot detach at this time.
273 argument points outside the process' allocated address space.
275 No device driver with the requested name exists.
277 An internal memory allocation request failed.
279 The device is disabled.
281 The new device driver failed to attach.
290 library first appeared in
293 If a device is suspended individually via
295 and the entire machine is subsequently suspended,
296 the device will be resumed when the machine resumes.