Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Dec 2013 14:57:37 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r259726 - user/nwhitehorn/mips_pic_if/mips/rmi
Message-ID:  <201312221457.rBMEvbME094126@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Sun Dec 22 14:57:36 2013
New Revision: 259726
URL: http://svnweb.freebsd.org/changeset/base/259726

Log:
  Convert to use pic_if.

Added:
  user/nwhitehorn/mips_pic_if/mips/rmi/rmi_ic.c
     - copied, changed from r259687, user/nwhitehorn/mips_pic_if/mips/rmi/intr_machdep.c
Deleted:
  user/nwhitehorn/mips_pic_if/mips/rmi/intr_machdep.c
Modified:
  user/nwhitehorn/mips_pic_if/mips/rmi/files.xlr
  user/nwhitehorn/mips_pic_if/mips/rmi/fmn.c
  user/nwhitehorn/mips_pic_if/mips/rmi/interrupt.h
  user/nwhitehorn/mips_pic_if/mips/rmi/iodi.c
  user/nwhitehorn/mips_pic_if/mips/rmi/tick.c
  user/nwhitehorn/mips_pic_if/mips/rmi/xlr_pci.c

Modified: user/nwhitehorn/mips_pic_if/mips/rmi/files.xlr
==============================================================================
--- user/nwhitehorn/mips_pic_if/mips/rmi/files.xlr	Sun Dec 22 14:39:04 2013	(r259725)
+++ user/nwhitehorn/mips_pic_if/mips/rmi/files.xlr	Sun Dec 22 14:57:36 2013	(r259726)
@@ -8,7 +8,7 @@ mips/rmi/msgring.c				standard
 mips/rmi/msgring_xls.c				standard
 mips/rmi/board.c				standard
 mips/rmi/fmn.c					standard
-mips/rmi/intr_machdep.c			        standard
+mips/rmi/rmi_ic.c			        standard
 mips/rmi/mpwait.S			        optional smp
 mips/rmi/xlr_i2c.c              		optional iic
 mips/rmi/uart_bus_xlr_iodi.c			optional uart 

Modified: user/nwhitehorn/mips_pic_if/mips/rmi/fmn.c
==============================================================================
--- user/nwhitehorn/mips_pic_if/mips/rmi/fmn.c	Sun Dec 22 14:39:04 2013	(r259725)
+++ user/nwhitehorn/mips_pic_if/mips/rmi/fmn.c	Sun Dec 22 14:57:36 2013	(r259726)
@@ -434,9 +434,9 @@ register_msgring_handler(int startb, int
 		create_msgring_thread(0);
 		if (msgring_maxthreads > xlr_threads_per_core)
 			msgring_maxthreads = xlr_threads_per_core;
-		cpu_establish_hardintr("msgring", msgring_process_fast_intr,
-			NULL, NULL, IRQ_MSGRING, 
-			INTR_TYPE_NET, &cookie);
+		mips_setup_intr("msgring", IRQ_MSGRING,
+		    msgring_process_fast_intr, NULL, NULL,
+		    INTR_TYPE_NET, &cookie);
 	}
 	return (0);
 }

Modified: user/nwhitehorn/mips_pic_if/mips/rmi/interrupt.h
==============================================================================
--- user/nwhitehorn/mips_pic_if/mips/rmi/interrupt.h	Sun Dec 22 14:39:04 2013	(r259725)
+++ user/nwhitehorn/mips_pic_if/mips/rmi/interrupt.h	Sun Dec 22 14:57:36 2013	(r259726)
@@ -42,9 +42,7 @@
  * XLR needs custom pre and post handlers for PCI/PCI-e interrupts
  * XXX: maybe follow i386 intsrc model
  */
-void xlr_establish_intr(const char *name, driver_filter_t filt,
-    driver_intr_t handler, void *arg, int irq, int flags,
-    void **cookiep, void (*busack)(int));
+void xlr_set_bus_ack(u_int irq, void (*busack)(int));
 void xlr_enable_irq(int irq);
 
 #endif				/* _RMI_INTERRUPT_H_ */

Modified: user/nwhitehorn/mips_pic_if/mips/rmi/iodi.c
==============================================================================
--- user/nwhitehorn/mips_pic_if/mips/rmi/iodi.c	Sun Dec 22 14:39:04 2013	(r259725)
+++ user/nwhitehorn/mips_pic_if/mips/rmi/iodi.c	Sun Dec 22 14:57:36 2013	(r259726)
@@ -101,24 +101,25 @@ iodi_setup_intr(device_t dev, device_t c
 
 	if (strcmp(name, "uart") == 0) {
 		/* FIXME uart 1? */
-		cpu_establish_hardintr("uart", filt, intr, arg,
-		    PIC_UART_0_IRQ, flags, cookiep);
+		mips_setup_intr("uart", PIC_UART_0_IRQ, filt, intr, arg,
+		    flags, cookiep);
 		pic_setup_intr(PIC_IRT_UART_0_INDEX, PIC_UART_0_IRQ, 0x1, 1);
 	} else if (strcmp(name, "rge") == 0 || strcmp(name, "nlge") == 0) {
 		int irq;
 
 		/* This is a hack to pass in the irq */
 		irq = (intptr_t)ires->__r_i;
-		cpu_establish_hardintr("rge", filt, intr, arg, irq, flags,
+		mips_setup_intr("rge", irq, filt, intr, arg, flags,
 		    cookiep);
 		pic_setup_intr(irq - PIC_IRQ_BASE, irq, 0x1, 1);
 	} else if (strcmp(name, "ehci") == 0) {
-		cpu_establish_hardintr("ehci", filt, intr, arg, PIC_USB_IRQ, flags,
+		mips_setup_intr("ehci", PIC_USB_IRQ, filt, intr, arg, flags,
 		    cookiep);
 		pic_setup_intr(PIC_USB_IRQ - PIC_IRQ_BASE, PIC_USB_IRQ, 0x1, 1);
 	} else if (strcmp(name, "ata") == 0) {
-		xlr_establish_intr("ata", filt, intr, arg, PIC_PCMCIA_IRQ, flags,
-		    cookiep, bridge_pcmcia_ack);
+		mips_setup_intr("ata", PIC_PCMCIA_IRQ, filt, intr, arg, flags,
+		    cookiep);
+		xlr_set_bus_ack(PIC_PCMCIA_IRQ, bridge_pcmcia_ack);
 		pic_setup_intr(PIC_PCMCIA_IRQ - PIC_IRQ_BASE, PIC_PCMCIA_IRQ, 0x1, 1);
 	}
 	return (0);

Copied and modified: user/nwhitehorn/mips_pic_if/mips/rmi/rmi_ic.c (from r259687, user/nwhitehorn/mips_pic_if/mips/rmi/intr_machdep.c)
==============================================================================
--- user/nwhitehorn/mips_pic_if/mips/rmi/intr_machdep.c	Sat Dec 21 17:24:31 2013	(r259687, copy source)
+++ user/nwhitehorn/mips_pic_if/mips/rmi/rmi_ic.c	Sun Dec 22 14:57:36 2013	(r259726)
@@ -1,40 +1,44 @@
 /*-
- * Copyright (c) 2006-2009 RMI Corporation
- * Copyright (c) 2002-2004 Juli Mallett <jmallett@FreeBSD.org>
- * All rights reserved.
+ * Copyright 2003-2011 Netlogic Microsystems (Netlogic). All rights
+ * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions, and the following disclaimer,
- *    without modification, immediately at the beginning of the file.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
+ * modification, are permitted provided that the following conditions are
+ * met:
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY Netlogic Microsystems ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE 
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
  *
- */
+ * NETLOGIC_BSD */
 
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/module.h>
 #include <sys/bus.h>
-#include <sys/interrupt.h>
+#include <sys/conf.h>
 #include <sys/kernel.h>
+#include <sys/rman.h>
 
+#include <machine/clock.h>
 #include <machine/cpu.h>
 #include <machine/cpufunc.h>
 #include <machine/cpuinfo.h>
@@ -43,85 +47,74 @@ __FBSDID("$FreeBSD$");
 #include <machine/intr_machdep.h>
 #include <machine/md_var.h>
 #include <machine/trap.h>
-#include <machine/hwfunc.h>
+
+#include "pic_if.h"
 
 #include <mips/rmi/rmi_mips_exts.h>
 #include <mips/rmi/interrupt.h>
 #include <mips/rmi/pic.h>
 
+#define XLR_MAX_INTR 64
+
 struct xlr_intrsrc {
 	void (*busack)(int);		/* Additional ack */
-	struct intr_event *ie;		/* event corresponding to intr */
-	int irq;
+	u_int vector;			/* event corresponding to intr */
+	u_int irq;
 };
 	
 static struct xlr_intrsrc xlr_interrupts[XLR_MAX_INTR];
-static mips_intrcnt_t mips_intr_counters[XLR_MAX_INTR];
-static int intrcnt_index;
 
-void
-xlr_enable_irq(int irq)
+static void
+xlr_ic_identify(driver_t *driver, device_t parent)
 {
-	uint64_t eimr;
 
-	eimr = read_c0_eimr64();
-	write_c0_eimr64(eimr | (1ULL << irq));
+	if (device_find_child(parent, "xlric", -1) == NULL)
+		BUS_ADD_CHILD(parent, 0, "xlric", 0);
 }
 
-void
-cpu_establish_softintr(const char *name, driver_filter_t * filt,
-    void (*handler) (void *), void *arg, int irq, int flags,
-    void **cookiep)
+static int
+xlr_ic_probe(device_t dev)
 {
 
-	panic("Soft interrupts unsupported!\n");
+	/* XXX: use FDT? */
+	device_set_desc(dev, "XLR Root Interrupt Controller");
+	return (BUS_PROBE_NOWILDCARD);
 }
 
-void
-cpu_establish_hardintr(const char *name, driver_filter_t * filt,
-    void (*handler) (void *), void *arg, int irq, int flags,
-    void **cookiep)
+static int
+xlr_ic_attach(device_t dev)
 {
 
-	xlr_establish_intr(name, filt, handler, arg, irq, flags,
-	    cookiep, NULL);
-}
+	mips_register_pic(dev, 0, XLR_MAX_INTR, 1);
+	root_pic = dev;
 
-static void
-xlr_post_filter(void *source)
-{
-	struct xlr_intrsrc *src = source;
-	
-	if (src->busack)
-		src->busack(src->irq);
-	pic_ack(PIC_IRQ_TO_INTR(src->irq));
+	return (0);
 }
 
-static void
-xlr_pre_ithread(void *source)
+void
+xlr_enable_irq(int irq)
 {
-	struct xlr_intrsrc *src = source;
+	uint64_t eimr;
 
-	if (src->busack)
-		src->busack(src->irq);
+	eimr = read_c0_eimr64();
+	write_c0_eimr64(eimr | (1ULL << irq));
 }
 
 static void
-xlr_post_ithread(void *source)
+xlr_eoi(device_t dev, u_int irq)
 {
-	struct xlr_intrsrc *src = source;
+	struct xlr_intrsrc *src = &xlr_interrupts[irq];
+	
+	if (src->busack)
+		src->busack(src->irq);
 
 	pic_ack(PIC_IRQ_TO_INTR(src->irq));
 }
 
-void
-xlr_establish_intr(const char *name, driver_filter_t filt,
-    driver_intr_t handler, void *arg, int irq, int flags,
-    void **cookiep, void (*busack)(int))
+static void
+xlr_enable(device_t dev, u_int irq, u_int vector)
 {
-	struct intr_event *ie;	/* descriptor for the IRQ */
 	struct xlr_intrsrc *src = NULL;
-	int errcode;
 
 	if (irq < 0 || irq > XLR_MAX_INTR)
 		panic("%s called for unknown hard intr %d", __func__, irq);
@@ -131,39 +124,27 @@ xlr_establish_intr(const char *name, dri
 	 * startup from CPU0
 	 */
 	src = &xlr_interrupts[irq];
-	ie = src->ie;
-	if (ie == NULL) {
-		/*
-		 * PIC based interrupts need ack in PIC, and some SoC
-		 * components need additional acks (e.g. PCI)
-		 */
-		if (PIC_IRQ_IS_PICINTR(irq))
-			errcode = intr_event_create(&ie, src, 0, irq,
-			    xlr_pre_ithread, xlr_post_ithread, xlr_post_filter,
-			    NULL, "hard intr%d:", irq);
-		else {
-			if (filt == NULL)
-				panic("Not supported - non filter percpu intr");
-			errcode = intr_event_create(&ie, src, 0, irq,
-			    NULL, NULL, NULL, NULL, "hard intr%d:", irq);
-		}
-		if (errcode) {
-			printf("Could not create event for intr %d\n", irq);
-			return;
-		}
-		src->irq = irq;
-		src->busack = busack;
-		src->ie = ie;
-	}
-	intr_event_add_handler(ie, name, filt, handler, arg,
-	    intr_priority(flags), flags, cookiep);
+	/*
+	 * PIC based interrupts need ack in PIC, and some SoC
+	 * components need additional acks (e.g. PCI)
+	 */
+
+	src->irq = irq;
+	src->vector = vector;
+
 	xlr_enable_irq(irq);
 }
 
 void
-cpu_intr(struct trapframe *tf)
+xlr_set_bus_ack(u_int irq, void (*busack)(int))
+{
+
+	xlr_interrupts[irq].busack = busack;
+}
+
+static void
+xlr_dispatch(device_t dev, struct trapframe *tf)
 {
-	struct intr_event *ie;
 	uint64_t eirr, eimr;
 	int i;
 
@@ -183,7 +164,7 @@ cpu_intr(struct trapframe *tf)
 	 * compare which ACKs the interrupt.
 	 */
 	if (eirr & (1 << IRQ_TIMER)) {
-		intr_event_handle(xlr_interrupts[IRQ_TIMER].ie, tf);
+		mips_dispatch_intr(xlr_interrupts[IRQ_TIMER].vector, tf);
 		critical_exit();
 		return;
 	}
@@ -193,57 +174,36 @@ cpu_intr(struct trapframe *tf)
 		if ((eirr & (1ULL << i)) == 0)
 			continue;
 
-		ie = xlr_interrupts[i].ie;
-		/* Don't account special IRQs */
-		switch (i) {
-		case IRQ_IPI:
-		case IRQ_MSGRING:
-			break;
-		default:
-			mips_intrcnt_inc(mips_intr_counters[i]);
-		}
-
 		/* Ack the IRQ on the CPU */
 		write_c0_eirr64(1ULL << i);
-		if (intr_event_handle(ie, tf) != 0) {
-			printf("stray interrupt %d\n", i);
-		}
+
+		mips_dispatch_intr(xlr_interrupts[i].vector, tf);
 	}
 	critical_exit();
 }
 
-void
-mips_intrcnt_setname(mips_intrcnt_t counter, const char *name)
-{
-	int idx = counter - intrcnt;
-
-	KASSERT(counter != NULL, ("mips_intrcnt_setname: NULL counter"));
-
-	snprintf(intrnames + (MAXCOMLEN + 1) * idx,
-	    MAXCOMLEN + 1, "%-*s", MAXCOMLEN, name);
-}
-
-mips_intrcnt_t
-mips_intrcnt_create(const char* name)
-{
-	mips_intrcnt_t counter = &intrcnt[intrcnt_index++];
+static device_method_t  xlr_ic_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_identify,	xlr_ic_identify),
+	DEVMETHOD(device_probe,		xlr_ic_probe),
+	DEVMETHOD(device_attach,	xlr_ic_attach),
+
+	/* PIC interface */
+	DEVMETHOD(pic_dispatch,		xlr_dispatch),
+	DEVMETHOD(pic_enable,		xlr_enable),
+	DEVMETHOD(pic_eoi,		xlr_eoi),
 
-	mips_intrcnt_setname(counter, name);
-	return counter;
-}
+	DEVMETHOD_END,
+};
 
-void
-cpu_init_interrupts()
-{
-	int i;
-	char name[MAXCOMLEN + 1];
+static driver_t xlr_ic_driver = {
+	"xlric",
+	xlr_ic_methods,
+	0
+};
+                        
+static devclass_t xlr_ic_devclass;
+                        
+EARLY_DRIVER_MODULE(xlric, nexus, xlr_ic_driver, xlr_ic_devclass, 0, 0,
+    BUS_PASS_INTERRUPT);
 
-	/*
-	 * Initialize all available vectors so spare IRQ
-	 * would show up in systat output 
-	 */
-	for (i = 0; i < XLR_MAX_INTR; i++) {
-		snprintf(name, MAXCOMLEN + 1, "int%d:", i);
-		mips_intr_counters[i] = mips_intrcnt_create(name);
-	}
-}

Modified: user/nwhitehorn/mips_pic_if/mips/rmi/tick.c
==============================================================================
--- user/nwhitehorn/mips_pic_if/mips/rmi/tick.c	Sun Dec 22 14:39:04 2013	(r259725)
+++ user/nwhitehorn/mips_pic_if/mips/rmi/tick.c	Sun Dec 22 14:57:36 2013	(r259726)
@@ -331,8 +331,8 @@ clock_attach(device_t dev)
 		panic("can't attach more clocks");
 
 	softc = sc = device_get_softc(dev);
-	cpu_establish_hardintr("compare", clock_intr, NULL,
-	    sc, IRQ_TIMER, INTR_TYPE_CLK, &sc->intr_handler);
+	mips_setup_intr("compare", IRQ_TIMER, clock_intr, NULL,
+	    sc, INTR_TYPE_CLK, &sc->intr_handler);
 
 	sc->tc.tc_get_timecount = counter_get_timecount;
 	sc->tc.tc_counter_mask = 0xffffffff;

Modified: user/nwhitehorn/mips_pic_if/mips/rmi/xlr_pci.c
==============================================================================
--- user/nwhitehorn/mips_pic_if/mips/rmi/xlr_pci.c	Sun Dec 22 14:39:04 2013	(r259725)
+++ user/nwhitehorn/mips_pic_if/mips/rmi/xlr_pci.c	Sun Dec 22 14:57:36 2013	(r259726)
@@ -478,8 +478,9 @@ mips_platform_pci_setup_intr(device_t de
 		return (0);
 
 	if (xlr_board_info.is_xls == 0) {
-		xlr_establish_intr(device_get_name(child), filt,
-		    intr, arg, PIC_PCIX_IRQ, flags, cookiep, bridge_pcix_ack);
+		mips_setup_intr(device_get_name(child), PIC_PCIX_IRQ, filt,
+		    intr, arg, flags, cookiep);
+		xlr_set_bus_ack(PIC_PCIX_IRQ, bridge_pcix_ack);
 		pic_setup_intr(PIC_IRT_PCIX_INDEX, PIC_PCIX_IRQ, 0x1, 1);
 	} else {
 		/* 
@@ -494,8 +495,9 @@ mips_platform_pci_setup_intr(device_t de
 			if (xlrirq == -1)
 				return (EINVAL);
 		}
-		xlr_establish_intr(device_get_name(child), filt,
-		    intr, arg, xlrirq, flags, cookiep, bridge_pcie_ack);
+		mips_setup_intr(device_get_name(child), xlrirq, filt,
+		    intr, arg, flags, cookiep);
+		xlr_set_bus_ack(xlrirq, bridge_pcie_ack);
 		pic_setup_intr(xlrirq - PIC_IRQ_BASE, xlrirq, 0x1, 1);
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201312221457.rBMEvbME094126>