mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-12 14:29:28 +00:00
Merge from CheriBSD:
commit 003649d9622ce252a2794ae5891ee7e7c209caca Author: Robert N. M. Watson <robert.watson@cl.cam.ac.uk> 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 <robert.watson@cl.cam.ac.uk> 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 <robert.watson@cl.cam.ac.uk> 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
This commit is contained in:
parent
fa3dfa6128
commit
2ef3c88e4b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=264897
@ -1,6 +1,6 @@
|
||||
/*-
|
||||
* Copyright (c) 2006 Wojciech A. Koszek <wkoszek@FreeBSD.org>
|
||||
* 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 <vm/vm_object.h>
|
||||
#include <vm/vm_page.h>
|
||||
|
||||
#include <machine/bootinfo.h>
|
||||
#include <machine/clock.h>
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/cpuregs.h>
|
||||
@ -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, __register_t a1, __register_t a2,
|
||||
|
||||
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, __register_t a1, __register_t a2,
|
||||
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, __register_t a1, __register_t a2,
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user