diff options
author | John Baldwin <jhb@FreeBSD.org> | 2015-02-06 16:09:01 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2015-02-06 16:09:01 +0000 |
commit | 64de80195bba295c961a4cdf96dbe0e4979bdf2a (patch) | |
tree | c5571a1caff25473e47bc9c6a9b8b5a332646e70 /sys/kern/subr_hints.c | |
parent | b01589c956fab839123e07a0551d344fac67e7f3 (diff) | |
download | src-64de80195bba295c961a4cdf96dbe0e4979bdf2a.tar.gz src-64de80195bba295c961a4cdf96dbe0e4979bdf2a.zip |
Add a new device control utility for new-bus devices called devctl. This
allows the user to request administrative changes to individual devices
such as attach or detaching drivers or disabling and re-enabling devices.
- Add a new /dev/devctl2 character device which uses ioctls for device
requests. The ioctls use a common 'struct devreq' which is somewhat
similar to 'struct ifreq'.
- The ioctls identify the device to operate on via a string. This
string can either by the device's name, or it can be a bus-specific
address. (For unattached devices, a bus address is the only way to
locate a device.) Bus drivers register an eventhandler to claim
unrecognized device names that the driver recognizes as a valid address.
Two buses currently support addresses: ACPI recognizes any device
in the ACPI namespace via its full path starting with "\" and
the PCI bus driver recognizes an address specification of
'pci[<domain>:]<bus>:<slot>:<func>' (identical to the PCI selector
strings supported by pciconf).
- To make it easier to cut and paste, change the PnP location string
in the PCI bus driver to output a full PCI selector string rather
than 'slot=<slot> function=<func>'.
- Add a devctl(3) interface in libdevctl which provides a wrapper around
the ioctls and is the preferred interface for other userland code.
- Add a devctl(8) program which is a simple wrapper around the requests
supported by devctl(3).
- Add a device_is_suspended() function to check DF_SUSPENDED.
- Add a resource_unset_value() function that can be used to remove a
hint from the kernel environment. This is used to clear a
hint.<driver>.<unit>.disabled hint when re-enabling a boot-time
disabled device.
Reviewed by: imp (parts)
Requested by: imp (changing PCI location string)
Relnotes: yes
Notes
Notes:
svn path=/head/; revision=278320
Diffstat (limited to 'sys/kern/subr_hints.c')
-rw-r--r-- | sys/kern/subr_hints.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/sys/kern/subr_hints.c b/sys/kern/subr_hints.c index 25838ee34136..00cfbf1bfb88 100644 --- a/sys/kern/subr_hints.c +++ b/sys/kern/subr_hints.c @@ -461,3 +461,31 @@ resource_disabled(const char *name, int unit) return (0); return (value); } + +/* + * Clear a value associated with a device by removing it from + * the kernel environment. This only removes a hint for an + * exact unit. + */ +int +resource_unset_value(const char *name, int unit, const char *resname) +{ + char varname[128]; + const char *retname, *retvalue; + int error, line; + size_t len; + + line = 0; + error = resource_find(&line, NULL, name, &unit, resname, NULL, + &retname, NULL, NULL, NULL, NULL, &retvalue); + if (error) + return (error); + + retname -= strlen("hint."); + len = retvalue - retname - 1; + if (len > sizeof(varname) - 1) + return (ENAMETOOLONG); + memcpy(varname, retname, len); + varname[len] = '\0'; + return (kern_unsetenv(varname)); +} |