Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Nov 2013 15:00:34 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r257991 - head/sys/powerpc/ofw
Message-ID:  <201311111500.rABF0YgV095101@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Mon Nov 11 15:00:33 2013
New Revision: 257991
URL: http://svnweb.freebsd.org/changeset/base/257991

Log:
  Consolidate Apple firmware hacks and improve them by switching on the
  presence of mac-io devices in the tree, which uniquely identifies Apple
  hardware.
  
  MFC after:	6 weeks

Modified:
  head/sys/powerpc/ofw/ofw_machdep.c

Modified: head/sys/powerpc/ofw/ofw_machdep.c
==============================================================================
--- head/sys/powerpc/ofw/ofw_machdep.c	Mon Nov 11 14:08:25 2013	(r257990)
+++ head/sys/powerpc/ofw/ofw_machdep.c	Mon Nov 11 15:00:33 2013	(r257991)
@@ -67,6 +67,7 @@ extern register_t ofmsr[5];
 extern void	*openfirmware_entry;
 static void	*fdt;
 int		ofw_real_mode;
+static int	apple_hacks;
 
 int		ofwcall(void *);
 static int	openfirmware(void *args);
@@ -79,6 +80,9 @@ register_t	ofw_sprg0_save;
 static __inline void
 ofw_sprg_prepare(void)
 {
+	if (!apple_hacks)
+		return;
+	
 	/*
 	 * Assume that interrupt are disabled at this point, or
 	 * SPRG1-3 could be trashed
@@ -98,6 +102,9 @@ ofw_sprg_prepare(void)
 static __inline void
 ofw_sprg_restore(void)
 {
+	if (!apple_hacks)
+		return;
+	
 	/*
 	 * Note that SPRG1-3 contents are irrelevant. They are scratch
 	 * registers used in the early portion of trap handling when
@@ -178,15 +185,10 @@ parse_ofw_memory(phandle_t node, const c
 
 	/*
 	 * 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.
+	 * even when it is explicitly set to 2. All memory above 4 GB
+	 * also needs to be added by hand to the available list.
 	 */
-	if (strcmp(prop, "available") == 0 && !ofw_real_mode)
-		apple_hack_mode = 1;
-	
-	if (apple_hack_mode)
+	if (strcmp(prop, "available") == 0 && apple_hacks)
 		address_cells = 1;
 
 	/*
@@ -241,7 +243,7 @@ parse_ofw_memory(phandle_t node, const c
 	sz = j*sizeof(output[0]);
 
 	#ifdef __powerpc64__
-	if (apple_hack_mode) {
+	if (strcmp(prop, "available") == 0 && apple_hacks) {
 		/* Add in regions above 4 GB to the available list */
 		struct mem_region himem[16];
 		int hisz;
@@ -480,6 +482,9 @@ OF_bootstrap()
 		OF_init(fdt);
 	} 
 
+	/* Apple firmware has some bugs. Check for a "mac-io" alias. */
+	apple_hacks = (OF_finddevice("mac-io") != -1) ? 1 : 0;
+
 	return (status);
 }
 



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