diff options
| author | Thomas Moestl <tmm@FreeBSD.org> | 2004-04-28 13:06:46 +0000 |
|---|---|---|
| committer | Thomas Moestl <tmm@FreeBSD.org> | 2004-04-28 13:06:46 +0000 |
| commit | e6597c747ffa9671098b71fad677d0d5aafb767b (patch) | |
| tree | cc4413b93d0e5bbc9943f6f574c14c608433cea9 /sys/sparc64/isa | |
| parent | 5663c016deb1caf459b2d2b561c167bf42517d35 (diff) | |
Notes
Diffstat (limited to 'sys/sparc64/isa')
| -rw-r--r-- | sys/sparc64/isa/ofw_isa.c | 44 | ||||
| -rw-r--r-- | sys/sparc64/isa/ofw_isa.h | 5 |
2 files changed, 30 insertions, 19 deletions
diff --git a/sys/sparc64/isa/ofw_isa.c b/sys/sparc64/isa/ofw_isa.c index b5e746c22c9a..c6cff5253441 100644 --- a/sys/sparc64/isa/ofw_isa.c +++ b/sys/sparc64/isa/ofw_isa.c @@ -53,18 +53,35 @@ #include "pcib_if.h" +int +ofw_isa_range_restype(struct isa_ranges *range) +{ + int ps = ISA_RANGE_PS(range); + + switch (ps) { + case PCI_CS_IO: + return (SYS_RES_IOPORT); + case PCI_CS_MEM32: + return (SYS_RES_MEMORY); + default: + panic("ofw_isa_range_restype: illegal space %x", ps); + } + +} + /* XXX: this only supports PCI as parent bus right now. */ int -ofw_isa_map_iorange(struct isa_ranges *range, int nrange, u_long *start, - u_long *end) +ofw_isa_range_map(struct isa_ranges *range, int nrange, u_long *start, + u_long *end, int *which) { + struct isa_ranges *r; u_int64_t offs, cstart, cend; int i; for (i = 0; i < nrange; i++) { - cstart = ((u_int64_t)range[i].child_hi << 32) | - range[i].child_lo; - cend = cstart + range[i].size; + r = &range[i]; + cstart = ISA_RANGE_CHILD(r); + cend = cstart + r->size; if (*start < cstart || *start > cend) continue; if (*end < cstart || *end > cend) { @@ -72,21 +89,12 @@ ofw_isa_map_iorange(struct isa_ranges *range, int nrange, u_long *start, "ranges (%#lx not in %#lx - %#lx)", *end, cstart, cend); } - offs = (((u_int64_t)range[i].phys_mid << 32) | - range[i].phys_lo); + offs = ISA_RANGE_PHYS(r); *start = *start + offs - cstart; *end = *end + offs - cstart; - /* Isolate address space and find the right tag */ - switch (ISA_RANGE_PS(&range[i])) { - case PCI_CS_IO: - return (SYS_RES_IOPORT); - case PCI_CS_MEM32: - return (SYS_RES_MEMORY); - default: - panic("ofw_isa_map_iorange: illegal space %x", - ISA_RANGE_PS(&range[i])); - break; - } + if (which != NULL) + *which = i; + return (ofw_isa_range_restype(r)); } panic("ofw_isa_map_iorange: could not map range %#lx - %#lx", *start, *end); diff --git a/sys/sparc64/isa/ofw_isa.h b/sys/sparc64/isa/ofw_isa.h index dd534adef3f8..ab119eeb0787 100644 --- a/sys/sparc64/isa/ofw_isa.h +++ b/sys/sparc64/isa/ofw_isa.h @@ -59,6 +59,8 @@ struct isa_ranges { #define ISA_RANGE_CHILD(r) \ ((((u_int64_t)((r)->child_hi)) << 32) | ((u_int64_t)(r)->child_lo)) #define ISA_RANGE_PS(r) (((r)->phys_hi >> 24) & 0x03) +#define ISA_RANGE_PHYS(r) \ + ((((u_int64_t)(r)->phys_mid) << 32) | ((u_int64_t)(r)->phys_lo)) typedef u_int32_t ofw_isa_intr_t; @@ -76,8 +78,9 @@ struct isa_imap_msk { ofw_isa_intr_t intr; /* interrupt */ }; +int ofw_isa_range_restype(struct isa_ranges *); /* Map an IO range. Returns the resource type of the range. */ -int ofw_isa_map_iorange(struct isa_ranges *, int, u_long *, u_long *); +int ofw_isa_range_map(struct isa_ranges *, int, u_long *, u_long *, int *); #ifdef OFW_NEWPCI ofw_pci_intr_t ofw_isa_route_intr(device_t, phandle_t, struct ofw_bus_iinfo *, |
