FreeBSD/sys/dev/bhnd/cores/chipc/chipc.c
/* Allocate region records for the given port, and add the port's memory
 * range to the mem_rman */
Allocate region records for the given port, and add the port's memory
range to the mem_rman
Allocate region records for the given port and add the port ' s memory range to the mem_rman
static int
chipc_rman_init_regions (struct chipc_softc *sc, bhnd_port_type type,
    u_int port)
{
	struct	chipc_region	*cr;
	rman_res_t		 start, end;
	u_int			 num_regions;
	int			 error;
	num_regions = bhnd_get_region_count(sc->dev, type, port);
	for (u_int region = 0; region < num_regions; region++) {
		cr = chipc_alloc_region(sc, type, port, region);
		if (cr == NULL)
			return (ENODEV);
		if (cr->cr_rid < 0) {
			BHND_DEBUG_DEV(sc->dev, "no rid for chipc region "
			    "%s%u.%u", bhnd_port_type_name(type), port, region);
			chipc_free_region(sc, cr);
			continue;
		}
		start = cr->cr_addr;
		end = cr->cr_end;
		if ((error = rman_manage_region(&sc->mem_rman, start, end))) {
			chipc_free_region(sc, cr);
			return (error);
		}
		STAILQ_INSERT_TAIL(&sc->mem_regions, cr, cr_link);
	}
	return (0);
}
static int chipc_rman_init_regions ( struct chipc_softc * sc , bhnd_port_type type , u_int port ) { struct chipc_region * cr ; rman_res_t start , end ; u_int num_regions ; int error ; num_regions = bhnd_get_region_count ( sc -> dev , type , port ) ; for ( u_int region = 0 ; region < num_regions ; region ++ ) { cr = chipc_alloc_region ( sc , type , port , region ) ; if ( cr == NULL ) return ( ENODEV ) ; if ( cr -> cr_rid < 0 ) { BHND_DEBUG_DEV ( sc -> dev , " " " " , bhnd_port_type_name ( type ) , port , region ) ; chipc_free_region ( sc , cr ) ; continue ; } start = cr -> cr_addr ; end = cr -> cr_end ; if ( ( error = rman_manage_region ( & sc -> mem_rman , start , end ) ) ) { chipc_free_region ( sc , cr ) ; return ( error ) ; } STAILQ_INSERT_TAIL ( & sc -> mem_regions , cr , cr_link ) ; } return ( 0 ) ; }
Allocate region records for the given port, and add the port's memory
 range to the mem_rman
Allocate region records for the given port and add the port ' s memory range to the mem_rman
/* Allocate new region record */ /* Can't manage regions that cannot be allocated */ /* Add to rman's managed range */ /* Add to region list */