cfdata_t
config_search_loc(
cfsubmatch_t func
, device_t parent
, const char *ia
, const int *locs
, void *aux
)
cfdata_t
config_search_ia(
cfsubmatch_t func
, device_t parent
, const char *ia
, void *aux
)
device_t
config_found_sm_loc(
device_t parent
, const char *ia
, const int *locs
, void *aux
, cfprint_t print
, cfsubmatch_t submatch
)
device_t
config_found_ia(
device_t parent
, const char *ia
, void *aux
, cfprint_t print
)
device_t
config_found(
device_t parent
, void *aux
, cfprint_t print
)
int
config_match(
device_t parent
, cfdata_t cf
, void *aux
)
device_t
config_attach_loc(
device_t parent
, cfdata_t cf
, const int *locs
, void *aux
, cfprint_t print
)
device_t
config_attach(
device_t parent
, cfdata_t cf
, void *aux
, cfprint_t print
)
device_t
config_attach_pseudo(
cfdata_t cf
)
int
config_detach(
device_t dev
, int flags
)
int
config_activate(
device_t dev
)
int
config_deactivate(
device_t dev
)
int
config_defer(
device_t dev
, void (*func)(device_t)
)
void
config_interrupts(
device_t dev
, void (*func)(device_t)
)
void
config_pending_incr(
)
void
config_pending_decr(
)
int
config_finalize_register(
device_t dev
, int (*func)(device_t)
)
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(1). For a description of the config(1) ``device definition'' language, see config(9).
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.
func
, parent
, ia
, locs
, aux
)
)
iterates over all potential children, calling the given
function
func
for each one.
If
func
is
NULL
,
config_search_loc(
)
applies each child's match function instead.
The argument
parent
is the pointer to the parent's device structure.
The argument
ia
is the interface attribute on which the potential children should attach.
It can be
NULL
,
in which case all children attaching to any attribute are considered.
The
locs
argument lists the locator values for the device and are passed to function
func
.
The given
aux
argument describes the device that has been found and is simply passed
on through
func
to the child.
config_search_loc(
)
returns a pointer to the best-matched child or
NULL
otherwise.
The role of
func
is to call
the match function for each device and call
config_attach_loc()
for any positive matches.
If
func
is
NULL
,
then the parent should record the return value from
config_search_loc()
and call
config_attach_loc(
)
itself.
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.
func
, parent
, ia
, aux
)
func
, parent
, ia
, locs
, aux
)
with
locs
set to
NULL
.
parent
, ia
, locs
, aux
, print
, submatch
)
)
is called by the parent and in turn calls the
submatch
function to call the match function as
determined by the configuration table.
If
submatch
is
NULL
,
the driver match functions are called directly.
The argument
parent
is the pointer to the parent's device structure.
The argument
ia
is the name of the interface attribute on which the child will attach,
per
config(5)
syntax.
The argument
locs
lists the locator values for the device.
The given
aux
argument describes the device that has been found.
config_found_sm_loc(
)
internally uses
config_search_loc(
),
passing on
submatch
, ia
, locs
and
aux
.
The
softc
structure for the matched device will be allocated, and the
appropriate driver attach function will be called.
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 device, otherwise
NULL
.
The
print
function must return an integer value.
Two special strings, ``not configured'' and ``unsupported'' will be appended automatically to non-driver reports if the return value is UNCONF or UNSUPP respectively; otherwise the function should return the value QUIET.
config_found_sm_loc()
returns a pointer to the attached device's
softc
structure if the device is attached,
NULL
otherwise.
Most callers can ignore this value, since the system will already have
printed a diagnostic.
parent
, ia
, aux
, print
)
parent
, ia
, locs
, aux
, print
, submatch
)
with
locs
and
submatch
set to
NULL
.
It is provided for better source code readability with locator-less device
buses.
parent
, aux
, print
)
parent
, ia
, locs
, aux
, print
, submatch
)
with
ia
, locs
and
submatch
set to
NULL
and is provided for compatibility with older drivers.
New code should either make the interface attribute explicit or prefer an
indirect method based on
config_search_loc(
).
parent
, cf
, aux
)
)
function returns a nonzero integer indicating the confidence of
supporting this device and a value of 0 if the driver doesn't support
the device.
parent
, locs
, cf
, aux
, print
)
)
returns the
softc.
If unsuccessful, it returns
NULL
.
parent
, cf
, aux
, print
)
parent
, cf
, locs
, aux
, print
)
with
locs
set to
NULL
.
cf
)
device_t
instances can be created.
Such objects are similar to the devices that attach at the root of the device
tree.
The caller is expected to allocate and fill the
cfdata_t
object and pass it to
config_attach_pseudo().
The content of that object is similar to what is returned by
config_search_loc(
)
for regular devices.
dev
, flags
)
)
returns zero if successful and an error code otherwise.
config_detach(
)
is always called from a thread context, allowing condition variables
to be used while the device detaches itself.
dev
)
dev
.
It is called to activate resources and initialise other kernel
subsystems (such as the network subsystem).
config_activate(
)
is called from interrupt context after the device has been attached.
dev
)
dev
.
config_deactivate(
)
is called from interrupt context to immediately relinquish resources
and notify dependent kernel subsystems that the device is about to be
detached.
At some later point
config_detach(
)
will be called to finalise the removal of the device.
dev
, func
)
func
is called with the argument
dev
.
dev
, func
)
func
is called with the argument
dev
.
)
)
dev
, func
)Registered functions are all executed until all of them return 0. The callbacks should return 0 to indicate they do not require to be called another time, but they should be aware that they still might be in case one of them returns 1.
/usr/src
.
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
.