FreeBSD/sys/mips/mips/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				 isdefault, needactivate, passthrough;
	dprintf("%s: entry (%p, %p, %d, %p, %p, %p, %jd, %d)\n",
	    __func__, bus, child, type, rid, (void *)(intptr_t)start,
	    (void *)(intptr_t)end, count, flags);
	dprintf("%s: requested rid is %d\n", __func__, *rid);
	isdefault = (RMAN_IS_DEFAULT_RANGE(start, end) && count == 1);
	needactivate = flags & RF_ACTIVE;
	passthrough = (device_get_parent(child) != bus);
	rle = NULL;
	if (isdefault) {
		rle = resource_list_find(&ndev->nx_resources, type, *rid);
		if (rle == NULL)
			return (NULL);
		if (rle->res != NULL) {
			panic("%s: resource entry is busy", __func__);
		}
		start = rle->start;
		end = rle->end;
		count = rle->count;
	}
	switch (type) {
	case SYS_RES_IRQ:
		rm = &irq_rman;
		break;
	case SYS_RES_MEMORY:
		rm = &mem_rman;
		break;
	default:
		printf("%s: unknown resource type %d\n", __func__, type);
		return (0);
	}
	rv = rman_reserve_resource(rm, start, end, count, flags, child);
	if (rv == NULL) {
		printf("%s: could not reserve resource for %s\n", __func__,
		    device_get_nameunit(child));
		return (0);
	}
	rman_set_rid(rv, *rid);
	if (needactivate) {
		if (bus_activate_resource(child, type, *rid, rv)) {
			printf("%s: could not activate resource\n", __func__);
			rman_release_resource(rv);
			return (0);
		}
	}
	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 isdefault , needactivate , passthrough ; dprintf ( " \n " , __func__ , bus , child , type , rid , ( void * ) ( intptr_t ) start , ( void * ) ( intptr_t ) end , count , flags ) ; dprintf ( " \n " , __func__ , * rid ) ; isdefault = ( RMAN_IS_DEFAULT_RANGE ( start , end ) && count == 1 ) ; needactivate = flags & RF_ACTIVE ; passthrough = ( device_get_parent ( child ) != bus ) ; rle = NULL ; if ( isdefault ) { rle = resource_list_find ( & ndev -> nx_resources , type , * rid ) ; if ( rle == NULL ) return ( NULL ) ; if ( rle -> res != NULL ) { panic ( " " , __func__ ) ; } start = rle -> start ; end = rle -> end ; count = rle -> count ; } switch ( type ) { case SYS_RES_IRQ : rm = & irq_rman ; break ; case SYS_RES_MEMORY : rm = & mem_rman ; break ; default : printf ( " \n " , __func__ , type ) ; return ( 0 ) ; } rv = rman_reserve_resource ( rm , start , end , count , flags , child ) ; if ( rv == NULL ) { printf ( " \n " , __func__ , device_get_nameunit ( child ) ) ; return ( 0 ) ; } rman_set_rid ( rv , * rid ) ; if ( needactivate ) { if ( bus_activate_resource ( child , type , * rid , rv ) ) { printf ( " \n " , __func__ ) ; rman_release_resource ( rv ) ; return ( 0 ) ; } } 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.
	 */