Module Name: src
Committed By: cherry
Date: Sun Jul 16 06:14:24 UTC 2017
Modified Files:
src/sys/arch/x86/isa: isa_machdep.c
src/sys/arch/xen/include: intr.h pci_machdep.h
src/sys/arch/xen/x86: intr.c
src/sys/arch/xen/xen: isa_machdep.c pci_intr_machdep.c pciback.c
pciide_machdep.c
Log Message:
Remove the xen specific interrupt type for the x86 intr_handle_t
For this to work, we use the evtchn.c:get_pirq_to_evtchn() glue
function to make things easier.
To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/x86/isa/isa_machdep.c
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/xen/include/intr.h
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/xen/include/pci_machdep.h
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/xen/x86/intr.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/xen/xen/isa_machdep.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/xen/xen/pci_intr_machdep.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/xen/xen/pciback.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/xen/xen/pciide_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/x86/isa/isa_machdep.c
diff -u src/sys/arch/x86/isa/isa_machdep.c:1.34 src/sys/arch/x86/isa/isa_machdep.c:1.35
--- src/sys/arch/x86/isa/isa_machdep.c:1.34 Sat Oct 15 16:46:14 2016
+++ src/sys/arch/x86/isa/isa_machdep.c Sun Jul 16 06:14:23 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: isa_machdep.c,v 1.34 2016/10/15 16:46:14 jdolecek Exp $ */
+/* $NetBSD: isa_machdep.c,v 1.35 2017/07/16 06:14:23 cherry Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.34 2016/10/15 16:46:14 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.35 2017/07/16 06:14:23 cherry Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -212,7 +212,7 @@ isa_intr_establish_xname(isa_chipset_tag
int pin;
#if NIOAPIC > 0
intr_handle_t mpih;
- struct ioapic_softc *ioapic;
+ struct ioapic_softc *ioapic = NULL;
#endif
pin = irq;
@@ -237,20 +237,48 @@ isa_intr_establish_xname(isa_chipset_tag
printf("isa_intr_establish: no MP mapping found\n");
}
#endif
+#if defined(XEN)
+ KASSERT(APIC_IRQ_ISLEGACY(irq));
+
+ int evtch;
+ char evname[16];
+
+ mpih |= APIC_IRQ_LEGACY_IRQ(irq);
+
+ evtch = xen_intr_map((int *)&mpih, type); /* XXX: legacy - xen just tosses irq back at us */
+ if (evtch == -1)
+ return NULL;
+#if NIOAPIC > 0
+ if (ioapic)
+ snprintf(evname, sizeof(evname), "%s pin %d",
+ device_xname(ioapic->sc_dev), pin);
+ else
+#endif
+ snprintf(evname, sizeof(evname), "irq%d", irq);
+
+ aprint_debug("irq: %d requested on pic: %s.\n", irq, pic->pic_name);
+
+ return (void *)pirq_establish(irq, evtch, ih_fun, ih_arg, level,
+ evname);
+#else /* defined(XEN) */
return intr_establish_xname(irq, pic, pin, type, level, ih_fun, ih_arg,
false, xname);
+#endif
+
}
/* Deregister an interrupt handler. */
void
isa_intr_disestablish(isa_chipset_tag_t ic, void *arg)
{
+#if !defined(XEN)
struct intrhand *ih = arg;
if (!LEGAL_IRQ(ih->ih_pin))
panic("intr_disestablish: bogus irq");
intr_disestablish(ih);
+#endif
}
void
Index: src/sys/arch/xen/include/intr.h
diff -u src/sys/arch/xen/include/intr.h:1.40 src/sys/arch/xen/include/intr.h:1.41
--- src/sys/arch/xen/include/intr.h:1.40 Tue May 23 08:54:39 2017
+++ src/sys/arch/xen/include/intr.h Sun Jul 16 06:14:24 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: intr.h,v 1.40 2017/05/23 08:54:39 nonaka Exp $ */
+/* $NetBSD: intr.h,v 1.41 2017/07/16 06:14:24 cherry Exp $ */
/* NetBSD intr.h,v 1.15 2004/10/31 10:39:34 yamt Exp */
/*-
@@ -175,7 +175,7 @@ int xen_intr_map(int *, int);
#ifdef INTRDEBUG
void intr_printconfig(void);
#endif
-int intr_find_mpmapping(int, int, struct xen_intr_handle *);
+int intr_find_mpmapping(int, int, intr_handle_t *);
struct pic *intr_findpic(int);
void intr_add_pcibus(struct pcibus_attach_args *);
Index: src/sys/arch/xen/include/pci_machdep.h
diff -u src/sys/arch/xen/include/pci_machdep.h:1.18 src/sys/arch/xen/include/pci_machdep.h:1.19
--- src/sys/arch/xen/include/pci_machdep.h:1.18 Mon Apr 4 20:37:55 2011
+++ src/sys/arch/xen/include/pci_machdep.h Sun Jul 16 06:14:24 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.h,v 1.18 2011/04/04 20:37:55 dyoung Exp $ */
+/* $NetBSD: pci_machdep.h,v 1.19 2017/07/16 06:14:24 cherry Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -60,7 +60,7 @@
/*
* Types provided to machine-independent PCI code
*/
-typedef struct xen_intr_handle pci_intr_handle_t;
+typedef intr_handle_t pci_intr_handle_t;
#include <x86/pci_machdep_common.h>
Index: src/sys/arch/xen/x86/intr.c
diff -u src/sys/arch/xen/x86/intr.c:1.31 src/sys/arch/xen/x86/intr.c:1.32
--- src/sys/arch/xen/x86/intr.c:1.31 Tue May 23 08:54:39 2017
+++ src/sys/arch/xen/x86/intr.c Sun Jul 16 06:14:24 2017
@@ -103,7 +103,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.31 2017/05/23 08:54:39 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.32 2017/07/16 06:14:24 cherry Exp $");
#include "opt_multiprocessor.h"
#include "opt_xen.h"
@@ -125,6 +125,7 @@ __KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.3
#include <machine/i8259.h>
#include <machine/pio.h>
#include <xen/evtchn.h>
+#include <xen/intr.h>
#include "acpica.h"
#include "ioapic.h"
@@ -319,7 +320,9 @@ struct intr_extra_bus {
LIST_HEAD(, intr_extra_bus) intr_extra_buses =
LIST_HEAD_INITIALIZER(intr_extra_buses);
-static int intr_scan_bus(int, int, struct xen_intr_handle *);
+#if NPCI > 0
+static int intr_scan_bus(int, int, intr_handle_t *);
+#endif
void
intr_add_pcibus(struct pcibus_attach_args *pba)
@@ -364,8 +367,9 @@ intr_find_pcibridge(int bus, pcitag_t *p
return ENOENT;
}
+/* XXX: Unify with x86/intr.c */
int
-intr_find_mpmapping(int bus, int pin, struct xen_intr_handle *handle)
+intr_find_mpmapping(int bus, int pin, intr_handle_t *handle)
{
#if NPCI > 0
int dev, func;
@@ -391,8 +395,9 @@ intr_find_mpmapping(int bus, int pin, st
#endif
}
+#if NPCI > 0
static int
-intr_scan_bus(int bus, int pin, struct xen_intr_handle *handle)
+intr_scan_bus(int bus, int pin, intr_handle_t *handle)
{
struct mp_intr_map *mip, *intrs;
@@ -410,12 +415,13 @@ intr_scan_bus(int bus, int pin, struct x
if (mpacpi_findintr_linkdev(mip) != 0)
continue;
#endif
- handle->pirq = mip->ioapic_ih;
+ *handle = mip->ioapic_ih;
return 0;
}
}
return ENOENT;
}
+#endif /* NPCI > 0 */
#endif /* NIOAPIC > 0 || NACPICA > 0 */
#endif /* NPCI > 0 || NISA > 0 */
Index: src/sys/arch/xen/xen/isa_machdep.c
diff -u src/sys/arch/xen/xen/isa_machdep.c:1.26 src/sys/arch/xen/xen/isa_machdep.c:1.27
--- src/sys/arch/xen/xen/isa_machdep.c:1.26 Thu Sep 1 15:10:31 2011
+++ src/sys/arch/xen/xen/isa_machdep.c Sun Jul 16 06:14:24 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: isa_machdep.c,v 1.26 2011/09/01 15:10:31 christos Exp $ */
+/* $NetBSD: isa_machdep.c,v 1.27 2017/07/16 06:14:24 cherry Exp $ */
/* NetBSD isa_machdep.c,v 1.11 2004/06/20 18:04:08 thorpej Exp */
/*-
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.26 2011/09/01 15:10:31 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.27 2017/07/16 06:14:24 cherry Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -131,23 +131,23 @@ isa_intr_establish(isa_chipset_tag_t ic,
{
int evtch;
char evname[16];
- struct xen_intr_handle ih;
+ intr_handle_t ih;
#if NIOAPIC > 0
struct ioapic_softc *pic = NULL;
#endif
- ih.pirq = 0;
+ ih = 0;
#if NIOAPIC > 0
if (mp_busses != NULL) {
if (intr_find_mpmapping(mp_isa_bus, irq, &ih) == 0 ||
intr_find_mpmapping(mp_eisa_bus, irq, &ih) == 0) {
- if (!APIC_IRQ_ISLEGACY(ih.pirq)) {
- pic = ioapic_find(APIC_IRQ_APIC(ih.pirq));
+ if (!APIC_IRQ_ISLEGACY(ih)) {
+ pic = ioapic_find(APIC_IRQ_APIC(ih));
if (pic == NULL) {
printf("isa_intr_establish: "
"unknown apic %d\n",
- APIC_IRQ_APIC(ih.pirq));
+ APIC_IRQ_APIC(ih));
return NULL;
}
}
@@ -155,15 +155,15 @@ isa_intr_establish(isa_chipset_tag_t ic,
printf("isa_intr_establish: no MP mapping found\n");
}
#endif
- ih.pirq |= (irq & 0xff);
+ ih |= (irq & 0xff);
- evtch = xen_intr_map(&ih.pirq, type);
+ evtch = xen_intr_map((int *)&ih, type);
if (evtch == -1)
return NULL;
#if NIOAPIC > 0
if (pic)
snprintf(evname, sizeof(evname), "%s pin %d",
- device_xname(pic->sc_dev), APIC_IRQ_PIN(ih.pirq));
+ device_xname(pic->sc_dev), APIC_IRQ_PIN(ih));
else
#endif
snprintf(evname, sizeof(evname), "irq%d", irq);
Index: src/sys/arch/xen/xen/pci_intr_machdep.c
diff -u src/sys/arch/xen/xen/pci_intr_machdep.c:1.17 src/sys/arch/xen/xen/pci_intr_machdep.c:1.18
--- src/sys/arch/xen/xen/pci_intr_machdep.c:1.17 Sat Mar 14 10:49:36 2015
+++ src/sys/arch/xen/xen/pci_intr_machdep.c Sun Jul 16 06:14:24 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_intr_machdep.c,v 1.17 2015/03/14 10:49:36 bouyer Exp $ */
+/* $NetBSD: pci_intr_machdep.c,v 1.18 2017/07/16 06:14:24 cherry Exp $ */
/*
* Copyright (c) 2005 Manuel Bouyer.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.17 2015/03/14 10:49:36 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.18 2017/07/16 06:14:24 cherry Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -66,6 +66,7 @@ pci_intr_map(const struct pci_attach_arg
{
int pin;
int line;
+ int evtch;
#if NIOAPIC > 0
int rawpin = pa->pa_rawintrpin;
@@ -85,17 +86,17 @@ pci_intr_map(const struct pci_attach_arg
printf("pci_intr_map: bad interrupt pin %d\n", pin);
goto bad;
}
- ihp->pirq = 0;
+ *ihp = 0;
#if NIOAPIC > 0
pci_decompose_tag(pc, pa->pa_tag, &bus, &dev, &func);
if (mp_busses != NULL) {
if (intr_find_mpmapping(bus, (dev<<2)|(rawpin-1), ihp) == 0) {
- if (ihp->pirq & APIC_INT_VIA_APIC) {
+ if (*ihp & APIC_INT_VIA_APIC) {
/* make sure a new IRQ will be allocated */
- ihp->pirq &= ~0xff;
+ *ihp &= ~0xff;
} else {
- ihp->pirq |= line;
+ *ihp |= line;
}
goto end;
}
@@ -124,8 +125,8 @@ pci_intr_map(const struct pci_attach_arg
#if NIOAPIC > 0
if (mp_busses != NULL) {
if (intr_find_mpmapping(mp_isa_bus, line, ihp) == 0) {
- if ((ihp->pirq & 0xff) == 0)
- ihp->pirq |= line;
+ if ((*ihp & 0xff) == 0)
+ *ihp |= line;
goto end;
}
printf("pci_intr_map: bus %d dev %d func %d pin %d; line %d\n",
@@ -134,20 +135,19 @@ pci_intr_map(const struct pci_attach_arg
}
#endif /* NIOAPIC */
- ihp->pirq = line;
+ *ihp = line;
#if NIOAPIC > 0
end:
#endif
- ihp->evtch = xen_intr_map(&ihp->pirq, IST_LEVEL);
- if (ihp->evtch == -1)
+ evtch = xen_intr_map((int *)ihp, IST_LEVEL);
+ if (evtch == -1)
goto bad;
return 0;
bad:
- ihp->pirq = -1;
- ihp->evtch = -1;
+ *ihp = -1;
return 1;
}
@@ -155,23 +155,26 @@ const char *
pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih, char *buf,
size_t len)
{
+ int evtch;
+
+ evtch = get_pirq_to_evtch(APIC_IRQ_LEGACY_IRQ(ih));
#if NIOAPIC > 0
struct ioapic_softc *pic;
- if (ih.pirq & APIC_INT_VIA_APIC) {
- pic = ioapic_find(APIC_IRQ_APIC(ih.pirq));
+ if (ih & APIC_INT_VIA_APIC) {
+ pic = ioapic_find(APIC_IRQ_APIC(ih));
if (pic == NULL) {
printf("%s: bad ioapic %d\n", __func__,
- APIC_IRQ_APIC(ih.pirq));
+ APIC_IRQ_APIC(ih));
return NULL;
}
snprintf(buf, len, "%s pin %d, event channel %d",
- device_xname(pic->sc_dev), APIC_IRQ_PIN(ih.pirq),
- ih.evtch);
+ device_xname(pic->sc_dev), APIC_IRQ_PIN(ih),
+ evtch);
return buf;
}
#endif
snprintf(buf, len, "irq %d, event channel %d",
- ih.pirq, ih.evtch);
+ ih, evtch);
return buf;
}
@@ -201,21 +204,21 @@ pci_intr_establish(pci_chipset_tag_t pci
char evname[16];
#if NIOAPIC > 0
struct ioapic_softc *pic;
- if (intrh.pirq & APIC_INT_VIA_APIC) {
- pic = ioapic_find(APIC_IRQ_APIC(intrh.pirq));
+ if (intrh & APIC_INT_VIA_APIC) {
+ pic = ioapic_find(APIC_IRQ_APIC(intrh));
if (pic == NULL) {
printf("pci_intr_establish: bad ioapic %d\n",
- APIC_IRQ_APIC(intrh.pirq));
+ APIC_IRQ_APIC(intrh));
return NULL;
}
snprintf(evname, sizeof(evname), "%s pin %d",
- device_xname(pic->sc_dev), APIC_IRQ_PIN(intrh.pirq));
+ device_xname(pic->sc_dev), APIC_IRQ_PIN(intrh));
} else
#endif
- snprintf(evname, sizeof(evname), "irq%d", intrh.pirq);
+ snprintf(evname, sizeof(evname), "irq%d", intrh);
- return (void *)pirq_establish(intrh.pirq & 0xff,
- intrh.evtch, func, arg, level, evname);
+ return (void *)pirq_establish(APIC_IRQ_LEGACY_IRQ(intrh),
+ get_pirq_to_evtch(APIC_IRQ_LEGACY_IRQ(intrh)), func, arg, level, evname);
}
void
Index: src/sys/arch/xen/xen/pciback.c
diff -u src/sys/arch/xen/xen/pciback.c:1.11 src/sys/arch/xen/xen/pciback.c:1.12
--- src/sys/arch/xen/xen/pciback.c:1.11 Thu Jul 7 06:55:40 2016
+++ src/sys/arch/xen/xen/pciback.c Sun Jul 16 06:14:24 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: pciback.c,v 1.11 2016/07/07 06:55:40 msaitoh Exp $ */
+/* $NetBSD: pciback.c,v 1.12 2017/07/16 06:14:24 cherry Exp $ */
/*
* Copyright (c) 2009 Manuel Bouyer.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pciback.c,v 1.11 2016/07/07 06:55:40 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pciback.c,v 1.12 2017/07/16 06:14:24 cherry Exp $");
#include "opt_xen.h"
@@ -269,8 +269,8 @@ pciback_pci_attach(device_t parent, devi
buf, sizeof(buf));
aprint_normal_dev(self, "interrupting at %s\n", intrstr);
}
- unbind_pirq_from_evtch(APIC_IRQ_LEGACY_IRQ(sc->sc_intrhandle.pirq));
- sc->sc_irq = APIC_IRQ_LEGACY_IRQ(sc->sc_intrhandle.pirq);
+ unbind_pirq_from_evtch(APIC_IRQ_LEGACY_IRQ(sc->sc_intrhandle));
+ sc->sc_irq = APIC_IRQ_LEGACY_IRQ(sc->sc_intrhandle);
/* XXX should be done elsewhere ? */
reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_INTERRUPT_REG);
reg &= ~ (PCI_INTERRUPT_LINE_MASK << PCI_INTERRUPT_LINE_SHIFT);
Index: src/sys/arch/xen/xen/pciide_machdep.c
diff -u src/sys/arch/xen/xen/pciide_machdep.c:1.18 src/sys/arch/xen/xen/pciide_machdep.c:1.19
--- src/sys/arch/xen/xen/pciide_machdep.c:1.18 Mon Apr 4 20:37:55 2011
+++ src/sys/arch/xen/xen/pciide_machdep.c Sun Jul 16 06:14:24 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: pciide_machdep.c,v 1.18 2011/04/04 20:37:55 dyoung Exp $ */
+/* $NetBSD: pciide_machdep.c,v 1.19 2017/07/16 06:14:24 cherry Exp $ */
/*
* Copyright (c) 1998 Christopher G. Demetriou. All rights reserved.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pciide_machdep.c,v 1.18 2011/04/04 20:37:55 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pciide_machdep.c,v 1.19 2017/07/16 06:14:24 cherry Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -68,25 +68,25 @@ pciide_machdep_compat_intr_establish(dev
{
struct pintrhand *ih;
char evname[16];
- struct xen_intr_handle xenih;
+ intr_handle_t xenih;
#if NIOAPIC > 0
struct ioapic_softc *pic = NULL;
#endif
int evtch;
- xenih.pirq = PCIIDE_COMPAT_IRQ(chan);
- xenih.pirq = 0;
+ xenih = PCIIDE_COMPAT_IRQ(chan);
+ xenih = 0;
#if NIOAPIC > 0
if (mp_busses != NULL) {
int irq = PCIIDE_COMPAT_IRQ(chan);
if (intr_find_mpmapping(mp_isa_bus, irq, &xenih) == 0 ||
intr_find_mpmapping(mp_eisa_bus, irq, &xenih) == 0) {
- if (!APIC_IRQ_ISLEGACY(xenih.pirq)) {
- pic = ioapic_find(APIC_IRQ_APIC(xenih.pirq));
+ if (!APIC_IRQ_ISLEGACY(xenih)) {
+ pic = ioapic_find(APIC_IRQ_APIC(xenih));
if (pic == NULL) {
printf("pciide_machdep_compat_intr_establish: "
"unknown apic %d\n",
- APIC_IRQ_APIC(xenih.pirq));
+ APIC_IRQ_APIC(xenih));
return NULL;
}
}
@@ -95,14 +95,14 @@ pciide_machdep_compat_intr_establish(dev
"no MP mapping found\n");
}
#endif
- xenih.pirq |= PCIIDE_COMPAT_IRQ(chan);
- evtch = xen_intr_map(&xenih.pirq, IST_EDGE);
+ xenih |= PCIIDE_COMPAT_IRQ(chan);
+ evtch = xen_intr_map((int *)&xenih, IST_EDGE);
if (evtch == -1)
return NULL;
#if NIOAPIC > 0
if (pic)
snprintf(evname, sizeof(evname), "%s pin %d",
- device_xname(pic->sc_dev), APIC_IRQ_PIN(xenih.pirq));
+ device_xname(pic->sc_dev), APIC_IRQ_PIN(xenih));
else
#endif
snprintf(evname, sizeof(evname), "irq%d",
@@ -118,7 +118,7 @@ pciide_machdep_compat_intr_establish(dev
#if NIOAPIC > 0
if (pic)
printf("%s pin %d", device_xname(pic->sc_dev),
- APIC_IRQ_PIN(xenih.pirq));
+ APIC_IRQ_PIN(xenih));
else
#endif
printf("irq %d", ih->pirq);