Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_bus.c
Show First 20 Lines • Show All 3,945 Lines • ▼ Show 20 Lines | TAILQ_FOREACH(child, &dev->children, link) { | ||||
if (child->state >= DS_ATTACHED) | if (child->state >= DS_ATTACHED) | ||||
BUS_NEW_PASS(child); | BUS_NEW_PASS(child); | ||||
else if (child->state == DS_NOTPRESENT) | else if (child->state == DS_NOTPRESENT) | ||||
device_probe_and_attach(child); | device_probe_and_attach(child); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* @brief Helper function for implementing BUS_MAP_INTR(). | |||||
* | |||||
* This simple implementation of BUS_MAP_INTR() simply calls the | |||||
* BUS_MAP_INTR() method of the parent of @p dev. | |||||
*/ | |||||
int | |||||
bus_generic_map_intr(device_t dev, device_t child, int *rid, rman_res_t *start, | |||||
rman_res_t *end, rman_res_t *count, struct intr_map_data **imd) | |||||
{ | |||||
/* Propagate up the bus hierarchy until someone handles it. */ | |||||
if (dev->parent) | |||||
return (BUS_MAP_INTR(dev->parent, child, rid, start, end, count, | |||||
imd)); | |||||
return (EINVAL); | |||||
} | |||||
/** | |||||
* @brief Helper function for implementing BUS_SETUP_INTR(). | * @brief Helper function for implementing BUS_SETUP_INTR(). | ||||
* | * | ||||
* This simple implementation of BUS_SETUP_INTR() simply calls the | * This simple implementation of BUS_SETUP_INTR() simply calls the | ||||
* BUS_SETUP_INTR() method of the parent of @p dev. | * BUS_SETUP_INTR() method of the parent of @p dev. | ||||
*/ | */ | ||||
int | int | ||||
bus_generic_setup_intr(device_t dev, device_t child, struct resource *irq, | 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, | int flags, driver_filter_t *filter, driver_intr_t *intr, void *arg, | ||||
▲ Show 20 Lines • Show All 438 Lines • ▼ Show 20 Lines | bus_release_resources(device_t dev, const struct resource_spec *rs, | ||||
for (i = 0; rs[i].type != -1; i++) | for (i = 0; rs[i].type != -1; i++) | ||||
if (res[i] != NULL) { | if (res[i] != NULL) { | ||||
bus_release_resource( | bus_release_resource( | ||||
dev, rs[i].type, rs[i].rid, res[i]); | dev, rs[i].type, rs[i].rid, res[i]); | ||||
res[i] = NULL; | res[i] = NULL; | ||||
} | } | ||||
} | } | ||||
#ifdef INTRNG | |||||
/** | /** | ||||
* @internal | |||||
* | |||||
* This can be converted to bus method later. (XXX) | |||||
*/ | |||||
static struct intr_map_data * | |||||
bus_extend_resource(device_t dev, int type, int *rid, rman_res_t *start, | |||||
rman_res_t *end, rman_res_t *count) | |||||
{ | |||||
struct intr_map_data *imd; | |||||
struct resource_list *rl; | |||||
int rv; | |||||
if (dev->parent == NULL) | |||||
return (NULL); | |||||
if (type != SYS_RES_IRQ) | |||||
return (NULL); | |||||
if (!RMAN_IS_DEFAULT_RANGE(*start, *end)) | |||||
return (NULL); | |||||
rl = BUS_GET_RESOURCE_LIST(dev->parent, dev); | |||||
if (rl != NULL) { | |||||
if (resource_list_find(rl, type, *rid) != NULL) | |||||
return (NULL); | |||||
} | |||||
rv = BUS_MAP_INTR(dev->parent, dev, rid, start, end, count, &imd); | |||||
if (rv != 0) | |||||
return (NULL); | |||||
if (rl != NULL) | |||||
resource_list_add(rl, type, *rid, *start, *end, *count); | |||||
return (imd); | |||||
} | |||||
#endif | |||||
/** | |||||
* @brief Wrapper function for BUS_ALLOC_RESOURCE(). | * @brief Wrapper function for BUS_ALLOC_RESOURCE(). | ||||
* | * | ||||
* This function simply calls the BUS_ALLOC_RESOURCE() method of the | * This function simply calls the BUS_ALLOC_RESOURCE() method of the | ||||
* parent of @p dev. | * parent of @p dev. | ||||
*/ | */ | ||||
struct resource * | struct resource * | ||||
bus_alloc_resource(device_t dev, int type, int *rid, rman_res_t start, | 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) | rman_res_t end, rman_res_t count, u_int flags) | ||||
{ | { | ||||
struct resource *res; | struct resource *res; | ||||
#ifdef INTRNG | |||||
struct intr_map_data *imd; | |||||
#endif | |||||
if (dev->parent == NULL) | if (dev->parent == NULL) | ||||
return (NULL); | return (NULL); | ||||
#ifdef INTRNG | |||||
imd = bus_extend_resource(dev, type, rid, &start, &end, &count); | |||||
#endif | |||||
res = BUS_ALLOC_RESOURCE(dev->parent, dev, type, rid, start, end, | res = BUS_ALLOC_RESOURCE(dev->parent, dev, type, rid, start, end, | ||||
count, flags); | count, flags); | ||||
#ifdef INTRNG | |||||
if (imd != NULL) { | |||||
if (res != NULL && rman_get_virtual(res) == NULL) | |||||
rman_set_virtual(res, imd); | |||||
else | |||||
imd->destruct(imd); | |||||
} | |||||
#endif | |||||
return (res); | return (res); | ||||
} | } | ||||
/** | /** | ||||
* @brief Wrapper function for BUS_ADJUST_RESOURCE(). | * @brief Wrapper function for BUS_ADJUST_RESOURCE(). | ||||
* | * | ||||
* This function simply calls the BUS_ADJUST_RESOURCE() method of the | * This function simply calls the BUS_ADJUST_RESOURCE() method of the | ||||
* parent of @p dev. | * parent of @p dev. | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | |||||
* | * | ||||
* 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. | ||||
*/ | */ | ||||
int | int | ||||
bus_release_resource(device_t dev, int type, int rid, struct resource *r) | bus_release_resource(device_t dev, int type, int rid, struct resource *r) | ||||
{ | { | ||||
int rv; | int rv; | ||||
#ifdef INTRNG | |||||
struct intr_map_data *imd; | |||||
#endif | |||||
if (dev->parent == NULL) | if (dev->parent == NULL) | ||||
return (EINVAL); | return (EINVAL); | ||||
#ifdef INTRNG | |||||
imd = (type == SYS_RES_IRQ) ? rman_get_virtual(r) : NULL; | |||||
#endif | |||||
rv = BUS_RELEASE_RESOURCE(dev->parent, dev, type, rid, r); | rv = BUS_RELEASE_RESOURCE(dev->parent, dev, type, rid, r); | ||||
#ifdef INTRNG | |||||
if (imd != NULL) | |||||
imd->destruct(imd); | |||||
#endif | |||||
return (rv); | return (rv); | ||||
} | } | ||||
/** | /** | ||||
* @brief Wrapper function for BUS_SETUP_INTR(). | * @brief Wrapper function for BUS_SETUP_INTR(). | ||||
* | * | ||||
* This function simply calls the BUS_SETUP_INTR() method of the | * This function simply calls the BUS_SETUP_INTR() method of the | ||||
* parent of @p dev. | * parent of @p dev. | ||||
▲ Show 20 Lines • Show All 1,038 Lines • Show Last 20 Lines |