Module Name: src Committed By: jdc Date: Thu Jan 7 09:33:44 UTC 2010
Modified Files: src/sys/arch/sparc64/dev: pci_machdep.c Log Message: Cope with up to four "interrupts" properties for a node. Just use the first one for now. This should be improved. OK: m...@. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sys/arch/sparc64/dev/pci_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/sparc64/dev/pci_machdep.c diff -u src/sys/arch/sparc64/dev/pci_machdep.c:1.66 src/sys/arch/sparc64/dev/pci_machdep.c:1.67 --- src/sys/arch/sparc64/dev/pci_machdep.c:1.66 Wed Jan 6 05:55:01 2010 +++ src/sys/arch/sparc64/dev/pci_machdep.c Thu Jan 7 09:33:44 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_machdep.c,v 1.66 2010/01/06 05:55:01 mrg Exp $ */ +/* $NetBSD: pci_machdep.c,v 1.67 2010/01/07 09:33:44 jdc Exp $ */ /* * Copyright (c) 1999, 2000 Matthew R. Green @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.66 2010/01/06 05:55:01 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.67 2010/01/07 09:33:44 jdc Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -415,37 +415,44 @@ pci_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp) { pcitag_t tag = pa->pa_tag; - int interrupts, *intp; + int interrupts[4], *intp, int_used; int len, node = PCITAG_NODE(tag); char devtype[30]; - intp = &interrupts; - len = 1; - if (prom_getprop(node, "interrupts", sizeof(interrupts), + intp = &interrupts[0]; + len = prom_getproplen(node, "interrupts"); + if (len > sizeof(interrupts)) { + DPRINTF(SPDB_INTMAP, + ("pci_intr_map: too many available interrupts\n")); + return (ENODEV); + } + if (prom_getprop(node, "interrupts", len, &len, &intp) != 0 || len != 1) { DPRINTF(SPDB_INTMAP, ("pci_intr_map: could not read interrupts\n")); return (ENODEV); } - if (OF_mapintr(node, &interrupts, sizeof(interrupts), - sizeof(interrupts)) < 0) { + /* XXX We pick the first interrupt, but should do better */ + int_used = interrupts[0]; + if (OF_mapintr(node, &int_used, sizeof(int_used), + sizeof(int_used)) < 0) { printf("OF_mapintr failed\n"); KASSERT(pa->pa_pc->spc_find_ino); - pa->pa_pc->spc_find_ino(pa, &interrupts); + pa->pa_pc->spc_find_ino(pa, &int_used); } - DPRINTF(SPDB_INTMAP, ("OF_mapintr() gave %x\n", interrupts)); + DPRINTF(SPDB_INTMAP, ("OF_mapintr() gave %x\n", int_used)); /* Try to find an IPL for this type of device. */ prom_getpropstringA(node, "device_type", devtype, sizeof(devtype)); for (len = 0; intrmap[len].in_class != NULL; len++) if (strcmp(intrmap[len].in_class, devtype) == 0) { - interrupts |= INTLEVENCODE(intrmap[len].in_lev); - DPRINTF(SPDB_INTMAP, ("reset to %x\n", interrupts)); + int_used |= INTLEVENCODE(intrmap[len].in_lev); + DPRINTF(SPDB_INTMAP, ("reset to %x\n", int_used)); break; } - *ihp = interrupts; + *ihp = int_used; /* Call the sub-driver is necessary */ if (pa->pa_pc->spc_intr_map)