Module Name:    src
Committed By:   macallan
Date:           Wed Feb 15 01:56:58 UTC 2012

Modified Files:
        src/sys/arch/powerpc/oea: oea_machdep.c ofwoea_machdep.c

Log Message:
fix crash during early startup - we can't call OpenFirmware between zapping
the BATs and complete setting them up again
ok releng


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/powerpc/oea/oea_machdep.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/powerpc/oea/ofwoea_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/powerpc/oea/oea_machdep.c
diff -u src/sys/arch/powerpc/oea/oea_machdep.c:1.62 src/sys/arch/powerpc/oea/oea_machdep.c:1.63
--- src/sys/arch/powerpc/oea/oea_machdep.c:1.62	Wed Feb  1 09:54:03 2012
+++ src/sys/arch/powerpc/oea/oea_machdep.c	Wed Feb 15 01:56:57 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: oea_machdep.c,v 1.62 2012/02/01 09:54:03 matt Exp $	*/
+/*	$NetBSD: oea_machdep.c,v 1.63 2012/02/15 01:56:57 macallan Exp $	*/
 
 /*
  * Copyright (C) 2002 Matt Thomas
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: oea_machdep.c,v 1.62 2012/02/01 09:54:03 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: oea_machdep.c,v 1.63 2012/02/15 01:56:57 macallan Exp $");
 
 #include "opt_ppcarch.h"
 #include "opt_compat_netbsd.h"
@@ -600,6 +600,10 @@ oea_batinit(paddr_t pa, ...)
 	va_list ap;
 
 	cpuvers = mfpvr() >> 16;
+	/*
+	 * we need to call this before zapping BATs so OF calls work
+	 */
+	mem_regions(&allmem, &availmem);
 
 	/*
 	 * Initialize BAT registers to unmapped to not generate
@@ -698,7 +702,7 @@ oea_batinit(paddr_t pa, ...)
 		       "r"(battable[0x01800000 >> 23].batu));
 	}
 #endif /* PPC_OEA601 */
-
+	
 	/*
 	 * Now setup other fixed bat registers
 	 *
@@ -733,9 +737,7 @@ oea_batinit(paddr_t pa, ...)
 
 	/*
 	 * Set up battable to map all RAM regions.
-	 * This is here because mem_regions() call needs bat0 set up.
 	 */
-	mem_regions(&allmem, &availmem);
 #ifdef PPC_OEA601
 	if (cpuvers == MPC601) {
 		for (mp = allmem; mp->size; mp++) {

Index: src/sys/arch/powerpc/oea/ofwoea_machdep.c
diff -u src/sys/arch/powerpc/oea/ofwoea_machdep.c:1.26 src/sys/arch/powerpc/oea/ofwoea_machdep.c:1.27
--- src/sys/arch/powerpc/oea/ofwoea_machdep.c:1.26	Thu Aug  4 20:02:48 2011
+++ src/sys/arch/powerpc/oea/ofwoea_machdep.c	Wed Feb 15 01:56:58 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: ofwoea_machdep.c,v 1.26 2011/08/04 20:02:48 phx Exp $ */
+/* $NetBSD: ofwoea_machdep.c,v 1.27 2012/02/15 01:56:58 macallan Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofwoea_machdep.c,v 1.26 2011/08/04 20:02:48 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofwoea_machdep.c,v 1.27 2012/02/15 01:56:58 macallan Exp $");
 
 #include "opt_ppcarch.h"
 #include "opt_compat_netbsd.h"
@@ -166,6 +166,7 @@ ofwoea_initppc(u_int startkernel, u_int 
 			    sizeof(model_name));
 		model_init();
 	}
+
 	/* Initialize bus_space */
 	ofwoea_bus_space_init();
 
@@ -363,7 +364,7 @@ restore_ofmap(struct ofw_translations *m
 /*
  * Scan the device tree for ranges, and return them as bitmap 0..15
  */
-
+#ifndef macppc
 static u_int16_t
 ranges_bitmap(int node, u_int16_t bitmap)
 {
@@ -404,22 +405,33 @@ noranges:
 	}
 	return bitmap;
 }
+#endif /* !macppc */
 
 void
 ofwoea_batinit(void)
 {
 #if defined (PPC_OEA)
+
+#ifdef macppc
+	/*
+	 * cover PCI and register space but not the firmware ROM
+	 */
+	oea_batinit(0x80000000, BAT_BL_256M,
+		    0x90000000, BAT_BL_256M,
+		    0xa0000000, BAT_BL_256M,
+		    0xb0000000, BAT_BL_256M,
+		    0xf0000000, BAT_BL_128M,
+		    0xf8000000, BAT_BL_64M,
+		    0);
+#else
         u_int16_t bitmap;
 	int node, i;
 
 	node = OF_finddevice("/");
+
 	bitmap = ranges_bitmap(node, 0);
 	oea_batinit(0);
 
-#ifdef macppc
-	/* XXX this is a macppc-specific hack */
-	bitmap = 0x8f00;
-#endif
 	for (i=1; i < 0x10; i++) {
 		/* skip the three vital SR regions */
 		if (i == USER_SR || i == KERNEL_SR || i == KERNEL2_SR)
@@ -429,6 +441,7 @@ ofwoea_batinit(void)
 			DPRINTF("Batmapped 256M at 0x%x\n", 0x10000000 * i);
 		}
 	}
+#endif
 #endif /* OEA */
 }
 

Reply via email to