diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index d12968c07c25..5a53fc920c58 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -2933,6 +2933,30 @@ resource_list_busy(struct resource_list *rl, int type, int rid) return (1); } +/** + * @brief 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. + * + * @param rl the resource list to search + * @param type the resource entry type (e.g. SYS_RES_MEMORY) + * @param rid the resource identifier + * + * @returns Non-zero if the entry is reserved, zero otherwise. + */ +int +resource_list_reserved(struct resource_list *rl, int type, int rid) +{ + struct resource_list_entry *rle; + + rle = resource_list_find(rl, type, rid); + if (rle != NULL && rle->flags & RLE_RESERVED) + return (1); + return (0); +} + /** * @brief Find a resource entry by type and rid. * diff --git a/sys/sys/bus.h b/sys/sys/bus.h index 88a0f60cd7e3..ec3be645f79e 100644 --- a/sys/sys/bus.h +++ b/sys/sys/bus.h @@ -256,6 +256,7 @@ int resource_list_add_next(struct resource_list *rl, u_long start, u_long end, u_long count); int resource_list_busy(struct resource_list *rl, int type, int rid); +int resource_list_reserved(struct resource_list *rl, int type, int rid); struct resource_list_entry* resource_list_find(struct resource_list *rl, int type, int rid);