/*-
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* Copyright (C) 2006 Semihalf, Piotr Kruszynski <ppk@semihalf.com>
* Copyright (C) 2007-2008 Semihalf, Rafal Jaworowski <raj@semihalf.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
__FBSDID("$FreeBSD$");
#include <stand.h>
#include <machine/metadata.h>
#include "api_public.h"
#include "bootstrap.h"
#include "glue.h"
#if defined(LOADER_FDT_SUPPORT)
#include <fdt_platform.h>
#endif
static int
{
char *cp;
char *p;
int howto;
int active;
int i;
/* Parse kargs */
howto = 0;
active = 0;
while (*cp != 0) {
active = 1;
else if (active)
switch (*cp) {
case 'a':
howto |= RB_ASKNAME;
break;
case 'C':
break;
case 'd':
break;
case 'D':
howto |= RB_MULTIPLE;
break;
case 'm':
break;
case 'g':
break;
case 'h':
break;
case 'p':
break;
case 'r':
howto |= RB_DFLTROOT;
break;
case 's':
break;
case 'v':
howto |= RB_VERBOSE;
break;
default:
active = 0;
break;
}
cp++;
}
}
/* get equivalents from the environment */
}
if ((p = getenv("console"))) {
if (!strcmp(p, "comconsole"))
if (!strcmp(p, "nullconsole"))
}
return(howto);
}
/*
* Copy the environment into the load area starting at (addr).
* Each variable is formatted as <name>=<value>, with a single nul
* separating each variable, and a double nul terminating the environment.
*/
static vm_offset_t
{
/* traverse the environment */
addr++;
}
addr++;
}
addr++;
return(addr);
}
/*
* Copy module-related data into the load area, where it can be
* used as a directory for loaded modules.
*
* Module data is presented in a self-describing format. Each datum
* is preceded by a 32-bit identifier and a 32-bit size field.
*
* Currently, the following data are saved:
*
* MOD_NAME (variable) module name (string)
* MOD_TYPE (variable) module type (string)
* MOD_ARGS (variable) module parameters (string)
* MOD_ADDR sizeof(vm_offset_t) module load address
* MOD_SIZE sizeof(size_t) module size
* MOD_METADATA (variable) type-specific metadata
*/
#define COPY32(v, a, c) { \
u_int32_t x = (v); \
if (c) \
archsw.arch_copyin(&x, a, sizeof(x)); \
a += sizeof(x); \
}
#define MOD_STR(t, a, s, c) { \
COPY32(t, a, c); \
if (c) \
}
#define MOD_VAR(t, a, s, c) { \
COPY32(t, a, c); \
COPY32(sizeof(s), a, c); \
if (c) \
archsw.arch_copyin(&s, a, sizeof(s)); \
}
if (c) \
}
#define MOD_END(a, c) { \
COPY32(MODINFO_END, a, c); \
COPY32(0, a, c); \
}
static vm_offset_t
{
int c;
vm_offset_t a;
c = addr != 0;
/* start with the first module on the list, should be the kernel */
}
}
return(addr);
}
/*
* Load the information expected by a kernel.
*
* - The 'boothowto' argument is constructed
* - The 'bootdev' argument is constructed
* - The kernel environment is copied into kernel space.
* - Module metadata are formatted and placed in kernel space.
*/
int
{
#if defined(LOADER_FDT_SUPPORT)
int dtb_size;
#endif
char *rootdevname;
int howto;
int i;
/*
* These metadata addreses must be converted for kernel after
* relocation.
*/
#if defined(LOADER_FDT_SUPPORT)
#endif
};
/*
* Allow the environment variable 'rootdev' to override the supplied
*/
if (rootdevname == NULL)
/* Find the last module in the chain */
addr = 0;
}
/* Pad to a page boundary */
/* Copy our environment */
/* Pad to a page boundary */
#if defined(LOADER_FDT_SUPPORT)
/* Handle device tree blob */
/* Pad to a page boundary */
if (dtb_size)
#endif
kernend = 0;
panic("can't find kernel file");
#if defined(LOADER_FDT_SUPPORT)
if (dtb_size)
else
pager_output("WARNING! Trying to fire up the kernel, but no "
"device tree blob found!\n");
#endif
/* Figure out the size and location of the metadata */
size = md_copymodules(0);
/* Provide MODINFOMD_KERNEND */
/* Convert addresses to the final VA */
/* Do relocation fixup on metadata of each module. */
if (md) {
}
}
}
/* Only now copy actual modules and metadata */
(void)md_copymodules(addr);
return (0);
}