config_search_loc(func, parent, ia, locs, aux)
Performs indirect configuration of physical devices.
config_search_loc() 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.
config_search_ia(func, parent, ia, aux)
This function is equivalent to calling config_search_loc(func, parent, ia, locs, aux) with locs set to NULL.
config_found_sm_loc(parent, ia, locs, aux, print, submatch)
Performs direct configuration on a physical device.
config_found_sm_loc() 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.
config_found_ia(parent, ia, aux, print)
This function is equivalent to calling config_found_sm_loc(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.
config_found(parent, aux, print)
This function is equivalent to calling config_found_sm_loc(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().
config_match(parent, cf, aux)
Match a device. Invokes the drivers match function according to the configuration table. The config_match() 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.
config_attach_loc(parent, locs, cf, aux, print)
Attach a found device. Allocates the memory for the softc structure and calls the drivers attach function according to the configuration table. If successful, config_attach_loc() returns the softc. If unsuccessful, it returns NULL.
config_attach(parent, cf, aux, print)
This function is equivalent to calling config_attach_loc(parent, cf, locs, aux, print) with locs set to NULL.
config_attach_pseudo(cf)
Create an instance of a pseudo-device driver.
config(5) syntax allows the creation of pseudo-devices from which regular
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.
config_detach(dev, flags)
Called by the parent to detach the child device. The second argument flags contains detachment flags. Valid values are DETACH_FORCE (force detachment (e.g., because of hardware removal)) and DETACH_QUIET (do not print a notice). config_detach() 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.
config_deactivate(dev)
Called by the parent to deactivate the child device 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.
config_defer(dev, func)
Called by the child to defer the remainder of its configuration until all its parent's devices have been attached. At this point, the function func is called with the argument dev.
config_interrupts(dev, func)
Called by the child to defer the remainder of its configuration until interrupts are enabled. At this point, the function func is called with the argument dev.
config_mountroot(dev, func)
Called by the child to defer the remainder of its configuration until the root file system is mounted. At this point, the function func is called with the argument dev. This is used for devices that need to load firmware image from a mounted file system.
config_pending_incr()
Increment the config_pending semaphore. It is used to account for deferred configurations before mounting the root file system.
config_pending_decr()
Decrement the config_pending semaphore. It is used to account for deferred configurations before mounting the root file system.
config_finalize_register(dev, func)
Register a function to be called after all real devices have been found.
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.