From 58299dd09efaddfd00ea03565fa637e30f1bb6e6 Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Sat, 3 Dec 2005 19:52:20 +0000 Subject: [PATCH] - Move the declaration of struct upa_ranges and the UPA_RANGE_* macros from sys/sparc64/include/ofw_upa.h to sys/sparc64/pci/ofw_pci.h and rename them to struct ofw_pci_ranges and OFW_PCI_RANGE_* respectively. This ranges struct only applies to host-PCI bridges but no to other bridges found on UPA. At the same time it applies to all host-PCI bridges regardless of whether the interconnection bus is Fireplane/ Safari, JBus or UPA. - While here rename the PCI_CS_* macros in sys/sparc64/pci/ofw_pci.h to OFW_PCI_CS_* in order to be consistent and change this header to use uintXX_t instead of u_intXX_t. --- sys/sparc64/include/ofw_nexus.h | 18 ------------------ sys/sparc64/include/ofw_upa.h | 18 ------------------ sys/sparc64/isa/ofw_isa.c | 4 ++-- sys/sparc64/pci/ofw_pci.h | 30 ++++++++++++++++++++++++------ sys/sparc64/pci/psycho.c | 20 ++++++++++---------- 5 files changed, 36 insertions(+), 54 deletions(-) diff --git a/sys/sparc64/include/ofw_nexus.h b/sys/sparc64/include/ofw_nexus.h index 959c9d234c4..fbe6d396cdc 100644 --- a/sys/sparc64/include/ofw_nexus.h +++ b/sys/sparc64/include/ofw_nexus.h @@ -46,27 +46,9 @@ struct upa_regs { u_int32_t size_lo; }; -struct upa_ranges { - u_int32_t cspace; - u_int32_t child_hi; - u_int32_t child_lo; - u_int32_t phys_hi; - u_int32_t phys_lo; - u_int32_t size_hi; - u_int32_t size_lo; -}; - #define UPA_REG_PHYS(r) \ (((u_int64_t)(r)->phys_hi << 32) | (u_int64_t)(r)->phys_lo) #define UPA_REG_SIZE(r) \ (((u_int64_t)(r)->size_hi << 32) | (u_int64_t)(r)->size_lo) -#define UPA_RANGE_CHILD(r) \ - (((u_int64_t)(r)->child_hi << 32) | (u_int64_t)(r)->child_lo) -#define UPA_RANGE_PHYS(r) \ - (((u_int64_t)(r)->phys_hi << 32) | (u_int64_t)(r)->phys_lo) -#define UPA_RANGE_SIZE(r) \ - (((u_int64_t)(r)->size_hi << 32) | (u_int64_t)(r)->size_lo) -#define UPA_RANGE_CS(r) (((r)->cspace >> 24) & 0x03) - #endif /* !_MACHINE_OFW_UPA_H_ */ diff --git a/sys/sparc64/include/ofw_upa.h b/sys/sparc64/include/ofw_upa.h index 959c9d234c4..fbe6d396cdc 100644 --- a/sys/sparc64/include/ofw_upa.h +++ b/sys/sparc64/include/ofw_upa.h @@ -46,27 +46,9 @@ struct upa_regs { u_int32_t size_lo; }; -struct upa_ranges { - u_int32_t cspace; - u_int32_t child_hi; - u_int32_t child_lo; - u_int32_t phys_hi; - u_int32_t phys_lo; - u_int32_t size_hi; - u_int32_t size_lo; -}; - #define UPA_REG_PHYS(r) \ (((u_int64_t)(r)->phys_hi << 32) | (u_int64_t)(r)->phys_lo) #define UPA_REG_SIZE(r) \ (((u_int64_t)(r)->size_hi << 32) | (u_int64_t)(r)->size_lo) -#define UPA_RANGE_CHILD(r) \ - (((u_int64_t)(r)->child_hi << 32) | (u_int64_t)(r)->child_lo) -#define UPA_RANGE_PHYS(r) \ - (((u_int64_t)(r)->phys_hi << 32) | (u_int64_t)(r)->phys_lo) -#define UPA_RANGE_SIZE(r) \ - (((u_int64_t)(r)->size_hi << 32) | (u_int64_t)(r)->size_lo) -#define UPA_RANGE_CS(r) (((r)->cspace >> 24) & 0x03) - #endif /* !_MACHINE_OFW_UPA_H_ */ diff --git a/sys/sparc64/isa/ofw_isa.c b/sys/sparc64/isa/ofw_isa.c index 41ce54812c0..e1d75374aec 100644 --- a/sys/sparc64/isa/ofw_isa.c +++ b/sys/sparc64/isa/ofw_isa.c @@ -57,9 +57,9 @@ ofw_isa_range_restype(struct isa_ranges *range) int ps = ISA_RANGE_PS(range); switch (ps) { - case PCI_CS_IO: + case OFW_PCI_CS_IO: return (SYS_RES_IOPORT); - case PCI_CS_MEM32: + case OFW_PCI_CS_MEM32: return (SYS_RES_MEMORY); default: panic("ofw_isa_range_restype: illegal space %x", ps); diff --git a/sys/sparc64/pci/ofw_pci.h b/sys/sparc64/pci/ofw_pci.h index f87f65a30ce..6d102b09b18 100644 --- a/sys/sparc64/pci/ofw_pci.h +++ b/sys/sparc64/pci/ofw_pci.h @@ -36,16 +36,34 @@ #include -typedef u_int32_t ofw_pci_intr_t; +typedef uint32_t ofw_pci_intr_t; #include "ofw_pci_if.h" /* PCI range child spaces. XXX: are these MI? */ -#define PCI_CS_CONFIG 0x00 -#define PCI_CS_IO 0x01 -#define PCI_CS_MEM32 0x02 -#define PCI_CS_MEM64 0x03 +#define OFW_PCI_CS_CONFIG 0x00 +#define OFW_PCI_CS_IO 0x01 +#define OFW_PCI_CS_MEM32 0x02 +#define OFW_PCI_CS_MEM64 0x03 -u_int8_t ofw_pci_alloc_busno(phandle_t); +struct ofw_pci_ranges { + uint32_t cspace; + uint32_t child_hi; + uint32_t child_lo; + uint32_t phys_hi; + uint32_t phys_lo; + uint32_t size_hi; + uint32_t size_lo; +}; + +#define OFW_PCI_RANGE_CHILD(r) \ + (((uint64_t)(r)->child_hi << 32) | (uint64_t)(r)->child_lo) +#define OFW_PCI_RANGE_PHYS(r) \ + (((uint64_t)(r)->phys_hi << 32) | (uint64_t)(r)->phys_lo) +#define OFW_PCI_RANGE_SIZE(r) \ + (((uint64_t)(r)->size_hi << 32) | (uint64_t)(r)->size_lo) +#define OFW_PCI_RANGE_CS(r) (((r)->cspace >> 24) & 0x03) + +uint8_t ofw_pci_alloc_busno(phandle_t); #endif /* ! _SPARC64_PCI_OFW_PCI_H_ */ diff --git a/sys/sparc64/pci/psycho.c b/sys/sparc64/pci/psycho.c index 387a4c37e7f..322a058ad35 100644 --- a/sys/sparc64/pci/psycho.c +++ b/sys/sparc64/pci/psycho.c @@ -287,7 +287,7 @@ psycho_attach(device_t dev) struct psycho_softc *sc; struct psycho_softc *osc = NULL; struct psycho_softc *asc; - struct upa_ranges *range; + struct ofw_pci_ranges *range; struct upa_regs *reg; const struct psycho_desc *desc; phandle_t node; @@ -417,7 +417,7 @@ psycho_attach(device_t dev) nrange = OF_getprop_alloc(node, "ranges", sizeof(*range), (void **)&range); /* - * Make sure that the expected ranges are present. The PCI_CS_MEM64 + * Make sure that the expected ranges are present. The OFW_PCI_CS_MEM64 * one is not currently used though. */ if (nrange != PSYCHO_NRANGE) @@ -429,10 +429,10 @@ psycho_attach(device_t dev) * memory and I/O handles. */ for (n = 0; n < PSYCHO_NRANGE; n++) { - i = UPA_RANGE_CS(&range[n]); + i = OFW_PCI_RANGE_CS(&range[n]); if (sc->sc_pci_bh[i] != 0) panic("%s: duplicate range for space %d", __func__, i); - sc->sc_pci_bh[i] = UPA_RANGE_PHYS(&range[n]); + sc->sc_pci_bh[i] = OFW_PCI_RANGE_PHYS(&range[n]); } free(range, M_OFWPROP); @@ -806,7 +806,7 @@ psycho_read_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, sc = device_get_softc(dev); offset = PSYCHO_CONF_OFF(bus, slot, func, reg); - bh = sc->sc_pci_bh[PCI_CS_CONFIG]; + bh = sc->sc_pci_bh[OFW_PCI_CS_CONFIG]; switch (width) { case 1: i = bus_space_peek_1(sc->sc_pci_cfgt, bh, offset, &byte); @@ -844,7 +844,7 @@ psycho_write_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, sc = device_get_softc(dev); offset = PSYCHO_CONF_OFF(bus, slot, func, reg); - bh = sc->sc_pci_bh[PCI_CS_CONFIG]; + bh = sc->sc_pci_bh[OFW_PCI_CS_CONFIG]; switch (width) { case 1: bus_space_write_1(sc->sc_pci_cfgt, bh, offset, val); @@ -1040,12 +1040,12 @@ psycho_alloc_resource(device_t bus, device_t child, int type, int *rid, case SYS_RES_MEMORY: rm = &sc->sc_pci_mem_rman; bt = sc->sc_pci_memt; - bh = sc->sc_pci_bh[PCI_CS_MEM32]; + bh = sc->sc_pci_bh[OFW_PCI_CS_MEM32]; break; case SYS_RES_IOPORT: rm = &sc->sc_pci_io_rman; bt = sc->sc_pci_iot; - bh = sc->sc_pci_bh[PCI_CS_IO]; + bh = sc->sc_pci_bh[OFW_PCI_CS_IO]; break; default: return (NULL); @@ -1150,10 +1150,10 @@ psycho_get_bus_handle(device_t dev, int type, bus_space_handle_t childhdl, switch (type) { case SYS_RES_IOPORT: *tag = sc->sc_pci_iot; - return (sc->sc_pci_bh[PCI_CS_IO] + childhdl); + return (sc->sc_pci_bh[OFW_PCI_CS_IO] + childhdl); case SYS_RES_MEMORY: *tag = sc->sc_pci_memt; - return (sc->sc_pci_bh[PCI_CS_MEM32] + childhdl); + return (sc->sc_pci_bh[OFW_PCI_CS_MEM32] + childhdl); default: panic("%s: illegal space (%d)\n", __func__, type); }