Index: sys/sparc64/pci/fire.c =================================================================== --- sys/sparc64/pci/fire.c +++ sys/sparc64/pci/fire.c @@ -300,7 +300,7 @@ uint64_t ino_bitmap, val; phandle_t node; uint32_t prop, prop_array[2]; - int i, j, mode; + int i, j, mode, nrange; u_int lw; uint16_t mps; @@ -733,26 +733,34 @@ rman_manage_region(&sc->sc_pci_mem_rman, 0, FO_MEM_SIZE) != 0) panic("%s: failed to set up memory rman", __func__); - i = OF_getprop_alloc(node, "ranges", sizeof(*range), (void **)&range); - /* - * Make sure that the expected ranges are present. The - * OFW_PCI_CS_MEM64 one is not currently used though. - */ - if (i != FIRE_NRANGE) - panic("%s: unsupported number of ranges", __func__); + nrange = OF_getprop_alloc(node, "ranges", sizeof(*range), + (void **)&range); + /* * Find the addresses of the various bus spaces. * There should not be multiple ones of one kind. * The physical start addresses of the ranges are the configuration, * memory and I/O handles. */ - for (i = 0; i < FIRE_NRANGE; i++) { + for (i = 0; i < nrange; i++) { j = OFW_PCI_RANGE_CS(&range[i]); if (sc->sc_pci_bh[j] != 0) panic("%s: duplicate range for space %d", __func__, j); sc->sc_pci_bh[j] = OFW_PCI_RANGE_PHYS(&range[i]); } + + /* + * Make sure that the expected ranges are present. The + * OFW_PCI_CS_MEM64 one is not currently used. + */ + if (sc->sc_pci_bh[OFW_PCI_CS_CONFIG] == 0) + panic("%s: missing CONFIG range", __func__); + if (sc->sc_pci_bh[OFW_PCI_CS_IO] == 0) + panic("%s: missing IO range", __func__); + if (sc->sc_pci_bh[OFW_PCI_CS_MEM32] == 0) + panic("%s: missing MEM32 range", __func__); + free(range, M_OFWPROP); /* Allocate our tags. */ Index: sys/sparc64/pci/firereg.h =================================================================== --- sys/sparc64/pci/firereg.h +++ sys/sparc64/pci/firereg.h @@ -30,7 +30,6 @@ #define _SPARC64_PCI_FIREREG_H_ #define FIRE_NINTR 3 /* 2 OFW + 1 MSIq */ -#define FIRE_NRANGE 4 #define FIRE_NREG 2 #define FIRE_PCI 0 Index: sys/sparc64/pci/firevar.h =================================================================== --- sys/sparc64/pci/firevar.h +++ sys/sparc64/pci/firevar.h @@ -44,7 +44,7 @@ struct rman sc_pci_mem_rman; struct rman sc_pci_io_rman; - bus_space_handle_t sc_pci_bh[FIRE_NRANGE]; + bus_space_handle_t sc_pci_bh[OFW_PCI_NUM_CS]; bus_space_tag_t sc_pci_cfgt; bus_space_tag_t sc_pci_iot; bus_dma_tag_t sc_pci_dmat; Index: sys/sparc64/pci/ofw_pci.h =================================================================== --- sys/sparc64/pci/ofw_pci.h +++ sys/sparc64/pci/ofw_pci.h @@ -74,6 +74,8 @@ #define OFW_PCI_CS_MEM32 0x02 #define OFW_PCI_CS_MEM64 0x03 +#define OFW_PCI_NUM_CS 4 + /* OFW device types */ #define OFW_TYPE_PCI "pci" #define OFW_TYPE_PCIE "pciex" Index: sys/sparc64/pci/psycho.c =================================================================== --- sys/sparc64/pci/psycho.c +++ sys/sparc64/pci/psycho.c @@ -294,7 +294,7 @@ phandle_t node; uint32_t dvmabase, prop, prop_array[2]; u_int rerun, ver; - int i, j; + int i, j, nrange; node = ofw_bus_get_node(dev); sc = device_get_softc(dev); @@ -446,26 +446,34 @@ rman_manage_region(&sc->sc_pci_mem_rman, 0, PSYCHO_MEM_SIZE) != 0) panic("%s: failed to set up memory rman", __func__); - i = OF_getprop_alloc(node, "ranges", sizeof(*range), (void **)&range); - /* - * Make sure that the expected ranges are present. The - * OFW_PCI_CS_MEM64 one is not currently used though. - */ - if (i != PSYCHO_NRANGE) - panic("%s: unsupported number of ranges", __func__); + nrange = OF_getprop_alloc(node, "ranges", sizeof(*range), + (void **)&range); + /* * Find the addresses of the various bus spaces. * There should not be multiple ones of one kind. * The physical start addresses of the ranges are the configuration, * memory and I/O handles. */ - for (i = 0; i < PSYCHO_NRANGE; i++) { + for (i = 0; i < nrange; i++) { j = OFW_PCI_RANGE_CS(&range[i]); if (sc->sc_pci_bh[j] != 0) panic("%s: duplicate range for space %d", __func__, j); sc->sc_pci_bh[j] = OFW_PCI_RANGE_PHYS(&range[i]); } + + /* + * Make sure that the expected ranges are present. The + * OFW_PCI_CS_MEM64 one is not currently used. + */ + if (sc->sc_pci_bh[OFW_PCI_CS_CONFIG] == 0) + panic("%s: missing CONFIG range", __func__); + if (sc->sc_pci_bh[OFW_PCI_CS_IO] == 0) + panic("%s: missing IO range", __func__); + if (sc->sc_pci_bh[OFW_PCI_CS_MEM32] == 0) + panic("%s: missing MEM32 range", __func__); + free(range, M_OFWPROP); /* Register the softc, this is needed for paired Psychos. */ Index: sys/sparc64/pci/psychoreg.h =================================================================== --- sys/sparc64/pci/psychoreg.h +++ sys/sparc64/pci/psychoreg.h @@ -73,7 +73,6 @@ */ #define PSYCHO_NINTR 6 -#define PSYCHO_NRANGE 4 /* * Psycho register offsets Index: sys/sparc64/pci/psychovar.h =================================================================== --- sys/sparc64/pci/psychovar.h +++ sys/sparc64/pci/psychovar.h @@ -68,7 +68,7 @@ bus_space_tag_t sc_pci_iot; bus_dma_tag_t sc_pci_dmat; - bus_space_handle_t sc_pci_bh[PSYCHO_NRANGE]; + bus_space_handle_t sc_pci_bh[OFW_PCI_NUM_CS]; struct rman sc_pci_mem_rman; struct rman sc_pci_io_rman; Index: sys/sparc64/pci/schizo.c =================================================================== --- sys/sparc64/pci/schizo.c +++ sys/sparc64/pci/schizo.c @@ -277,7 +277,7 @@ uint64_t ino_bitmap, reg; phandle_t node; uint32_t prop, prop_array[2]; - int i, j, mode, rid, tsbsize; + int i, j, mode, nrange, rid, tsbsize; sc = device_get_softc(dev); node = ofw_bus_get_node(dev); @@ -554,26 +554,34 @@ rman_manage_region(&sc->sc_pci_mem_rman, 0, STX_MEM_SIZE) != 0) panic("%s: failed to set up memory rman", __func__); - i = OF_getprop_alloc(node, "ranges", sizeof(*range), (void **)&range); - /* - * Make sure that the expected ranges are present. The - * OFW_PCI_CS_MEM64 one is not currently used though. - */ - if (i != STX_NRANGE) - panic("%s: unsupported number of ranges", __func__); + nrange = OF_getprop_alloc(node, "ranges", sizeof(*range), + (void **)&range); + /* * Find the addresses of the various bus spaces. * There should not be multiple ones of one kind. * The physical start addresses of the ranges are the configuration, * memory and I/O handles. */ - for (i = 0; i < STX_NRANGE; i++) { + for (i = 0; i < nrange; i++) { j = OFW_PCI_RANGE_CS(&range[i]); if (sc->sc_pci_bh[j] != 0) panic("%s: duplicate range for space %d", __func__, j); sc->sc_pci_bh[j] = OFW_PCI_RANGE_PHYS(&range[i]); } + + /* + * Make sure that the expected ranges are present. The + * OFW_PCI_CS_MEM64 one is not currently used. + */ + if (sc->sc_pci_bh[OFW_PCI_CS_CONFIG] == 0) + panic("%s: missing CONFIG range", __func__); + if (sc->sc_pci_bh[OFW_PCI_CS_IO] == 0) + panic("%s: missing IO range", __func__); + if (sc->sc_pci_bh[OFW_PCI_CS_MEM32] == 0) + panic("%s: missing MEM32 range", __func__); + free(range, M_OFWPROP); /* Register the softc, this is needed for paired Schizos. */ Index: sys/sparc64/pci/schizoreg.h =================================================================== --- sys/sparc64/pci/schizoreg.h +++ sys/sparc64/pci/schizoreg.h @@ -32,7 +32,6 @@ #define _SPARC64_PCI_SCHIZOREG_H_ #define STX_NINTR 5 /* 4 via OFW + 1 CDMA */ -#define STX_NRANGE 4 #define SCZ_NREG 3 #define TOM_NREG 4 Index: sys/sparc64/pci/schizovar.h =================================================================== --- sys/sparc64/pci/schizovar.h +++ sys/sparc64/pci/schizovar.h @@ -80,7 +80,7 @@ struct rman sc_pci_mem_rman; struct rman sc_pci_io_rman; - bus_space_handle_t sc_pci_bh[STX_NRANGE]; + bus_space_handle_t sc_pci_bh[OFW_PCI_NUM_CS]; bus_space_tag_t sc_pci_cfgt; bus_space_tag_t sc_pci_iot; bus_dma_tag_t sc_pci_dmat;