Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Oct 2013 19:50:40 +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: r257191 - head/sys/powerpc/booke
Message-ID:  <201310261950.r9QJoers008480@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Sat Oct 26 19:50:40 2013
New Revision: 257191
URL: http://svnweb.freebsd.org/changeset/base/257191

Log:
  Handle (in a slightly ugly way) ePAPR-type loaders that just place a
  device tree into r3. Rather than worrying about mapping that tree, reserving
  its space in the global physical memory space, etc., just copy it to some
  memory after the kernel.

Modified:
  head/sys/powerpc/booke/machdep.c

Modified: head/sys/powerpc/booke/machdep.c
==============================================================================
--- head/sys/powerpc/booke/machdep.c	Sat Oct 26 19:49:09 2013	(r257190)
+++ head/sys/powerpc/booke/machdep.c	Sat Oct 26 19:50:40 2013	(r257191)
@@ -137,6 +137,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/linker.h>
 #include <sys/reboot.h>
 
+#include <contrib/libfdt/libfdt.h>
 #include <dev/fdt/fdt_common.h>
 #include <dev/ofw/openfirm.h>
 
@@ -276,6 +277,23 @@ print_kernel_section_addr(void)
 	debugf(" _end           = 0x%08x\n", (uint32_t)_end);
 }
 
+static int
+booke_check_for_fdt(uint32_t arg1, vm_offset_t *dtbp)
+{
+	void *ptr;
+
+	if (arg1 % 8 != 0)
+		return (-1);
+
+	ptr = (void *)pmap_early_io_map(arg1, PAGE_SIZE);
+	if (fdt_check_header(ptr) != 0)
+		return (-1);
+
+	*dtbp = (vm_offset_t)ptr;
+
+	return (0);
+}
+
 u_int
 booke_init(uint32_t arg1, uint32_t arg2)
 {
@@ -288,6 +306,10 @@ booke_init(uint32_t arg1, uint32_t arg2)
 	end = (uintptr_t)_end;
 	dtbp = (vm_offset_t)NULL;
 
+	/* Set up TLB initially */
+	bootinfo = NULL;
+	tlb1_init();
+
 	/*
 	 * Handle the various ways we can get loaded and started:
 	 *  -	FreeBSD's loader passes the pointer to the metadata
@@ -302,11 +324,21 @@ booke_init(uint32_t arg1, uint32_t arg2)
 	 *	in arg1 and arg2 (resp). arg1 is between 1 and some
 	 *	relatively small number, such as 64K. arg2 is the
 	 *	physical address of the argv vector.
+	 *  -   ePAPR loaders pass an FDT blob in r3 (arg1) and the magic hex
+	 *      string 0x45504150 ('ePAP') in r6 (which has been lost by now).
+	 *      r4 (arg2) is supposed to be set to zero, but is not always.
 	 */
-	if (arg1 > (uintptr_t)kernel_text)	/* FreeBSD loader */
-		mdp = (void *)arg1;
-	else if (arg1 == 0)			/* Juniper loader */
+	
+	if (arg1 == 0)				/* Juniper loader */
 		mdp = (void *)arg2;
+	else if (booke_check_for_fdt(arg1, &dtbp) == 0) { /* ePAPR */
+		end = roundup(end, 8);
+		memmove((void *)end, (void *)dtbp, fdt_totalsize((void *)dtbp));
+		dtbp = end;
+		end += fdt_totalsize((void *)dtbp);
+		mdp = NULL;
+	} else if (arg1 > (uintptr_t)kernel_text)	/* FreeBSD loader */
+		mdp = (void *)arg1;
 	else					/* U-Boot */
 		mdp = NULL;
 
@@ -352,7 +384,7 @@ booke_init(uint32_t arg1, uint32_t arg2)
 
 	OF_interpret("perform-fixup", 0);
 	
-	/* Set up TLB initially */
+	/* Reset TLB1 to get rid of temporary mappings */
 	tlb1_init();
 
 	/* Set up IMMR */



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