From owner-svn-src-head@FreeBSD.ORG Thu Apr 24 22:28:53 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B8DFD840; Thu, 24 Apr 2014 22:28:53 +0000 (UTC) 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)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 98C6A17E7; Thu, 24 Apr 2014 22:28:53 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3OMSrlC071903; Thu, 24 Apr 2014 22:28:53 GMT (envelope-from brooks@svn.freebsd.org) Received: (from brooks@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3OMSrPl071902; Thu, 24 Apr 2014 22:28:53 GMT (envelope-from brooks@svn.freebsd.org) Message-Id: <201404242228.s3OMSrPl071902@svn.freebsd.org> From: Brooks Davis Date: Thu, 24 Apr 2014 22:28:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r264897 - head/sys/mips/beri 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.17 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: Thu, 24 Apr 2014 22:28:53 -0000 Author: brooks Date: Thu Apr 24 22:28:53 2014 New Revision: 264897 URL: http://svnweb.freebsd.org/changeset/base/264897 Log: Merge from CheriBSD: commit 003649d9622ce252a2794ae5891ee7e7c209caca Author: Robert N. M. Watson Date: Wed Feb 5 18:32:09 2014 +0000 Teach the FreeBSD/beri boot to "auto-detect" whether argument 4 (a3) is a memory size of pointer to a struct bootinfo * by looking at its value and seeing whether it is pointer-like. If a pointer, assume it's a bootinfo and extract memsize from it instead; otherwise, use it as memsize directly. This allows kernels to support bootinfo being passed by loader (and boot2) while still supporting older Miniboot setups. commit f7045af9a1e92b6bd92541fe5d25abf66d824e8f Author: Robert N. M. Watson Date: Thu Feb 6 13:45:34 2014 +0000 When the module metadata pointer is available from loader, use it in the kernel. commit 52e0e1ff2cba9dfcfab9e1d0a31fb7fdf7317450 Author: Robert N. M. Watson Date: Thu Feb 6 19:57:48 2014 +0000 In the BERI kernel boot code, extract 'boothowto' (which includes boot flags such as '-s') and 'envp' from passed module data. Booting to single-user mode using boot flags now works. Sponsored by: DARPA, AFRL Modified: head/sys/mips/beri/beri_machdep.c Modified: head/sys/mips/beri/beri_machdep.c ============================================================================== --- head/sys/mips/beri/beri_machdep.c Thu Apr 24 21:18:29 2014 (r264896) +++ head/sys/mips/beri/beri_machdep.c Thu Apr 24 22:28:53 2014 (r264897) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Wojciech A. Koszek - * Copyright (c) 2012 Robert N. M. Watson + * Copyright (c) 2012-2014 Robert N. M. Watson * All rights reserved. * * This software was developed by SRI International and the University of @@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -131,60 +132,19 @@ platform_reset(void) __asm__ __volatile("wait"); } -#ifdef FDT -/* Parse cmd line args as env - copied from xlp_machdep. */ -/* XXX-BZ this should really be centrally provided for all (boot) code. */ -static void -_parse_bootargs(char *cmdline) -{ - char *n, *v; - - while ((v = strsep(&cmdline, " \n")) != NULL) { - if (*v == '\0') - continue; - if (*v == '-') { - while (*v != '\0') { - v++; - switch (*v) { - case 'a': boothowto |= RB_ASKNAME; break; - /* Someone should simulate that ;-) */ - case 'C': boothowto |= RB_CDROM; break; - case 'd': boothowto |= RB_KDB; break; - case 'D': boothowto |= RB_MULTIPLE; break; - case 'm': boothowto |= RB_MUTE; break; - case 'g': boothowto |= RB_GDB; break; - case 'h': boothowto |= RB_SERIAL; break; - case 'p': boothowto |= RB_PAUSE; break; - case 'r': boothowto |= RB_DFLTROOT; break; - case 's': boothowto |= RB_SINGLE; break; - case 'v': boothowto |= RB_VERBOSE; break; - } - } - } else { - n = strsep(&v, "="); - if (v == NULL) - setenv(n, "1"); - else - setenv(n, v); - } - } -} -#endif - void platform_start(__register_t a0, __register_t a1, __register_t a2, __register_t a3) { + struct bootinfo *bootinfop; vm_offset_t kernend; uint64_t platform_counter_freq; int argc = a0; char **argv = (char **)a1; char **envp = (char **)a2; - unsigned int memsize = a3; + long memsize; #ifdef FDT - char buf[2048]; /* early stack supposedly big enough */ vm_offset_t dtbp; - phandle_t chosen; void *kmdp; #endif int i; @@ -197,6 +157,25 @@ platform_start(__register_t a0, __regist mips_pcpu0_init(); + /* + * Over time, we've changed out boot-time binary interface for the + * kernel. Miniboot simply provides a 'memsize' in a3, whereas the + * FreeBSD boot loader provides a 'bootinfo *' in a3. While slightly + * grody, we support both here by detecting 'pointer-like' values in + * a3 and assuming physical memory can never be that back. + * + * XXXRW: Pull more values than memsize out of bootinfop -- e.g., + * module information. + */ + if (a3 >= 0x9800000000000000ULL) { + bootinfop = (void *)a3; + memsize = bootinfop->bi_memsize; + preload_metadata = (caddr_t)bootinfop->bi_modulep; + } else { + bootinfop = NULL; + memsize = a3; + } + #ifdef FDT /* * Find the dtb passed in by the boot loader (currently fictional). @@ -222,14 +201,13 @@ platform_start(__register_t a0, __regist while (1); if (OF_init((void *)dtbp) != 0) while (1); +#endif /* - * Get bootargs from FDT if specified. + * Configure more boot-time parameters passed in by loader. */ - chosen = OF_finddevice("/chosen"); - if (OF_getprop(chosen, "bootargs", buf, sizeof(buf)) != -1) - _parse_bootargs(buf); -#endif + boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int); + kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); /* * XXXRW: We have no way to compare wallclock time to cycle rate on @@ -252,7 +230,10 @@ platform_start(__register_t a0, __regist for (i = 0; envp[i]; i += 2) printf("\t%s = %s\n", envp[i], envp[i+1]); - printf("memsize = %08x\n", memsize); + if (bootinfop != NULL) + printf("bootinfo found at %p\n", bootinfop); + + printf("memsize = %p\n", (void *)memsize); } realmem = btoc(memsize);