FreeBSD kernel kern code
subr_bus.c File Reference
#include <sys/cdefs.h>
#include "opt_bus.h"
#include "opt_ddb.h"
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/domainset.h>
#include <sys/eventhandler.h>
#include <sys/filio.h>
#include <sys/lock.h>
#include <sys/kernel.h>
#include <sys/kobj.h>
#include <sys/limits.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/mutex.h>
#include <sys/poll.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/condvar.h>
#include <sys/queue.h>
#include <machine/bus.h>
#include <sys/random.h>
#include <sys/refcount.h>
#include <sys/rman.h>
#include <sys/sbuf.h>
#include <sys/selinfo.h>
#include <sys/signalvar.h>
#include <sys/smp.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/uio.h>
#include <sys/bus.h>
#include <sys/cpuset.h>
#include <net/vnet.h>
#include <machine/cpu.h>
#include <machine/stdarg.h>
#include <vm/uma.h>
#include <vm/vm.h>
#include <ddb/ddb.h>
Include dependency graph for subr_bus.c:

Go to the source code of this file.

Data Structures

struct  driverlink
 
struct  _device
 Implementation of _device. More...
 
struct  dev_event_info
 
struct  dev_softc
 
struct  device_location_node
 

Macros

#define DL_DEFERRED_PROBE   1 /* Probe deferred on this */
 
#define DC_HAS_CHILDREN   1
 
#define DRIVERNAME(d)   ((d)? d->name : "no driver")
 
#define DEVCLANAME(d)   ((d)? d->name : "no devclass")
 
#define PDEBUG(a)   /* nop */
 
#define DEVICENAME(d)   /* nop */
 
#define print_device_short(d, i)   /* nop */
 
#define print_device(d, i)   /* nop */
 
#define print_device_tree_short(d, i)   /* nop */
 
#define print_device_tree(d, i)   /* nop */
 
#define print_driver_short(d, i)   /* nop */
 
#define print_driver(d, i)   /* nop */
 
#define print_driver_list(d, i)   /* nop */
 
#define print_devclass_short(d, i)   /* nop */
 
#define print_devclass(d, i)   /* nop */
 
#define print_devclass_list_short()   /* nop */
 
#define print_devclass_list()   /* nop */
 
#define DEVCTL_DEFAULT_QUEUE_LEN   1000
 
#define DEVCTL_BUFFER   (1024 - sizeof(void *))
 

Typedefs

typedef struct driverlinkdriverlink_t
 

Enumerations

enum  { DEVCLASS_SYSCTL_PARENT }
 
enum  {
  DEVICE_SYSCTL_DESC , DEVICE_SYSCTL_DRIVER , DEVICE_SYSCTL_LOCATION , DEVICE_SYSCTL_PNPINFO ,
  DEVICE_SYSCTL_PARENT
}
 

Functions

 __FBSDID ("$FreeBSD$")
 
 SYSCTL_NODE (_hw, OID_AUTO, bus, CTLFLAG_RW|CTLFLAG_MPSAFE, NULL, NULL)
 
 SYSCTL_ROOT_NODE (OID_AUTO, dev, CTLFLAG_RW|CTLFLAG_MPSAFE, NULL, NULL)
 
typedef TAILQ_HEAD (devclass_list, devclass)
 
static MALLOC_DEFINE (M_BUS, "bus", "Bus data structures")
 
static MALLOC_DEFINE (M_BUS_SC, "bus-sc", "Bus data structures, softc")
 
 EVENTHANDLER_LIST_DEFINE (device_attach)
 
 EVENTHANDLER_LIST_DEFINE (device_detach)
 
 EVENTHANDLER_LIST_DEFINE (dev_lookup)
 
static void devctl2_init (void)
 
static int devclass_sysctl_handler (SYSCTL_HANDLER_ARGS)
 
static void devclass_sysctl_init (devclass_t dc)
 
static int device_sysctl_handler (SYSCTL_HANDLER_ARGS)
 
static void device_sysctl_init (device_t dev)
 
static void device_sysctl_update (device_t dev)
 
static void device_sysctl_fini (device_t dev)
 
static int sysctl_devctl_queue (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_hw_bus, OID_AUTO, devctl_queue, CTLTYPE_INT|CTLFLAG_RWTUN|CTLFLAG_MPSAFE, NULL, 0, sysctl_devctl_queue, "I", "devctl queue length")
 
 STAILQ_HEAD (devq, dev_event_info)
 
static void filt_devctl_detach (struct knote *kn)
 
static int filt_devctl_read (struct knote *kn, long hint)
 
static void devinit (void)
 
static int devopen (struct cdev *dev, int oflags, int devtype, struct thread *td)
 
static int devclose (struct cdev *dev, int fflag, int devtype, struct thread *td)
 
static int devread (struct cdev *dev, struct uio *uio, int ioflag)
 
static int devioctl (struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
 
static int devpoll (struct cdev *dev, int events, struct thread *td)
 
static int devkqfilter (struct cdev *dev, struct knote *kn)
 
bool devctl_process_running (void)
 Return whether the userland process is running. More...
 
static struct dev_event_infodevctl_alloc_dei (void)
 
static struct dev_event_infodevctl_alloc_dei_sb (struct sbuf *sb)
 
static void devctl_free_dei (struct dev_event_info *dei)
 
static void devctl_queue (struct dev_event_info *dei)
 
void devctl_notify (const char *system, const char *subsystem, const char *type, const char *data)
 Send a 'notification' to userland, using standard ways. More...
 
static void devaddq (const char *type, const char *what, device_t dev)
 
static void devadded (device_t dev)
 
static void devremoved (device_t dev)
 
static void devnomatch (device_t dev)
 
void devctl_safe_quote_sb (struct sbuf *sb, const char *src)
 safely quotes strings that might have double quotes in them. More...
 
 DEFINE_CLASS (null, null_methods, 0)
 
void bus_topo_assert ()
 
struct mtxbus_topo_mtx (void)
 
void bus_topo_lock (void)
 
void bus_topo_unlock (void)
 
static void driver_register_pass (struct driverlink *new)
 Register the pass level of a new driver attachment. More...
 
void bus_set_pass (int pass)
 Raise the current bus pass. More...
 
static devclass_t devclass_find_internal (const char *classname, const char *parentname, int create)
 Find or create a device class. More...
 
devclass_t devclass_create (const char *classname)
 Create a device class. More...
 
devclass_t devclass_find (const char *classname)
 Find a device class. More...
 
static void devclass_driver_added (devclass_t dc, driver_t *driver)
 Register that a device driver has been added to a devclass. More...
 
int devclass_add_driver (devclass_t dc, driver_t *driver, int pass, devclass_t *dcp)
 Add a device driver to a device class. More...
 
static int devclass_driver_deleted (devclass_t busclass, devclass_t dc, driver_t *driver)
 Register that a device driver has been deleted from a devclass. More...
 
int devclass_delete_driver (devclass_t busclass, driver_t *driver)
 Delete a device driver from a device class. More...
 
static int devclass_quiesce_driver (devclass_t busclass, driver_t *driver)
 Quiesces a set of device drivers from a device class. More...
 
static driverlink_t devclass_find_driver_internal (devclass_t dc, const char *classname)
 
const char * devclass_get_name (devclass_t dc)
 Return the name of the devclass. More...
 
device_t devclass_get_device (devclass_t dc, int unit)
 Find a device given a unit number. More...
 
void * devclass_get_softc (devclass_t dc, int unit)
 Find the softc field of a device given a unit number. More...
 
int devclass_get_devices (devclass_t dc, device_t **devlistp, int *devcountp)
 Get a list of devices in the devclass. More...
 
int devclass_get_drivers (devclass_t dc, driver_t ***listp, int *countp)
 Get a list of drivers in the devclass. More...
 
int devclass_get_count (devclass_t dc)
 Get the number of devices in a devclass. More...
 
int devclass_get_maxunit (devclass_t dc)
 Get the maximum unit number used in a devclass. More...
 
int devclass_find_free_unit (devclass_t dc, int unit)
 Find a free unit number in a devclass. More...
 
void devclass_set_parent (devclass_t dc, devclass_t pdc)
 Set the parent of a devclass. More...
 
devclass_t devclass_get_parent (devclass_t dc)
 Get the parent of a devclass. More...
 
struct sysctl_ctx_list * devclass_get_sysctl_ctx (devclass_t dc)
 
struct sysctl_oid * devclass_get_sysctl_tree (devclass_t dc)
 
static int devclass_alloc_unit (devclass_t dc, device_t dev, int *unitp)
 Allocate a unit number. More...
 
static int devclass_add_device (devclass_t dc, device_t dev)
 Add a device to a devclass. More...
 
static int devclass_delete_device (devclass_t dc, device_t dev)
 Delete a device from a devclass. More...
 
static device_t make_device (device_t parent, const char *name, int unit)
 Make a new device and add it as a child of parent. More...
 
static int device_print_child (device_t dev, device_t child)
 Print a description of a device. More...
 
device_t device_add_child (device_t dev, const char *name, int unit)
 Create a new device. More...
 
device_t device_add_child_ordered (device_t dev, u_int order, const char *name, int unit)
 Create a new device. More...
 
int device_delete_child (device_t dev, device_t child)
 Delete a device. More...
 
int device_delete_children (device_t dev)
 Delete all children devices of the given device, if any. More...
 
device_t device_find_child (device_t dev, const char *classname, int unit)
 Find a device given a unit number. More...
 
static driverlink_t first_matching_driver (devclass_t dc, device_t dev)
 
static driverlink_t next_matching_driver (devclass_t dc, device_t dev, driverlink_t last)
 
int device_probe_child (device_t dev, device_t child)
 
device_t device_get_parent (device_t dev)
 Return the parent of a device. More...
 
int device_get_children (device_t dev, device_t **devlistp, int *devcountp)
 Get a list of children of a device. More...
 
driver_t * device_get_driver (device_t dev)
 Return the current driver for the device or NULL if there is no driver currently attached. More...
 
devclass_t device_get_devclass (device_t dev)
 Return the current devclass for the device or NULL if there is none. More...
 
const char * device_get_name (device_t dev)
 Return the name of the device's devclass or NULL if there is none. More...
 
const char * device_get_nameunit (device_t dev)
 Return a string containing the device's devclass name followed by an ascii representation of the device's unit number (e.g. "foo2"). More...
 
int device_get_unit (device_t dev)
 Return the device's unit number. More...
 
const char * device_get_desc (device_t dev)
 Return the device's description string. More...
 
uint32_t device_get_flags (device_t dev)
 Return the device's flags. More...
 
struct sysctl_ctx_list * device_get_sysctl_ctx (device_t dev)
 
struct sysctl_oid * device_get_sysctl_tree (device_t dev)
 
int device_print_prettyname (device_t dev)
 Print the name of the device followed by a colon and a space. More...
 
int device_printf (device_t dev, const char *fmt,...)
 Print the name of the device followed by a colon, a space and the result of calling vprintf() with the value of fmt and the following arguments. More...
 
int device_log (device_t dev, int pri, const char *fmt,...)
 Print the name of the device followed by a colon, a space and the result of calling log() with the value of fmt and the following arguments. More...
 
static void device_set_desc_internal (device_t dev, const char *desc, int copy)
 
void device_set_desc (device_t dev, const char *desc)
 Set the device's description. More...
 
void device_set_desc_copy (device_t dev, const char *desc)
 Set the device's description. More...
 
void device_set_flags (device_t dev, uint32_t flags)
 Set the device's flags. More...
 
void * device_get_softc (device_t dev)
 Return the device's softc field. More...
 
void device_set_softc (device_t dev, void *softc)
 Set the device's softc field. More...
 
void device_free_softc (void *softc)
 Free claimed softc. More...
 
void device_claim_softc (device_t dev)
 Claim softc. More...
 
void * device_get_ivars (device_t dev)
 Get the device's ivars field. More...
 
void device_set_ivars (device_t dev, void *ivars)
 Set the device's ivars field. More...
 
device_state_t device_get_state (device_t dev)
 Return the device's state. More...
 
void device_enable (device_t dev)
 Set the DF_ENABLED flag for the device. More...
 
void device_disable (device_t dev)
 Clear the DF_ENABLED flag for the device. More...
 
void device_busy (device_t dev)
 Increment the busy counter for the device. More...
 
void device_unbusy (device_t dev)
 Decrement the busy counter for the device. More...
 
void device_quiet (device_t dev)
 Set the DF_QUIET flag for the device. More...
 
void device_quiet_children (device_t dev)
 Set the DF_QUIET_CHILDREN flag for the device. More...
 
void device_verbose (device_t dev)
 Clear the DF_QUIET flag for the device. More...
 
ssize_t device_get_property (device_t dev, const char *prop, void *val, size_t sz, device_property_type_t type)
 
bool device_has_property (device_t dev, const char *prop)
 
int device_has_quiet_children (device_t dev)
 Return non-zero if the DF_QUIET_CHIDLREN flag is set on the device. More...
 
int device_is_quiet (device_t dev)
 Return non-zero if the DF_QUIET flag is set on the device. More...
 
int device_is_enabled (device_t dev)
 Return non-zero if the DF_ENABLED flag is set on the device. More...
 
int device_is_alive (device_t dev)
 Return non-zero if the device was successfully probed. More...
 
int device_is_attached (device_t dev)
 Return non-zero if the device currently has a driver attached to it. More...
 
int device_is_suspended (device_t dev)
 Return non-zero if the device is currently suspended. More...
 
int device_set_devclass (device_t dev, const char *classname)
 Set the devclass of a device. More...
 
int device_set_devclass_fixed (device_t dev, const char *classname)
 Set the devclass of a device and mark the devclass fixed. More...
 
bool device_is_devclass_fixed (device_t dev)
 Query the device to determine if it's of a fixed devclass. More...
 
int device_set_driver (device_t dev, driver_t *driver)
 Set the driver of a device. More...
 
int device_probe (device_t dev)
 Probe a device, and return this status. More...
 
int device_probe_and_attach (device_t dev)
 Probe a device and attach a driver if possible. More...
 
int device_attach (device_t dev)
 Attach a device driver to a device. More...
 
int device_detach (device_t dev)
 Detach a driver from a device. More...
 
int device_quiesce (device_t dev)
 Tells a driver to quiesce itself. More...
 
int device_shutdown (device_t dev)
 Notify a device of system shutdown. More...
 
int device_set_unit (device_t dev, int unit)
 Set the unit number of a device. More...
 
void resource_init_map_request_impl (struct resource_map_request *args, size_t sz)
 
void resource_list_init (struct resource_list *rl)
 Initialise a resource list. More...
 
void resource_list_free (struct resource_list *rl)
 Reclaim memory used by a resource list. More...
 
int resource_list_add_next (struct resource_list *rl, int type, rman_res_t start, rman_res_t end, rman_res_t count)
 Add a resource entry. More...
 
struct resource_list_entry * resource_list_add (struct resource_list *rl, int type, int rid, rman_res_t start, rman_res_t end, rman_res_t count)
 Add or modify a resource entry. More...
 
int resource_list_busy (struct resource_list *rl, int type, int rid)
 Determine if a resource entry is busy. More...
 
int resource_list_reserved (struct resource_list *rl, int type, int rid)
 Determine if a resource entry is reserved. More...
 
struct resource_list_entry * resource_list_find (struct resource_list *rl, int type, int rid)
 Find a resource entry by type and rid. More...
 
void resource_list_delete (struct resource_list *rl, int type, int rid)
 Delete a resource entry. More...
 
struct resource * resource_list_reserve (struct resource_list *rl, device_t bus, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
 Allocate a reserved resource. More...
 
struct resource * resource_list_alloc (struct resource_list *rl, device_t bus, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
 Helper function for implementing BUS_ALLOC_RESOURCE() More...
 
int resource_list_release (struct resource_list *rl, device_t bus, device_t child, int type, int rid, struct resource *res)
 Helper function for implementing BUS_RELEASE_RESOURCE() More...
 
int resource_list_release_active (struct resource_list *rl, device_t bus, device_t child, int type)
 Release all active resources of a given type. More...
 
int resource_list_unreserve (struct resource_list *rl, device_t bus, device_t child, int type, int rid)
 Fully release a reserved resource. More...
 
int resource_list_print_type (struct resource_list *rl, const char *name, int type, const char *format)
 Print a description of resources in a resource list. More...
 
void resource_list_purge (struct resource_list *rl)
 Releases all the resources in a list. More...
 
device_t bus_generic_add_child (device_t dev, u_int order, const char *name, int unit)
 
int bus_generic_probe (device_t dev)
 Helper function for implementing DEVICE_PROBE() More...
 
int bus_generic_attach (device_t dev)
 Helper function for implementing DEVICE_ATTACH() More...
 
int bus_delayed_attach_children (device_t dev)
 Helper function for delaying attaching children. More...
 
int bus_generic_detach (device_t dev)
 Helper function for implementing DEVICE_DETACH() More...
 
int bus_generic_shutdown (device_t dev)
 Helper function for implementing DEVICE_SHUTDOWN() More...
 
int bus_generic_suspend_child (device_t dev, device_t child)
 Default function for suspending a child device. More...
 
int bus_generic_resume_child (device_t dev, device_t child)
 Default function for resuming a child device. More...
 
int bus_generic_suspend (device_t dev)
 Helper function for implementing DEVICE_SUSPEND() More...
 
int bus_generic_resume (device_t dev)
 Helper function for implementing DEVICE_RESUME() More...
 
int bus_helper_reset_post (device_t dev, int flags)
 Helper function for implementing BUS_RESET_POST. More...
 
static void bus_helper_reset_prepare_rollback (device_t dev, device_t child, int flags)
 
int bus_helper_reset_prepare (device_t dev, int flags)
 Helper function for implementing BUS_RESET_PREPARE. More...
 
int bus_print_child_header (device_t dev, device_t child)
 Helper function for implementing BUS_PRINT_CHILD(). More...
 
int bus_print_child_footer (device_t dev, device_t child)
 Helper function for implementing BUS_PRINT_CHILD(). More...
 
int bus_print_child_domain (device_t dev, device_t child)
 Helper function for implementing BUS_PRINT_CHILD(). More...
 
int bus_generic_print_child (device_t dev, device_t child)
 Helper function for implementing BUS_PRINT_CHILD(). More...
 
int bus_generic_read_ivar (device_t dev, device_t child, int index, uintptr_t *result)
 Stub function for implementing BUS_READ_IVAR(). More...
 
int bus_generic_write_ivar (device_t dev, device_t child, int index, uintptr_t value)
 Stub function for implementing BUS_WRITE_IVAR(). More...
 
ssize_t bus_generic_get_property (device_t dev, device_t child, const char *propname, void *propvalue, size_t size, device_property_type_t type)
 Helper function for implementing BUS_GET_PROPERTY(). More...
 
struct resource_list * bus_generic_get_resource_list (device_t dev, device_t child)
 Stub function for implementing BUS_GET_RESOURCE_LIST(). More...
 
void bus_generic_driver_added (device_t dev, driver_t *driver)
 Helper function for implementing BUS_DRIVER_ADDED(). More...
 
void bus_generic_new_pass (device_t dev)
 Helper function for implementing BUS_NEW_PASS(). More...
 
int bus_generic_setup_intr (device_t dev, device_t child, struct resource *irq, int flags, driver_filter_t *filter, driver_intr_t *intr, void *arg, void **cookiep)
 Helper function for implementing BUS_SETUP_INTR(). More...
 
int bus_generic_teardown_intr (device_t dev, device_t child, struct resource *irq, void *cookie)
 Helper function for implementing BUS_TEARDOWN_INTR(). More...
 
int bus_generic_suspend_intr (device_t dev, device_t child, struct resource *irq)
 Helper function for implementing BUS_SUSPEND_INTR(). More...
 
int bus_generic_resume_intr (device_t dev, device_t child, struct resource *irq)
 Helper function for implementing BUS_RESUME_INTR(). More...
 
int bus_generic_adjust_resource (device_t dev, device_t child, int type, struct resource *r, rman_res_t start, rman_res_t end)
 Helper function for implementing BUS_ADJUST_RESOURCE(). More...
 
int bus_generic_translate_resource (device_t dev, int type, rman_res_t start, rman_res_t *newstart)
 
struct resource * bus_generic_alloc_resource (device_t dev, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
 Helper function for implementing BUS_ALLOC_RESOURCE(). More...
 
int bus_generic_release_resource (device_t dev, device_t child, int type, int rid, struct resource *r)
 Helper function for implementing BUS_RELEASE_RESOURCE(). More...
 
int bus_generic_activate_resource (device_t dev, device_t child, int type, int rid, struct resource *r)
 Helper function for implementing BUS_ACTIVATE_RESOURCE(). More...
 
int bus_generic_deactivate_resource (device_t dev, device_t child, int type, int rid, struct resource *r)
 Helper function for implementing BUS_DEACTIVATE_RESOURCE(). More...
 
int bus_generic_map_resource (device_t dev, device_t child, int type, struct resource *r, struct resource_map_request *args, struct resource_map *map)
 Helper function for implementing BUS_MAP_RESOURCE(). More...
 
int bus_generic_unmap_resource (device_t dev, device_t child, int type, struct resource *r, struct resource_map *map)
 Helper function for implementing BUS_UNMAP_RESOURCE(). More...
 
int bus_generic_bind_intr (device_t dev, device_t child, struct resource *irq, int cpu)
 Helper function for implementing BUS_BIND_INTR(). More...
 
int bus_generic_config_intr (device_t dev, int irq, enum intr_trigger trig, enum intr_polarity pol)
 Helper function for implementing BUS_CONFIG_INTR(). More...
 
int bus_generic_describe_intr (device_t dev, device_t child, struct resource *irq, void *cookie, const char *descr)
 Helper function for implementing BUS_DESCRIBE_INTR(). More...
 
int bus_generic_get_cpus (device_t dev, device_t child, enum cpu_sets op, size_t setsize, cpuset_t *cpuset)
 Helper function for implementing BUS_GET_CPUS(). More...
 
bus_dma_tag_t bus_generic_get_dma_tag (device_t dev, device_t child)
 Helper function for implementing BUS_GET_DMA_TAG(). More...
 
bus_space_tag_t bus_generic_get_bus_tag (device_t dev, device_t child)
 Helper function for implementing BUS_GET_BUS_TAG(). More...
 
int bus_generic_rl_get_resource (device_t dev, device_t child, int type, int rid, rman_res_t *startp, rman_res_t *countp)
 Helper function for implementing BUS_GET_RESOURCE(). More...
 
int bus_generic_rl_set_resource (device_t dev, device_t child, int type, int rid, rman_res_t start, rman_res_t count)
 Helper function for implementing BUS_SET_RESOURCE(). More...
 
void bus_generic_rl_delete_resource (device_t dev, device_t child, int type, int rid)
 Helper function for implementing BUS_DELETE_RESOURCE(). More...
 
int bus_generic_rl_release_resource (device_t dev, device_t child, int type, int rid, struct resource *r)
 Helper function for implementing BUS_RELEASE_RESOURCE(). More...
 
struct resource * bus_generic_rl_alloc_resource (device_t dev, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
 Helper function for implementing BUS_ALLOC_RESOURCE(). More...
 
int bus_generic_child_present (device_t dev, device_t child)
 Helper function for implementing BUS_CHILD_PRESENT(). More...
 
int bus_generic_get_domain (device_t dev, device_t child, int *domain)
 
int bus_generic_get_device_path (device_t bus, device_t child, const char *locator, struct sbuf *sb)
 Helper function to implement normal BUS_GET_DEVICE_PATH() More...
 
int bus_null_rescan (device_t dev)
 Helper function for implementing BUS_RESCAN(). More...
 
int bus_alloc_resources (device_t dev, struct resource_spec *rs, struct resource **res)
 
void bus_release_resources (device_t dev, const struct resource_spec *rs, struct resource **res)
 
struct resource * bus_alloc_resource (device_t dev, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
 Wrapper function for BUS_ALLOC_RESOURCE(). More...
 
int bus_adjust_resource (device_t dev, int type, struct resource *r, rman_res_t start, rman_res_t end)
 Wrapper function for BUS_ADJUST_RESOURCE(). More...
 
int bus_translate_resource (device_t dev, int type, rman_res_t start, rman_res_t *newstart)
 Wrapper function for BUS_TRANSLATE_RESOURCE(). More...
 
int bus_activate_resource (device_t dev, int type, int rid, struct resource *r)
 Wrapper function for BUS_ACTIVATE_RESOURCE(). More...
 
int bus_deactivate_resource (device_t dev, int type, int rid, struct resource *r)
 Wrapper function for BUS_DEACTIVATE_RESOURCE(). More...
 
int bus_map_resource (device_t dev, int type, struct resource *r, struct resource_map_request *args, struct resource_map *map)
 Wrapper function for BUS_MAP_RESOURCE(). More...
 
int bus_unmap_resource (device_t dev, int type, struct resource *r, struct resource_map *map)
 Wrapper function for BUS_UNMAP_RESOURCE(). More...
 
int bus_release_resource (device_t dev, int type, int rid, struct resource *r)
 Wrapper function for BUS_RELEASE_RESOURCE(). More...
 
int bus_setup_intr (device_t dev, struct resource *r, int flags, driver_filter_t filter, driver_intr_t handler, void *arg, void **cookiep)
 Wrapper function for BUS_SETUP_INTR(). More...
 
int bus_teardown_intr (device_t dev, struct resource *r, void *cookie)
 Wrapper function for BUS_TEARDOWN_INTR(). More...
 
int bus_suspend_intr (device_t dev, struct resource *r)
 Wrapper function for BUS_SUSPEND_INTR(). More...
 
int bus_resume_intr (device_t dev, struct resource *r)
 Wrapper function for BUS_RESUME_INTR(). More...
 
int bus_bind_intr (device_t dev, struct resource *r, int cpu)
 Wrapper function for BUS_BIND_INTR(). More...
 
int bus_describe_intr (device_t dev, struct resource *irq, void *cookie, const char *fmt,...)
 Wrapper function for BUS_DESCRIBE_INTR(). More...
 
int bus_set_resource (device_t dev, int type, int rid, rman_res_t start, rman_res_t count)
 Wrapper function for BUS_SET_RESOURCE(). More...
 
int bus_get_resource (device_t dev, int type, int rid, rman_res_t *startp, rman_res_t *countp)
 Wrapper function for BUS_GET_RESOURCE(). More...
 
rman_res_t bus_get_resource_start (device_t dev, int type, int rid)
 Wrapper function for BUS_GET_RESOURCE(). More...
 
rman_res_t bus_get_resource_count (device_t dev, int type, int rid)
 Wrapper function for BUS_GET_RESOURCE(). More...
 
void bus_delete_resource (device_t dev, int type, int rid)
 Wrapper function for BUS_DELETE_RESOURCE(). More...
 
int bus_child_present (device_t child)
 Wrapper function for BUS_CHILD_PRESENT(). More...
 
int bus_child_pnpinfo (device_t child, struct sbuf *sb)
 Wrapper function for BUS_CHILD_PNPINFO(). More...
 
int bus_generic_child_pnpinfo (device_t dev, device_t child, struct sbuf *sb)
 Generic implementation that does nothing for bus_child_pnpinfo. More...
 
int bus_child_location (device_t child, struct sbuf *sb)
 Wrapper function for BUS_CHILD_LOCATION(). More...
 
int bus_generic_child_location (device_t dev, device_t child, struct sbuf *sb)
 Generic implementation that does nothing for bus_child_location. More...
 
int bus_get_cpus (device_t dev, enum cpu_sets op, size_t setsize, cpuset_t *cpuset)
 Wrapper function for BUS_GET_CPUS(). More...
 
bus_dma_tag_t bus_get_dma_tag (device_t dev)
 Wrapper function for BUS_GET_DMA_TAG(). More...
 
bus_space_tag_t bus_get_bus_tag (device_t dev)
 Wrapper function for BUS_GET_BUS_TAG(). More...
 
int bus_get_domain (device_t dev, int *domain)
 Wrapper function for BUS_GET_DOMAIN(). More...
 
static int root_resume (device_t dev)
 
static int root_print_child (device_t dev, device_t child)
 
static int root_setup_intr (device_t dev, device_t child, struct resource *irq, int flags, driver_filter_t *filter, driver_intr_t *intr, void *arg, void **cookiep)
 
static int root_child_present (device_t dev, device_t child)
 
static int root_get_cpus (device_t dev, device_t child, enum cpu_sets op, size_t setsize, cpuset_t *cpuset)
 
static int root_bus_module_handler (module_t mod, int what, void *arg)
 
 DECLARE_MODULE (rootbus, root_bus_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST)
 
void root_bus_configure (void)
 Automatically configure devices. More...
 
int driver_module_handler (module_t mod, int what, void *arg)
 Module handler for registering device drivers. More...
 
void bus_enumerate_hinted_children (device_t bus)
 Enumerate all hinted devices for this bus. More...
 
static int sysctl_bus_info (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_hw_bus, OID_AUTO, info, CTLTYPE_STRUCT|CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, 0, sysctl_bus_info, "S,u_businfo", "bus-related data")
 
static int sysctl_devices (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_NODE (_hw_bus, OID_AUTO, devices, CTLFLAG_RD|CTLFLAG_NEEDGIANT, sysctl_devices, "system device tree")
 
int bus_data_generation_check (int generation)
 
void bus_data_generation_update (void)
 
int bus_free_resource (device_t dev, int type, struct resource *r)
 
device_t device_lookup_by_name (const char *name)
 
static int find_device (struct devreq *req, device_t *devp)
 
static bool driver_exists (device_t bus, const char *driver)
 
static void device_gen_nomatch (device_t dev)
 
static void device_do_deferred_actions (void)
 
static char * device_get_path (device_t dev, const char *locator)
 
static int devctl2_ioctl (struct cdev *cdev, u_long cmd, caddr_t data, int fflag, struct thread *td)
 
typedef TAILQ_HEAD (device_location_list, device_location_node)
 
device_location_cache_t * dev_wired_cache_init (void)
 
void dev_wired_cache_fini (device_location_cache_t *dcp)
 
static struct device_location_nodedev_wired_cache_lookup (device_location_cache_t *dcp, const char *locator)
 
static struct device_location_nodedev_wired_cache_add (device_location_cache_t *dcp, const char *locator, const char *path)
 
bool dev_wired_cache_match (device_location_cache_t *dcp, device_t dev, const char *at)
 
 SYSCTL_INT (_debug, OID_AUTO, obsolete_panic, CTLFLAG_RWTUN, &obsolete_panic, 0, "Panic when obsolete features are used (0 = never, 1 = if obsolete, " "2 = if deprecated)")
 
static void gone_panic (int major, int running, const char *msg)
 
void _gone_in (int major, const char *msg)
 
void _gone_in_dev (device_t dev, int major, const char *msg)
 

Variables

static bool device_frozen
 
static int devctl_queue_length = DEVCTL_DEFAULT_QUEUE_LEN
 
static d_open_t devopen
 
static d_close_t devclose
 
static d_read_t devread
 
static d_ioctl_t devioctl
 
static d_poll_t devpoll
 
static d_kqfilter_t devkqfilter
 
static struct cdevsw dev_cdevsw
 
static struct dev_softc devsoftc
 
struct filterops devctl_rfiltops
 
static struct cdev * devctl_dev
 
static struct device_list bus_data_devices
 
static int bus_data_generation = 1
 
static kobj_method_t null_methods []
 
static driver_list_t passes = TAILQ_HEAD_INITIALIZER(passes)
 
int bus_current_pass = BUS_PASS_ROOT
 
static devclass_list_t devclasses = TAILQ_HEAD_INITIALIZER(devclasses)
 
static kobj_method_t root_methods []
 
static driver_t root_driver
 
device_t root_bus
 
devclass_t root_devclass
 
static moduledata_t root_bus_mod
 
static struct cdevsw devctl2_cdevsw
 
static int obsolete_panic = 0
 

Macro Definition Documentation

◆ DC_HAS_CHILDREN

#define DC_HAS_CHILDREN   1

◆ DEVCLANAME

#define DEVCLANAME (   d)    ((d)? d->name : "no devclass")

Definition at line 167 of file subr_bus.c.

◆ DEVCTL_BUFFER

#define DEVCTL_BUFFER   (1024 - sizeof(void *))

Definition at line 399 of file subr_bus.c.

◆ DEVCTL_DEFAULT_QUEUE_LEN

#define DEVCTL_DEFAULT_QUEUE_LEN   1000

Definition at line 375 of file subr_bus.c.

◆ DEVICENAME

#define DEVICENAME (   d)    /* nop */

Definition at line 198 of file subr_bus.c.

◆ DL_DEFERRED_PROBE

#define DL_DEFERRED_PROBE   1 /* Probe deferred on this */

◆ DRIVERNAME

#define DRIVERNAME (   d)    ((d)? d->name : "no driver")

Definition at line 166 of file subr_bus.c.

◆ PDEBUG

#define PDEBUG (   a)    /* nop */

Definition at line 197 of file subr_bus.c.

◆ print_devclass

#define print_devclass (   d,
 
)    /* nop */

Definition at line 208 of file subr_bus.c.

◆ print_devclass_list

#define print_devclass_list ( )    /* nop */

Definition at line 210 of file subr_bus.c.

◆ print_devclass_list_short

#define print_devclass_list_short ( )    /* nop */

Definition at line 209 of file subr_bus.c.

◆ print_devclass_short

#define print_devclass_short (   d,
 
)    /* nop */

Definition at line 207 of file subr_bus.c.

◆ print_device

#define print_device (   d,
 
)    /* nop */

Definition at line 201 of file subr_bus.c.

◆ print_device_short

#define print_device_short (   d,
 
)    /* nop */

Definition at line 200 of file subr_bus.c.

◆ print_device_tree

#define print_device_tree (   d,
 
)    /* nop */

Definition at line 203 of file subr_bus.c.

◆ print_device_tree_short

#define print_device_tree_short (   d,
 
)    /* nop */

Definition at line 202 of file subr_bus.c.

◆ print_driver

#define print_driver (   d,
 
)    /* nop */

Definition at line 205 of file subr_bus.c.

◆ print_driver_list

#define print_driver_list (   d,
 
)    /* nop */

Definition at line 206 of file subr_bus.c.

◆ print_driver_short

#define print_driver_short (   d,
 
)    /* nop */

Definition at line 204 of file subr_bus.c.

Typedef Documentation

◆ driverlink_t

typedef struct driverlink* driverlink_t

Definition at line 84 of file subr_bus.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
DEVCLASS_SYSCTL_PARENT 

Definition at line 217 of file subr_bus.c.

◆ anonymous enum

anonymous enum
Enumerator
DEVICE_SYSCTL_DESC 
DEVICE_SYSCTL_DRIVER 
DEVICE_SYSCTL_LOCATION 
DEVICE_SYSCTL_PNPINFO 
DEVICE_SYSCTL_PARENT 

Definition at line 253 of file subr_bus.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ _gone_in()

void _gone_in ( int  major,
const char *  msg 
)

Definition at line 6259 of file subr_bus.c.

References gone_panic(), and printf().

Here is the call graph for this function:

◆ _gone_in_dev()

void _gone_in_dev ( device_t  dev,
int  major,
const char *  msg 
)

Definition at line 6270 of file subr_bus.c.

References device_printf(), and gone_panic().

Here is the call graph for this function:

◆ bus_activate_resource()

int bus_activate_resource ( device_t  dev,
int  type,
int  rid,
struct resource *  r 
)

Wrapper function for BUS_ACTIVATE_RESOURCE().

This function simply calls the BUS_ACTIVATE_RESOURCE() method of the parent of dev.

Definition at line 4818 of file subr_bus.c.

References type.

Referenced by resource_list_alloc().

Here is the caller graph for this function:

◆ bus_adjust_resource()

int bus_adjust_resource ( device_t  dev,
int  type,
struct resource *  r,
rman_res_t  start,
rman_res_t  end 
)

Wrapper function for BUS_ADJUST_RESOURCE().

This function simply calls the BUS_ADJUST_RESOURCE() method of the parent of dev.

Definition at line 4788 of file subr_bus.c.

References start, and type.

◆ bus_alloc_resource()

struct resource * bus_alloc_resource ( device_t  dev,
int  type,
int *  rid,
rman_res_t  start,
rman_res_t  end,
rman_res_t  count,
u_int  flags 
)

Wrapper function for BUS_ALLOC_RESOURCE().

This function simply calls the BUS_ALLOC_RESOURCE() method of the parent of dev.

Definition at line 4769 of file subr_bus.c.

References count, flags, res, start, and type.

◆ bus_alloc_resources()

int bus_alloc_resources ( device_t  dev,
struct resource_spec *  rs,
struct resource **  res 
)

Definition at line 4730 of file subr_bus.c.

References bus_release_resources(), flags, res, and type.

Here is the call graph for this function:

◆ bus_bind_intr()

int bus_bind_intr ( device_t  dev,
struct resource *  r,
int  cpu 
)

Wrapper function for BUS_BIND_INTR().

This function simply calls the BUS_BIND_INTR() method of the parent of dev.

Definition at line 4958 of file subr_bus.c.

Referenced by taskqgroup_attach(), and taskqgroup_attach_cpu().

Here is the caller graph for this function:

◆ bus_child_location()

int bus_child_location ( device_t  child,
struct sbuf *  sb 
)

Wrapper function for BUS_CHILD_LOCATION().

This function simply calls the BUS_CHILD_LOCATION() method of the parent of dev.

Definition at line 5115 of file subr_bus.c.

References child, device_get_parent(), and parent.

Referenced by devaddq(), device_sysctl_handler(), and sysctl_devices().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bus_child_pnpinfo()

int bus_child_pnpinfo ( device_t  child,
struct sbuf *  sb 
)

Wrapper function for BUS_CHILD_PNPINFO().

This function simply calls the BUS_CHILD_PNPINFO() method of the parent of dev.

Definition at line 5086 of file subr_bus.c.

References child, device_get_parent(), and parent.

Referenced by devaddq(), device_sysctl_handler(), and sysctl_devices().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bus_child_present()

int bus_child_present ( device_t  child)

Wrapper function for BUS_CHILD_PRESENT().

This function simply calls the BUS_CHILD_PRESENT() method of the parent of dev.

Definition at line 5074 of file subr_bus.c.

References child, and device_get_parent().

Referenced by devctl2_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bus_data_generation_check()

int bus_data_generation_check ( int  generation)

Definition at line 5682 of file subr_bus.c.

References bus_data_generation.

Referenced by sysctl_devices(), and sysctl_rman().

Here is the caller graph for this function:

◆ bus_data_generation_update()

◆ bus_deactivate_resource()

int bus_deactivate_resource ( device_t  dev,
int  type,
int  rid,
struct resource *  r 
)

Wrapper function for BUS_DEACTIVATE_RESOURCE().

This function simply calls the BUS_DEACTIVATE_RESOURCE() method of the parent of dev.

Definition at line 4832 of file subr_bus.c.

References type.

Referenced by resource_list_release().

Here is the caller graph for this function:

◆ bus_delayed_attach_children()

int bus_delayed_attach_children ( device_t  dev)

Helper function for delaying attaching children.

Many buses can't run transactions on the bus which children need to probe and attach until after interrupts and/or timers are running. This function delays their attach until interrupts and timers are enabled.

Definition at line 3812 of file subr_bus.c.

References bus_generic_attach(), and config_intrhook_oneshot().

Here is the call graph for this function:

◆ bus_delete_resource()

void bus_delete_resource ( device_t  dev,
int  type,
int  rid 
)

Wrapper function for BUS_DELETE_RESOURCE().

This function simply calls the BUS_DELETE_RESOURCE() method of the parent of dev.

Definition at line 5062 of file subr_bus.c.

References device_get_parent(), and type.

Here is the call graph for this function:

◆ bus_describe_intr()

int bus_describe_intr ( device_t  dev,
struct resource *  irq,
void *  cookie,
const char *  fmt,
  ... 
)

Wrapper function for BUS_DESCRIBE_INTR().

This function first formats the requested description into a temporary buffer and then calls the BUS_DESCRIBE_INTR() method of the parent of dev.

Definition at line 4973 of file subr_bus.c.

References vsnprintf().

Here is the call graph for this function:

◆ bus_enumerate_hinted_children()

void bus_enumerate_hinted_children ( device_t  bus)

Enumerate all hinted devices for this bus.

Walks through the hints for this bus and calls the bus_hinted_child routine for each one it fines. It searches first for the specific bus that's being probed for hinted children (eg isa0), and then for generic children (eg isa).

Parameters
devbus device to enumerate

Definition at line 5410 of file subr_bus.c.

References bus, device_get_name(), device_get_nameunit(), and resource_find_match().

Here is the call graph for this function:

◆ bus_free_resource()

int bus_free_resource ( device_t  dev,
int  type,
struct resource *  r 
)

Definition at line 5698 of file subr_bus.c.

References bus_release_resource(), rman_get_rid(), and type.

Here is the call graph for this function:

◆ bus_generic_activate_resource()

int bus_generic_activate_resource ( device_t  dev,
device_t  child,
int  type,
int  rid,
struct resource *  r 
)

Helper function for implementing BUS_ACTIVATE_RESOURCE().

This simple implementation of BUS_ACTIVATE_RESOURCE() simply calls the BUS_ACTIVATE_RESOURCE() method of the parent of dev.

Definition at line 4362 of file subr_bus.c.

References child, and type.

◆ bus_generic_add_child()

device_t bus_generic_add_child ( device_t  dev,
u_int  order,
const char *  name,
int  unit 
)

Definition at line 3748 of file subr_bus.c.

References device_add_child_ordered(), and name.

Here is the call graph for this function:

◆ bus_generic_adjust_resource()

int bus_generic_adjust_resource ( device_t  dev,
device_t  child,
int  type,
struct resource *  r,
rman_res_t  start,
rman_res_t  end 
)

Helper function for implementing BUS_ADJUST_RESOURCE().

This simple implementation of BUS_ADJUST_RESOURCE() simply calls the BUS_ADJUST_RESOURCE() method of the parent of dev.

Definition at line 4293 of file subr_bus.c.

References child, start, and type.

◆ bus_generic_alloc_resource()

struct resource * bus_generic_alloc_resource ( device_t  dev,
device_t  child,
int  type,
int *  rid,
rman_res_t  start,
rman_res_t  end,
rman_res_t  count,
u_int  flags 
)

Helper function for implementing BUS_ALLOC_RESOURCE().

This simple implementation of BUS_ALLOC_RESOURCE() simply calls the BUS_ALLOC_RESOURCE() method of the parent of dev.

Definition at line 4328 of file subr_bus.c.

References child, count, flags, start, and type.

◆ bus_generic_attach()

int bus_generic_attach ( device_t  dev)

Helper function for implementing DEVICE_ATTACH()

This function can be used to help implement the DEVICE_ATTACH() for a bus. It calls device_probe_and_attach() for each of the device's children.

Definition at line 3793 of file subr_bus.c.

References child, and device_probe_and_attach().

Referenced by bus_delayed_attach_children().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bus_generic_bind_intr()

int bus_generic_bind_intr ( device_t  dev,
device_t  child,
struct resource *  irq,
int  cpu 
)

Helper function for implementing BUS_BIND_INTR().

This simple implementation of BUS_BIND_INTR() simply calls the BUS_BIND_INTR() method of the parent of dev.

Definition at line 4430 of file subr_bus.c.

References child.

◆ bus_generic_child_location()

int bus_generic_child_location ( device_t  dev,
device_t  child,
struct sbuf *  sb 
)

Generic implementation that does nothing for bus_child_location.

This function has the right signature and returns 0 since the sbuf is passed to us to append to.

Definition at line 5132 of file subr_bus.c.

◆ bus_generic_child_pnpinfo()

int bus_generic_child_pnpinfo ( device_t  dev,
device_t  child,
struct sbuf *  sb 
)

Generic implementation that does nothing for bus_child_pnpinfo.

This function has the right signature and returns 0 since the sbuf is passed to us to append to.

Definition at line 5103 of file subr_bus.c.

◆ bus_generic_child_present()

int bus_generic_child_present ( device_t  dev,
device_t  child 
)

Helper function for implementing BUS_CHILD_PRESENT().

This simple implementation of BUS_CHILD_PRESENT() simply calls the BUS_CHILD_PRESENT() method of the parent of dev.

Definition at line 4650 of file subr_bus.c.

References device_get_parent().

Here is the call graph for this function:

◆ bus_generic_config_intr()

int bus_generic_config_intr ( device_t  dev,
int  irq,
enum intr_trigger  trig,
enum intr_polarity  pol 
)

Helper function for implementing BUS_CONFIG_INTR().

This simple implementation of BUS_CONFIG_INTR() simply calls the BUS_CONFIG_INTR() method of the parent of dev.

Definition at line 4446 of file subr_bus.c.

◆ bus_generic_deactivate_resource()

int bus_generic_deactivate_resource ( device_t  dev,
device_t  child,
int  type,
int  rid,
struct resource *  r 
)

Helper function for implementing BUS_DEACTIVATE_RESOURCE().

This simple implementation of BUS_DEACTIVATE_RESOURCE() simply calls the BUS_DEACTIVATE_RESOURCE() method of the parent of dev.

Definition at line 4379 of file subr_bus.c.

References child, and type.

◆ bus_generic_describe_intr()

int bus_generic_describe_intr ( device_t  dev,
device_t  child,
struct resource *  irq,
void *  cookie,
const char *  descr 
)

Helper function for implementing BUS_DESCRIBE_INTR().

This simple implementation of BUS_DESCRIBE_INTR() simply calls the BUS_DESCRIBE_INTR() method of the parent of dev.

Definition at line 4462 of file subr_bus.c.

References child.

◆ bus_generic_detach()

int bus_generic_detach ( device_t  dev)

Helper function for implementing DEVICE_DETACH()

This function can be used to help implement the DEVICE_DETACH() for a bus. It calls device_detach() for each of the device's children.

Definition at line 3828 of file subr_bus.c.

References child, and device_detach().

Here is the call graph for this function:

◆ bus_generic_driver_added()

void bus_generic_driver_added ( device_t  dev,
driver_t *  driver 
)

Helper function for implementing BUS_DRIVER_ADDED().

This implementation of BUS_DRIVER_ADDED() simply calls the driver's DEVICE_IDENTIFY() method to allow it to add new children to the bus and then calls device_probe_and_attach() for each unattached child.

Definition at line 4181 of file subr_bus.c.

References child, and device_probe_and_attach().

Here is the call graph for this function:

◆ bus_generic_get_bus_tag()

bus_space_tag_t bus_generic_get_bus_tag ( device_t  dev,
device_t  child 
)

Helper function for implementing BUS_GET_BUS_TAG().

This simple implementation of BUS_GET_BUS_TAG() simply calls the BUS_GET_BUS_TAG() method of the parent of dev.

Definition at line 4510 of file subr_bus.c.

References child.

◆ bus_generic_get_cpus()

int bus_generic_get_cpus ( device_t  dev,
device_t  child,
enum cpu_sets  op,
size_t  setsize,
cpuset_t *  cpuset 
)

Helper function for implementing BUS_GET_CPUS().

This simple implementation of BUS_GET_CPUS() simply calls the BUS_GET_CPUS() method of the parent of dev.

Definition at line 4479 of file subr_bus.c.

References child.

◆ bus_generic_get_device_path()

int bus_generic_get_device_path ( device_t  bus,
device_t  child,
const char *  locator,
struct sbuf *  sb 
)

Helper function to implement normal BUS_GET_DEVICE_PATH()

This function knows how to (a) pass the request up the tree if there's a parent and (b) Knows how to supply a FreeBSD locator.

Parameters
busbus in the walk up the tree
childleaf node to print information about
locatorBUS_LOCATOR_xxx string for locator
sbBuffer to print information into

Definition at line 4676 of file subr_bus.c.

References bus, child, device_get_nameunit(), device_get_parent(), parent, and sbuf_printf().

Here is the call graph for this function:

◆ bus_generic_get_dma_tag()

bus_dma_tag_t bus_generic_get_dma_tag ( device_t  dev,
device_t  child 
)

Helper function for implementing BUS_GET_DMA_TAG().

This simple implementation of BUS_GET_DMA_TAG() simply calls the BUS_GET_DMA_TAG() method of the parent of dev.

Definition at line 4495 of file subr_bus.c.

References child.

◆ bus_generic_get_domain()

int bus_generic_get_domain ( device_t  dev,
device_t  child,
int *  domain 
)

Definition at line 4656 of file subr_bus.c.

References domain.

◆ bus_generic_get_property()

ssize_t bus_generic_get_property ( device_t  dev,
device_t  child,
const char *  propname,
void *  propvalue,
size_t  size,
device_property_type_t  type 
)

Helper function for implementing BUS_GET_PROPERTY().

This simply calls the BUS_GET_PROPERTY of the parent of dev, until a non-default implementation is found.

Definition at line 4152 of file subr_bus.c.

References child, device_get_parent(), and type.

Here is the call graph for this function:

◆ bus_generic_get_resource_list()

struct resource_list * bus_generic_get_resource_list ( device_t  dev,
device_t  child 
)

Stub function for implementing BUS_GET_RESOURCE_LIST().

Returns
NULL

Definition at line 4168 of file subr_bus.c.

◆ bus_generic_map_resource()

int bus_generic_map_resource ( device_t  dev,
device_t  child,
int  type,
struct resource *  r,
struct resource_map_request *  args,
struct resource_map *  map 
)

Helper function for implementing BUS_MAP_RESOURCE().

This simple implementation of BUS_MAP_RESOURCE() simply calls the BUS_MAP_RESOURCE() method of the parent of dev.

Definition at line 4396 of file subr_bus.c.

References child, and type.

◆ bus_generic_new_pass()

void bus_generic_new_pass ( device_t  dev)

Helper function for implementing BUS_NEW_PASS().

This implementing of BUS_NEW_PASS() first calls the identify routines for any drivers that probe at the current pass. Then it walks the list of devices for this bus. If a device is already attached, then it calls BUS_NEW_PASS() on that device. If the device is not already attached, it attempts to attach a driver to it.

Definition at line 4203 of file subr_bus.c.

References bus_current_pass, child, device_probe_and_attach(), and driverlink::driver.

Here is the call graph for this function:

◆ bus_generic_print_child()

int bus_generic_print_child ( device_t  dev,
device_t  child 
)

Helper function for implementing BUS_PRINT_CHILD().

This function simply calls bus_print_child_header() followed by bus_print_child_footer().

Returns
the number of characters printed

Definition at line 4110 of file subr_bus.c.

References bus_print_child_domain(), bus_print_child_footer(), bus_print_child_header(), and child.

Here is the call graph for this function:

◆ bus_generic_probe()

int bus_generic_probe ( device_t  dev)

Helper function for implementing DEVICE_PROBE()

This function can be used to help implement the DEVICE_PROBE() for a bus (i.e. a device which has other devices attached to it). It calls the DEVICE_IDENTIFY() method of each driver in the device's devclass.

Definition at line 3762 of file subr_bus.c.

References bus_current_pass, and driverlink::driver.

◆ bus_generic_read_ivar()

int bus_generic_read_ivar ( device_t  dev,
device_t  child,
int  index,
uintptr_t *  result 
)

Stub function for implementing BUS_READ_IVAR().

Returns
ENOENT

Definition at line 4127 of file subr_bus.c.

◆ bus_generic_release_resource()

int bus_generic_release_resource ( device_t  dev,
device_t  child,
int  type,
int  rid,
struct resource *  r 
)

Helper function for implementing BUS_RELEASE_RESOURCE().

This simple implementation of BUS_RELEASE_RESOURCE() simply calls the BUS_RELEASE_RESOURCE() method of the parent of dev.

Definition at line 4345 of file subr_bus.c.

References child, and type.

◆ bus_generic_resume()

int bus_generic_resume ( device_t  dev)

Helper function for implementing DEVICE_RESUME()

This function can be used to help implement the DEVICE_RESUME() for a bus. It calls DEVICE_RESUME() on each of the device's children.

Definition at line 3946 of file subr_bus.c.

References child.

Referenced by root_resume().

Here is the caller graph for this function:

◆ bus_generic_resume_child()

int bus_generic_resume_child ( device_t  dev,
device_t  child 
)

Default function for resuming a child device.

This function is to be used by a bus's DEVICE_RESUME_CHILD().

Definition at line 3895 of file subr_bus.c.

References child.

◆ bus_generic_resume_intr()

int bus_generic_resume_intr ( device_t  dev,
device_t  child,
struct resource *  irq 
)

Helper function for implementing BUS_RESUME_INTR().

This simple implementation of BUS_RESUME_INTR() simply calls the BUS_RESUME_INTR() method of the parent of dev.

Definition at line 4278 of file subr_bus.c.

References child.

◆ bus_generic_rl_alloc_resource()

struct resource * bus_generic_rl_alloc_resource ( device_t  dev,
device_t  child,
int  type,
int *  rid,
rman_res_t  start,
rman_res_t  end,
rman_res_t  count,
u_int  flags 
)

Helper function for implementing BUS_ALLOC_RESOURCE().

This implementation of BUS_ALLOC_RESOURCE() uses the resource_list_alloc() function to do most of the work. It calls BUS_GET_RESOURCE_LIST() to find a suitable resource list.

Definition at line 4626 of file subr_bus.c.

References child, count, device_get_parent(), flags, resource_list_alloc(), start, and type.

Here is the call graph for this function:

◆ bus_generic_rl_delete_resource()

void bus_generic_rl_delete_resource ( device_t  dev,
device_t  child,
int  type,
int  rid 
)

Helper function for implementing BUS_DELETE_RESOURCE().

This implementation of BUS_DELETE_RESOURCE() uses the resource_list_delete() function to do most of the work. It calls BUS_GET_RESOURCE_LIST() to find a suitable resource list to edit.

Definition at line 4581 of file subr_bus.c.

References child, resource_list_delete(), and type.

Here is the call graph for this function:

◆ bus_generic_rl_get_resource()

int bus_generic_rl_get_resource ( device_t  dev,
device_t  child,
int  type,
int  rid,
rman_res_t *  startp,
rman_res_t *  countp 
)

Helper function for implementing BUS_GET_RESOURCE().

This implementation of BUS_GET_RESOURCE() uses the resource_list_find() function to do most of the work. It calls BUS_GET_RESOURCE_LIST() to find a suitable resource list to search.

Definition at line 4527 of file subr_bus.c.

References child, resource_list_find(), and type.

Here is the call graph for this function:

◆ bus_generic_rl_release_resource()

int bus_generic_rl_release_resource ( device_t  dev,
device_t  child,
int  type,
int  rid,
struct resource *  r 
)

Helper function for implementing BUS_RELEASE_RESOURCE().

This implementation of BUS_RELEASE_RESOURCE() uses the resource_list_release() function to do most of the work. It calls BUS_GET_RESOURCE_LIST() to find a suitable resource list.

Definition at line 4602 of file subr_bus.c.

References child, device_get_parent(), resource_list_release(), and type.

Here is the call graph for this function:

◆ bus_generic_rl_set_resource()

int bus_generic_rl_set_resource ( device_t  dev,
device_t  child,
int  type,
int  rid,
rman_res_t  start,
rman_res_t  count 
)

Helper function for implementing BUS_SET_RESOURCE().

This implementation of BUS_SET_RESOURCE() uses the resource_list_add() function to do most of the work. It calls BUS_GET_RESOURCE_LIST() to find a suitable resource list to edit.

Definition at line 4558 of file subr_bus.c.

References child, count, resource_list_add(), start, and type.

Here is the call graph for this function:

◆ bus_generic_setup_intr()

int bus_generic_setup_intr ( device_t  dev,
device_t  child,
struct resource *  irq,
int  flags,
driver_filter_t *  filter,
driver_intr_t *  intr,
void *  arg,
void **  cookiep 
)

Helper function for implementing BUS_SETUP_INTR().

This simple implementation of BUS_SETUP_INTR() simply calls the BUS_SETUP_INTR() method of the parent of dev.

Definition at line 4229 of file subr_bus.c.

References child, and flags.

◆ bus_generic_shutdown()

int bus_generic_shutdown ( device_t  dev)

Helper function for implementing DEVICE_SHUTDOWN()

This function can be used to help implement the DEVICE_SHUTDOWN() for a bus. It calls device_shutdown() for each of the device's children.

Definition at line 3856 of file subr_bus.c.

References child, and device_shutdown().

Here is the call graph for this function:

◆ bus_generic_suspend()

int bus_generic_suspend ( device_t  dev)

Helper function for implementing DEVICE_SUSPEND()

This function can be used to help implement the DEVICE_SUSPEND() for a bus. It calls DEVICE_SUSPEND() for each of the device's children. If any call to DEVICE_SUSPEND() fails, the suspend operation is aborted and any devices which were suspended are resumed immediately by calling their DEVICE_RESUME() methods.

Definition at line 3913 of file subr_bus.c.

References child.

◆ bus_generic_suspend_child()

int bus_generic_suspend_child ( device_t  dev,
device_t  child 
)

Default function for suspending a child device.

This function is to be used by a bus's DEVICE_SUSPEND_CHILD().

Definition at line 3877 of file subr_bus.c.

References child.

◆ bus_generic_suspend_intr()

int bus_generic_suspend_intr ( device_t  dev,
device_t  child,
struct resource *  irq 
)

Helper function for implementing BUS_SUSPEND_INTR().

This simple implementation of BUS_SUSPEND_INTR() simply calls the BUS_SUSPEND_INTR() method of the parent of dev.

Definition at line 4263 of file subr_bus.c.

References child.

◆ bus_generic_teardown_intr()

int bus_generic_teardown_intr ( device_t  dev,
device_t  child,
struct resource *  irq,
void *  cookie 
)

Helper function for implementing BUS_TEARDOWN_INTR().

This simple implementation of BUS_TEARDOWN_INTR() simply calls the BUS_TEARDOWN_INTR() method of the parent of dev.

Definition at line 4247 of file subr_bus.c.

References child.

◆ bus_generic_translate_resource()

int bus_generic_translate_resource ( device_t  dev,
int  type,
rman_res_t  start,
rman_res_t *  newstart 
)

Definition at line 4311 of file subr_bus.c.

References start, and type.

◆ bus_generic_unmap_resource()

int bus_generic_unmap_resource ( device_t  dev,
device_t  child,
int  type,
struct resource *  r,
struct resource_map *  map 
)

Helper function for implementing BUS_UNMAP_RESOURCE().

This simple implementation of BUS_UNMAP_RESOURCE() simply calls the BUS_UNMAP_RESOURCE() method of the parent of dev.

Definition at line 4414 of file subr_bus.c.

References child, and type.

◆ bus_generic_write_ivar()

int bus_generic_write_ivar ( device_t  dev,
device_t  child,
int  index,
uintptr_t  value 
)

Stub function for implementing BUS_WRITE_IVAR().

Returns
ENOENT

Definition at line 4139 of file subr_bus.c.

◆ bus_get_bus_tag()

bus_space_tag_t bus_get_bus_tag ( device_t  dev)

Wrapper function for BUS_GET_BUS_TAG().

This function simply calls the BUS_GET_BUS_TAG() method of the parent of dev.

Definition at line 5178 of file subr_bus.c.

References device_get_parent(), and parent.

Here is the call graph for this function:

◆ bus_get_cpus()

int bus_get_cpus ( device_t  dev,
enum cpu_sets  op,
size_t  setsize,
cpuset_t *  cpuset 
)

Wrapper function for BUS_GET_CPUS().

This function simply calls the BUS_GET_CPUS() method of the parent of dev.

Definition at line 5144 of file subr_bus.c.

References device_get_parent(), and parent.

Here is the call graph for this function:

◆ bus_get_dma_tag()

bus_dma_tag_t bus_get_dma_tag ( device_t  dev)

Wrapper function for BUS_GET_DMA_TAG().

This function simply calls the BUS_GET_DMA_TAG() method of the parent of dev.

Definition at line 5161 of file subr_bus.c.

References device_get_parent(), and parent.

Here is the call graph for this function:

◆ bus_get_domain()

int bus_get_domain ( device_t  dev,
int *  domain 
)

Wrapper function for BUS_GET_DOMAIN().

This function simply calls the BUS_GET_DOMAIN() method of the parent of dev.

Definition at line 5195 of file subr_bus.c.

References device_get_parent(), and domain.

Referenced by device_set_driver(), and device_sysctl_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bus_get_resource()

int bus_get_resource ( device_t  dev,
int  type,
int  rid,
rman_res_t *  startp,
rman_res_t *  countp 
)

Wrapper function for BUS_GET_RESOURCE().

This function simply calls the BUS_GET_RESOURCE() method of the parent of dev.

Definition at line 5008 of file subr_bus.c.

References device_get_parent(), and type.

Here is the call graph for this function:

◆ bus_get_resource_count()

rman_res_t bus_get_resource_count ( device_t  dev,
int  type,
int  rid 
)

Wrapper function for BUS_GET_RESOURCE().

This function simply calls the BUS_GET_RESOURCE() method of the parent of dev and returns the count value.

Definition at line 5042 of file subr_bus.c.

References count, device_get_parent(), start, and type.

Here is the call graph for this function:

◆ bus_get_resource_start()

rman_res_t bus_get_resource_start ( device_t  dev,
int  type,
int  rid 
)

Wrapper function for BUS_GET_RESOURCE().

This function simply calls the BUS_GET_RESOURCE() method of the parent of dev and returns the start value.

Definition at line 5022 of file subr_bus.c.

References count, device_get_parent(), start, and type.

Here is the call graph for this function:

◆ bus_helper_reset_post()

int bus_helper_reset_post ( device_t  dev,
int  flags 
)

Helper function for implementing BUS_RESET_POST.

Bus can use this function to implement common operations of re-attaching or resuming the children after the bus itself was reset, and after restoring bus-unique state of children.

Parameters
devThe bus #param flags DEVF_RESET_*

Definition at line 3968 of file subr_bus.c.

References child, device_probe_and_attach(), and flags.

Here is the call graph for this function:

◆ bus_helper_reset_prepare()

int bus_helper_reset_prepare ( device_t  dev,
int  flags 
)

Helper function for implementing BUS_RESET_PREPARE.

Bus can use this function to implement common operations of detaching or suspending the children before the bus itself is reset, and then save bus-unique state of children that must persists around reset.

Parameters
devThe bus #param flags DEVF_RESET_*

Definition at line 4012 of file subr_bus.c.

References bus_helper_reset_prepare_rollback(), child, device_detach(), device_get_state(), device_probe_and_attach(), and flags.

Here is the call graph for this function:

◆ bus_helper_reset_prepare_rollback()

static void bus_helper_reset_prepare_rollback ( device_t  dev,
device_t  child,
int  flags 
)
static

Definition at line 3986 of file subr_bus.c.

References child, device_probe_and_attach(), and flags.

Referenced by bus_helper_reset_prepare().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bus_map_resource()

int bus_map_resource ( device_t  dev,
int  type,
struct resource *  r,
struct resource_map_request *  args,
struct resource_map *  map 
)

Wrapper function for BUS_MAP_RESOURCE().

This function simply calls the BUS_MAP_RESOURCE() method of the parent of dev.

Definition at line 4846 of file subr_bus.c.

References type.

◆ bus_null_rescan()

int bus_null_rescan ( device_t  dev)

Helper function for implementing BUS_RESCAN().

This null implementation of BUS_RESCAN() always fails to indicate the bus does not support rescanning.

Definition at line 4716 of file subr_bus.c.

◆ bus_print_child_domain()

int bus_print_child_domain ( device_t  dev,
device_t  child 
)

Helper function for implementing BUS_PRINT_CHILD().

This function prints out the VM domain for the given device.

Returns
the number of characters printed

Definition at line 4090 of file subr_bus.c.

References child, domain, and printf().

Referenced by bus_generic_print_child().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bus_print_child_footer()

int bus_print_child_footer ( device_t  dev,
device_t  child 
)

Helper function for implementing BUS_PRINT_CHILD().

This function prints the last part of the ascii representation of child, which consists of the string " on " followed by the name and unit of the dev.

Returns
the number of characters printed

Definition at line 4077 of file subr_bus.c.

References device_get_nameunit(), and printf().

Referenced by bus_generic_print_child().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bus_print_child_header()

int bus_print_child_header ( device_t  dev,
device_t  child 
)

Helper function for implementing BUS_PRINT_CHILD().

This function prints the first part of the ascii representation of child, including its name, unit and description (if any - see device_set_desc()).

Returns
the number of characters printed

Definition at line 4054 of file subr_bus.c.

References child, device_get_desc(), device_get_nameunit(), device_printf(), and printf().

Referenced by bus_generic_print_child(), and root_print_child().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bus_release_resource()

int bus_release_resource ( device_t  dev,
int  type,
int  rid,
struct resource *  r 
)

Wrapper function for BUS_RELEASE_RESOURCE().

This function simply calls the BUS_RELEASE_RESOURCE() method of the parent of dev.

Definition at line 4876 of file subr_bus.c.

References type.

Referenced by bus_free_resource(), bus_release_resources(), and resource_list_purge().

Here is the caller graph for this function:

◆ bus_release_resources()

void bus_release_resources ( device_t  dev,
const struct resource_spec *  rs,
struct resource **  res 
)

Definition at line 4749 of file subr_bus.c.

References bus_release_resource(), res, and type.

Referenced by bus_alloc_resources().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bus_resume_intr()

int bus_resume_intr ( device_t  dev,
struct resource *  r 
)

Wrapper function for BUS_RESUME_INTR().

This function simply calls the BUS_RESUME_INTR() method of the parent of dev.

Definition at line 4944 of file subr_bus.c.

◆ bus_set_pass()

void bus_set_pass ( int  pass)

Raise the current bus pass.

Raise the current bus pass level to pass. Call the BUS_NEW_PASS() method on the root bus to kick off a new device tree scan for each new pass level that has at least one driver.

Definition at line 948 of file subr_bus.c.

References bus_current_pass, panic(), passes, and root_bus.

Referenced by root_bus_configure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bus_set_resource()

int bus_set_resource ( device_t  dev,
int  type,
int  rid,
rman_res_t  start,
rman_res_t  count 
)

Wrapper function for BUS_SET_RESOURCE().

This function simply calls the BUS_SET_RESOURCE() method of the parent of dev.

Definition at line 4994 of file subr_bus.c.

References count, device_get_parent(), start, and type.

Here is the call graph for this function:

◆ bus_setup_intr()

int bus_setup_intr ( device_t  dev,
struct resource *  r,
int  flags,
driver_filter_t  filter,
driver_intr_t  handler,
void *  arg,
void **  cookiep 
)

Wrapper function for BUS_SETUP_INTR().

This function simply calls the BUS_SETUP_INTR() method of the parent of dev.

Definition at line 4893 of file subr_bus.c.

References device_printf(), and flags.

Here is the call graph for this function:

◆ bus_suspend_intr()

int bus_suspend_intr ( device_t  dev,
struct resource *  r 
)

Wrapper function for BUS_SUSPEND_INTR().

This function simply calls the BUS_SUSPEND_INTR() method of the parent of dev.

Definition at line 4930 of file subr_bus.c.

◆ bus_teardown_intr()

int bus_teardown_intr ( device_t  dev,
struct resource *  r,
void *  cookie 
)

Wrapper function for BUS_TEARDOWN_INTR().

This function simply calls the BUS_TEARDOWN_INTR() method of the parent of dev.

Definition at line 4916 of file subr_bus.c.

◆ bus_topo_assert()

void bus_topo_assert ( )

Definition at line 871 of file subr_bus.c.

Referenced by device_detach(), device_probe(), device_probe_and_attach(), and device_probe_child().

Here is the caller graph for this function:

◆ bus_topo_lock()

void bus_topo_lock ( void  )

Definition at line 885 of file subr_bus.c.

References bus_topo_mtx().

Referenced by devctl2_ioctl(), and device_sysctl_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bus_topo_mtx()

struct mtx * bus_topo_mtx ( void  )

Definition at line 878 of file subr_bus.c.

References Giant.

Referenced by bus_topo_lock(), and bus_topo_unlock().

Here is the caller graph for this function:

◆ bus_topo_unlock()

void bus_topo_unlock ( void  )

Definition at line 892 of file subr_bus.c.

References bus_topo_mtx().

Referenced by devctl2_ioctl(), and device_sysctl_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bus_translate_resource()

int bus_translate_resource ( device_t  dev,
int  type,
rman_res_t  start,
rman_res_t *  newstart 
)

Wrapper function for BUS_TRANSLATE_RESOURCE().

This function simply calls the BUS_TRANSLATE_RESOURCE() method of the parent of dev.

Definition at line 4803 of file subr_bus.c.

References start, and type.

◆ bus_unmap_resource()

int bus_unmap_resource ( device_t  dev,
int  type,
struct resource *  r,
struct resource_map *  map 
)

Wrapper function for BUS_UNMAP_RESOURCE().

This function simply calls the BUS_UNMAP_RESOURCE() method of the parent of dev.

Definition at line 4861 of file subr_bus.c.

References type.

◆ DECLARE_MODULE()

DECLARE_MODULE ( rootbus  ,
root_bus_mod  ,
SI_SUB_DRIVERS  ,
SI_ORDER_FIRST   
)

◆ DEFINE_CLASS()

DEFINE_CLASS ( null  ,
null_methods  ,
 
)

◆ dev_wired_cache_add()

static struct device_location_node * dev_wired_cache_add ( device_location_cache_t *  dcp,
const char *  locator,
const char *  path 
)
static

Definition at line 6190 of file subr_bus.c.

References device_location_node::dln_locator, device_location_node::dln_path, malloc(), and path.

Referenced by dev_wired_cache_match().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dev_wired_cache_fini()

void dev_wired_cache_fini ( device_location_cache_t *  dcp)

Definition at line 6164 of file subr_bus.c.

References device_location_node::dln_path, and free().

Here is the call graph for this function:

◆ dev_wired_cache_init()

device_location_cache_t * dev_wired_cache_init ( void  )

Definition at line 6153 of file subr_bus.c.

References malloc().

Here is the call graph for this function:

◆ dev_wired_cache_lookup()

static struct device_location_node * dev_wired_cache_lookup ( device_location_cache_t *  dcp,
const char *  locator 
)
static

Definition at line 6177 of file subr_bus.c.

References device_location_node::dln_locator.

Referenced by dev_wired_cache_match().

Here is the caller graph for this function:

◆ dev_wired_cache_match()

bool dev_wired_cache_match ( device_location_cache_t *  dcp,
device_t  dev,
const char *  at 
)

Definition at line 6205 of file subr_bus.c.

References dev_wired_cache_add(), dev_wired_cache_lookup(), device_get_path(), path, and res.

Here is the call graph for this function:

◆ devadded()

static void devadded ( device_t  dev)
static

Definition at line 771 of file subr_bus.c.

References devaddq(), and device_get_nameunit().

Referenced by device_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devaddq()

static void devaddq ( const char *  type,
const char *  what,
device_t  dev 
)
static

Definition at line 727 of file subr_bus.c.

References bus_child_location(), bus_child_pnpinfo(), devctl_alloc_dei_sb(), devctl_free_dei(), devctl_queue(), device_get_nameunit(), device_get_parent(), sbuf_cat(), sbuf_cpy(), sbuf_finish(), sbuf_putc(), and type.

Referenced by devadded(), devnomatch(), and devremoved().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devclass_add_device()

static int devclass_add_device ( devclass_t  dc,
device_t  dev 
)
static

Add a device to a devclass.

A unit number is allocated for the device (using the device's preferred unit number if any) and the device is registered in the devclass. This allows the device to be looked up by its unit number, e.g. by decoding a dev_t minor number.

Parameters
dcthe devclass to add to
devthe device to add
Return values
0success
EEXISTthe requested unit number is already allocated
ENOMEMmemory allocation failure

Definition at line 1733 of file subr_bus.c.

References DEVCLANAME, devclass_alloc_unit(), DEVICENAME, free(), malloc(), PDEBUG, and snprintf().

Referenced by devctl2_ioctl(), device_set_devclass(), device_set_unit(), and make_device().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devclass_add_driver()

int devclass_add_driver ( devclass_t  dc,
driver_t *  driver,
int  pass,
devclass_t *  dcp 
)

Add a device driver to a device class.

Add a device driver to a devclass. This is normally called automatically by DRIVER_MODULE(). The BUS_DRIVER_ADDED() method of all devices in the devclass will be called to allow them to attempt to re-probe any unmatched children.

Parameters
dcthe devclass to edit
driverthe driver to register

Definition at line 1140 of file subr_bus.c.

References bus_data_generation_update(), devclass_driver_added(), devclass_find_internal(), device_frozen, DL_DEFERRED_PROBE, driverlink::driver, driver_register_pass(), DRIVERNAME, kobj_class_compile(), malloc(), and PDEBUG.

Referenced by driver_module_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devclass_alloc_unit()

static int devclass_alloc_unit ( devclass_t  dc,
device_t  dev,
int *  unitp 
)
static

Allocate a unit number.

On entry, *unitp is the desired unit number (or -1 if any will do). The allocated unit number is returned in *unitp.

Parameters
dcthe devclass to allocate from
unitppoints at the location for the allocated unit number
Return values
0success
EEXISTthe requested unit number is already allocated
ENOMEMmemory allocation failure

Definition at line 1647 of file subr_bus.c.

References bootverbose, DEVCLANAME, device_get_parent(), free(), malloc(), PDEBUG, printf(), and resource_string_value().

Referenced by devclass_add_device().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devclass_create()

devclass_t devclass_create ( const char *  classname)

Create a device class.

If a device class with the name classname exists, return it, otherwise create and return a new device class.

Parameters
classnamethe devclass name to find or create

Definition at line 1062 of file subr_bus.c.

References devclass_find_internal().

Referenced by devctl2_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devclass_delete_device()

static int devclass_delete_device ( devclass_t  dc,
device_t  dev 
)
static

Delete a device from a devclass.

The device is removed from the devclass's device list and its unit number is freed.

Parameters
dcthe devclass to delete from
devthe device to delete
Return values
0success

Definition at line 1771 of file subr_bus.c.

References DEVCLANAME, DEVICENAME, free(), panic(), and PDEBUG.

Referenced by devctl2_ioctl(), device_attach(), device_delete_child(), device_detach(), device_set_devclass(), and device_set_unit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devclass_delete_driver()

int devclass_delete_driver ( devclass_t  busclass,
driver_t *  driver 
)

Delete a device driver from a device class.

Delete a device driver from a devclass. This is normally called automatically by DRIVER_MODULE().

If the driver is currently attached to any devices, devclass_delete_driver() will first attempt to detach from each device. If one of the detach calls fails, the driver will not be deleted.

Parameters
dcthe devclass to edit
driverthe driver to unregister

Definition at line 1285 of file subr_bus.c.

References bus_data_generation_update(), DEVCLANAME, devclass_driver_deleted(), devclass_find(), driverlink::driver, free(), kobj_class_free(), and PDEBUG.

Referenced by driver_module_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devclass_driver_added()

static void devclass_driver_added ( devclass_t  dc,
driver_t *  driver 
)
static

Register that a device driver has been added to a devclass.

Register that a device driver has been added to a devclass. This is called by devclass_add_driver to accomplish the recursive notification of all the children classes of dc, as well as dc. Each layer will have BUS_DRIVER_ADDED() called for all instances of the devclass.

We do a full search here of the devclass list at each iteration level to save storing children-lists in the devclass structure. If we ever move beyond a few dozen devices doing this, we may need to reevaluate...

Parameters
dcthe devclass to edit
driverthe driver that was just added

Definition at line 1099 of file subr_bus.c.

References DC_HAS_CHILDREN, devclass_driver_added(), devclasses, device_is_attached(), driverlink::driver, and parent.

Referenced by devclass_add_driver(), devclass_driver_added(), and device_do_deferred_actions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devclass_driver_deleted()

static int devclass_driver_deleted ( devclass_t  busclass,
devclass_t  dc,
driver_t *  driver 
)
static

Register that a device driver has been deleted from a devclass.

Register that a device driver has been removed from a devclass. This is called by devclass_delete_driver to accomplish the recursive notification of all the children classes of busclass, as well as busclass. Each layer will attempt to detach the driver from any devices that are children of the bus's devclass. The function will return an error if a device fails to detach.

We do a full search here of the devclass list at each iteration level to save storing children-lists in the devclass structure. If we ever move beyond a few dozen devices doing this, we may need to reevaluate...

Parameters
busclassthe devclass of the parent bus
dcthe devclass of the driver being deleted
driverthe driver being deleted

Definition at line 1211 of file subr_bus.c.

References DC_HAS_CHILDREN, devclass_driver_deleted(), devclasses, device_detach(), device_frozen, devnomatch(), driverlink::driver, and parent.

Referenced by devclass_delete_driver(), and devclass_driver_deleted().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devclass_find()

devclass_t devclass_find ( const char *  classname)

Find a device class.

If a device class with the name classname exists, return it, otherwise return NULL.

Parameters
classnamethe devclass name to find

Definition at line 1076 of file subr_bus.c.

References devclass_find_internal().

Referenced by devclass_delete_driver(), devclass_quiesce_driver(), and device_find_child().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devclass_find_driver_internal()

static driverlink_t devclass_find_driver_internal ( devclass_t  dc,
const char *  classname 
)
static

Definition at line 1395 of file subr_bus.c.

References DEVCLANAME, driverlink::driver, and PDEBUG.

Referenced by driver_exists(), and first_matching_driver().

Here is the caller graph for this function:

◆ devclass_find_free_unit()

int devclass_find_free_unit ( devclass_t  dc,
int  unit 
)

Find a free unit number in a devclass.

This function searches for the first unused unit number greater that or equal to unit.

Parameters
dcthe devclass to examine
unitthe first unit number to check

Definition at line 1584 of file subr_bus.c.

◆ devclass_find_internal()

static devclass_t devclass_find_internal ( const char *  classname,
const char *  parentname,
int  create 
)
static

Find or create a device class.

If a device class with the name classname exists, return it, otherwise if create is non-zero create and return a new device class.

If parentname is non-NULL, the parent of the devclass is set to the devclass of that name.

Parameters
classnamethe devclass name to find or create
parentnamethe parent devclass name or NULL
createnon-zero to create a devclass

Definition at line 1007 of file subr_bus.c.

References bus_data_generation_update(), DC_HAS_CHILDREN, devclass_find_internal(), devclasses, malloc(), and PDEBUG.

Referenced by devclass_add_driver(), devclass_create(), devclass_find(), devclass_find_internal(), device_set_devclass(), driver_module_handler(), make_device(), and root_bus_module_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devclass_get_count()

int devclass_get_count ( devclass_t  dc)

Get the number of devices in a devclass.

Parameters
dcthe devclass to examine

Definition at line 1546 of file subr_bus.c.

References count.

Referenced by devclass_get_devices().

Here is the caller graph for this function:

◆ devclass_get_device()

device_t devclass_get_device ( devclass_t  dc,
int  unit 
)

Find a device given a unit number.

Parameters
dcthe devclass to search
unitthe unit number to search for
Returns
the device with the given unit number or NULL if there is no such device

Definition at line 1429 of file subr_bus.c.

Referenced by devclass_get_softc(), and device_find_child().

Here is the caller graph for this function:

◆ devclass_get_devices()

int devclass_get_devices ( devclass_t  dc,
device_t **  devlistp,
int *  devcountp 
)

Get a list of devices in the devclass.

An array containing a list of all the devices in the given devclass is allocated and returned in *devlistp. The number of devices in the array is returned in *devcountp. The caller should free the array using free(p, M_TEMP), even if *devcountp is 0.

Parameters
dcthe devclass to examine
devlistppoints at location for array pointer return value
devcountppoints at location for array size return value
Return values
0success
ENOMEMthe array allocation failed

Definition at line 1475 of file subr_bus.c.

References count, devclass_get_count(), and malloc().

Referenced by cpufreq_curr_sysctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devclass_get_drivers()

int devclass_get_drivers ( devclass_t  dc,
driver_t ***  listp,
int *  countp 
)

Get a list of drivers in the devclass.

An array containing a list of pointers to all the drivers in the given devclass is allocated and returned in *listp. The number of drivers in the array is returned in *countp. The caller should free the array using free(p, M_TEMP).

Parameters
dcthe devclass to examine
listpgives location for array pointer return value
countpgives location for number of array elements return value
Return values
0success
ENOMEMthe array allocation failed

Definition at line 1516 of file subr_bus.c.

References count, driverlink::driver, and malloc().

Here is the call graph for this function:

◆ devclass_get_maxunit()

int devclass_get_maxunit ( devclass_t  dc)

Get the maximum unit number used in a devclass.

Note that this is one greater than the highest currently-allocated unit. If a null devclass_t is passed in, -1 is returned to indicate that not even the devclass has been allocated yet.

Parameters
dcthe devclass to examine

Definition at line 1567 of file subr_bus.c.

Referenced by device_find_child().

Here is the caller graph for this function:

◆ devclass_get_name()

const char * devclass_get_name ( devclass_t  dc)

Return the name of the devclass.

Definition at line 1414 of file subr_bus.c.

Referenced by device_get_name().

Here is the caller graph for this function:

◆ devclass_get_parent()

devclass_t devclass_get_parent ( devclass_t  dc)

Get the parent of a devclass.

Parameters
dcthe devclass to examine

Definition at line 1614 of file subr_bus.c.

◆ devclass_get_softc()

void * devclass_get_softc ( devclass_t  dc,
int  unit 
)

Find the softc field of a device given a unit number.

Parameters
dcthe devclass to search
unitthe unit number to search for
Returns
the softc field of the device with the given unit number or NULL if there is no such device

Definition at line 1447 of file subr_bus.c.

References devclass_get_device(), and device_get_softc().

Here is the call graph for this function:

◆ devclass_get_sysctl_ctx()

struct sysctl_ctx_list * devclass_get_sysctl_ctx ( devclass_t  dc)

Definition at line 1620 of file subr_bus.c.

◆ devclass_get_sysctl_tree()

struct sysctl_oid * devclass_get_sysctl_tree ( devclass_t  dc)

Definition at line 1626 of file subr_bus.c.

◆ devclass_quiesce_driver()

static int devclass_quiesce_driver ( devclass_t  busclass,
driver_t *  driver 
)
static

Quiesces a set of device drivers from a device class.

Quiesce a device driver from a devclass. This is normally called automatically by DRIVER_MODULE().

If the driver is currently attached to any devices, devclass_quiesece_driver() will first attempt to quiesce each device.

Parameters
dcthe devclass to edit
driverthe driver to unregister

Definition at line 1340 of file subr_bus.c.

References DEVCLANAME, devclass_find(), device_quiesce(), driverlink::driver, and PDEBUG.

Referenced by driver_module_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devclass_set_parent()

void devclass_set_parent ( devclass_t  dc,
devclass_t  pdc 
)

Set the parent of a devclass.

The parent class is normally initialised automatically by DRIVER_MODULE().

Parameters
dcthe devclass to edit
pdcthe new parent devclass

Definition at line 1603 of file subr_bus.c.

◆ devclass_sysctl_handler()

static int devclass_sysctl_handler ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 222 of file subr_bus.c.

References DEVCLASS_SYSCTL_PARENT, and value.

Referenced by devclass_sysctl_init().

Here is the caller graph for this function:

◆ devclass_sysctl_init()

static void devclass_sysctl_init ( devclass_t  dc)
static

Definition at line 238 of file subr_bus.c.

References devclass_sysctl_handler(), DEVCLASS_SYSCTL_PARENT, and sysctl_ctx_init().

Referenced by device_sysctl_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devclose()

static int devclose ( struct cdev *  dev,
int  fflag,
int  devtype,
struct thread *  td 
)
static

Definition at line 478 of file subr_bus.c.

References dev_softc::async, dev_softc::cv, devsoftc, funsetown(), dev_softc::inuse, dev_softc::mtx, dev_softc::nonblock, and dev_softc::sigio.

Here is the call graph for this function:

◆ devctl2_init()

static void devctl2_init ( void  )
static

Definition at line 6128 of file subr_bus.c.

References devctl2_cdevsw, and make_dev_credf().

Referenced by devinit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devctl2_ioctl()

◆ devctl_alloc_dei()

static struct dev_event_info * devctl_alloc_dei ( void  )
static

Definition at line 614 of file subr_bus.c.

References devctl_queue_length, dev_softc::devq, devsoftc, dev_softc::mtx, dev_softc::queued, and dev_softc::zone.

Referenced by devctl_alloc_dei_sb().

Here is the caller graph for this function:

◆ devctl_alloc_dei_sb()

static struct dev_event_info * devctl_alloc_dei_sb ( struct sbuf *  sb)
static

Definition at line 647 of file subr_bus.c.

References devctl_alloc_dei(), and sbuf_new().

Referenced by devaddq(), and devctl_notify().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devctl_free_dei()

static void devctl_free_dei ( struct dev_event_info dei)
static

Definition at line 658 of file subr_bus.c.

References devsoftc, and dev_softc::zone.

Referenced by devaddq(), and devctl_notify().

Here is the caller graph for this function:

◆ devctl_notify()

void devctl_notify ( const char *  system,
const char *  subsystem,
const char *  type,
const char *  data 
)

Send a 'notification' to userland, using standard ways.

Definition at line 681 of file subr_bus.c.

References data, devctl_alloc_dei_sb(), devctl_free_dei(), devctl_queue(), sbuf_cat(), sbuf_cpy(), sbuf_finish(), sbuf_putc(), and type.

Referenced by coredump(), mount_devctl_event(), notify(), and root_resume().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devctl_process_running()

bool devctl_process_running ( void  )

Return whether the userland process is running.

Definition at line 608 of file subr_bus.c.

References devsoftc, and dev_softc::inuse.

◆ devctl_queue()

static void devctl_queue ( struct dev_event_info dei)
static

Definition at line 664 of file subr_bus.c.

References dev_softc::async, dev_softc::cv, dev_softc::devq, devsoftc, dev_softc::mtx, pgsigio(), dev_softc::queued, dev_softc::sel, selwakeup(), and dev_softc::sigio.

Referenced by devaddq(), and devctl_notify().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devctl_safe_quote_sb()

void devctl_safe_quote_sb ( struct sbuf *  sb,
const char *  src 
)

safely quotes strings that might have double quotes in them.

The devctl protocol relies on quoted strings having matching quotes. This routine quotes any internal quotes so the resulting string is safe to pass to snprintf to construct, for example pnp info strings.

Parameters
sbsbuf to place the characters into
srcOriginal buffer.

Definition at line 850 of file subr_bus.c.

References sbuf_putc(), and src.

Referenced by coredump(), and mount_devctl_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_add_child()

device_t device_add_child ( device_t  dev,
const char *  name,
int  unit 
)

Create a new device.

This creates a new device and adds it as a child of an existing parent device. The new device will be added after the last existing child with order zero.

Parameters
devthe device which will be the parent of the new child device
namedevclass name for new device or NULL if not specified
unitunit number for new device or -1 if not specified
Returns
the new device

Definition at line 1893 of file subr_bus.c.

References device_add_child_ordered(), and name.

Here is the call graph for this function:

◆ device_add_child_ordered()

device_t device_add_child_ordered ( device_t  dev,
u_int  order,
const char *  name,
int  unit 
)

Create a new device.

This creates a new device and adds it as a child of an existing parent device. The new device will be added after the last existing child with the same order.

Parameters
devthe device which will be the parent of the new child device
ordera value which is used to partially sort the children of dev - devices created using lower values of order appear first in dev's list of children
namedevclass name for new device or NULL if not specified
unitunit number for new device or -1 if not specified
Returns
the new device

Definition at line 1919 of file subr_bus.c.

References bus_data_generation_update(), child, DEVICENAME, make_device(), name, and PDEBUG.

Referenced by bus_generic_add_child(), and device_add_child().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_attach()

int device_attach ( device_t  dev)

Attach a device driver to a device.

This function is a wrapper around the DEVICE_ATTACH() driver method. In addition to calling DEVICE_ATTACH(), it initialises the device's sysctl tree, optionally prints a description of the device and queues a notification event for user-based device management services.

Normally this function is only called internally from device_probe_and_attach().

Parameters
devthe device to initialise
Return values
0success
ENXIOno driver was found
ENOMEMmemory allocation failure
non-zerosome other unix error code

Definition at line 3015 of file subr_bus.c.

References bootverbose, devadded(), devclass_delete_device(), device_attach(), device_disable(), device_is_quiet(), device_print_child(), device_printf(), device_set_driver(), device_sysctl_fini(), device_sysctl_init(), device_sysctl_update(), printf(), and resource_disabled().

Referenced by devctl2_ioctl(), device_attach(), and device_probe_and_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_busy()

void device_busy ( device_t  dev)

Increment the busy counter for the device.

Definition at line 2667 of file subr_bus.c.

References device_busy().

Referenced by device_busy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_claim_softc()

void device_claim_softc ( device_t  dev)

Claim softc.

This function can be used to let the driver free the automatically allocated softc using "device_free_softc()". This function is useful when the driver is refcounting the softc and the softc cannot be freed when the "device_detach" method is called.

Definition at line 2604 of file subr_bus.c.

◆ device_delete_child()

int device_delete_child ( device_t  dev,
device_t  child 
)

Delete a device.

This function deletes a device along with all of its children. If the device currently has a driver attached to it, the device is detached first using device_detach().

Parameters
devthe parent device
childthe device to delete
Return values
0success
non-zeroa unit error code describing the error

Definition at line 1971 of file subr_bus.c.

References bus_data_devices, bus_data_generation_update(), child, devclass_delete_device(), device_delete_child(), device_detach(), DEVICENAME, kobj_delete(), and PDEBUG.

Referenced by cpufreq_unregister(), devctl2_ioctl(), device_delete_child(), and device_delete_children().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_delete_children()

int device_delete_children ( device_t  dev)

Delete all children devices of the given device, if any.

This function deletes all children devices of the given device, if any, using the device_delete_child() function for each device it finds. If a child device cannot be deleted, this function will return an error code.

Parameters
devthe parent device
Return values
0success
non-zeroa device would not detach

Definition at line 2015 of file subr_bus.c.

References child, device_delete_child(), DEVICENAME, and PDEBUG.

Here is the call graph for this function:

◆ device_detach()

int device_detach ( device_t  dev)

Detach a driver from a device.

This function is a wrapper around the DEVICE_DETACH() driver method. If the call to DEVICE_DETACH() succeeds, it calls BUS_CHILD_DETACHED() for the parent of dev, queues a notification event for user-based device management services and cleans up the device's sysctl tree.

Parameters
devthe device to un-initialise
Return values
0success
ENXIOno driver was found
ENOMEMmemory allocation failure
non-zerosome other unix error code

Definition at line 3075 of file subr_bus.c.

References bus_topo_assert(), devclass_delete_device(), device_detach(), device_is_quiet(), device_printf(), device_set_driver(), device_sysctl_fini(), device_verbose(), DEVICENAME, devremoved(), and PDEBUG.

Referenced by bus_generic_detach(), bus_helper_reset_prepare(), devclass_driver_deleted(), devctl2_ioctl(), device_delete_child(), and device_detach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_disable()

void device_disable ( device_t  dev)

Clear the DF_ENABLED flag for the device.

Definition at line 2658 of file subr_bus.c.

Referenced by devctl2_ioctl(), and device_attach().

Here is the caller graph for this function:

◆ device_do_deferred_actions()

static void device_do_deferred_actions ( void  )
static

Definition at line 5782 of file subr_bus.c.

References bus_data_generation_update(), devclass_driver_added(), devclasses, device_gen_nomatch(), DL_DEFERRED_PROBE, driverlink::driver, and root_bus.

Referenced by devctl2_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_enable()

void device_enable ( device_t  dev)

Set the DF_ENABLED flag for the device.

Definition at line 2649 of file subr_bus.c.

Referenced by devctl2_ioctl().

Here is the caller graph for this function:

◆ device_find_child()

device_t device_find_child ( device_t  dev,
const char *  classname,
int  unit 
)

Find a device given a unit number.

This is similar to devclass_get_devices() but only searches for devices which have dev as a parent.

Parameters
devthe parent device to search
unitthe unit number to search for. If the unit is -1, return the first child of dev which has name classname (that is, the one with the lowest unit.)
Returns
the device with the given unit number or NULL if there is no such device

Definition at line 2049 of file subr_bus.c.

References child, devclass_find(), devclass_get_device(), and devclass_get_maxunit().

Referenced by cpufreq_register(), and cpufreq_unregister().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_free_softc()

void device_free_softc ( void *  softc)

Free claimed softc.

Most drivers do not need to use this since the softc is freed automatically when the driver is detached.

Definition at line 2590 of file subr_bus.c.

References free().

Here is the call graph for this function:

◆ device_gen_nomatch()

static void device_gen_nomatch ( device_t  dev)
static

Definition at line 5765 of file subr_bus.c.

References child, device_gen_nomatch(), and devnomatch().

Referenced by device_do_deferred_actions(), and device_gen_nomatch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_get_children()

int device_get_children ( device_t  dev,
device_t **  devlistp,
int *  devcountp 
)

Get a list of children of a device.

An array containing a list of all the children of the given device is allocated and returned in *devlistp. The number of devices in the array is returned in *devcountp. The caller should free the array using free(p, M_TEMP).

Parameters
devthe device to examine
devlistppoints at location for array pointer return value
devcountppoints at location for array size return value
Return values
0success
ENOMEMthe array allocation failed

Definition at line 2285 of file subr_bus.c.

References child, count, and malloc().

Here is the call graph for this function:

◆ device_get_desc()

const char * device_get_desc ( device_t  dev)

Return the device's description string.

Definition at line 2373 of file subr_bus.c.

Referenced by bus_print_child_header().

Here is the caller graph for this function:

◆ device_get_devclass()

devclass_t device_get_devclass ( device_t  dev)

Return the current devclass for the device or NULL if there is none.

Definition at line 2332 of file subr_bus.c.

Referenced by device_set_unit().

Here is the caller graph for this function:

◆ device_get_driver()

driver_t * device_get_driver ( device_t  dev)

Return the current driver for the device or NULL if there is no driver currently attached.

Definition at line 2322 of file subr_bus.c.

◆ device_get_flags()

uint32_t device_get_flags ( device_t  dev)

Return the device's flags.

Definition at line 2382 of file subr_bus.c.

◆ device_get_ivars()

void * device_get_ivars ( device_t  dev)

Get the device's ivars field.

The ivars field is used by the parent device to store per-device state (e.g. the physical location of the device or a list of resources).

Definition at line 2620 of file subr_bus.c.

◆ device_get_name()

const char * device_get_name ( device_t  dev)

Return the name of the device's devclass or NULL if there is none.

Definition at line 2342 of file subr_bus.c.

References devclass_get_name().

Referenced by bus_enumerate_hinted_children(), device_log(), device_print_prettyname(), device_printf(), device_probe(), device_probe_child(), intr_alloc_msi(), intr_alloc_msix(), intr_map_msi(), intr_pic_claim_root(), intr_release_msi(), intr_release_msix(), intr_resolve_irq(), and sysctl_rman().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_get_nameunit()

const char * device_get_nameunit ( device_t  dev)

◆ device_get_parent()

◆ device_get_path()

static char * device_get_path ( device_t  dev,
const char *  locator 
)
static

Definition at line 5812 of file subr_bus.c.

References device_get_parent(), malloc(), sbuf_data(), sbuf_delete(), sbuf_finish(), sbuf_len(), and sbuf_new().

Referenced by dev_wired_cache_match(), and devctl2_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_get_property()

ssize_t device_get_property ( device_t  dev,
const char *  prop,
void *  val,
size_t  sz,
device_property_type_t  type 
)

Definition at line 2720 of file subr_bus.c.

References bus, device_get_parent(), and type.

Referenced by device_has_property().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_get_softc()

void * device_get_softc ( device_t  dev)

Return the device's softc field.

The softc is allocated and zeroed when a driver is attached, based on the size field of the driver.

Definition at line 2560 of file subr_bus.c.

Referenced by cf_get_method(), cf_levels_method(), cf_set_method(), cpufreq_add_freq_driver_sysctl(), cpufreq_add_levels(), cpufreq_attach(), cpufreq_detach(), cpufreq_register(), cpufreq_unregister(), and devclass_get_softc().

Here is the caller graph for this function:

◆ device_get_state()

device_state_t device_get_state ( device_t  dev)

Return the device's state.

Definition at line 2640 of file subr_bus.c.

Referenced by bus_helper_reset_prepare().

Here is the caller graph for this function:

◆ device_get_sysctl_ctx()

struct sysctl_ctx_list * device_get_sysctl_ctx ( device_t  dev)

Definition at line 2388 of file subr_bus.c.

Referenced by cpufreq_register().

Here is the caller graph for this function:

◆ device_get_sysctl_tree()

struct sysctl_oid * device_get_sysctl_tree ( device_t  dev)

Definition at line 2394 of file subr_bus.c.

Referenced by cpufreq_add_freq_driver_sysctl(), cpufreq_attach(), and cpufreq_register().

Here is the caller graph for this function:

◆ device_get_unit()

int device_get_unit ( device_t  dev)

Return the device's unit number.

Definition at line 2364 of file subr_bus.c.

Referenced by cpufreq_register(), cpufreq_settings_changed(), device_log(), device_print_prettyname(), device_printf(), and sysctl_rman().

Here is the caller graph for this function:

◆ device_has_property()

bool device_has_property ( device_t  dev,
const char *  prop 
)

Definition at line 2745 of file subr_bus.c.

References device_get_property().

Here is the call graph for this function:

◆ device_has_quiet_children()

int device_has_quiet_children ( device_t  dev)

Return non-zero if the DF_QUIET_CHIDLREN flag is set on the device.

Definition at line 2754 of file subr_bus.c.

Referenced by make_device().

Here is the caller graph for this function:

◆ device_is_alive()

int device_is_alive ( device_t  dev)

Return non-zero if the device was successfully probed.

Definition at line 2781 of file subr_bus.c.

Referenced by devctl2_ioctl(), and device_print_child().

Here is the caller graph for this function:

◆ device_is_attached()

int device_is_attached ( device_t  dev)

Return non-zero if the device currently has a driver attached to it.

Definition at line 2791 of file subr_bus.c.

Referenced by cf_set_method(), cpufreq_add_levels(), devclass_driver_added(), and devctl2_ioctl().

Here is the caller graph for this function:

◆ device_is_devclass_fixed()

bool device_is_devclass_fixed ( device_t  dev)

Query the device to determine if it's of a fixed devclass.

See also
device_set_devclass_fixed()

Definition at line 2860 of file subr_bus.c.

◆ device_is_enabled()

int device_is_enabled ( device_t  dev)

Return non-zero if the DF_ENABLED flag is set on the device.

Definition at line 2772 of file subr_bus.c.

Referenced by devctl2_ioctl().

Here is the caller graph for this function:

◆ device_is_quiet()

int device_is_quiet ( device_t  dev)

Return non-zero if the DF_QUIET flag is set on the device.

Definition at line 2763 of file subr_bus.c.

Referenced by device_attach(), and device_detach().

Here is the caller graph for this function:

◆ device_is_suspended()

int device_is_suspended ( device_t  dev)

Return non-zero if the device is currently suspended.

Definition at line 2800 of file subr_bus.c.

Referenced by devctl2_ioctl().

Here is the caller graph for this function:

◆ device_log()

int device_log ( device_t  dev,
int  pri,
const char *  fmt,
  ... 
)

Print the name of the device followed by a colon, a space and the result of calling log() with the value of fmt and the following arguments.

Returns
the number of characters printed

Definition at line 2460 of file subr_bus.c.

References buf, device_get_name(), device_get_unit(), log(), name, sbuf_cat(), sbuf_data(), sbuf_delete(), sbuf_finish(), sbuf_len(), sbuf_new(), sbuf_printf(), and sbuf_vprintf().

Here is the call graph for this function:

◆ device_lookup_by_name()

device_t device_lookup_by_name ( const char *  name)

Definition at line 5706 of file subr_bus.c.

References bus_data_devices, and name.

Referenced by find_device().

Here is the caller graph for this function:

◆ device_print_child()

static int device_print_child ( device_t  dev,
device_t  child 
)
static

Print a description of a device.

Definition at line 1864 of file subr_bus.c.

References child, device_is_alive(), and device_printf().

Referenced by device_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_print_prettyname()

int device_print_prettyname ( device_t  dev)

Print the name of the device followed by a colon and a space.

Returns
the number of characters printed

Definition at line 2405 of file subr_bus.c.

References device_get_name(), device_get_unit(), name, and printf().

Referenced by device_probe().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_printf()

int device_printf ( device_t  dev,
const char *  fmt,
  ... 
)

Print the name of the device followed by a colon, a space and the result of calling vprintf() with the value of fmt and the following arguments.

Returns
the number of characters printed

Definition at line 2422 of file subr_bus.c.

References buf, device_get_name(), device_get_unit(), name, sbuf_cat(), sbuf_delete(), sbuf_finish(), sbuf_new(), sbuf_printf(), sbuf_printf_drain(), sbuf_set_drain(), and sbuf_vprintf().

Referenced by _gone_in_dev(), bus_print_child_header(), bus_setup_intr(), cf_set_method(), clock_dbgprint_hdr(), clock_register_flags(), cpufreq_unregister(), device_attach(), device_detach(), device_print_child(), intr_pic_claim_root(), read_clocks(), resource_list_alloc(), resource_list_release_active(), and settime_task_func().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_probe()

int device_probe ( device_t  dev)

Probe a device, and return this status.

This function is the core of the device autoconfiguration system. Its purpose is to select a suitable driver for a device and then call that driver to initialise the hardware appropriately. The driver is selected by calling the DEVICE_PROBE() method of a set of candidate drivers and then choosing the driver which returned the best value. This driver is then attached to the device using device_attach().

The set of suitable drivers is taken from the list of drivers in the parent device's devclass. If the device was originally created with a specific class name (see device_add_child()), only drivers with that name are probed, otherwise all drivers in the devclass are probed. If no drivers return successful probe values in the parent devclass, the search continues in the parent of that devclass (see devclass_get_parent()) if any.

Parameters
devthe device to initialise
Return values
0success
ENXIOno driver was found
ENOMEMmemory allocation failure
non-zerosome other unix error code
-1Device already attached

Definition at line 2943 of file subr_bus.c.

References bootverbose, bus_current_pass, bus_topo_assert(), device_get_name(), device_print_prettyname(), device_probe_child(), devnomatch(), and printf().

Referenced by device_probe_and_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_probe_and_attach()

int device_probe_and_attach ( device_t  dev)

Probe a device and attach a driver if possible.

calls device_probe() and attaches if that was successful.

Definition at line 2977 of file subr_bus.c.

References bus_topo_assert(), device_attach(), and device_probe().

Referenced by bus_generic_attach(), bus_generic_driver_added(), bus_generic_new_pass(), bus_helper_reset_post(), bus_helper_reset_prepare(), bus_helper_reset_prepare_rollback(), cpufreq_register(), and devctl2_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_probe_child()

int device_probe_child ( device_t  dev,
device_t  child 
)

◆ device_quiesce()

int device_quiesce ( device_t  dev)

Tells a driver to quiesce itself.

This function is a wrapper around the DEVICE_QUIESCE() driver method. If the call to DEVICE_QUIESCE() succeeds.

Parameters
devthe device to quiesce
Return values
0success
ENXIOno driver was found
ENOMEMmemory allocation failure
non-zerosome other unix error code

Definition at line 3131 of file subr_bus.c.

References DEVICENAME, and PDEBUG.

Referenced by devclass_quiesce_driver(), and devctl2_ioctl().

Here is the caller graph for this function:

◆ device_quiet()

void device_quiet ( device_t  dev)

Set the DF_QUIET flag for the device.

Definition at line 2696 of file subr_bus.c.

Referenced by cpufreq_register().

Here is the caller graph for this function:

◆ device_quiet_children()

void device_quiet_children ( device_t  dev)

Set the DF_QUIET_CHILDREN flag for the device.

Definition at line 2705 of file subr_bus.c.

◆ device_set_desc()

void device_set_desc ( device_t  dev,
const char *  desc 
)

Set the device's description.

The value of desc should be a string constant that will not change (at least until the description is changed in a subsequent call to device_set_desc() or device_set_desc_copy()).

Definition at line 2527 of file subr_bus.c.

References device_set_desc_internal().

Referenced by device_set_driver().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_set_desc_copy()

void device_set_desc_copy ( device_t  dev,
const char *  desc 
)

Set the device's description.

The string pointed to by desc is copied. Use this function if the device description is generated, (e.g. with sprintf()).

Definition at line 2539 of file subr_bus.c.

References device_set_desc_internal().

Here is the call graph for this function:

◆ device_set_desc_internal()

static void device_set_desc_internal ( device_t  dev,
const char *  desc,
int  copy 
)
static

Definition at line 2497 of file subr_bus.c.

References bus_data_generation_update(), free(), and malloc().

Referenced by device_set_desc(), and device_set_desc_copy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_set_devclass()

int device_set_devclass ( device_t  dev,
const char *  classname 
)

Set the devclass of a device.

See also
devclass_add_device().

Definition at line 2810 of file subr_bus.c.

References bus_data_generation_update(), devclass_add_device(), devclass_delete_device(), devclass_find_internal(), and printf().

Referenced by device_probe_child(), and device_set_devclass_fixed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_set_devclass_fixed()

int device_set_devclass_fixed ( device_t  dev,
const char *  classname 
)

Set the devclass of a device and mark the devclass fixed.

See also
device_set_devclass()

Definition at line 2841 of file subr_bus.c.

References device_set_devclass().

Here is the call graph for this function:

◆ device_set_driver()

int device_set_driver ( device_t  dev,
driver_t *  driver 
)

Set the driver of a device.

Return values
0success
EBUSYthe device already has a driver attached
ENOMEMa memory allocation failure occurred

Definition at line 2873 of file subr_bus.c.

References bus_data_generation_update(), bus_get_domain(), device_set_desc(), domain, free(), kobj_delete(), kobj_init(), and malloc_domainset().

Referenced by device_attach(), device_detach(), and device_probe_child().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_set_flags()

void device_set_flags ( device_t  dev,
uint32_t  flags 
)

Set the device's flags.

Definition at line 2548 of file subr_bus.c.

References flags.

◆ device_set_ivars()

void device_set_ivars ( device_t  dev,
void *  ivars 
)

Set the device's ivars field.

Definition at line 2630 of file subr_bus.c.

◆ device_set_softc()

void device_set_softc ( device_t  dev,
void *  softc 
)

Set the device's softc field.

Most drivers do not need to use this since the softc is allocated automatically when the driver is attached.

Definition at line 2572 of file subr_bus.c.

References free().

Here is the call graph for this function:

◆ device_set_unit()

int device_set_unit ( device_t  dev,
int  unit 
)

Set the unit number of a device.

This function can be used to override the unit number used for a device (e.g. to wire a device to a pre-configured unit number).

Definition at line 3165 of file subr_bus.c.

References bus_data_generation_update(), devclass_add_device(), devclass_delete_device(), and device_get_devclass().

Here is the call graph for this function:

◆ device_shutdown()

int device_shutdown ( device_t  dev)

Notify a device of system shutdown.

This function calls the DEVICE_SHUTDOWN() driver method if the device currently has an attached driver.

Returns
the value returned by DEVICE_SHUTDOWN()

Definition at line 3151 of file subr_bus.c.

Referenced by bus_generic_shutdown(), and root_bus_module_handler().

Here is the caller graph for this function:

◆ device_sysctl_fini()

static void device_sysctl_fini ( device_t  dev)
static

Definition at line 353 of file subr_bus.c.

References sysctl_ctx_free().

Referenced by device_attach(), and device_detach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_sysctl_handler()

static int device_sysctl_handler ( SYSCTL_HANDLER_ARGS  )
static

◆ device_sysctl_init()

static void device_sysctl_init ( device_t  dev)
static

Definition at line 299 of file subr_bus.c.

References bus_get_domain(), devclass_sysctl_init(), DEVICE_SYSCTL_DESC, DEVICE_SYSCTL_DRIVER, device_sysctl_handler(), DEVICE_SYSCTL_LOCATION, DEVICE_SYSCTL_PARENT, DEVICE_SYSCTL_PNPINFO, domain, and sysctl_ctx_init().

Referenced by device_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_sysctl_update()

static void device_sysctl_update ( device_t  dev)
static

Definition at line 343 of file subr_bus.c.

References sysctl_rename_oid().

Referenced by device_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_unbusy()

void device_unbusy ( device_t  dev)

Decrement the busy counter for the device.

Definition at line 2682 of file subr_bus.c.

References device_unbusy().

Referenced by device_unbusy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_verbose()

void device_verbose ( device_t  dev)

Clear the DF_QUIET flag for the device.

Definition at line 2714 of file subr_bus.c.

Referenced by device_detach(), and device_probe_child().

Here is the caller graph for this function:

◆ devinit()

static void devinit ( void  )
static

Definition at line 432 of file subr_bus.c.

References dev_softc::cv, cv_init(), dev_cdevsw, devctl2_init(), devctl_dev, devctl_queue_length, dev_softc::devq, devsoftc, knlist_init_mtx(), make_dev_credf(), dev_softc::mtx, dev_softc::sel, and dev_softc::zone.

Referenced by root_bus_module_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devioctl()

static int devioctl ( struct cdev *  dev,
u_long  cmd,
caddr_t  data,
int  fflag,
struct thread *  td 
)
static

Definition at line 529 of file subr_bus.c.

References dev_softc::async, data, devsoftc, fgetown(), fsetown(), dev_softc::nonblock, and dev_softc::sigio.

Here is the call graph for this function:

◆ devkqfilter()

static int devkqfilter ( struct cdev *  dev,
struct knote kn 
)
static

Definition at line 578 of file subr_bus.c.

References devctl_rfiltops, devsoftc, knlist_add(), and dev_softc::sel.

Here is the call graph for this function:

◆ devnomatch()

static void devnomatch ( device_t  dev)
static

Definition at line 794 of file subr_bus.c.

References devaddq().

Referenced by devclass_driver_deleted(), device_gen_nomatch(), and device_probe().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devopen()

static int devopen ( struct cdev *  dev,
int  oflags,
int  devtype,
struct thread *  td 
)
static

Definition at line 464 of file subr_bus.c.

References devsoftc, dev_softc::inuse, and dev_softc::mtx.

◆ devpoll()

static int devpoll ( struct cdev *  dev,
int  events,
struct thread *  td 
)
static

Definition at line 561 of file subr_bus.c.

References dev_softc::devq, devsoftc, dev_softc::mtx, dev_softc::sel, and selrecord().

Here is the call graph for this function:

◆ devread()

static int devread ( struct cdev *  dev,
struct uio *  uio,
int  ioflag 
)
static

Definition at line 499 of file subr_bus.c.

References dev_softc::cv, dev_softc::devq, devsoftc, dev_softc::mtx, dev_softc::nonblock, dev_softc::queued, uiomove(), and dev_softc::zone.

Here is the call graph for this function:

◆ devremoved()

static void devremoved ( device_t  dev)
static

Definition at line 781 of file subr_bus.c.

References devaddq(), and device_get_nameunit().

Referenced by device_detach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ driver_exists()

static bool driver_exists ( device_t  bus,
const char *  driver 
)
static

Definition at line 5753 of file subr_bus.c.

References bus, and devclass_find_driver_internal().

Referenced by devctl2_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ driver_module_handler()

int driver_module_handler ( module_t  mod,
int  what,
void *  arg 
)

Module handler for registering device drivers.

This module handler is used to automatically register device drivers when modules are loaded. If what is MOD_LOAD, it calls devclass_add_driver() for the driver described by the driver_module_data structure pointed to by arg

Definition at line 5347 of file subr_bus.c.

References devclass_add_driver(), devclass_delete_driver(), devclass_find_internal(), devclass_quiesce_driver(), DRIVERNAME, and PDEBUG.

Here is the call graph for this function:

◆ driver_register_pass()

static void driver_register_pass ( struct driverlink new)
static

Register the pass level of a new driver attachment.

Register a new driver attachment's pass level. If no driver attachment with the same pass level has been added, then new will be added to the global passes list.

Parameters
newthe new driver attachment

Definition at line 916 of file subr_bus.c.

References bus_current_pass, and passes.

Referenced by devclass_add_driver().

Here is the caller graph for this function:

◆ EVENTHANDLER_LIST_DEFINE() [1/3]

EVENTHANDLER_LIST_DEFINE ( dev_lookup  )

◆ EVENTHANDLER_LIST_DEFINE() [2/3]

EVENTHANDLER_LIST_DEFINE ( device_attach  )

◆ EVENTHANDLER_LIST_DEFINE() [3/3]

EVENTHANDLER_LIST_DEFINE ( device_detach  )

◆ filt_devctl_detach()

static void filt_devctl_detach ( struct knote kn)
static

Definition at line 592 of file subr_bus.c.

References devsoftc, knlist_remove(), and dev_softc::sel.

Here is the call graph for this function:

◆ filt_devctl_read()

static int filt_devctl_read ( struct knote kn,
long  hint 
)
static

Definition at line 598 of file subr_bus.c.

References devsoftc, and dev_softc::queued.

◆ find_device()

static int find_device ( struct devreq *  req,
device_t *  devp 
)
static

Definition at line 5723 of file subr_bus.c.

References device_lookup_by_name().

Referenced by devctl2_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ first_matching_driver()

static driverlink_t first_matching_driver ( devclass_t  dc,
device_t  dev 
)
static

Definition at line 2076 of file subr_bus.c.

References devclass_find_driver_internal().

Referenced by device_probe_child().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gone_panic()

static void gone_panic ( int  major,
int  running,
const char *  msg 
)
static

Definition at line 6243 of file subr_bus.c.

References obsolete_panic, and panic().

Referenced by _gone_in(), and _gone_in_dev().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_device()

static device_t make_device ( device_t  parent,
const char *  name,
int  unit 
)
static

Make a new device and add it as a child of parent.

Parameters
parentthe parent of the new device
namethe devclass name of the new device or NULL to leave the devclass unspecified @parem unit the unit number of the new device of -1 to leave the unit number unspecified
Returns
the new device

Definition at line 1803 of file subr_bus.c.

References bus_data_devices, bus_data_generation_update(), devclass_add_device(), devclass_find_internal(), device_has_quiet_children(), DEVICENAME, kobj_delete(), kobj_init(), malloc(), name, parent, PDEBUG, and printf().

Referenced by device_add_child_ordered(), and root_bus_module_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MALLOC_DEFINE() [1/2]

static MALLOC_DEFINE ( M_BUS  ,
"bus"  ,
"Bus data structures"   
)
static

◆ MALLOC_DEFINE() [2/2]

static MALLOC_DEFINE ( M_BUS_SC  ,
"bus-sc"  ,
"Bus data  structures,
softc"   
)
static

◆ next_matching_driver()

static driverlink_t next_matching_driver ( devclass_t  dc,
device_t  dev,
driverlink_t  last 
)
static

Definition at line 2087 of file subr_bus.c.

References driverlink::driver.

Referenced by device_probe_child().

Here is the caller graph for this function:

◆ resource_init_map_request_impl()

void resource_init_map_request_impl ( struct resource_map_request *  args,
size_t  sz 
)

Definition at line 3193 of file subr_bus.c.

◆ resource_list_add()

struct resource_list_entry * resource_list_add ( struct resource_list *  rl,
int  type,
int  rid,
rman_res_t  start,
rman_res_t  end,
rman_res_t  count 
)

Add or modify a resource entry.

If an existing entry exists with the same type and rid, it will be modified using the given values of start, end and count. If no entry exists, a new one will be created using the given values. The resource list entry that matches is then returned.

Parameters
rlthe resource list to edit
typethe resource entry type (e.g. SYS_RES_MEMORY)
ridthe resource identifier
startthe start address of the resource
endthe end address of the resource
countXXX end-start+1

Definition at line 3274 of file subr_bus.c.

References count, malloc(), panic(), resource_list_find(), start, and type.

Referenced by bus_generic_rl_set_resource(), and resource_list_add_next().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resource_list_add_next()

int resource_list_add_next ( struct resource_list *  rl,
int  type,
rman_res_t  start,
rman_res_t  end,
rman_res_t  count 
)

Add a resource entry.

This function adds a resource entry using the given type, start, end and count values. A rid value is chosen by searching sequentially for the first unused rid starting at zero.

Parameters
rlthe resource list to edit
typethe resource entry type (e.g. SYS_RES_MEMORY)
startthe start address of the resource
endthe end address of the resource
countXXX end-start+1

Definition at line 3246 of file subr_bus.c.

References count, resource_list_add(), resource_list_find(), start, and type.

Here is the call graph for this function:

◆ resource_list_alloc()

struct resource * resource_list_alloc ( struct resource_list *  rl,
device_t  bus,
device_t  child,
int  type,
int *  rid,
rman_res_t  start,
rman_res_t  end,
rman_res_t  count,
u_int  flags 
)

Helper function for implementing BUS_ALLOC_RESOURCE()

Implement BUS_ALLOC_RESOURCE() by looking up a resource from the list and passing the allocation up to the parent of bus. This assumes that the first entry of device_get_ivars(child) is a struct resource_list. This also handles 'passthrough' allocations where a child is a remote descendant of bus by passing the allocation up to the parent of bus.

Typically, a bus driver would store a list of child resources somewhere in the child device's ivars (see device_get_ivars()) and its implementation of BUS_ALLOC_RESOURCE() would find that list and then call resource_list_alloc() to perform the allocation.

Parameters
rlthe resource list to allocate from
busthe parent device of child
childthe device which is requesting an allocation
typethe type of resource to allocate
rida pointer to the resource identifier
starthint at the start of the resource range - pass 0 for any start address
endhint at the end of the resource range - pass ~0 for any end address
counthint at the size of range required - pass 1 for any size
flagsany extra flags to control the resource allocation - see RF_XXX flags in <sys/rman.h> for details
Returns
the resource which was allocated or NULL if no resource could be allocated

Definition at line 3489 of file subr_bus.c.

References bus, bus_activate_resource(), child, count, device_get_nameunit(), device_get_parent(), device_printf(), flags, resource_list_find(), rman_get_end(), rman_get_start(), start, and type.

Referenced by bus_generic_rl_alloc_resource(), and resource_list_reserve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resource_list_busy()

int resource_list_busy ( struct resource_list *  rl,
int  type,
int  rid 
)

Determine if a resource entry is busy.

Returns true if a resource entry is busy meaning that it has an associated resource that is not an unallocated "reserved" resource.

Parameters
rlthe resource list to search
typethe resource entry type (e.g. SYS_RES_MEMORY)
ridthe resource identifier
Returns
Non-zero if the entry is busy, zero otherwise.

Definition at line 3314 of file subr_bus.c.

References resource_list_find(), rman_get_flags(), and type.

Here is the call graph for this function:

◆ resource_list_delete()

void resource_list_delete ( struct resource_list *  rl,
int  type,
int  rid 
)

Delete a resource entry.

Parameters
rlthe resource list to edit
typethe resource entry type (e.g. SYS_RES_MEMORY)
ridthe resource identifier

Definition at line 3383 of file subr_bus.c.

References free(), panic(), resource_list_find(), and type.

Referenced by bus_generic_rl_delete_resource().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resource_list_find()

struct resource_list_entry * resource_list_find ( struct resource_list *  rl,
int  type,
int  rid 
)

Find a resource entry by type and rid.

Parameters
rlthe resource list to search
typethe resource entry type (e.g. SYS_RES_MEMORY)
ridthe resource identifier
Returns
the resource entry pointer or NULL if there is no such entry.

Definition at line 3364 of file subr_bus.c.

References type.

Referenced by bus_generic_rl_get_resource(), resource_list_add(), resource_list_add_next(), resource_list_alloc(), resource_list_busy(), resource_list_delete(), resource_list_release(), resource_list_reserve(), resource_list_reserved(), and resource_list_unreserve().

Here is the caller graph for this function:

◆ resource_list_free()

void resource_list_free ( struct resource_list *  rl)

Reclaim memory used by a resource list.

This function frees the memory for all resource entries on the list (if any).

Parameters
rlthe resource list to free

Definition at line 3220 of file subr_bus.c.

References free(), and panic().

Here is the call graph for this function:

◆ resource_list_init()

void resource_list_init ( struct resource_list *  rl)

Initialise a resource list.

Parameters
rlthe resource list to initialise

Definition at line 3206 of file subr_bus.c.

◆ resource_list_print_type()

int resource_list_print_type ( struct resource_list *  rl,
const char *  name,
int  type,
const char *  format 
)

Print a description of resources in a resource list.

Print all resources of a specified type, for use in BUS_PRINT_CHILD(). The name is printed if at least one resource of the given type is available. The format is used to print resource start and end.

Parameters
rlthe resource list to print
namethe name of type, e.g. "memory"
typetype type of resource entry to print
formatprintf(9) format string to print resource start and end values
Returns
the number of characters printed

Definition at line 3699 of file subr_bus.c.

References name, printf(), and type.

Here is the call graph for this function:

◆ resource_list_purge()

void resource_list_purge ( struct resource_list *  rl)

Releases all the resources in a list.

Parameters
rlThe resource list to purge.
Returns
nothing

Definition at line 3734 of file subr_bus.c.

References bus_release_resource(), free(), and rman_get_device().

Here is the call graph for this function:

◆ resource_list_release()

int resource_list_release ( struct resource_list *  rl,
device_t  bus,
device_t  child,
int  type,
int  rid,
struct resource *  res 
)

Helper function for implementing BUS_RELEASE_RESOURCE()

Implement BUS_RELEASE_RESOURCE() using a resource list. Normally used with resource_list_alloc().

Parameters
rlthe resource list which was allocated from
busthe parent device of child
childthe device which is requesting a release
typethe type of resource to release
ridthe resource identifier
resthe resource to release
Return values
0success
non-zeroa standard unix error code indicating what error condition prevented the operation

Definition at line 3562 of file subr_bus.c.

References bus, bus_deactivate_resource(), child, device_get_parent(), panic(), res, resource_list_find(), rman_get_flags(), and type.

Referenced by bus_generic_rl_release_resource(), resource_list_release_active(), and resource_list_unreserve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resource_list_release_active()

int resource_list_release_active ( struct resource_list *  rl,
device_t  bus,
device_t  child,
int  type 
)

Release all active resources of a given type.

Release all active resources of a specified type. This is intended to be used to cleanup resources leaked by a driver after detach or a failed attach.

Parameters
rlthe resource list which was allocated from
busthe parent device of child
childthe device whose active resources are being released
typethe type of resources to release
Return values
0success
EBUSYat least one resource was active

Definition at line 3619 of file subr_bus.c.

References bus, child, device_printf(), resource_list_release(), rman_get_rid(), and type.

Here is the call graph for this function:

◆ resource_list_reserve()

struct resource * resource_list_reserve ( struct resource_list *  rl,
device_t  bus,
device_t  child,
int  type,
int *  rid,
rman_res_t  start,
rman_res_t  end,
rman_res_t  count,
u_int  flags 
)

Allocate a reserved resource.

This can be used by buses to force the allocation of resources that are always active in the system even if they are not allocated by a driver (e.g. PCI BARs). This function is usually called when adding a new child to the bus. The resource is allocated from the parent bus when it is reserved. The resource list entry is marked with RLE_RESERVED to note that it is a reserved resource.

Subsequent attempts to allocate the resource with resource_list_alloc() will succeed the first time and will set RLE_ALLOCATED to note that it has been allocated. When a reserved resource that has been allocated is released with resource_list_release() the resource RLE_ALLOCATED is cleared, but the actual resource remains allocated. The resource can be released to the parent bus by calling resource_list_unreserve().

Parameters
rlthe resource list to allocate from
busthe parent device of child
childthe device for which the resource is being reserved
typethe type of resource to allocate
rida pointer to the resource identifier
starthint at the start of the resource range - pass 0 for any start address
endhint at the end of the resource range - pass ~0 for any end address
counthint at the size of range required - pass 1 for any size
flagsany extra flags to control the resource allocation - see RF_XXX flags in <sys/rman.h> for details
Returns
the resource which was allocated or NULL if no resource could be allocated

Definition at line 3432 of file subr_bus.c.

References bus, child, count, device_get_parent(), flags, panic(), resource_list_alloc(), resource_list_find(), start, and type.

Here is the call graph for this function:

◆ resource_list_reserved()

int resource_list_reserved ( struct resource_list *  rl,
int  type,
int  rid 
)

Determine if a resource entry is reserved.

Returns true if a resource entry is reserved meaning that it has an associated "reserved" resource. The resource can either be allocated or unallocated.

Parameters
rlthe resource list to search
typethe resource entry type (e.g. SYS_RES_MEMORY)
ridthe resource identifier
Returns
Non-zero if the entry is reserved, zero otherwise.

Definition at line 3343 of file subr_bus.c.

References resource_list_find(), and type.

Here is the call graph for this function:

◆ resource_list_unreserve()

int resource_list_unreserve ( struct resource_list *  rl,
device_t  bus,
device_t  child,
int  type,
int  rid 
)

Fully release a reserved resource.

Fully releases a resource reserved via resource_list_reserve().

Parameters
rlthe resource list which was allocated from
busthe parent device of child
childthe device whose reserved resource is being released
typethe type of resource to release
ridthe resource identifier
resthe resource to release
Return values
0success
non-zeroa standard unix error code indicating what error condition prevented the operation

Definition at line 3661 of file subr_bus.c.

References bus, child, device_get_parent(), panic(), resource_list_find(), resource_list_release(), and type.

Here is the call graph for this function:

◆ root_bus_configure()

void root_bus_configure ( void  )

Automatically configure devices.

This function begins the autoconfiguration process by calling device_probe_and_attach() for each child of the root0 device.

Definition at line 5330 of file subr_bus.c.

References bus_set_pass(), and PDEBUG.

Here is the call graph for this function:

◆ root_bus_module_handler()

static int root_bus_module_handler ( module_t  mod,
int  what,
void *  arg 
)
static

Definition at line 5291 of file subr_bus.c.

References bus_data_devices, devclass_find_internal(), device_shutdown(), devinit(), kobj_class_compile(), kobj_init(), make_device(), root_bus, root_devclass, and root_driver.

Here is the call graph for this function:

◆ root_child_present()

static int root_child_present ( device_t  dev,
device_t  child 
)
static

Definition at line 5243 of file subr_bus.c.

◆ root_get_cpus()

static int root_get_cpus ( device_t  dev,
device_t  child,
enum cpu_sets  op,
size_t  setsize,
cpuset_t *  cpuset 
)
static

Definition at line 5249 of file subr_bus.c.

References all_cpus.

◆ root_print_child()

static int root_print_child ( device_t  dev,
device_t  child 
)
static

Definition at line 5215 of file subr_bus.c.

References bus_print_child_header(), child, and printf().

Here is the call graph for this function:

◆ root_resume()

static int root_resume ( device_t  dev)
static

Definition at line 5202 of file subr_bus.c.

References bus_generic_resume(), and devctl_notify().

Here is the call graph for this function:

◆ root_setup_intr()

static int root_setup_intr ( device_t  dev,
device_t  child,
struct resource *  irq,
int  flags,
driver_filter_t *  filter,
driver_intr_t *  intr,
void *  arg,
void **  cookiep 
)
static

Definition at line 5226 of file subr_bus.c.

References panic().

Here is the call graph for this function:

◆ STAILQ_HEAD()

STAILQ_HEAD ( devq  ,
dev_event_info   
)

◆ sysctl_bus_info()

static int sysctl_bus_info ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 5602 of file subr_bus.c.

References bus_data_generation.

◆ sysctl_devctl_queue()

static int sysctl_devctl_queue ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 800 of file subr_bus.c.

References devctl_queue_length, devsoftc, dev_softc::mtx, sysctl_handle_int(), and dev_softc::zone.

Here is the call graph for this function:

◆ sysctl_devices()

static int sysctl_devices ( SYSCTL_HANDLER_ARGS  )
static

◆ SYSCTL_INT()

SYSCTL_INT ( _debug  ,
OID_AUTO  ,
obsolete_panic  ,
CTLFLAG_RWTUN  ,
obsolete_panic,
,
"Panic when obsolete features are used (0 = never, 1 = if obsolete, " "2 = if deprecated)"   
)

◆ SYSCTL_NODE() [1/2]

SYSCTL_NODE ( _hw  ,
OID_AUTO  ,
bus  ,
CTLFLAG_RW|  CTLFLAG_MPSAFE,
NULL  ,
NULL   
)

◆ SYSCTL_NODE() [2/2]

SYSCTL_NODE ( _hw_bus  ,
OID_AUTO  ,
devices  ,
CTLFLAG_RD|  CTLFLAG_NEEDGIANT,
sysctl_devices  ,
"system device tree"   
)

◆ SYSCTL_PROC() [1/2]

SYSCTL_PROC ( _hw_bus  ,
OID_AUTO  ,
devctl_queue  ,
CTLTYPE_INT|CTLFLAG_RWTUN|  CTLFLAG_MPSAFE,
NULL  ,
,
sysctl_devctl_queue  ,
"I"  ,
"devctl queue length"   
)

◆ SYSCTL_PROC() [2/2]

SYSCTL_PROC ( _hw_bus  ,
OID_AUTO  ,
info  ,
CTLTYPE_STRUCT|CTLFLAG_RD|  CTLFLAG_MPSAFE,
NULL  ,
,
sysctl_bus_info  ,
S,
u_businfo"  ,
"bus-related data  
)

◆ SYSCTL_ROOT_NODE()

SYSCTL_ROOT_NODE ( OID_AUTO  ,
dev  ,
CTLFLAG_RW|  CTLFLAG_MPSAFE,
NULL  ,
NULL   
)

◆ TAILQ_HEAD() [1/2]

typedef TAILQ_HEAD ( devclass_list  ,
devclass   
)

Definition at line 97 of file subr_bus.c.

References flags, name, and parent.

◆ TAILQ_HEAD() [2/2]

typedef TAILQ_HEAD ( device_location_list  ,
device_location_node   
)

Definition at line 6142 of file subr_bus.c.

Variable Documentation

◆ bus_current_pass

int bus_current_pass = BUS_PASS_ROOT

◆ bus_data_devices

struct device_list bus_data_devices
static

◆ bus_data_generation

int bus_data_generation = 1
static

◆ dev_cdevsw

struct cdevsw dev_cdevsw
static
Initial value:
= {
.d_version = D_VERSION,
.d_open = devopen,
.d_close = devclose,
.d_read = devread,
.d_ioctl = devioctl,
.d_poll = devpoll,
.d_kqfilter = devkqfilter,
.d_name = "devctl",
}
static d_read_t devread
Definition: subr_bus.c:383
static d_ioctl_t devioctl
Definition: subr_bus.c:384
static d_kqfilter_t devkqfilter
Definition: subr_bus.c:386
static d_close_t devclose
Definition: subr_bus.c:382
static d_poll_t devpoll
Definition: subr_bus.c:385
static d_open_t devopen
Definition: subr_bus.c:381

Definition at line 388 of file subr_bus.c.

Referenced by devinit().

◆ devclasses

devclass_list_t devclasses = TAILQ_HEAD_INITIALIZER(devclasses)
static

◆ devclose

d_close_t devclose
static

Definition at line 382 of file subr_bus.c.

◆ devctl2_cdevsw

struct cdevsw devctl2_cdevsw
static
Initial value:
= {
.d_version = D_VERSION,
.d_ioctl = devctl2_ioctl,
.d_name = "devctl2",
}
static int devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag, struct thread *td)
Definition: subr_bus.c:5835

Definition at line 6121 of file subr_bus.c.

Referenced by devctl2_init().

◆ devctl_dev

struct cdev* devctl_dev
static

Definition at line 429 of file subr_bus.c.

Referenced by devinit().

◆ devctl_queue_length

int devctl_queue_length = DEVCTL_DEFAULT_QUEUE_LEN
static

Definition at line 377 of file subr_bus.c.

Referenced by devctl_alloc_dei(), devinit(), and sysctl_devctl_queue().

◆ devctl_rfiltops

struct filterops devctl_rfiltops
Initial value:
= {
.f_isfd = 1,
.f_detach = filt_devctl_detach,
.f_event = filt_devctl_read,
}
static int filt_devctl_read(struct knote *kn, long hint)
Definition: subr_bus.c:598
static void filt_devctl_detach(struct knote *kn)
Definition: subr_bus.c:592

Definition at line 423 of file subr_bus.c.

Referenced by devkqfilter().

◆ device_frozen

bool device_frozen
static

Definition at line 164 of file subr_bus.c.

Referenced by devclass_add_driver(), devclass_driver_deleted(), and devctl2_ioctl().

◆ devioctl

d_ioctl_t devioctl
static

Definition at line 384 of file subr_bus.c.

◆ devkqfilter

d_kqfilter_t devkqfilter
static

Definition at line 386 of file subr_bus.c.

◆ devopen

d_open_t devopen
static

Definition at line 381 of file subr_bus.c.

◆ devpoll

d_poll_t devpoll
static

Definition at line 385 of file subr_bus.c.

◆ devread

d_read_t devread
static

Definition at line 383 of file subr_bus.c.

◆ devsoftc

◆ null_methods

kobj_method_t null_methods[]
static
Initial value:
= {
KOBJMETHOD_END
}

Definition at line 864 of file subr_bus.c.

◆ obsolete_panic

int obsolete_panic = 0
static

Definition at line 6237 of file subr_bus.c.

Referenced by gone_panic().

◆ passes

driver_list_t passes = TAILQ_HEAD_INITIALIZER(passes)
static

Definition at line 902 of file subr_bus.c.

Referenced by bus_set_pass(), clockcalib(), and driver_register_pass().

◆ root_bus

device_t root_bus

Definition at line 5287 of file subr_bus.c.

Referenced by bus_set_pass(), device_do_deferred_actions(), and root_bus_module_handler().

◆ root_bus_mod

moduledata_t root_bus_mod
static
Initial value:
= {
"rootbus",
NULL
}
static int root_bus_module_handler(module_t mod, int what, void *arg)
Definition: subr_bus.c:5291

Definition at line 5316 of file subr_bus.c.

◆ root_devclass

devclass_t root_devclass

Definition at line 5288 of file subr_bus.c.

Referenced by root_bus_module_handler().

◆ root_driver

driver_t root_driver
static
Initial value:
= {
"root",
1,
}
static kobj_method_t root_methods[]
Definition: subr_bus.c:5264

Definition at line 5281 of file subr_bus.c.

Referenced by root_bus_module_handler().

◆ root_methods

kobj_method_t root_methods[]
static
Initial value:
= {
KOBJMETHOD(device_suspend, bus_generic_suspend),
KOBJMETHOD(device_resume, root_resume),
KOBJMETHOD(bus_print_child, root_print_child),
KOBJMETHOD(bus_read_ivar, bus_generic_read_ivar),
KOBJMETHOD(bus_write_ivar, bus_generic_write_ivar),
KOBJMETHOD_END
}
static int root_resume(device_t dev)
Definition: subr_bus.c:5202
int bus_generic_suspend(device_t dev)
Helper function for implementing DEVICE_SUSPEND()
Definition: subr_bus.c:3913
static int root_get_cpus(device_t dev, device_t child, enum cpu_sets op, size_t setsize, cpuset_t *cpuset)
Definition: subr_bus.c:5249
int bus_generic_write_ivar(device_t dev, device_t child, int index, uintptr_t value)
Stub function for implementing BUS_WRITE_IVAR().
Definition: subr_bus.c:4139
int bus_child_present(device_t child)
Wrapper function for BUS_CHILD_PRESENT().
Definition: subr_bus.c:5074
static int root_setup_intr(device_t dev, device_t child, struct resource *irq, int flags, driver_filter_t *filter, driver_intr_t *intr, void *arg, void **cookiep)
Definition: subr_bus.c:5226
static int root_print_child(device_t dev, device_t child)
Definition: subr_bus.c:5215
int bus_setup_intr(device_t dev, struct resource *r, int flags, driver_filter_t filter, driver_intr_t handler, void *arg, void **cookiep)
Wrapper function for BUS_SETUP_INTR().
Definition: subr_bus.c:4893
int bus_generic_shutdown(device_t dev)
Helper function for implementing DEVICE_SHUTDOWN()
Definition: subr_bus.c:3856
int bus_generic_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
Stub function for implementing BUS_READ_IVAR().
Definition: subr_bus.c:4127
int device_shutdown(device_t dev)
Notify a device of system shutdown.
Definition: subr_bus.c:3151
int bus_get_cpus(device_t dev, enum cpu_sets op, size_t setsize, cpuset_t *cpuset)
Wrapper function for BUS_GET_CPUS().
Definition: subr_bus.c:5144
static int root_child_present(device_t dev, device_t child)
Definition: subr_bus.c:5243

Definition at line 5264 of file subr_bus.c.