Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Jul 2009 22:19:52 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r195956 - in projects/ppc64/sys/powerpc: aim include
Message-ID:  <200907292219.n6TMJq0J083991@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Wed Jul 29 22:19:52 2009
New Revision: 195956
URL: http://svn.freebsd.org/changeset/base/195956

Log:
  Make 32-bit kernels operational again by not storing DAR and R31 in the
  same part of the register cache for traps, and by dealing with some
  stupidity in the way Apple stores the available physical memory list
  in firmware.

Modified:
  projects/ppc64/sys/powerpc/aim/ofw_machdep.c
  projects/ppc64/sys/powerpc/include/pcpu.h

Modified: projects/ppc64/sys/powerpc/aim/ofw_machdep.c
==============================================================================
--- projects/ppc64/sys/powerpc/aim/ofw_machdep.c	Wed Jul 29 22:02:13 2009	(r195955)
+++ projects/ppc64/sys/powerpc/aim/ofw_machdep.c	Wed Jul 29 22:19:52 2009	(r195956)
@@ -145,8 +145,11 @@ parse_ofw_memory(phandle_t node, const c
 {
 	cell_t address_cells, size_cells;
 	int sz, i, j;
+	int apple_hack_mode;
 	phandle_t phandle;
+
 	sz = 0;
+	apple_hack_mode = 0;
 
 	/*
 	 * Get #address-cells from root node, defaulting to 1 if it cannot
@@ -159,7 +162,20 @@ parse_ofw_memory(phandle_t node, const c
 	if (OF_getprop(phandle, "#size-cells", &size_cells, 
 	    sizeof(size_cells)) < sizeof(size_cells))
 		size_cells = 1;
+
+	/*
+	 * On Apple hardware, address_cells is always 1 for "available",
+	 * even when it is explicitly set to 2. Then all memory above 4 GB
+	 * should be added by hand to the available list. Detect Apple hardware
+	 * by seeing if ofw_real_mode is set -- only Apple seems to use
+	 * virtual-mode OF.
+	 */
+	if (strcmp(prop, "available") == 0 && !ofw_real_mode)
+		apple_hack_mode = 1;
 	
+	if (apple_hack_mode)
+		address_cells = 1;
+
 	/*
 	 * Get memory.
 	 */
@@ -217,6 +233,25 @@ parse_ofw_memory(phandle_t node, const c
 		panic("Physical memory map not found");
 	}
 
+	#ifdef __powerpc64__
+	if (apple_hack_mode) {
+		/* Add in regions above 4 GB to the available list */
+		struct mem_region himem[OFMEM_REGIONS];
+		int hisz;
+
+		hisz = parse_ofw_memory(node, "reg", himem);
+		j = sz/sizeof(output[0]);
+		for (i = 0; i < hisz/sizeof(himem[0]); i++) {
+			if (himem[i].mr_start > BUS_SPACE_MAXADDR_32BIT) {
+				output[j].mr_start = himem[i].mr_start;
+				output[j].mr_size = himem[i].mr_size;
+				j++;
+			}
+		}
+		sz = j*sizeof(output[0]);
+	}
+	#endif
+
 	return (sz);
 }
 

Modified: projects/ppc64/sys/powerpc/include/pcpu.h
==============================================================================
--- projects/ppc64/sys/powerpc/include/pcpu.h	Wed Jul 29 22:02:13 2009	(r195955)
+++ projects/ppc64/sys/powerpc/include/pcpu.h	Wed Jul 29 22:19:52 2009	(r195956)
@@ -71,12 +71,12 @@ struct pmap;
 #define	CPUSAVE_R29	2		/* where r29 gets saved */
 #define	CPUSAVE_R30	3		/* where r30 gets saved */
 #define	CPUSAVE_R31	4		/* where r31 gets saved */
-#define	CPUSAVE_AIM_DAR		4	/* where SPR_DAR gets saved */
-#define	CPUSAVE_AIM_DSISR	5	/* where SPR_DSISR gets saved */
-#define	CPUSAVE_BOOKE_DEAR	4	/* where SPR_DEAR gets saved */
-#define	CPUSAVE_BOOKE_ESR	5	/* where SPR_ESR gets saved */
-#define	CPUSAVE_SRR0	6		/* where SRR0 gets saved */
-#define	CPUSAVE_SRR1	7		/* where SRR1 gets saved */
+#define	CPUSAVE_AIM_DAR		5	/* where SPR_DAR gets saved */
+#define	CPUSAVE_AIM_DSISR	6	/* where SPR_DSISR gets saved */
+#define	CPUSAVE_BOOKE_DEAR	5	/* where SPR_DEAR gets saved */
+#define	CPUSAVE_BOOKE_ESR	6	/* where SPR_ESR gets saved */
+#define	CPUSAVE_SRR0	7		/* where SRR0 gets saved */
+#define	CPUSAVE_SRR1	8		/* where SRR1 gets saved */
 
 /* Book-E TLBSAVE is more elaborate */
 #define TLBSAVE_BOOKE_LR	0



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