Index: sys/dev/bhnd/bhndb/bhndb.c =================================================================== --- sys/dev/bhnd/bhndb/bhndb.c +++ sys/dev/bhnd/bhndb/bhndb.c @@ -1080,8 +1080,8 @@ if (error) { device_printf(dev, "failed to activate entry %#x type %d for " - "child %s\n", - *rid, type, device_get_nameunit(child)); + "child %s: %d\n", + *rid, type, device_get_nameunit(child), error); rman_release_resource(rv); @@ -1342,10 +1342,27 @@ /* Look for a bus region matching the resource's address range */ r_start = rman_get_start(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)); + } + region = bhndb_find_resource_region(sc->bus_res, r_start, r_size); if (region != NULL) 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. */ if (region && region->static_regwin) { error = bhndb_activate_static_region(sc, region, child, type, @@ -1361,18 +1378,25 @@ /* A dynamic window will be required; is this resource high enough * priority to be reserved a dynamic window? */ 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) *indirect = true; return (ENOMEM); } + if(bootverbose){ + device_printf(sc->dev, "%s: trying to find and retain window...\n", __func__); + } + /* Find and retain a usable window */ BHNDB_LOCK(sc); { dwa = bhndb_retain_dynamic_window(sc, r); } BHNDB_UNLOCK(sc); if (dwa == NULL) { + device_printf(sc->dev, "%s: no window is found...\n", __func__); if (indirect) *indirect = true; return (ENOMEM); Index: sys/dev/bhnd/bhndb/bhndb_private.h =================================================================== --- sys/dev/bhnd/bhndb/bhndb_private.h +++ sys/dev/bhnd/bhndb/bhndb_private.h @@ -124,6 +124,8 @@ const struct bhndb_hw_priority *table, device_t device); +void bhndb_print_resources(struct bhndb_resources* res); +char* bhndb_print_class(bhnd_devclass_t class); /** * Dynamic register window allocation reference. Index: sys/dev/bhnd/bhndb/bhndb_subr.c =================================================================== --- sys/dev/bhnd/bhndb/bhndb_subr.c +++ sys/dev/bhnd/bhndb/bhndb_subr.c @@ -33,6 +33,7 @@ #include #include +#include #include "bhndb_private.h" #include "bhndbvar.h" @@ -887,3 +888,87 @@ /* not found */ return (NULL); } + +char* bhndb_print_class(bhnd_devclass_t class){ + switch (class) { + case BHND_DEVCLASS_CC: + return "ChipCommon IO controller"; + case BHND_DEVCLASS_CC_B: + return "ChipCommon Auxiliary controller"; + case BHND_DEVCLASS_PMU: + return "PMU Controller"; + case BHND_DEVCLASS_PCI: + return "PCI host/device bridge"; + case BHND_DEVCLASS_PCIE: + return "pcie host/device bridge"; + case BHND_DEVCLASS_PCCARD: + return "pcmcia host/device bridge"; + case BHND_DEVCLASS_RAM: + return "internal RAM/SRAM"; + case BHND_DEVCLASS_MEMC: + return "memory controller"; + case BHND_DEVCLASS_ENET: + return "802.3 MAC/PHY"; + case BHND_DEVCLASS_ENET_MAC: + return "802.3 MAC "; + case BHND_DEVCLASS_ENET_PHY: + return "802.3 PHY "; + case BHND_DEVCLASS_WLAN: + return "802.11 MAC/PHY/Radio "; + case BHND_DEVCLASS_WLAN_MAC: + return "802.11 MAC "; + case BHND_DEVCLASS_WLAN_PHY: + return "802.11 PHY "; + case BHND_DEVCLASS_CPU: + return "cpu core "; + case BHND_DEVCLASS_SOC_ROUTER: + return "interconnect router "; + case BHND_DEVCLASS_SOC_BRIDGE: + return "interconnect host bridge "; + case BHND_DEVCLASS_EROM: + return "bus device enumeration ROM "; + case BHND_DEVCLASS_NVRAM: + return "nvram/flash controller "; + case BHND_DEVCLASS_OTHER: + return "other / unknown "; + default: + return "invalid"; + } +} + +void bhndb_print_resources(struct bhndb_resources* res){ + + device_t dev = res->dev; + device_t parent = res->parent_dev; + const struct bhndb_hwcfg* cfg = res->cfg; + + printf("============ DUMP bridge resources ===========\n"); + printf(" owner %s / parent %s =\n", device_get_nameunit(dev), device_get_nameunit(parent)); + printf("--------------- Configurations ---------------\n"); + const struct resource_spec* res_spec = cfg->resource_specs; + while(res_spec->type >= 0 ){ + printf(" -> %d (type %d)\n", res_spec->rid, res_spec->type); + res_spec++; + } + + const struct bhndb_regwin* rw = cfg->register_windows; + while(rw->win_type != BHNDB_REGWIN_T_INVALID){ + printf(" -> [%p-%p]", (void*)rw->win_offset, (void*)(rw->win_offset + rw->win_size)); + if(rw->win_type == BHNDB_REGWIN_T_CORE){ + printf("(core %s port %d)", bhndb_print_class(rw->win_spec.core.class), rw->win_spec.core.port); + } + printf("\n"); + rw++; + } + + //TODO: print cfg and other fields + + printf("--------------- Bus regions ------------------\n"); + struct bhndb_region *region; + STAILQ_FOREACH(region, &res->bus_regions, link){ + printf(" * %p-%p (%s prio=%d)\n", + (void*)(uintptr_t)region->addr, (void*)(uintptr_t)(region->addr+region->size-1), + ((region->static_regwin) ? "static" : ""), region->priority); + } + printf("==============================================\n"); +}