Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ofw/ofw_pcib.c
Show First 20 Lines • Show All 205 Lines • ▼ Show 20 Lines | if (error != 0) { | ||||
goto out; | goto out; | ||||
} | } | ||||
sc->sc_mem_rman.rm_type = RMAN_ARRAY; | sc->sc_mem_rman.rm_type = RMAN_ARRAY; | ||||
sc->sc_mem_rman.rm_descr = "PCI Non Prefetchable Memory"; | sc->sc_mem_rman.rm_descr = "PCI Non Prefetchable Memory"; | ||||
error = rman_init(&sc->sc_mem_rman); | error = rman_init(&sc->sc_mem_rman); | ||||
if (error != 0) { | if (error != 0) { | ||||
device_printf(dev, "rman_init() failed. error = %d\n", error); | device_printf(dev, "rman_init() failed. error = %d\n", error); | ||||
goto out; | goto out_mem_rman; | ||||
} | } | ||||
sc->sc_pmem_rman.rm_type = RMAN_ARRAY; | sc->sc_pmem_rman.rm_type = RMAN_ARRAY; | ||||
sc->sc_pmem_rman.rm_descr = "PCI Prefetchable Memory"; | sc->sc_pmem_rman.rm_descr = "PCI Prefetchable Memory"; | ||||
error = rman_init(&sc->sc_pmem_rman); | error = rman_init(&sc->sc_pmem_rman); | ||||
if (error != 0) { | if (error != 0) { | ||||
device_printf(dev, "rman_init() failed. error = %d\n", error); | device_printf(dev, "rman_init() failed. error = %d\n", error); | ||||
goto out; | goto out_pmem_rman; | ||||
} | } | ||||
for (i = 0; i < sc->sc_nrange; i++) { | for (i = 0; i < sc->sc_nrange; i++) { | ||||
error = 0; | error = 0; | ||||
rp = sc->sc_range + i; | rp = sc->sc_range + i; | ||||
if (sc->sc_range_mask & ((uint64_t)1 << i)) | if (sc->sc_range_mask & ((uint64_t)1 << i)) | ||||
continue; | continue; | ||||
Show All 18 Lines | for (i = 0; i < sc->sc_nrange; i++) { | ||||
} | } | ||||
if (error != 0) { | if (error != 0) { | ||||
device_printf(dev, | device_printf(dev, | ||||
"rman_manage_region(%x, %#jx, %#jx) failed. " | "rman_manage_region(%x, %#jx, %#jx) failed. " | ||||
"error = %d\n", rp->pci_hi & | "error = %d\n", rp->pci_hi & | ||||
OFW_PCI_PHYS_HI_SPACEMASK, rp->pci, | OFW_PCI_PHYS_HI_SPACEMASK, rp->pci, | ||||
rp->pci + rp->size - 1, error); | rp->pci + rp->size - 1, error); | ||||
goto out; | goto out_full; | ||||
} | } | ||||
} | } | ||||
ofw_bus_setup_iinfo(node, &sc->sc_pci_iinfo, sizeof(cell_t)); | ofw_bus_setup_iinfo(node, &sc->sc_pci_iinfo, sizeof(cell_t)); | ||||
return (0); | return (0); | ||||
out_full: | |||||
rman_fini(&sc->sc_pmem_rman); | |||||
out_pmem_rman: | |||||
rman_fini(&sc->sc_mem_rman); | |||||
out_mem_rman: | |||||
rman_fini(&sc->sc_io_rman); | |||||
out: | out: | ||||
free(cell_info, M_DEVBUF); | free(sc->sc_cell_info, M_DEVBUF); | ||||
free(sc->sc_range, M_DEVBUF); | free(sc->sc_range, M_DEVBUF); | ||||
return (error); | |||||
} | |||||
void | |||||
ofw_pcib_fini(device_t dev) | |||||
{ | |||||
struct ofw_pci_softc *sc; | |||||
sc = device_get_softc(dev); | |||||
free(sc->sc_cell_info, M_DEVBUF); | |||||
free(sc->sc_range, M_DEVBUF); | |||||
rman_fini(&sc->sc_io_rman); | rman_fini(&sc->sc_io_rman); | ||||
rman_fini(&sc->sc_mem_rman); | rman_fini(&sc->sc_mem_rman); | ||||
rman_fini(&sc->sc_pmem_rman); | rman_fini(&sc->sc_pmem_rman); | ||||
return (error); | |||||
} | } | ||||
int | int | ||||
ofw_pcib_attach(device_t dev) | ofw_pcib_attach(device_t dev) | ||||
{ | { | ||||
struct ofw_pci_softc *sc; | struct ofw_pci_softc *sc; | ||||
int error; | int error; | ||||
▲ Show 20 Lines • Show All 436 Lines • Show Last 20 Lines |