PERFORCE change 125785 for review

Rafal Jaworowski raj at FreeBSD.org
Tue Aug 28 10:09:31 PDT 2007


http://perforce.freebsd.org/chv.cgi?CH=125785

Change 125785 by raj at raj_booke_intgr on 2007/08/28 17:09:26

	Cleanup after the IFC
	
	Move AIM files from sys/powerpc/powerpc to sys/powerpc/aim, minor
	other cleanups so as to let GENERIC (AIM) kernel build again.

Affected files ...

.. //depot/projects/e500/sys/powerpc/aim/interrupt.c#3 edit
.. //depot/projects/e500/sys/powerpc/aim/nexus.c#3 edit
.. //depot/projects/e500/sys/powerpc/aim/trap.c#4 edit
.. //depot/projects/e500/sys/powerpc/aim/uio_machdep.c#3 edit
.. //depot/projects/e500/sys/powerpc/aim/vm_machdep.c#4 edit
.. //depot/projects/e500/sys/powerpc/powerpc/clock.c#4 delete
.. //depot/projects/e500/sys/powerpc/powerpc/interrupt.c#4 delete
.. //depot/projects/e500/sys/powerpc/powerpc/machdep.c#6 delete
.. //depot/projects/e500/sys/powerpc/powerpc/nexus.c#4 delete
.. //depot/projects/e500/sys/powerpc/powerpc/trap.c#4 delete
.. //depot/projects/e500/sys/powerpc/powerpc/uio_machdep.c#4 delete
.. //depot/projects/e500/sys/powerpc/powerpc/vm_machdep.c#4 delete
.. //depot/projects/e500/sys/powerpc/psim/iobus.c#3 edit

Differences ...

==== //depot/projects/e500/sys/powerpc/aim/interrupt.c#3 (text+ko) ====

@@ -24,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/powerpc/powerpc/interrupt.c,v 1.5 2005/12/22 22:16:08 jhb Exp $
+ * $FreeBSD: src/sys/powerpc/powerpc/interrupt.c,v 1.8 2007/08/11 19:25:32 marcel Exp $
  */
 
 /*
@@ -49,30 +49,20 @@
 #include <sys/vmmeter.h>
 
 #include <machine/cpu.h>
+#include <machine/clock.h>
 #include <machine/db_machdep.h>
 #include <machine/fpu.h>
 #include <machine/frame.h>
+#include <machine/intr_machdep.h>
+#include <machine/md_var.h>
 #include <machine/pcb.h>
 #include <machine/psl.h>
 #include <machine/trap.h>
 #include <machine/spr.h>
 #include <machine/sr.h>
-#include <machine/interruptvar.h>
 
-void powerpc_interrupt(struct trapframe *);
-
-/*
- * External interrupt install routines
- */
-static void (*powerpc_extintr_handler)(void);
-
-void
-ext_intr_install(void (*new_extint)(void))
-{
-	powerpc_extintr_handler = new_extint;
-}
+#include "pic_if.h"
 
-extern void	decr_intr(struct trapframe *);
 extern void	trap(struct trapframe *);
 
 /*
@@ -83,14 +73,15 @@
 void
 powerpc_interrupt(struct trapframe *framep)
 {
-        struct thread *td;
+	struct thread *td;
+	register_t ee;
 
 	td = curthread;
 
 	switch (framep->exc) {
 	case EXC_EXI:
 		atomic_add_int(&td->td_intr_nesting_level, 1);
-		(*powerpc_extintr_handler)();
+		PIC_DISPATCH(pic, framep);
 		atomic_subtract_int(&td->td_intr_nesting_level, 1);	
 		break;
 
@@ -101,14 +92,12 @@
 		break;
 
 	default:
-		/*
-		 * Re-enable interrupts and call the generic trap code
-		 */
-#if 0
-		printf("powerpc_interrupt: got trap\n");
-		mtmsr(mfmsr() | PSL_EE);
-		isync();
-#endif
+		/* Re-enable interrupts if applicable. */
+		ee = framep->srr1 & PSL_EE;
+		if (ee != 0) {
+			mtmsr(mfmsr() | ee);
+			isync();
+		}
 		trap(framep);
 	}	        
 }

==== //depot/projects/e500/sys/powerpc/aim/nexus.c#3 (text+ko) ====

@@ -52,7 +52,7 @@
  *
  * 	from: FreeBSD: src/sys/i386/i386/nexus.c,v 1.43 2001/02/09
  *
- * $FreeBSD: src/sys/powerpc/powerpc/nexus.c,v 1.14 2007/04/20 03:24:59 grehan Exp $
+ * $FreeBSD: src/sys/powerpc/powerpc/nexus.c,v 1.15 2007/08/11 19:25:32 marcel Exp $
  */
 #include "opt_psim.h"
 
@@ -97,7 +97,7 @@
 };
 
 struct nexus_softc {
-	device_t	sc_pic;
+	struct rman	sc_rman;
 };
 
 /*
@@ -182,12 +182,24 @@
 	phandle_t	root;
 	phandle_t	child;
 	struct		nexus_softc *sc;
+	u_long		start, end;
 
 	if ((root = OF_peer(0)) == -1)
 		panic("nexus_probe: OF_peer failed.");
 
 	sc = device_get_softc(dev);
 
+	start = 0;
+	end = INTR_VECTORS - 1;
+
+	sc->sc_rman.rm_start = start;
+	sc->sc_rman.rm_end = end;
+	sc->sc_rman.rm_type = RMAN_ARRAY;
+	sc->sc_rman.rm_descr = "Interrupt request lines";
+	if (rman_init(&sc->sc_rman) ||
+	    rman_manage_region(&sc->sc_rman, start, end))
+		panic("nexus_probe IRQ rman");
+
 	/*
 	 * Allow devices to identify
 	 */
@@ -302,31 +314,40 @@
 
 static int
 nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags,
-    driver_filter_t *filter, driver_intr_t *intr, void *arg, void **cookiep)
+    driver_filter_t *filter, driver_intr_t *ihand, void *arg, void **cookiep)
 {
-	struct	nexus_softc *sc;
+	driver_t	*driver;
+	int		error;
+
+	/* somebody tried to setup an irq that failed to allocate! */
+	if (res == NULL)
+		panic("nexus_setup_intr: NULL irq resource!");
+
+	*cookiep = 0;
+	if ((rman_get_flags(res) & RF_SHAREABLE) == 0)
+		flags |= INTR_EXCL;
+
+	driver = device_get_driver(child);
 
-	sc = device_get_softc(dev);
+	/*
+	 * We depend here on rman_activate_resource() being idempotent.
+	 */
+	error = rman_activate_resource(res);
+	if (error)
+		return (error);
 
-	if (device_get_state(sc->sc_pic) != DS_ATTACHED)
-		panic("nexus_setup_intr: no pic attached\n");
+	error = powerpc_setup_intr(device_get_nameunit(child),
+	    rman_get_start(res), filter, ihand, arg, flags, cookiep);
 
-	return (PIC_SETUP_INTR(sc->sc_pic, child, res, flags, filter, intr, 
-	    arg, cookiep));
+	return (error);
 }
 
 static int
 nexus_teardown_intr(device_t dev, device_t child, struct resource *res,
-    void *ih)
+    void *cookie)
 {
-	struct	nexus_softc *sc;
 
-	sc = device_get_softc(dev);
-
-	if (device_get_state(sc->sc_pic) != DS_ATTACHED)
-		panic("nexus_teardown_intr: no pic attached\n");
-
-	return (PIC_TEARDOWN_INTR(sc->sc_pic, child, res, ih));
+	return (powerpc_teardown_intr(cookie));
 }
 
 /*
@@ -337,10 +358,8 @@
 nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
     u_long start, u_long end, u_long count, u_int flags)
 {
-	struct	nexus_softc *sc;
-	struct	resource *rv;
-
-	sc = device_get_softc(bus);
+	struct nexus_softc *sc;
+	struct resource *rv;
 
 	if (type != SYS_RES_IRQ) {
 		device_printf(bus, "unknown resource request from %s\n",
@@ -348,10 +367,21 @@
 		return (NULL);
 	}
 
-	if (device_get_state(sc->sc_pic) != DS_ATTACHED)
-		panic("nexus_alloc_resource: no pic attached\n");
+	if (count == 0 || start + count - 1 != end) {
+		device_printf(bus, "invalid IRQ allocation from %s\n",
+		    device_get_nameunit(child));
+		return (NULL);
+	}
+
+	sc = device_get_softc(bus);
 
-	rv = PIC_ALLOCATE_INTR(sc->sc_pic, child, rid, start, flags);
+	rv = rman_reserve_resource(&sc->sc_rman, start, end, count,
+	    flags, child);
+	if (rv == NULL) {
+		device_printf(bus, "IRQ allocation failed for %s\n",
+		    device_get_nameunit(child));
+	} else
+		rman_set_rid(rv, *rid);
 
 	return (rv);
 }
@@ -378,20 +408,14 @@
 nexus_release_resource(device_t bus, device_t child, int type, int rid,
     struct resource *res)
 {
-	struct	nexus_softc *sc;
 
-	sc = device_get_softc(bus);
-
 	if (type != SYS_RES_IRQ) {
 		device_printf(bus, "unknown resource request from %s\n",
 		    device_get_nameunit(child));
 		return (EINVAL);
 	}
 
-	if (device_get_state(sc->sc_pic) != DS_ATTACHED)
-		panic("nexus_release_resource: no pic attached\n");
-
-	return (PIC_RELEASE_INTR(sc->sc_pic, child, rid, res));
+	return (rman_release_resource(res));
 }
 
 static device_t
@@ -418,17 +442,6 @@
 	return (cdev);
 }
 
-int
-nexus_install_intcntlr(device_t dev)
-{
-	struct	nexus_softc *sc;
-
-	sc = device_get_softc(device_get_parent(dev));
-	sc->sc_pic = dev;
-
-	return (0);
-}
-
 static const char *
 nexus_ofw_get_name(device_t bus, device_t dev)
 {

==== //depot/projects/e500/sys/powerpc/aim/trap.c#4 (text+ko) ====

@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/powerpc/powerpc/trap.c,v 1.64 2007/03/09 04:02:37 mohans Exp $");
+__FBSDID("$FreeBSD: src/sys/powerpc/powerpc/trap.c,v 1.67 2007/08/07 18:40:02 marcel Exp $");
 
 #include "opt_ktrace.h"
 
@@ -433,8 +433,8 @@
 	}
 	switch (error) {
 	case 0:
-		if ((frame->fixreg[0] == SYS___syscall) &&
-		    (code != SYS_lseek)) {
+		if (frame->fixreg[0] == SYS___syscall &&
+		    code != SYS_freebsd6_lseek && code != SYS_lseek) {
 			/*
 			 * 64-bit return, 32-bit syscall. Fixup byte order
 			 */

==== //depot/projects/e500/sys/powerpc/aim/uio_machdep.c#3 (text+ko) ====

@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/powerpc/powerpc/uio_machdep.c,v 1.6 2006/12/05 04:01:52 grehan Exp $");
+__FBSDID("$FreeBSD: src/sys/powerpc/powerpc/uio_machdep.c,v 1.7 2007/06/09 21:55:16 marcel Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -49,7 +49,7 @@
 #include <vm/vm.h>
 #include <vm/vm_page.h>
 
-#include <machine/cpu.h>
+#include <machine/md_var.h>
 #include <machine/vmparam.h>
 
 /*

==== //depot/projects/e500/sys/powerpc/aim/vm_machdep.c#4 (text+ko) ====

@@ -38,7 +38,7 @@
  *
  *	from: @(#)vm_machdep.c	7.3 (Berkeley) 5/13/91
  *	Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
- * $FreeBSD: src/sys/powerpc/powerpc/vm_machdep.c,v 1.113 2006/12/28 23:56:50 marcel Exp $
+ * $FreeBSD: src/sys/powerpc/powerpc/vm_machdep.c,v 1.115 2007/06/06 06:01:56 grehan Exp $
  */
 /*-
  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -154,7 +154,7 @@
 	pcb->pcb_lr = (register_t)fork_trampoline;
 	pcb->pcb_usr = kernel_pmap->pm_sr[USER_SR];
 
-	/* Setup to release sched_lock in fork_exit(). */
+	/* Setup to release spin count in fork_exit(). */
 	td2->td_md.md_spinlock_count = 1;
 	td2->td_md.md_saved_msr = PSL_KERNSET;
 
@@ -327,7 +327,7 @@
 	pcb2->pcb_lr = (register_t)fork_trampoline;
 	pcb2->pcb_usr = kernel_pmap->pm_sr[USER_SR];
 
-	/* Setup to release sched_lock in fork_exit(). */
+	/* Setup to release spin count in fork_exit(). */
 	td->td_md.md_spinlock_count = 1;
 	td->td_md.md_saved_msr = PSL_KERNSET;
 }

==== //depot/projects/e500/sys/powerpc/psim/iobus.c#3 (text+ko) ====

@@ -311,7 +311,6 @@
 	int  needactivate;
 	struct  resource *rv;
 	struct  rman *rm;
-	bus_space_tag_t tagval;
 
 	sc = device_get_softc(bus);
 


More information about the p4-projects mailing list