예제 #1
0
int
thunder_pcie_release_resource(device_t dev, device_t child, int type, int rid,
    struct resource *res)
{

	if (type != SYS_RES_MEMORY)
		return (bus_generic_release_resource(dev, child,
		    type, rid, res));

	return (rman_release_resource(res));
}
예제 #2
0
파일: sb_zbpci.c 프로젝트: 2asoft/freebsd
static int
zbpci_release_resource(device_t bus, device_t child, int type, int rid,
		       struct resource *r)
{
	int error;

	if (type != SYS_RES_IOPORT)
		return (bus_generic_release_resource(bus, child, type, rid, r));

	if (rman_get_flags(r) & RF_ACTIVE) {
		error = bus_deactivate_resource(child, type, rid, r);
		if (error)
			return (error);
	}

	return (rman_release_resource(r));
}
예제 #3
0
파일: isa_pci.c 프로젝트: coyizumi/cs111
static int
isab_pci_release_resource(device_t dev, device_t child, int type, int rid,
    struct resource *r)
{
	struct isab_pci_softc *sc;
	int bar, error;

	if (device_get_parent(child) != dev)
		return bus_generic_release_resource(dev, child, type, rid, r);

	switch (type) {
	case SYS_RES_MEMORY:
	case SYS_RES_IOPORT:
		/*
		 * For BARs, we release the resource from the PCI bus
		 * when the last child reference goes away.
		 */
		bar = PCI_RID2BAR(rid);
		if (bar < 0 || bar > PCIR_MAX_BAR_0)
			return (EINVAL);
		sc = device_get_softc(dev);
		if (sc->isab_pci_res[bar].ip_res == NULL)
			return (EINVAL);
		KASSERT(sc->isab_pci_res[bar].ip_res == r,
		    ("isa_pci resource mismatch"));
		if (sc->isab_pci_res[bar].ip_refs > 1) {
			sc->isab_pci_res[bar].ip_refs--;
			return (0);
		}
		KASSERT(sc->isab_pci_res[bar].ip_refs > 0,
		    ("isa_pci resource reference count underflow"));
		error = bus_release_resource(dev, type, rid, r);
		if (error == 0) {
			sc->isab_pci_res[bar].ip_res = NULL;
			sc->isab_pci_res[bar].ip_refs = 0;
		}
		return (error);
	}

	return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child, type,
		rid, r));
}
예제 #4
0
파일: fhc.c 프로젝트: MarginC/kame
int
fhc_release_resource(device_t bus, device_t child, int type, int rid,
    struct resource *r)
{
	struct resource_list_entry *rle;
	struct fhc_devinfo *fdi;
	int error;

	error = bus_generic_release_resource(bus, child, type, rid, r);
	if (type != SYS_RES_MEMORY || error != 0)
		return (error);
	fdi = device_get_ivars(child);
	rle = resource_list_find(&fdi->fdi_rl, type, rid);
	if (rle == NULL)
		panic("fhc_release_resource: can't find resource");
	if (rle->res == NULL)
		panic("fhc_release_resource: resource entry is not busy");
	rle->res = NULL;
	return (error);
}
예제 #5
0
int
pci_host_generic_core_release_resource(device_t dev, device_t child, int type,
    int rid, struct resource *res)
{
	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_release_bus(sc->ecam, child, rid, res));
	}
#endif

	rm = generic_pcie_rman(sc, type);
	if (rm != NULL) {
		KASSERT(rman_is_region_manager(res, rm), ("rman mismatch"));
		rman_release_resource(res);
	}

	return (bus_generic_release_resource(dev, child, type, rid, res));
}