FreeBSD/sys/dev/bhnd/cores/chipc/chipc.c
/* Initialize memory state for all chipc port regions */
Initialize memory state for all chipc port regions
Initialize memory state for all chipc port regions
static int
chipc_init_rman(struct chipc_softc *sc)
{
	u_int	num_ports;
	int	error;
	bhnd_port_type types[] = {
	    BHND_PORT_DEVICE
	};
	sc->mem_rman.rm_start = 0;
	sc->mem_rman.rm_end = BUS_SPACE_MAXADDR;
	sc->mem_rman.rm_type = RMAN_ARRAY;
	sc->mem_rman.rm_descr = "ChipCommon Device Memory";
	if ((error = rman_init(&sc->mem_rman))) {
		device_printf(sc->dev, "could not initialize mem_rman: %d\n",
		    error);
		return (error);
	}
	for (u_int i = 0; i < nitems(types); i++) {
		num_ports = bhnd_get_port_count(sc->dev, types[i]);
		for (u_int port = 0; port < num_ports; port++) {
			error = chipc_rman_init_regions(sc, types[i], port);
			if (error) {
				device_printf(sc->dev,
				    "region init failed for %s%u: %d\n",
				     bhnd_port_type_name(types[i]), port,
				     error);
				goto failed;
			}
		}
	}
	return (0);
failed:
	chipc_free_rman(sc);
	return (error);
}
static int chipc_init_rman ( struct chipc_softc * sc ) { u_int num_ports ; int error ; bhnd_port_type types [ ] = { BHND_PORT_DEVICE } ; sc -> mem_rman . rm_start = 0 ; sc -> mem_rman . rm_end = BUS_SPACE_MAXADDR ; sc -> mem_rman . rm_type = RMAN_ARRAY ; sc -> mem_rman . rm_descr = " " ; if ( ( error = rman_init ( & sc -> mem_rman ) ) ) { device_printf ( sc -> dev , " \n " , error ) ; return ( error ) ; } for ( u_int i = 0 ; i < nitems ( types ) ; i ++ ) { num_ports = bhnd_get_port_count ( sc -> dev , types [ i ] ) ; for ( u_int port = 0 ; port < num_ports ; port ++ ) { error = chipc_rman_init_regions ( sc , types [ i ] , port ) ; if ( error ) { device_printf ( sc -> dev , " \n " , bhnd_port_type_name ( types [ i ] ) , port , error ) ; goto failed ; } } } return ( 0 ) ; failed : chipc_free_rman ( sc ) ; return ( error ) ; }
Initialize memory state for all chipc port regions
Initialize memory state for all chipc port regions
/* Port types for which we'll register chipc_region mappings */ /* Initialize resource manager */ /* Populate per-port-region state */