Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/subr_bus.c
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
#include <sys/cpuset.h> | #include <sys/cpuset.h> | ||||
#include <net/vnet.h> | #include <net/vnet.h> | ||||
#include <machine/cpu.h> | #include <machine/cpu.h> | ||||
#include <machine/stdarg.h> | #include <machine/stdarg.h> | ||||
#include <vm/uma.h> | #include <vm/uma.h> | ||||
#include <vm/vm.h> | |||||
SYSCTL_NODE(_hw, OID_AUTO, bus, CTLFLAG_RW, NULL, NULL); | SYSCTL_NODE(_hw, OID_AUTO, bus, CTLFLAG_RW, NULL, NULL); | ||||
SYSCTL_ROOT_NODE(OID_AUTO, dev, CTLFLAG_RW, NULL, NULL); | SYSCTL_ROOT_NODE(OID_AUTO, dev, CTLFLAG_RW, NULL, NULL); | ||||
/* | /* | ||||
* Used to attach drivers to devclasses. | * Used to attach drivers to devclasses. | ||||
*/ | */ | ||||
typedef struct driverlink *driverlink_t; | typedef struct driverlink *driverlink_t; | ||||
▲ Show 20 Lines • Show All 2,971 Lines • ▼ Show 20 Lines | device_set_unit(device_t dev, int unit) | ||||
return (0); | return (0); | ||||
} | } | ||||
/*======================================*/ | /*======================================*/ | ||||
/* | /* | ||||
* Some useful method implementations to make life easier for bus drivers. | * Some useful method implementations to make life easier for bus drivers. | ||||
*/ | */ | ||||
void | |||||
resource_init_map_request_impl(struct resource_map_request *args, size_t sz) | |||||
{ | |||||
bzero(args, sz); | |||||
args->size = sz; | |||||
args->memattr = VM_MEMATTR_UNCACHEABLE; | |||||
} | |||||
/** | /** | ||||
* @brief Initialise a resource list. | * @brief Initialise a resource list. | ||||
* | * | ||||
* @param rl the resource list to initialise | * @param rl the resource list to initialise | ||||
*/ | */ | ||||
void | void | ||||
resource_list_init(struct resource_list *rl) | resource_list_init(struct resource_list *rl) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 994 Lines • ▼ Show 20 Lines | bus_generic_deactivate_resource(device_t dev, device_t child, int type, | ||||
/* 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_DEACTIVATE_RESOURCE(dev->parent, child, type, rid, | return (BUS_DEACTIVATE_RESOURCE(dev->parent, child, type, rid, | ||||
r)); | r)); | ||||
return (EINVAL); | return (EINVAL); | ||||
} | } | ||||
/** | /** | ||||
* @brief 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 @p dev. | |||||
*/ | |||||
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) | |||||
{ | |||||
/* Propagate up the bus hierarchy until someone handles it. */ | |||||
if (dev->parent) | |||||
return (BUS_MAP_RESOURCE(dev->parent, child, type, r, args, | |||||
map)); | |||||
return (EINVAL); | |||||
} | |||||
/** | |||||
* @brief 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 @p dev. | |||||
*/ | |||||
int | |||||
bus_generic_unmap_resource(device_t dev, device_t child, int type, | |||||
struct resource *r, struct resource_map *map) | |||||
{ | |||||
/* Propagate up the bus hierarchy until someone handles it. */ | |||||
if (dev->parent) | |||||
return (BUS_UNMAP_RESOURCE(dev->parent, child, type, r, map)); | |||||
return (EINVAL); | |||||
} | |||||
/** | |||||
* @brief Helper function for implementing BUS_BIND_INTR(). | * @brief Helper function for implementing BUS_BIND_INTR(). | ||||
* | * | ||||
* This simple implementation of BUS_BIND_INTR() simply calls the | * This simple implementation of BUS_BIND_INTR() simply calls the | ||||
* BUS_BIND_INTR() method of the parent of @p dev. | * BUS_BIND_INTR() method of the parent of @p dev. | ||||
*/ | */ | ||||
int | int | ||||
bus_generic_bind_intr(device_t dev, device_t child, struct resource *irq, | bus_generic_bind_intr(device_t dev, device_t child, struct resource *irq, | ||||
int cpu) | int cpu) | ||||
▲ Show 20 Lines • Show All 342 Lines • ▼ Show 20 Lines | |||||
* parent of @p dev. | * parent of @p dev. | ||||
*/ | */ | ||||
int | int | ||||
bus_deactivate_resource(device_t dev, int type, int rid, struct resource *r) | bus_deactivate_resource(device_t dev, int type, int rid, struct resource *r) | ||||
{ | { | ||||
if (dev->parent == NULL) | if (dev->parent == NULL) | ||||
return (EINVAL); | return (EINVAL); | ||||
return (BUS_DEACTIVATE_RESOURCE(dev->parent, dev, type, rid, r)); | return (BUS_DEACTIVATE_RESOURCE(dev->parent, dev, type, rid, r)); | ||||
} | |||||
/** | |||||
* @brief Wrapper function for BUS_MAP_RESOURCE(). | |||||
* | |||||
* This function simply calls the BUS_MAP_RESOURCE() method of the | |||||
* parent of @p dev. | |||||
*/ | |||||
int | |||||
bus_map_resource(device_t dev, int type, struct resource *r, | |||||
struct resource_map_request *args, struct resource_map *map) | |||||
{ | |||||
if (dev->parent == NULL) | |||||
return (EINVAL); | |||||
return (BUS_MAP_RESOURCE(dev->parent, dev, type, r, args, map)); | |||||
} | |||||
/** | |||||
* @brief Wrapper function for BUS_UNMAP_RESOURCE(). | |||||
* | |||||
* This function simply calls the BUS_UNMAP_RESOURCE() method of the | |||||
* parent of @p dev. | |||||
*/ | |||||
int | |||||
bus_unmap_resource(device_t dev, int type, struct resource *r, | |||||
struct resource_map *map) | |||||
{ | |||||
if (dev->parent == NULL) | |||||
return (EINVAL); | |||||
return (BUS_UNMAP_RESOURCE(dev->parent, dev, type, r, map)); | |||||
} | } | ||||
/** | /** | ||||
* @brief Wrapper function for BUS_RELEASE_RESOURCE(). | * @brief Wrapper function for BUS_RELEASE_RESOURCE(). | ||||
* | * | ||||
* This function simply calls the BUS_RELEASE_RESOURCE() method of the | * This function simply calls the BUS_RELEASE_RESOURCE() method of the | ||||
* parent of @p dev. | * parent of @p dev. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 1,051 Lines • Show Last 20 Lines |