Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ofw/ofwpci.c
Show All 24 Lines | |||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/bus.h> | #include <sys/bus.h> | ||||
#include <sys/kdb.h> | |||||
#include <sys/conf.h> | #include <sys/conf.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/rman.h> | #include <sys/rman.h> | ||||
#include <dev/ofw/openfirm.h> | #include <dev/ofw/openfirm.h> | ||||
#include <dev/ofw/ofw_pci.h> | #include <dev/ofw/ofw_pci.h> | ||||
#include <dev/ofw/ofw_bus.h> | #include <dev/ofw/ofw_bus.h> | ||||
#include <dev/ofw/ofw_bus_subr.h> | #include <dev/ofw/ofw_bus_subr.h> | ||||
▲ Show 20 Lines • Show All 363 Lines • ▼ Show 20 Lines | |||||
ofw_pci_alloc_resource(device_t bus, device_t child, int type, int *rid, | ofw_pci_alloc_resource(device_t bus, device_t child, int type, int *rid, | ||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) | rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) | ||||
{ | { | ||||
struct ofw_pci_softc *sc; | struct ofw_pci_softc *sc; | ||||
struct resource *rv; | struct resource *rv; | ||||
struct rman *rm; | struct rman *rm; | ||||
int needactivate; | int needactivate; | ||||
needactivate = flags & RF_ACTIVE; | needactivate = flags & RF_ACTIVE; | ||||
flags &= ~RF_ACTIVE; | flags &= ~RF_ACTIVE; | ||||
sc = device_get_softc(bus); | sc = device_get_softc(bus); | ||||
#if defined(NEW_PCIB) && defined(PCI_RES_BUS) | #if defined(NEW_PCIB) && defined(PCI_RES_BUS) | ||||
if (type == PCI_RES_BUS) { | if (type == PCI_RES_BUS) { | ||||
return (pci_domain_alloc_bus(sc->sc_pci_domain, child, rid, | return (pci_domain_alloc_bus(sc->sc_pci_domain, child, rid, | ||||
start, end, count, flags | needactivate)); | start, end, count, flags | needactivate)); | ||||
} | } | ||||
#endif | #endif | ||||
rm = ofw_pci_get_rman(sc, type, flags); | rm = ofw_pci_get_rman(sc, type, flags); | ||||
if (rm == NULL) { | if (rm == NULL) { | ||||
return (bus_generic_alloc_resource(bus, child, type, rid, | return (bus_generic_alloc_resource(bus, child, type, rid, | ||||
start, end, count, flags | needactivate)); | start, end, count, flags | needactivate)); | ||||
} | } | ||||
rv = rman_reserve_resource(rm, start, end, count, flags, child); | rv = rman_reserve_resource(rm, start, end, count, flags, child); | ||||
if (rv == NULL) { | if (rv == NULL) { | ||||
device_printf(bus, "failed to reserve resource for %s\n", | |||||
device_get_nameunit(child)); | |||||
return (NULL); | return (NULL); | ||||
} | } | ||||
rman_set_rid(rv, *rid); | rman_set_rid(rv, *rid); | ||||
if (needactivate) { | if (needactivate) { | ||||
if (bus_activate_resource(child, type, *rid, rv) != 0) { | if (bus_activate_resource(child, type, *rid, rv) != 0) { | ||||
device_printf(bus, | |||||
"failed to activate resource for %s\n", | |||||
device_get_nameunit(child)); | |||||
rman_release_resource(rv); | rman_release_resource(rv); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
} | } | ||||
return (rv); | return (rv); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 265 Lines • Show Last 20 Lines |