diff options
Diffstat (limited to 'sys/sparc64/sparc64/ofw_bus.c')
-rw-r--r-- | sys/sparc64/sparc64/ofw_bus.c | 171 |
1 files changed, 1 insertions, 170 deletions
diff --git a/sys/sparc64/sparc64/ofw_bus.c b/sys/sparc64/sparc64/ofw_bus.c index 6c894b6..c1fcfcb 100644 --- a/sys/sparc64/sparc64/ofw_bus.c +++ b/sys/sparc64/sparc64/ofw_bus.c @@ -64,8 +64,6 @@ * bits left. */ -#include "opt_ofw_pci.h" - #include <sys/param.h> #include <sys/malloc.h> #include <sys/systm.h> @@ -86,8 +84,6 @@ ofw_bus_searchprop(phandle_t node, char *propname, void *buf, int buflen) return (-1); } -#ifdef OFW_NEWPCI - void ofw_bus_setup_iinfo(phandle_t node, struct ofw_bus_iinfo *ii, int intrsz) { @@ -181,7 +177,7 @@ ofw_bus_search_intrmap(void *intr, int intrsz, void *regs, int physsz, i = imapsz; tsz = physsz + intrsz + sizeof(phandle_t) + rintrsz; while (i > 0) { - KASSERT(i >= tsz, ("ofw_bus_find_intr: truncated map")); + KASSERT(i >= tsz, ("ofw_bus_search_intrmap: truncated map")); bcopy(mptr + physsz + intrsz, &parent, sizeof(parent)); if (ofw_bus_searchprop(parent, "#interrupt-cells", &pintrsz, sizeof(pintrsz)) == -1) @@ -200,168 +196,3 @@ ofw_bus_search_intrmap(void *intr, int intrsz, void *regs, int physsz, } return (0); } - -#else -/* - * Map an interrupt using the firmware reg, interrupt-map and - * interrupt-map-mask properties. - * The interrupt is returned in *result, which is malloc()'ed. The size of - * the interrupt specifiaction is returned. - */ -static int -ofw_bus_find_intr(u_int8_t *intr, int intrsz, u_int8_t *regs, int physsz, - u_int8_t *imap, int imapsz, u_int8_t *imapmsk, u_int8_t **result) -{ - phandle_t parent; - char *ref; - u_int8_t *mptr; - pcell_t pintrsz; - int i, rsz, tsz; - - rsz = -1; - ref = malloc(physsz + intrsz, M_TEMP, M_WAITOK); - if (imapmsk != NULL) { - for (i = 0; i < physsz; i++) - ref[i] = regs[i] & imapmsk[i]; - for (i = 0; i < intrsz; i++) - ref[physsz + i] = intr[i] & imapmsk[physsz + i]; - } else { - bcopy(regs, ref, physsz); - bcopy(intr, ref + physsz, intrsz); - } - mptr = imap; - i = imapsz; - while (i > 0) { - KASSERT(i >= physsz + sizeof(parent), - ("ofw_bus_find_intr: truncated map")); - bcopy(mptr + physsz + intrsz, &parent, sizeof(parent)); - if (ofw_bus_searchprop(parent, "#interrupt-cells", - &pintrsz, sizeof(pintrsz)) == -1) - pintrsz = 1; /* default */ - pintrsz *= sizeof(pcell_t); - KASSERT(i >= physsz + intrsz + sizeof(parent) + - pintrsz, ("ofw_bus_find_intr: truncated map")); - if (bcmp(ref, mptr, physsz + intrsz) == 0) { - *result = malloc(pintrsz, M_OFWPROP, M_WAITOK); - bcopy(mptr + physsz + intrsz + sizeof(parent), - *result, pintrsz); - rsz = pintrsz; - break; - } - tsz = physsz + intrsz + sizeof(phandle_t) + pintrsz; - mptr += tsz; - i -= tsz; - } - free(ref, M_TEMP); - return (rsz); -} - -/* - * Apply the OpenFirmware algorithm for mapping an interrupt. First, the - * 'interrupts' and 'reg' properties are retrieved; those are matched against - * the interrupt map of the next higher node. If there is no match or no such - * propery, we go to the next higher node, using the 'reg' property of the node - * that was just processed unusccessfully. - * When a match occurs, we should continue to search, using the new interrupt - * specification that was just found; this is currently not performed - * (see below). - * When the root node is reached with at least one successful mapping performed, - * and the format is right, the interrupt number is returned. - * - * This should work for all bus systems. - */ -u_int32_t -ofw_bus_route_intr(phandle_t node, int intrp, obr_callback_t *cb, void *cookie) -{ - u_int8_t *reg, *intr, *tintr, *imap, *imapmsk; - phandle_t parent; - pcell_t addrc, ic; - u_int32_t rv; - int regsz, tisz, isz, imapsz, found; - - found = 0; - reg = imap = imapmsk = NULL; - if (intrp == ORIP_NOINT) { - isz = OF_getprop_alloc(node, "interrupts", 1, (void **)&intr); - if (isz < 0) - return (ORIR_NOTFOUND); - } else { - ic = intrp; - isz = sizeof(ic); - intr = malloc(isz, M_OFWPROP, M_WAITOK); - bcopy(&ic, intr, isz); - } - /* - * Note that apparently, remapping at multiple levels is allowed; - * however, this causes problems with EBus at least, and seems to never - * be needed, so we disable it for now (*sigh*). - */ - for (parent = OF_parent(node); parent != 0 && !found; - parent = OF_parent(node = parent)) { - if (reg != NULL) - free(reg, M_OFWPROP); - regsz = OF_getprop_alloc(node, "reg", 1, (void **)®); - if (regsz < 0) - panic("ofw_bus_route_intr: could not get reg property"); - imapsz = OF_getprop_alloc(parent, "interrupt-map", 1, - (void **)&imap); - if (imapsz == -1) { - /* - * Use the callback to allow caller-specific workarounds - * for firmware bugs (missing properties). - */ - if (cb != NULL) { - tisz = cb(parent, intr, isz, reg, regsz, &tintr, - &found, cookie); - if (tisz != -1) { - isz = tisz; - free(intr, M_OFWPROP); - intr = tintr; - } - } - continue; - } - if (OF_getprop(parent, "#address-cells", &addrc, - sizeof(addrc)) == -1) - addrc = 2; - addrc *= sizeof(pcell_t); - /* - * Failures to get the mask are ignored; a full mask is assumed - * in this case. - */ - OF_getprop_alloc(parent, "interrupt-map-mask", 1, - (void **)&imapmsk); - tisz = ofw_bus_find_intr(intr, isz, reg, addrc, imap, imapsz, - imapmsk, &tintr); - if (tisz != -1) { - found = 1; - isz = tisz; - free(intr, M_OFWPROP); - intr = tintr; - } - free(imap, M_OFWPROP); - if (imapmsk != NULL) - free(imapmsk, M_OFWPROP); - } - if (reg != NULL) - free(reg, M_OFWPROP); -#if 0 - /* - * Obviously there are some boxes that don't require mapping at all, - * for example the U30, which has no interrupt maps for children of - * the root PCI bus. - */ - if (!found) { - if (intrp != ORIP_NOINT) - return (ORIR_NOTFOUND); - panic("ofw_bus_route_intr: 'interrupts' property, but no " - "mapping found"); - } -#endif - KASSERT(isz == sizeof(u_int32_t), - ("ofw_bus_route_intr: bad interrupt spec size %d", isz)); - bcopy(intr, &rv, sizeof(rv)); - free(intr, M_OFWPROP); - return (rv); -} -#endif /* OFW_NEWPCI */ |