FreeBSD/sys/kern/subr_bus.c
/**
 * @brief Allocate a reserved resource
 *
 * This can be used by busses 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().
 *
 * @param rl		the resource list to allocate from
 * @param bus		the parent device of @p child
 * @param child		the device for which the resource is being reserved
 * @param type		the type of resource to allocate
 * @param rid		a pointer to the resource identifier
 * @param start		hint at the start of the resource range - pass
 *			@c 0 for any start address
 * @param end		hint at the end of the resource range - pass
 *			@c ~0 for any end address
 * @param count		hint at the size of range required - pass @c 1
 *			for any size
 * @param flags		any extra flags to control the resource
 *			allocation - see @c RF_XXX flags in
 *			<sys/rman.h> for details
 *
 * @returns		the resource which was allocated or @c NULL if no
 *			resource could be allocated
 */
@brief Allocate a reserved resource
This can be used by busses to force the allocation of resources
that are always active in the system even if they are not allocated
by a driver .  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().



@returns             the resource which was allocated or @c NULL if no
resource could be allocated
@brief Allocate a reserved resource This can be used by busses to force the allocation of resources that are always active in the system even if they are not allocated by a driver . 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 () . @returns the resource which was allocated or @c NULL if no resource could be allocated
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)
{
	struct resource_list_entry *rle = NULL;
	int passthrough = (device_get_parent(child) != bus);
	struct resource *r;
	if (passthrough)
		panic(
    "resource_list_reserve() should only be called for direct children");
	if (flags & RF_ACTIVE)
		panic(
    "resource_list_reserve() should only reserve inactive resources");
	r = resource_list_alloc(rl, bus, child, type, rid, start, end, count,
	    flags);
	if (r != NULL) {
		rle = resource_list_find(rl, type, *rid);
		rle->flags |= RLE_RESERVED;
	}
	return (r);
}
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 ) { struct resource_list_entry * rle = NULL ; int passthrough = ( device_get_parent ( child ) != bus ) ; struct resource * r ; if ( passthrough ) panic ( " " ) ; if ( flags & RF_ACTIVE ) panic ( " " ) ; r = resource_list_alloc ( rl , bus , child , type , rid , start , end , count , flags ) ; if ( r != NULL ) { rle = resource_list_find ( rl , type , * rid ) ; rle -> flags |= RLE_RESERVED ; } return ( r ) ; }
@brief Allocate a reserved resource
 This can be used by busses to force the allocation of resources
 that are always active in the system even if they are not allocated
 by a driver (e.g.
@brief Allocate a reserved resource This can be used by busses to force the allocation of resources that are always active in the system even if they are not allocated by a driver ( e . g .