Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/bhnd/bhndb/bhndb.c
| Context not available. | |||||
| /* Fetch the base address of the mapped port. */ | /* Fetch the base address of the mapped port. */ | ||||
| error = bhnd_get_region_addr(child, | error = bhnd_get_region_addr(child, | ||||
| regw->core.port_type, regw->core.port, | regw->win_spec.core.port_type, regw->win_spec.core.port, | ||||
| regw->core.region, &addr, &size); | regw->win_spec.core.region, &addr, &size); | ||||
| if (error) | if (error) | ||||
| return (error); | return (error); | ||||
| Context not available. | |||||
| } | } | ||||
| if (hostb == NULL) { | if (hostb == NULL) { | ||||
| device_printf(sc->dev, "no host bridge core found\n"); | if(sc->bus_res->cfg->is_hostb_required){ | ||||
| error = ENODEV; | device_printf(sc->dev, "no host bridge core found\n"); | ||||
| goto cleanup; | error = ENODEV; | ||||
| goto cleanup; | |||||
| } | |||||
| device_printf(sc->dev, "WARNING: no host bridge core found\n"); | |||||
| } | } | ||||
| /* Find our full register window configuration */ | /* Find our full register window configuration */ | ||||
| Context not available. | |||||
| if (error) { | if (error) { | ||||
| device_printf(dev, | device_printf(dev, | ||||
| "failed to activate entry %#x type %d for " | "failed to activate entry %#x type %d for " | ||||
| "child %s\n", | "child %s: %d\n", | ||||
| *rid, type, device_get_nameunit(child)); | *rid, type, device_get_nameunit(child), error); | ||||
| rman_release_resource(rv); | rman_release_resource(rv); | ||||
| Context not available. | |||||
| /* Look for a bus region matching the resource's address range */ | /* Look for a bus region matching the resource's address range */ | ||||
| r_start = rman_get_start(r); | r_start = rman_get_start(r); | ||||
| r_size = rman_get_size(r); | r_size = rman_get_size(r); | ||||
| if(bootverbose){ | |||||
| device_printf(sc->dev, "%s: trying to activate %p (%ld) : rid=%d for %s\n", | |||||
| __func__, | |||||
| (void *)(uintptr_t)r_start, r_size, rid, device_get_nameunit(child)); | |||||
| bhndb_print_resources(sc->bus_res); | |||||
| } | |||||
| region = bhndb_find_resource_region(sc->bus_res, r_start, r_size); | region = bhndb_find_resource_region(sc->bus_res, r_start, r_size); | ||||
| if (region != NULL) | if (region != NULL) | ||||
| dw_priority = region->priority; | dw_priority = region->priority; | ||||
| if(bootverbose){ | |||||
| if(region == NULL){ | |||||
| device_printf(sc->dev, "%s: no region found\n", __func__); | |||||
| }else{ | |||||
| device_printf(sc->dev, "%s: found %s region %p (%lld)\n", __func__ , | |||||
| ((region->static_regwin) ? "static" : "dynamic"), | |||||
| (void *)(uintptr_t)region->addr, region->size); | |||||
| } | |||||
| } | |||||
| /* Prefer static mappings over consuming a dynamic windows. */ | /* Prefer static mappings over consuming a dynamic windows. */ | ||||
| if (region && region->static_regwin) { | if (region && region->static_regwin) { | ||||
| error = bhndb_activate_static_region(sc, region, child, type, | error = bhndb_activate_static_region(sc, region, child, type, | ||||
| rid, r); | rid, r); | ||||
| if (error) | if (error) | ||||
| device_printf(sc->dev, "static window allocation " | device_printf(sc->dev, "%s: static window allocation " | ||||
| "for 0x%llx-0x%llx failed\n", | "for 0x%llx-0x%llx failed\n", | ||||
| __func__, | |||||
| (unsigned long long) r_start, | (unsigned long long) r_start, | ||||
| (unsigned long long) r_start + r_size - 1); | (unsigned long long) r_start + r_size - 1); | ||||
| return (error); | return (error); | ||||
| Context not available. | |||||
| /* A dynamic window will be required; is this resource high enough | /* A dynamic window will be required; is this resource high enough | ||||
| * priority to be reserved a dynamic window? */ | * priority to be reserved a dynamic window? */ | ||||
| if (dw_priority < sc->bus_res->min_prio) { | if (dw_priority < sc->bus_res->min_prio) { | ||||
| device_printf(sc->dev, "%s: priority %d is lower than min priority %d\n", | |||||
| __func__, dw_priority, sc->bus_res->min_prio); | |||||
| if (indirect) | if (indirect) | ||||
| *indirect = true; | *indirect = true; | ||||
| return (ENOMEM); | return (ENOMEM); | ||||
| } | } | ||||
| if(bootverbose){ | |||||
| device_printf(sc->dev, "%s: trying to find and retain window...\n", __func__); | |||||
| } | |||||
| /* Find and retain a usable window */ | /* Find and retain a usable window */ | ||||
| BHNDB_LOCK(sc); { | BHNDB_LOCK(sc); { | ||||
| dwa = bhndb_retain_dynamic_window(sc, r); | dwa = bhndb_retain_dynamic_window(sc, r); | ||||
| } BHNDB_UNLOCK(sc); | } BHNDB_UNLOCK(sc); | ||||
| if (dwa == NULL) { | if (dwa == NULL) { | ||||
| device_printf(sc->dev, "%s: no window is found...\n", __func__); | |||||
| if (indirect) | if (indirect) | ||||
| *indirect = true; | *indirect = true; | ||||
| return (ENOMEM); | return (ENOMEM); | ||||
| Context not available. | |||||
| parent_offset = dwa->win->win_offset; | parent_offset = dwa->win->win_offset; | ||||
| parent_offset += r_start - dwa->target; | parent_offset += r_start - dwa->target; | ||||
| if(bootverbose){ | |||||
| device_printf(sc->dev, "%s: parent_offset=%p\n", __func__ , (void*)(uintptr_t)parent_offset); | |||||
| } | |||||
| error = bhndb_init_child_resource(r, dwa->parent_res, parent_offset, | error = bhndb_init_child_resource(r, dwa->parent_res, parent_offset, | ||||
| dwa->win->win_size); | dwa->win->win_size); | ||||
| if (error) | if (error) | ||||
| Context not available. | |||||
| DEVMETHOD(bhnd_bus_alloc_resource, bhndb_alloc_bhnd_resource), | DEVMETHOD(bhnd_bus_alloc_resource, bhndb_alloc_bhnd_resource), | ||||
| DEVMETHOD(bhnd_bus_release_resource, bhndb_release_bhnd_resource), | DEVMETHOD(bhnd_bus_release_resource, bhndb_release_bhnd_resource), | ||||
| DEVMETHOD(bhnd_bus_activate_resource, bhndb_activate_bhnd_resource), | DEVMETHOD(bhnd_bus_activate_resource, bhndb_activate_bhnd_resource), | ||||
| DEVMETHOD(bhnd_bus_activate_resource, bhndb_deactivate_bhnd_resource), | DEVMETHOD(bhnd_bus_deactivate_resource, bhndb_deactivate_bhnd_resource), | ||||
| DEVMETHOD(bhnd_bus_read_1, bhndb_bus_read_1), | DEVMETHOD(bhnd_bus_read_1, bhndb_bus_read_1), | ||||
| DEVMETHOD(bhnd_bus_read_2, bhndb_bus_read_2), | DEVMETHOD(bhnd_bus_read_2, bhndb_bus_read_2), | ||||
| DEVMETHOD(bhnd_bus_read_4, bhndb_bus_read_4), | DEVMETHOD(bhnd_bus_read_4, bhndb_bus_read_4), | ||||
| Context not available. | |||||