Esempio n. 1
0
int
ofw_pci_adjust_resource(device_t bus, device_t child, int type,
                        struct resource *r, rman_res_t start, rman_res_t end)
{
    struct ofw_pci_softc *sc;
    struct rman *rm;

    sc = device_get_softc(bus);
    switch (type) {
    case SYS_RES_IRQ:
        return (bus_generic_adjust_resource(bus, child, type, r,
                                            start, end));
    case SYS_RES_MEMORY:
        rm = &sc->sc_pci_mem_rman;
        break;
    case SYS_RES_IOPORT:
        rm = &sc->sc_pci_io_rman;
        break;
    default:
        return (EINVAL);
    }
    if (rman_is_region_manager(r, rm) == 0)
        return (EINVAL);
    return (rman_adjust_resource(r, start, end));
}
Esempio n. 2
0
static int
thunder_pem_adjust_resource(device_t dev, device_t child, int type,
    struct resource *res, rman_res_t start, rman_res_t end)
{
	struct thunder_pem_softc *sc;
	struct rman *rm;

	sc = device_get_softc(dev);
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
	if (type == PCI_RES_BUS)
		return (pci_domain_adjust_bus(sc->id, child, res, start, end));
#endif

	rm = thunder_pem_rman(sc, type);
	if (rm == NULL)
		return (bus_generic_adjust_resource(dev, child, type, res,
		    start, end));
	if (!rman_is_region_manager(res, rm))
		/*
		 * This means a child device has a memory or I/O
		 * resource not from you which shouldn't happen.
		 */
		return (EINVAL);
	return (rman_adjust_resource(res, start, end));
}
Esempio n. 3
0
static int
chipc_adjust_resource(device_t dev, device_t child, int type,
    struct resource *r, rman_res_t start, rman_res_t end)
{
	struct chipc_softc		*sc;
	struct chipc_region		*cr;
	struct rman			*rm;
	
	sc = device_get_softc(dev);

	/* Handled by parent bus? */
	rm = chipc_get_rman(sc, type);
	if (rm == NULL || !rman_is_region_manager(r, rm)) {
		return (bus_generic_adjust_resource(dev, child, type, r, start,
		    end));
	}

	/* The range is limited to the existing region mapping */
	cr = chipc_find_region(sc, rman_get_start(r), rman_get_end(r));
	if (cr == NULL)
		return (EINVAL);
	
	if (end <= start)
		return (EINVAL);

	if (start < cr->cr_addr || end > cr->cr_end)
		return (EINVAL);

	/* Range falls within the existing region */
	return (rman_adjust_resource(r, start, end));
}
Esempio n. 4
0
static int
cbb_pci_adjust_resource(device_t bus, device_t child, int type,
    struct resource *r, rman_res_t start, rman_res_t end)
{
	struct cbb_softc *sc;

	sc = device_get_softc(bus);
	if (type == PCI_RES_BUS) {
		if (!rman_is_region_manager(r, &sc->bus.rman))
			return (EINVAL);
		return (rman_adjust_resource(r, start, end));
	}
	return (bus_generic_adjust_resource(bus, child, type, r, start, end));
}
Esempio n. 5
0
int
pcib_host_res_adjust(struct pcib_host_resources *hr, device_t dev, int type,
    struct resource *r, u_long start, u_long end)
{
	struct resource_list_entry *rle;

	rle = resource_list_find(&hr->hr_rl, type, 0);
	if (rle == NULL) {
		/*
		 * No decoding ranges for this resource type, just pass
		 * the request up to the parent.
		 */
		return (bus_generic_adjust_resource(hr->hr_pcib, dev, type, r,
		    start, end));
	}

	/* Only allow adjustments that stay within a decoded range. */
	for (; rle != NULL; rle = STAILQ_NEXT(rle, link)) {
		if (rle->start <= start && rle->end >= end)
			return (bus_generic_adjust_resource(hr->hr_pcib, dev,
			    type, r, start, end));
	}
	return (ERANGE);
}
Esempio n. 6
0
static int
sbus_adjust_resource(device_t bus, device_t child, int type,
                     struct resource *r, rman_res_t start, rman_res_t end)
{
    struct sbus_softc *sc;
    int i;

    if (type == SYS_RES_MEMORY) {
        sc = device_get_softc(bus);
        for (i = 0; i < sc->sc_nrange; i++)
            if (rman_is_region_manager(r,
                                       &sc->sc_rd[i].rd_rman) != 0)
                return (rman_adjust_resource(r, start, end));
        return (EINVAL);
    }
    return (bus_generic_adjust_resource(bus, child, type, r, start, end));
}
Esempio n. 7
0
static int
apb_adjust_resource(device_t dev, device_t child, int type,
                    struct resource *r, u_long start, u_long end)
{
    struct apb_softc *sc;

    sc = device_get_softc(dev);
    switch (type) {
    case SYS_RES_IOPORT:
        if (!apb_checkrange(sc->sc_iomap, APB_IO_SCALE, start, end))
            return (ENXIO);
        break;
    case SYS_RES_MEMORY:
        if (!apb_checkrange(sc->sc_memmap, APB_MEM_SCALE, start, end))
            return (ENXIO);
        break;
    }
    return (bus_generic_adjust_resource(dev, child, type, r, start, end));
}
static int
generic_pcie_adjust_resource(device_t dev, device_t child, int type,
    struct resource *res, rman_res_t start, rman_res_t end)
{
	struct generic_pcie_core_softc *sc;
	struct rman *rm;

	sc = device_get_softc(dev);
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
	if (type == PCI_RES_BUS)
		return (pci_domain_adjust_bus(sc->ecam, child, res, start,
		    end));
#endif

	rm = generic_pcie_rman(sc, type);
	if (rm != NULL)
		return (rman_adjust_resource(res, start, end));
	return (bus_generic_adjust_resource(dev, child, type, res, start, end));
}
Esempio n. 9
0
static int
thunder_pem_adjust_resource(device_t dev, device_t child, int type,
    struct resource *res, rman_res_t start, rman_res_t end)
{
	struct thunder_pem_softc *sc;
	struct rman *rm;

	sc = device_get_softc(dev);

	rm = thunder_pem_rman(sc, type);
	if (rm == NULL)
		return (bus_generic_adjust_resource(dev, child, type, res,
		    start, end));
	if (!rman_is_region_manager(res, rm))
		/*
		 * This means a child device has a memory or I/O
		 * resource not from you which shouldn't happen.
		 */
		return (EINVAL);
	return (rman_adjust_resource(res, start, end));
}