static int generic_pcie_activate_resource(device_t dev, device_t child, int type, int rid, struct resource *r) { struct generic_pcie_core_softc *sc; uint64_t phys_base; uint64_t pci_base; uint64_t size; int found; int res; int i; sc = device_get_softc(dev); if ((res = rman_activate_resource(r)) != 0) return (res); switch (type) { case SYS_RES_IOPORT: found = 0; for (i = 0; i < MAX_RANGES_TUPLES; i++) { pci_base = sc->ranges[i].pci_base; phys_base = sc->ranges[i].phys_base; size = sc->ranges[i].size; if ((rid > pci_base) && (rid < (pci_base + size))) { found = 1; break; } } if (found) { rman_set_start(r, rman_get_start(r) + phys_base); rman_set_end(r, rman_get_end(r) + phys_base); res = BUS_ACTIVATE_RESOURCE(device_get_parent(dev), child, type, rid, r); } else { device_printf(dev, "Failed to activate IOPORT resource\n"); res = 0; } break; case SYS_RES_MEMORY: case SYS_RES_IRQ: res = BUS_ACTIVATE_RESOURCE(device_get_parent(dev), child, type, rid, r); break; default: break; } return (res); }
static int gt_activate_resource(device_t dev, device_t child, int type, int rid, struct resource *r) { return (BUS_ACTIVATE_RESOURCE(device_get_parent(dev), child, type, rid, r)); }
static int apb_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { /* XXX: should we mask/unmask IRQ here? */ return (BUS_ACTIVATE_RESOURCE(device_get_parent(bus), child, type, rid, r)); }
/** * Helper function for implementing BHND_BUS_ACTIVATE_RESOURCE(). * * This simple implementation of BHND_BUS_ACTIVATE_RESOURCE() simply calls the * BHND_BUS_ACTIVATE_RESOURCE() method of the parent of @p dev. * * If no parent device is available, the request is delegated to * BUS_ACTIVATE_RESOURCE(). */ int bhnd_generic_activate_bhnd_resource(device_t dev, device_t child, int type, int rid, struct bhnd_resource *r) { /* Try to delegate to the parent */ if (device_get_parent(dev) != NULL) return (BHND_BUS_ACTIVATE_RESOURCE(device_get_parent(dev), child, type, rid, r)); /* Activate the resource directly */ if (!r->direct) { panic("bhnd indirect resource released without " "bhnd parent bus"); } return (BUS_ACTIVATE_RESOURCE(dev, child, type, rid, r->res)); };
static int sbus_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { void *p; int error; if (type == SYS_RES_IRQ) { return (BUS_ACTIVATE_RESOURCE(device_get_parent(bus), child, type, rid, r)); } if (type == SYS_RES_MEMORY) { /* * Need to memory-map the device space, as some drivers * depend on the virtual address being set and usable. */ error = sparc64_bus_mem_map(rman_get_bustag(r), rman_get_bushandle(r), rman_get_size(r), 0, 0, &p); if (error != 0) return (error); rman_set_virtual(r, p); } return (rman_activate_resource(r)); }