FreeBSD/sys/arm64/arm64/nexus.c
/*
 * Allocate a resource on behalf of child.  NB: child is usually going to be a
 * child of one of our descendants, not a direct child of nexus0.
 * (Exceptions include footbridge.)
 */
Allocate a resource on behalf of child.  NB: child is usually going to be a
child of one of our descendants, not a direct child of nexus0.
(Exceptions include footbridge.)
Allocate a resource on behalf of child . NB : child is usually going to be a child of one of our descendants not a direct child of nexus0 . ( Exceptions include footbridge . )
static struct resource *
nexus_alloc_resource(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 nexus_device *ndev = DEVTONX(child);
	struct resource *rv;
	struct resource_list_entry *rle;
	struct rman *rm;
	int needactivate = flags & RF_ACTIVE;
	if (RMAN_IS_DEFAULT_RANGE(start, end) && (count == 1)) {
		if (device_get_parent(child) != bus || ndev == NULL)
			return(NULL);
		rle = resource_list_find(&ndev->nx_resources, type, *rid);
		if (rle == NULL)
			return(NULL);
		start = rle->start;
		end = rle->end;
		count = rle->count;
	}
	switch (type) {
	case SYS_RES_IRQ:
		rm = &irq_rman;
		break;
	case SYS_RES_MEMORY:
	case SYS_RES_IOPORT:
		rm = &mem_rman;
		break;
	default:
		return (NULL);
	}
	rv = rman_reserve_resource(rm, start, end, count, flags, child);
	if (rv == NULL)
		return (NULL);
	rman_set_rid(rv, *rid);
	rman_set_bushandle(rv, rman_get_start(rv));
	if (needactivate) {
		if (bus_activate_resource(child, type, *rid, rv)) {
			rman_release_resource(rv);
			return (NULL);
		}
	}
	return (rv);
}
static struct resource * nexus_alloc_resource ( 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 nexus_device * ndev = DEVTONX ( child ) ; struct resource * rv ; struct resource_list_entry * rle ; struct rman * rm ; int needactivate = flags & RF_ACTIVE ; if ( RMAN_IS_DEFAULT_RANGE ( start , end ) && ( count == 1 ) ) { if ( device_get_parent ( child ) != bus || ndev == NULL ) return ( NULL ) ; rle = resource_list_find ( & ndev -> nx_resources , type , * rid ) ; if ( rle == NULL ) return ( NULL ) ; start = rle -> start ; end = rle -> end ; count = rle -> count ; } switch ( type ) { case SYS_RES_IRQ : rm = & irq_rman ; break ; case SYS_RES_MEMORY : case SYS_RES_IOPORT : rm = & mem_rman ; break ; default : return ( NULL ) ; } rv = rman_reserve_resource ( rm , start , end , count , flags , child ) ; if ( rv == NULL ) return ( NULL ) ; rman_set_rid ( rv , * rid ) ; rman_set_bushandle ( rv , rman_get_start ( rv ) ) ; if ( needactivate ) { if ( bus_activate_resource ( child , type , * rid , rv ) ) { rman_release_resource ( rv ) ; return ( NULL ) ; } } return ( rv ) ; }
Allocate a resource on behalf of child.
Allocate a resource on behalf of child .
/*
	 * If this is an allocation of the "default" range for a given
	 * RID, and we know what the resources for this device are
	 * (ie. they aren't maintained by a child bus), then work out
	 * the start/end values.
	 */