Module Name:    src
Committed By:   cherry
Date:           Sat Nov  4 14:56:48 UTC 2017

Modified Files:
        src/sys/arch/x86/include: intr.h
        src/sys/arch/x86/isa: isa_machdep.c
        src/sys/arch/x86/x86: intr.c ioapic.c
        src/sys/arch/xen/conf: files.xen
        src/sys/arch/xen/include: evtchn.h intr.h
        src/sys/arch/xen/xen: pci_intr_machdep.c pciide_machdep.c
Removed Files:
        src/sys/arch/xen/x86: intr.c

Log Message:
Retire xen/x86/intr.c and use the new xen specific glue in x86/x86/intr.c

The purpose of this change is to expose the x86/include/intr.h API
to drivers. Specifically the following functions:

   void *intr_establish_xname(...);
   void *intr_establish(...);
   void intr_disestablish(...);

while maintaining the old API from xen/include/evtchn.h, specifically
the following functions:

    int event_set_handler(...);
    int event_remove_handler(...);

This is so that if things break, we can keep using the old API until
everything stabilises. This is a stepping stone towards getting the
actual XEN event callback path rework code in place - which can be
done opaquely behind the intr.h API - NetBSD/XEN specific drivers that
have been ported to the intr.h API should then work without
significant further modifications.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/x86/include/intr.h
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/x86/isa/isa_machdep.c
cvs rdiff -u -r1.105 -r1.106 src/sys/arch/x86/x86/intr.c
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/x86/x86/ioapic.c
cvs rdiff -u -r1.160 -r1.161 src/sys/arch/xen/conf/files.xen
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/xen/include/evtchn.h
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/xen/include/intr.h
cvs rdiff -u -r1.33 -r0 src/sys/arch/xen/x86/intr.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/xen/xen/pci_intr_machdep.c
cvs rdiff -u -r1.19 -r1.20 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/include/intr.h
diff -u src/sys/arch/x86/include/intr.h:1.51 src/sys/arch/x86/include/intr.h:1.52
--- src/sys/arch/x86/include/intr.h:1.51	Sun Jul 16 14:02:48 2017
+++ src/sys/arch/x86/include/intr.h	Sat Nov  4 14:56:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.h,v 1.51 2017/07/16 14:02:48 cherry Exp $	*/
+/*	$NetBSD: intr.h,v 1.52 2017/11/04 14:56:48 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -117,6 +117,18 @@ struct intrsource {
  */
 
 struct intrhand {
+#if defined(XEN)
+	/*
+	 * Note: This is transitional and will go away.
+	 *
+	 * We ought to use a union here, but too much effort.
+	 * We use this field to tear down the cookie handed to us
+	 * via x86/intr.c:intr_disestablish();
+	 * Interestingly, the intr_establish_xname() function returns
+	 * a "void *" - so we abuse this for now.
+	 */
+	int	pic_type; /* Overloading wrt struct pintrhand */
+#endif
 	int	(*ih_fun)(void *);
 	void	*ih_arg;
 	int	ih_level;
@@ -124,10 +136,9 @@ struct intrhand {
 	void	*ih_realarg;
 	struct	intrhand *ih_next;
 	struct	intrhand **ih_prevp;
-#if !defined(XEN)
 	int	ih_pin;
 	int	ih_slot;
-#else
+#if defined(XEN)
 	struct	intrhand *ih_evt_next;
 #endif
 	struct cpu_info *ih_cpu;

Index: src/sys/arch/x86/isa/isa_machdep.c
diff -u src/sys/arch/x86/isa/isa_machdep.c:1.36 src/sys/arch/x86/isa/isa_machdep.c:1.37
--- src/sys/arch/x86/isa/isa_machdep.c:1.36	Fri Jul 21 12:27:48 2017
+++ src/sys/arch/x86/isa/isa_machdep.c	Sat Nov  4 14:56:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: isa_machdep.c,v 1.36 2017/07/21 12:27:48 cherry Exp $	*/
+/*	$NetBSD: isa_machdep.c,v 1.37 2017/11/04 14:56:48 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.36 2017/07/21 12:27:48 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.37 2017/11/04 14:56:48 cherry Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -245,7 +245,7 @@ isa_intr_establish_xname(isa_chipset_tag
 
 	mpih |= APIC_IRQ_LEGACY_IRQ(irq);
 
-	evtch = xen_intr_map((int *)&mpih, type); /* XXX: legacy - xen just tosses irq back at us */
+	evtch = xen_pirq_alloc((intr_handle_t *)&mpih, type); /* XXX: legacy - xen just tosses irq back at us */
 	if (evtch == -1)
 		return NULL;
 #if NIOAPIC > 0

Index: src/sys/arch/x86/x86/intr.c
diff -u src/sys/arch/x86/x86/intr.c:1.105 src/sys/arch/x86/x86/intr.c:1.106
--- src/sys/arch/x86/x86/intr.c:1.105	Fri Oct 27 12:25:14 2017
+++ src/sys/arch/x86/x86/intr.c	Sat Nov  4 14:56:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.105 2017/10/27 12:25:14 joerg Exp $	*/
+/*	$NetBSD: intr.c,v 1.106 2017/11/04 14:56:48 cherry Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.105 2017/10/27 12:25:14 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.106 2017/11/04 14:56:48 cherry Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -188,6 +188,13 @@ __KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.1
 #define msipic_is_msi_pic(PIC)	(false)
 #endif
 
+#if defined(XEN) /* XXX: Cleanup */
+#include <xen/xen.h>
+#include <xen/hypervisor.h>
+#include <xen/evtchn.h>
+#include <xen/xenfunc.h>
+#endif /* XEN */
+
 #ifdef DDB
 #include <ddb/db_output.h>
 #endif
@@ -220,6 +227,7 @@ static int intr_find_pcibridge(int, pcit
 #endif
 #endif
 
+#if !defined(XEN)
 static int intr_allocate_slot_cpu(struct cpu_info *, struct pic *, int, int *,
 				  struct intrsource *);
 static int __noinline intr_allocate_slot(struct pic *, int, int,
@@ -232,6 +240,10 @@ static void intr_establish_xcall(void *,
 static void intr_disestablish_xcall(void *, void *);
 
 static const char *legacy_intr_string(int, char *, size_t, struct pic *);
+#if defined(XEN) /* XXX: nuke conditional after integration */
+static const char *xen_intr_string(int, char *, size_t, struct pic *);
+#endif /* XXX: XEN */
+#endif
 
 static inline bool redzone_const_or_false(bool);
 static inline int redzone_const_or_zero(int);
@@ -241,10 +253,12 @@ static void intr_redistribute_xc_s1(void
 static void intr_redistribute_xc_s2(void *, void *);
 static bool intr_redistribute(struct cpu_info *);
 
+#if !defined(XEN)
 static const char *create_intrid(int, struct pic *, int, char *, size_t);
-
+#endif /* XEN */
 static struct intrsource *intr_get_io_intrsource(const char *);
 static void intr_free_io_intrsource_direct(struct intrsource *);
+#if !defined(XEN)
 static int intr_num_handlers(struct intrsource *);
 
 static int intr_find_unused_slot(struct cpu_info *, int *);
@@ -252,6 +266,7 @@ static void intr_activate_xcall(void *, 
 static void intr_deactivate_xcall(void *, void *);
 static void intr_get_affinity(struct intrsource *, kcpuset_t *);
 static int intr_set_affinity(struct intrsource *, const kcpuset_t *);
+#endif /* XEN */
 
 /*
  * Fill in default interrupt table (in case of spurious interrupt
@@ -260,6 +275,7 @@ static int intr_set_affinity(struct intr
 void
 intr_default_setup(void)
 {
+#if !defined(XEN)
 	int i;
 
 	/* icu vectors */
@@ -273,6 +289,9 @@ intr_default_setup(void)
 	 */
 	i8259_default_setup();
 
+#else
+	events_default_setup();
+#endif /* !XEN */
 	mutex_init(&intr_distribute_lock, MUTEX_DEFAULT, IPL_NONE);
 }
 
@@ -471,6 +490,7 @@ intr_scan_bus(int bus, int pin, intr_han
 }
 #endif
 
+#if !defined(XEN)
 /*
  * Create an interrupt id such as "ioapic0 pin 9". This interrupt id is used
  * by MI code and intrctl(8).
@@ -478,7 +498,7 @@ intr_scan_bus(int bus, int pin, intr_han
 static const char *
 create_intrid(int legacy_irq, struct pic *pic, int pin, char *buf, size_t len)
 {
-	int ih;
+	int ih = 0;
 
 #if NPCI > 0
 	if ((pic->pic_type == PIC_MSI) || (pic->pic_type == PIC_MSIX)) {
@@ -499,6 +519,15 @@ create_intrid(int legacy_irq, struct pic
 	}
 #endif
 
+#if defined(XEN)
+	evtchn_port_t port = pin; /* Port number */
+
+	if (pic->pic_type == PIC_XEN) {
+		ih = pin;
+		return xen_intr_string(port, buf, len, pic);
+	}
+#endif
+
 	/*
 	 * If the device is pci, "legacy_irq" is alway -1. Least 8 bit of "ih"
 	 * is only used in intr_string() to show the irq number.
@@ -510,6 +539,7 @@ create_intrid(int legacy_irq, struct pic
 		return legacy_intr_string(ih, buf, len, pic);
 	}
 
+#if NIOAPIC > 0 || NACPICA > 0
 	ih = ((pic->pic_apicid << APIC_INT_APIC_SHIFT) & APIC_INT_APIC_MASK)
 	    | ((pin << APIC_INT_PIN_SHIFT) & APIC_INT_PIN_MASK);
 	if (pic->pic_type == PIC_IOAPIC) {
@@ -517,8 +547,13 @@ create_intrid(int legacy_irq, struct pic
 	}
 	ih |= pin;
 	return intr_string(ih, buf, len);
+#endif
+
+	return NULL; /* No pic found! */
 }
 
+#endif /* XEN */
+
 /*
  * Find intrsource from io_interrupt_sources list.
  */
@@ -613,6 +648,7 @@ intr_free_io_intrsource(const char *intr
 	intr_free_io_intrsource_direct(isp);
 }
 
+#if !defined(XEN)
 static int
 intr_allocate_slot_cpu(struct cpu_info *ci, struct pic *pic, int pin,
 		       int *index, struct intrsource *chained)
@@ -815,7 +851,9 @@ intr_biglock_wrapper(void *vp)
 	return ret;
 }
 #endif /* MULTIPROCESSOR */
+#endif /* XEN */
 
+#if defined(DOM0OPS) || !defined(XEN)
 struct pic *
 intr_findpic(int num)
 {
@@ -831,7 +869,8 @@ intr_findpic(int num)
 
 	return NULL;
 }
-
+#endif
+#if !defined(XEN)
 /*
  * Append device name to intrsource. If device A and device B share IRQ number,
  * the device name of the interrupt id is "device A, device B".
@@ -1168,12 +1207,96 @@ intr_num_handlers(struct intrsource *isp
 	return num;
 }
 
+#else /* XEN */
+void *
+intr_establish_xname(int legacy_irq, struct pic *pic, int pin,
+    int type, int level, int (*handler)(void *) , void *arg,
+    bool known_mpsafe, const char *xname)
+{
+	/* XXX xname registration not supported */
+	return intr_establish(legacy_irq, pic, pin, type, level, handler, arg,
+	    known_mpsafe);
+}
+
+void *
+intr_establish(int legacy_irq, struct pic *pic, int pin,
+    int type, int level, int (*handler)(void *) , void *arg,
+    bool known_mpsafe)
+{
+	if (pic->pic_type == PIC_XEN) {
+		struct intrhand *rih;
+		event_set_handler(pin, handler,
+		    arg, IPL_CLOCK, "clock");
+
+		rih = kmem_zalloc(sizeof(struct intrhand),
+	    cold ? KM_NOSLEEP : KM_SLEEP);
+		if (rih == NULL) {
+			printf("%s: can't allocate handler info\n", __func__);
+			return NULL;
+		}
+
+		/*
+		 * XXX:
+		 * This is just a copy for API conformance.
+		 * The real ih is lost in the innards of
+		 * event_set_handler(); where the details of
+		 * biglock_wrapper etc are taken care of.
+		 * All that goes away when we nuke event_set_handler()
+		 * et. al. and unify with x86/intr.c
+		 */
+		
+		rih->ih_pin = pin; /* port */
+		rih->ih_fun = handler;
+		rih->ih_arg = arg;
+		rih->pic_type = pic->pic_type;
+		return rih;
+	} 	/* Else we assume pintr */
+
+#if NPCI > 0 || NISA > 0
+	struct pintrhand *pih;
+	int evtchn;
+	char evname[16];
+
+#ifdef DIAGNOSTIC
+	if (legacy_irq != -1 && (legacy_irq < 0 || legacy_irq > 15))
+		panic("intr_establish: bad legacy IRQ value");
+	if (legacy_irq == -1 && pic == &i8259_pic)
+		panic("intr_establish: non-legacy IRQ on i8259");
+#endif /* DIAGNOSTIC */
+	if (legacy_irq == -1) {
+#if NIOAPIC > 0
+		/* will do interrupts via I/O APIC */
+		legacy_irq = APIC_INT_VIA_APIC;
+		legacy_irq |= pic->pic_apicid << APIC_INT_APIC_SHIFT;
+		legacy_irq |= pin << APIC_INT_PIN_SHIFT;
+		snprintf(evname, sizeof(evname), "%s pin %d",
+		    pic->pic_name, pin);
+#else /* NIOAPIC */
+		return NULL;
+#endif /* NIOAPIC */
+	} else
+		snprintf(evname, sizeof(evname), "irq%d", legacy_irq);
+
+	evtchn = xen_pirq_alloc((intr_handle_t *)&legacy_irq, type);
+	pih = pirq_establish(legacy_irq & 0xff, evtchn, handler, arg, level,
+	    evname);
+	pih->pic_type = pic->pic_type;
+	return pih;
+#endif /* NPCI > 0 || NISA > 0 */
+
+	/* FALLTHROUGH */
+	return NULL;
+}
+
+#endif /* XEN */
+
 /*
  * Deregister an interrupt handler.
  */
 void
 intr_disestablish(struct intrhand *ih)
 {
+#if !defined(XEN)
 	struct cpu_info *ci;
 	struct intrsource *isp;
 	uint64_t where;
@@ -1199,7 +1322,33 @@ intr_disestablish(struct intrhand *ih)
 	}
 	mutex_exit(&cpu_lock);
 	kmem_free(ih, sizeof(*ih));
+#else /* XEN */
+	if (ih->pic_type == PIC_XEN) {
+		event_remove_handler(ih->ih_pin, ih->ih_realfun, ih->ih_realarg);
+		return;
+	}
+#if defined(DOM0OPS)
+	pirq_disestablish((struct pintrhand *)ih);
+#endif
+	return;
+#endif /* XEN */
+}
+
+#if !defined(XEN)
+#if defined(XEN) /* nuke conditional post integration */
+static const char *
+xen_intr_string(int port, char *buf, size_t len, struct pic *pic)
+{
+	KASSERT(pic->pic_type == PIC_XEN);
+
+	KASSERT(port >= 0);
+	KASSERT(port < NR_EVENT_CHANNELS);
+
+	snprintf(buf, len, "%s channel %d", pic->pic_name, port);
+
+	return buf;
 }
+#endif /* XXX: XEN */
 
 static const char *
 legacy_intr_string(int ih, char *buf, size_t len, struct pic *pic)
@@ -1207,15 +1356,20 @@ legacy_intr_string(int ih, char *buf, si
 	int legacy_irq;
 
 	KASSERT(pic->pic_type == PIC_I8259);
+#if NLAPIC > 0
 	KASSERT(APIC_IRQ_ISLEGACY(ih));
 
 	legacy_irq = APIC_IRQ_LEGACY_IRQ(ih);
+#else
+	legacy_irq = ih;
+#endif
 	KASSERT(legacy_irq >= 0 && legacy_irq < 16);
 
 	snprintf(buf, len, "%s pin %d", pic->pic_name, legacy_irq);
 
 	return buf;
 }
+#endif
 
 const char *
 intr_string(intr_handle_t ih, char *buf, size_t len)
@@ -1242,9 +1396,11 @@ intr_string(intr_handle_t ih, char *buf,
 		}
 	} else
 		snprintf(buf, len, "irq %d", APIC_IRQ_LEGACY_IRQ(ih));
-#else
 
+#elif NLAPIC > 0
 	snprintf(buf, len, "irq %d" APIC_IRQ_LEGACY_IRQ(ih));
+#else
+	snprintf(buf, len, "irq %d", (int) ih);
 #endif
 	return buf;
 
@@ -1289,6 +1445,7 @@ redzone_const_or_zero(int x)
 void
 cpu_intr_init(struct cpu_info *ci)
 {
+#if !defined(XEN)
 	struct intrsource *isp;
 #if NLAPIC > 0 && defined(MULTIPROCESSOR)
 	int i;
@@ -1326,6 +1483,7 @@ cpu_intr_init(struct cpu_info *ci)
 #endif
 #endif
 
+#if defined(__HAVE_PREEMPTION)
 	isp = kmem_zalloc(sizeof(*isp), KM_SLEEP);
 	isp->is_recurse = Xpreemptrecurse;
 	isp->is_resume = Xpreemptresume;
@@ -1334,8 +1492,17 @@ cpu_intr_init(struct cpu_info *ci)
 	isp->is_pic = &softintr_pic;
 	ci->ci_isources[SIR_PREEMPT] = isp;
 
+#endif
 	intr_calculatemasks(ci);
 
+#else /* XEN */
+	int i; /* XXX: duplicate */
+	vaddr_t istack; /* XXX: duplicate */
+		ci->ci_iunmask[0] = 0xfffffffe;
+	for (i = 1; i < NIPL; i++)
+		ci->ci_iunmask[i] = ci->ci_iunmask[i - 1] & ~(1 << i);
+#endif /* XEN */
+
 #if defined(INTRSTACKSIZE)
 	/*
 	 * If the red zone is activated, protect both the top and
@@ -1413,6 +1580,7 @@ intr_printconfig(void)
 
 #endif
 
+#if defined(__HAVE_FAST_SOFTINTS)
 void
 softint_init_md(lwp_t *l, u_int level, uintptr_t *machdep)
 {
@@ -1460,7 +1628,7 @@ softint_init_md(lwp_t *l, u_int level, u
 
 	intr_calculatemasks(ci);
 }
-
+#endif /* __HAVE_FAST_SOFTINTS */
 /*
  * Save current affinitied cpu's interrupt count.
  */
@@ -1690,6 +1858,9 @@ cpu_intr_redistribute(void)
 	KASSERT(mutex_owned(&cpu_lock));
 	KASSERT(mp_online);
 
+#if defined(XEN) /* XXX: remove */
+	return;
+#endif
 	/* Direct interrupts away from shielded CPUs. */
 	for (CPU_INFO_FOREACH(cii, ci)) {
 		if ((ci->ci_schedstate.spc_flags & SPCF_NOINTR) == 0) {
@@ -1712,6 +1883,7 @@ cpu_intr_count(struct cpu_info *ci)
 	return ci->ci_nintrhand;
 }
 
+#if !defined(XEN)
 static int
 intr_find_unused_slot(struct cpu_info *ci, int *index)
 {
@@ -1942,7 +2114,7 @@ intr_set_affinity(struct intrsource *isp
 
 	return err;
 }
-
+#endif /* XEN */
 static bool
 intr_is_affinity_intrsource(struct intrsource *isp, const kcpuset_t *cpuset)
 {
@@ -1970,6 +2142,7 @@ intr_get_handler(const char *intrid)
 	return isp->is_handlers;
 }
 
+#if !defined(XEN)
 /*
  * MI interface for subr_interrupt.c
  */
@@ -2015,6 +2188,8 @@ interrupt_get_count(const char *intrid, 
 	return count;
 }
 
+#endif /* XEN */
+
 /*
  * MI interface for subr_interrupt.c
  */
@@ -2039,6 +2214,8 @@ interrupt_get_assigned(const char *intri
 	mutex_exit(&cpu_lock);
 }
 
+#if !defined(XEN)
+
 /*
  * MI interface for subr_interrupt.c
  */
@@ -2150,6 +2327,7 @@ interrupt_distribute_handler(const char 
 	mutex_exit(&intr_distribute_lock);
 	return error;
 }
+#endif
 
 /*
  * MI interface for subr_interrupt.c

Index: src/sys/arch/x86/x86/ioapic.c
diff -u src/sys/arch/x86/x86/ioapic.c:1.52 src/sys/arch/x86/x86/ioapic.c:1.53
--- src/sys/arch/x86/x86/ioapic.c:1.52	Mon Jul 27 15:45:20 2015
+++ src/sys/arch/x86/x86/ioapic.c	Sat Nov  4 14:56:48 2017
@@ -1,4 +1,4 @@
-/* 	$NetBSD: ioapic.c,v 1.52 2015/07/27 15:45:20 msaitoh Exp $	*/
+/* 	$NetBSD: ioapic.c,v 1.53 2017/11/04 14:56:48 cherry Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2009 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ioapic.c,v 1.52 2015/07/27 15:45:20 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ioapic.c,v 1.53 2017/11/04 14:56:48 cherry Exp $");
 
 #include "opt_ddb.h"
 
@@ -565,6 +565,25 @@ ioapic_addroute(struct pic *pic, struct 
 	pp->ip_vector = idtvec;
 	pp->ip_cpu = ci;
 	apic_set_redir(sc, pin, idtvec, ci);
+
+#if defined(XEN)
+	/*
+	 * This is kludgy, and not the right place, but we can't bind
+	 * before the routing has been set to the appropriate 'vector'.
+	 * in x86/intr.c, this is done after idt_vec_set(), where this
+	 * would have been more appropriate to put this.
+	 */
+
+	int port, irq;
+	irq = vect2irq[idtvec];
+	port = bind_pirq_to_evtch(irq);
+	KASSERT(port < NR_EVENT_CHANNELS);
+
+	irq2port[irq] = port;
+
+	xen_atomic_set_bit(&ci->ci_evtmask[0], port);
+#endif
+
 }
 
 static void
@@ -573,6 +592,16 @@ ioapic_delroute(struct pic *pic, struct 
 {
 
 	ioapic_hwmask(pic, pin);
+
+#if defined(XEN)
+	int port, irq;
+	irq = vect2irq[idtvec];
+	port = bind_pirq_to_evtch(irq);
+	port = unbind_pirq_from_evtch(irq);
+
+	KASSERT(port < NR_EVENT_CHANNELS);
+#endif
+
 }
 
 #ifdef DDB

Index: src/sys/arch/xen/conf/files.xen
diff -u src/sys/arch/xen/conf/files.xen:1.160 src/sys/arch/xen/conf/files.xen:1.161
--- src/sys/arch/xen/conf/files.xen:1.160	Sat Nov  4 09:22:16 2017
+++ src/sys/arch/xen/conf/files.xen	Sat Nov  4 14:56:48 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: files.xen,v 1.160 2017/11/04 09:22:16 cherry Exp $
+#	$NetBSD: files.xen,v 1.161 2017/11/04 14:56:48 cherry Exp $
 #	NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp 
 #	NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp 
 
@@ -141,6 +141,7 @@ file	arch/x86/x86/identcpu.c		machdep
 file	arch/xen/x86/pintr.c		machdep & dom0ops
 file	arch/xen/x86/intr.c		machdep
 file	arch/xen/x86/xen_ipi.c		multiprocessor
+file	arch/x86/x86/intr.c		machdep
 file	arch/x86/x86/idt.c		machdep
 file	arch/x86/x86/pmap.c		machdep
 file	arch/x86/x86/pmap_tlb.c		machdep

Index: src/sys/arch/xen/include/evtchn.h
diff -u src/sys/arch/xen/include/evtchn.h:1.24 src/sys/arch/xen/include/evtchn.h:1.25
--- src/sys/arch/xen/include/evtchn.h:1.24	Sun Jul 16 05:03:36 2017
+++ src/sys/arch/xen/include/evtchn.h	Sat Nov  4 14:56:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: evtchn.h,v 1.24 2017/07/16 05:03:36 cherry Exp $	*/
+/*	$NetBSD: evtchn.h,v 1.25 2017/11/04 14:56:48 cherry Exp $	*/
 
 /*
  *
@@ -60,6 +60,8 @@ int unbind_virq_from_evtch(int);
 evtchn_port_t bind_vcpu_to_evtch(cpuid_t);
 
 struct pintrhand {
+	/* See comments in x86/include/intr.h:struct intrhand {} */
+	int pic_type;
 	int pirq;
 	int evtch;
 	int (*func)(void *);

Index: src/sys/arch/xen/include/intr.h
diff -u src/sys/arch/xen/include/intr.h:1.43 src/sys/arch/xen/include/intr.h:1.44
--- src/sys/arch/xen/include/intr.h:1.43	Sat Nov  4 09:22:16 2017
+++ src/sys/arch/xen/include/intr.h	Sat Nov  4 14:56:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.h,v 1.43 2017/11/04 09:22:16 cherry Exp $	*/
+/*	$NetBSD: intr.h,v 1.44 2017/11/04 14:56:48 cherry Exp $	*/
 /*	NetBSD intr.h,v 1.15 2004/10/31 10:39:34 yamt Exp	*/
 
 /*-
@@ -69,9 +69,6 @@ extern int irq2port[NR_EVENT_CHANNELS];
 int xen_intr_biglock_wrapper(void *);
 #endif
 
-int xen_intr_map(int *, int);
-struct pic *intr_findpic(int);
-void intr_add_pcibus(struct pcibus_attach_args *);
 #if defined(DOM0OPS) || NPCI > 0
 int xen_pirq_alloc(intr_handle_t *, int);
 #endif /* defined(DOM0OPS) || NPCI > 0 */

Index: src/sys/arch/xen/xen/pci_intr_machdep.c
diff -u src/sys/arch/xen/xen/pci_intr_machdep.c:1.20 src/sys/arch/xen/xen/pci_intr_machdep.c:1.21
--- src/sys/arch/xen/xen/pci_intr_machdep.c:1.20	Fri Jul 28 07:42:41 2017
+++ src/sys/arch/xen/xen/pci_intr_machdep.c	Sat Nov  4 14:56:48 2017
@@ -1,4 +1,4 @@
-/*      $NetBSD: pci_intr_machdep.c,v 1.20 2017/07/28 07:42:41 cherry Exp $      */
+/*      $NetBSD: pci_intr_machdep.c,v 1.21 2017/11/04 14:56:48 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.20 2017/07/28 07:42:41 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.21 2017/11/04 14:56:48 cherry Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -149,7 +149,7 @@ pci_intr_map(const struct pci_attach_arg
 #if NIOAPIC > 0
 end:
 #endif
-	evtch = xen_intr_map((int *)ihp, IST_LEVEL);
+	evtch = xen_pirq_alloc((intr_handle_t *)ihp, IST_LEVEL);
 	if (evtch == -1)
 		goto bad;
 

Index: src/sys/arch/xen/xen/pciide_machdep.c
diff -u src/sys/arch/xen/xen/pciide_machdep.c:1.19 src/sys/arch/xen/xen/pciide_machdep.c:1.20
--- src/sys/arch/xen/xen/pciide_machdep.c:1.19	Sun Jul 16 06:14:24 2017
+++ src/sys/arch/xen/xen/pciide_machdep.c	Sat Nov  4 14:56:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pciide_machdep.c,v 1.19 2017/07/16 06:14:24 cherry Exp $	*/
+/*	$NetBSD: pciide_machdep.c,v 1.20 2017/11/04 14:56:48 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.19 2017/07/16 06:14:24 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pciide_machdep.c,v 1.20 2017/11/04 14:56:48 cherry Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -96,7 +96,7 @@ pciide_machdep_compat_intr_establish(dev
 	}
 #endif
 	xenih |= PCIIDE_COMPAT_IRQ(chan);
-	evtch = xen_intr_map((int *)&xenih, IST_EDGE);
+	evtch = xen_pirq_alloc((intr_handle_t *)&xenih, IST_EDGE);
 	if (evtch == -1)
 		return NULL;
 #if NIOAPIC > 0

Reply via email to