Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_bus.c
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/condvar.h> | #include <sys/condvar.h> | ||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
#include <machine/bus.h> | #include <machine/bus.h> | ||||
#include <sys/random.h> | #include <sys/random.h> | ||||
#include <sys/rman.h> | #include <sys/rman.h> | ||||
#include <sys/selinfo.h> | #include <sys/selinfo.h> | ||||
#include <sys/signalvar.h> | #include <sys/signalvar.h> | ||||
#include <sys/smp.h> | |||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/uio.h> | #include <sys/uio.h> | ||||
#include <sys/bus.h> | #include <sys/bus.h> | ||||
#include <sys/interrupt.h> | #include <sys/interrupt.h> | ||||
#include <sys/cpuset.h> | #include <sys/cpuset.h> | ||||
#include <net/vnet.h> | #include <net/vnet.h> | ||||
▲ Show 20 Lines • Show All 4,014 Lines • ▼ Show 20 Lines | bus_generic_describe_intr(device_t dev, device_t child, struct resource *irq, | ||||
/* Propagate up the bus hierarchy until someone handles it. */ | /* Propagate up the bus hierarchy until someone handles it. */ | ||||
if (dev->parent) | if (dev->parent) | ||||
return (BUS_DESCRIBE_INTR(dev->parent, child, irq, cookie, | return (BUS_DESCRIBE_INTR(dev->parent, child, irq, cookie, | ||||
descr)); | descr)); | ||||
return (EINVAL); | return (EINVAL); | ||||
} | } | ||||
/** | /** | ||||
* @brief 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 @p dev. | |||||
*/ | |||||
int | |||||
bus_generic_get_cpus(device_t dev, device_t child, enum cpu_sets op, | |||||
cpuset_t *cpuset, int size) | |||||
{ | |||||
/* Propagate up the bus hierarchy until someone handles it. */ | |||||
if (dev->parent != NULL) | |||||
return (BUS_GET_CPUS(dev->parent, child, op, cpuset, size)); | |||||
return (EINVAL); | |||||
} | |||||
/** | |||||
* @brief Helper function for implementing BUS_GET_DMA_TAG(). | * @brief Helper function for implementing BUS_GET_DMA_TAG(). | ||||
* | * | ||||
* This simple implementation of BUS_GET_DMA_TAG() simply calls the | * This simple implementation of BUS_GET_DMA_TAG() simply calls the | ||||
* BUS_GET_DMA_TAG() method of the parent of @p dev. | * BUS_GET_DMA_TAG() method of the parent of @p dev. | ||||
*/ | */ | ||||
bus_dma_tag_t | bus_dma_tag_t | ||||
bus_generic_get_dma_tag(device_t dev, device_t child) | bus_generic_get_dma_tag(device_t dev, device_t child) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 464 Lines • ▼ Show 20 Lines | bus_child_location_str(device_t child, char *buf, size_t buflen) | ||||
if (parent == NULL) { | if (parent == NULL) { | ||||
*buf = '\0'; | *buf = '\0'; | ||||
return (0); | return (0); | ||||
} | } | ||||
return (BUS_CHILD_LOCATION_STR(parent, child, buf, buflen)); | return (BUS_CHILD_LOCATION_STR(parent, child, buf, buflen)); | ||||
} | } | ||||
/** | /** | ||||
* @brief Wrapper function for BUS_GET_CPUS(). | |||||
* | |||||
* This function simply calls the BUS_GET_CPUS() method of the | |||||
* parent of @p dev. | |||||
*/ | |||||
int | |||||
bus_get_cpus(device_t dev, enum cpu_sets op, cpuset_t *cpuset, int size) | |||||
{ | |||||
device_t parent; | |||||
/* | |||||
* How should we handle size mismatch? | |||||
*/ | |||||
if (size < sizeof(cpuset_t)) | |||||
return (ENXIO); | |||||
parent = device_get_parent(dev); | |||||
if (parent == NULL) | |||||
return (EINVAL); | |||||
return (BUS_GET_CPUS(parent, dev, op, cpuset, size)); | |||||
} | |||||
/** | |||||
* @brief Wrapper function for BUS_GET_DMA_TAG(). | * @brief Wrapper function for BUS_GET_DMA_TAG(). | ||||
* | * | ||||
* This function simply calls the BUS_GET_DMA_TAG() method of the | * This function simply calls the BUS_GET_DMA_TAG() method of the | ||||
* parent of @p dev. | * parent of @p dev. | ||||
*/ | */ | ||||
bus_dma_tag_t | bus_dma_tag_t | ||||
bus_get_dma_tag(device_t dev) | bus_get_dma_tag(device_t dev) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
* chain. | * chain. | ||||
*/ | */ | ||||
static int | static int | ||||
root_child_present(device_t dev, device_t child) | root_child_present(device_t dev, device_t child) | ||||
{ | { | ||||
return (-1); | return (-1); | ||||
} | } | ||||
static int | |||||
root_get_cpus(device_t dev, device_t child, enum cpu_sets op, cpuset_t *cpuset, int size) | |||||
{ | |||||
switch (op) { | |||||
case INTR_CPUS: | |||||
/* Default to returning the set of all CPUs. */ | |||||
*cpuset = all_cpus; | |||||
return (0); | |||||
default: | |||||
return (EINVAL); | |||||
} | |||||
} | |||||
static kobj_method_t root_methods[] = { | static kobj_method_t root_methods[] = { | ||||
/* Device interface */ | /* Device interface */ | ||||
KOBJMETHOD(device_shutdown, bus_generic_shutdown), | KOBJMETHOD(device_shutdown, bus_generic_shutdown), | ||||
KOBJMETHOD(device_suspend, bus_generic_suspend), | KOBJMETHOD(device_suspend, bus_generic_suspend), | ||||
KOBJMETHOD(device_resume, root_resume), | KOBJMETHOD(device_resume, root_resume), | ||||
/* Bus interface */ | /* Bus interface */ | ||||
KOBJMETHOD(bus_print_child, root_print_child), | KOBJMETHOD(bus_print_child, root_print_child), | ||||
KOBJMETHOD(bus_read_ivar, bus_generic_read_ivar), | KOBJMETHOD(bus_read_ivar, bus_generic_read_ivar), | ||||
KOBJMETHOD(bus_write_ivar, bus_generic_write_ivar), | KOBJMETHOD(bus_write_ivar, bus_generic_write_ivar), | ||||
KOBJMETHOD(bus_setup_intr, root_setup_intr), | KOBJMETHOD(bus_setup_intr, root_setup_intr), | ||||
KOBJMETHOD(bus_child_present, root_child_present), | KOBJMETHOD(bus_child_present, root_child_present), | ||||
KOBJMETHOD(bus_get_cpus, root_get_cpus), | |||||
KOBJMETHOD_END | KOBJMETHOD_END | ||||
}; | }; | ||||
static driver_t root_driver = { | static driver_t root_driver = { | ||||
"root", | "root", | ||||
root_methods, | root_methods, | ||||
1, /* no softc */ | 1, /* no softc */ | ||||
▲ Show 20 Lines • Show All 656 Lines • Show Last 20 Lines |