metadata.c revision 199767f8919635c4928607450d9e0abb932109ce
/*-
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* 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 "bootstrap.h"
#include "libofw.h"
extern struct tlb_entry *dtlb_store;
extern struct tlb_entry *itlb_store;
extern int dtlb_slot;
extern int itlb_slot;
static int md_bootserial(void);
int
md_getboothowto(char *kargs)
{
char *cp;
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 (md_bootserial() != -1)
return(howto);
}
static int
md_bootserial(void)
{
char buf[64];
return(-1);
return(-1);
return(-1);
return(-1);
return(-1);
return(-1);
return(-1);
return(-1);
}
return(-1);
return(-1);
return(-1);
return(0);
}
/*
* 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.
*/
{
/* 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)); \
}
#define MOD_METADATA(a, mm, c) { \
if (c) \
}
#define MOD_END(a, c) { \
COPY32(MODINFO_END, a, c); \
COPY32(0, a, c); \
}
{
struct preloaded_file *fp;
struct file_metadata *md;
int c;
c = addr != 0;
/* start with the first module on the list, should be the kernel */
}
}
}
return(addr);
}
/*
* Load the information expected by a sparc64 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
{
struct preloaded_file *kfp;
struct preloaded_file *xp;
struct file_metadata *md;
char *rootdevname;
int howto;
*dtbp = 0;
/*
* Allow the environment variable 'rootdev' to override the supplied device
* MI code before launching the kernel.
*/
/* find the last module in the chain */
addr = 0;
}
/* pad to a page boundary */
/* copy our environment */
/* pad to a page boundary */
kernend = 0;
panic("can't find kernel file");
size = md_copymodules(0);
(void)md_copymodules(addr);
return(0);
}