|autoconf(4/alpha)||diagnostics from the autoconfiguration code|
|autoconf(4/amd64)||diagnostics from the autoconfiguration code|
|autoconf(4/i386)||diagnostics from the autoconfiguration code|
|autoconf(4/loongson)||diagnostics from the autoconfiguration code|
|autoconf(4/luna88k)||diagnostics from the autoconfiguration code|
|autoconf(4/macppc)||diagnostics from the autoconfiguration code|
|autoconf(4/sparc64)||diagnostics from the autoconfiguration code|
|autoconf, config_search, config_found, config_found_sm, config_rootfound, config_rootsearch(9)||autoconfiguration framework|
|CONFIG_SEARCH(9)||Kernel Developer's Manual||CONFIG_SEARCH(9)|
func, struct device
struct device *
*parent, void *aux, cfprint_t
print, cfmatch_t submatch);
struct device *
device *parent, void
struct device *
Autoconfiguration is the process of matching hardware devices with an appropriate device driver. In its most basic form, autoconfiguration consists of the recursive process of finding and attaching all devices on a bus, including other buses.
The autoconfiguration framework supports direct configuration where the bus driver can determine the devices present.
The autoconfiguration framework also supports indirect configuration where the drivers must probe the bus looking for the presence of a device. Direct configuration is preferred since it can find hardware regardless of the presence of proper drivers.
The autoconfiguration process occurs at system bootstrap and is driven by a table generated from a “machine description” file by config(8). For a description of the config(8) “device definition” language, see files.conf(5).
Each device must have a name consisting of an alphanumeric string that ends with a unit number. The unit number identifies an instance of the driver. Device data structures are allocated dynamically during autoconfiguration, giving a unique address for each instance.
function performs indirect configuration of physical devices by iterating
over all potential children, calling the given function
func for each one.
function finds the root device identified by the string
rootname, in a manner similar to
config_search(), except that there is no parent
device. If func is
config_search() applies each child's match function
instead. The argument parent is the pointer to the
parent's device structure. The given aux argument
describes the device that has been found and is simply passed on through
func to the child.
config_search() returns a pointer to the
best-matched child or
The role of func is to call the match
function for each device and call
for any positive matches.
typedef int (*cfmatch_t)(struct device *parent, void *child, void *aux);
If func is
then the parent should record the return value from
Note that this function is designed so that it can be used to apply an arbitrary function to all potential children. In this case callers may choose to ignore the return value.
function performs direct configuration on a physical device.
config_found_sm() is called by the parent and in
turn calls the submatch function to call the match
function as determined by the configuration table. If
NULL, the driver
match functions are called directly. The argument
parent is the pointer to the parent's device
structure. The given aux argument describes the device
that has been found. The softc structure for the matched
device will be allocated, and the appropriate driver attach function will be
If the device is matched, the system prints the name of the child
and parent devices, and then calls the print function
to produce additional information if desired. If no driver takes a match,
the same print function is called to complain. The
print function is called with the aux argument and, if
the matches failed, the full name (including unit number) of the parent
typedef int (*cfprint_t)(void *aux, const char *parentname); #define QUIET 0 /* print nothing */ #define UNCONF 1 /* print " not configured" */ #define UNSUPP 2 /* print " not supported" */
Two special strings, “not configured” and
“unsupported” will be appended automatically to non-driver
reports if the return value is
UNSUPP respectively, otherwise the function should
return the value
function returns a pointer to the attached device's softc
structure if the device is attached,
Most callers can ignore this value, since the system will already have
printed a diagnostic.
macro expands to
submatch) with submatch set to
NULL and is provided for compatibility with older
function performs the same operation on the root device identified by the
The autoconfiguration framework itself is implemented within the file sys/kern/subr_autoconf.c. Data structures and function prototypes for the framework are located in sys/sys/device.h.
Autoconfiguration first appeared in 4.1BSD. The autoconfiguration framework was completely revised in 4.4BSD.
|April 18, 2018||OpenBSD-current|