From owner-svn-src-head@FreeBSD.ORG Sat Oct 26 19:50:41 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 0E0BC425; Sat, 26 Oct 2013 19:50:41 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D5AE02FD1; Sat, 26 Oct 2013 19:50:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9QJoePe008481; Sat, 26 Oct 2013 19:50:40 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9QJoers008480; Sat, 26 Oct 2013 19:50:40 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201310261950.r9QJoers008480@svn.freebsd.org> From: Nathan Whitehorn Date: Sat, 26 Oct 2013 19:50:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r257191 - head/sys/powerpc/booke X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Oct 2013 19:50:41 -0000 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 #include +#include #include #include @@ -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 */