- reorganize bootinfo structures and fix bootinfo handling in bootloader

(mostly based on pmax)
- pass symbol info from bootloader to kernel via bootinfo
  (currently bootinfo is allocated in the bootloader and
   copied by kernel later; maybe we should rethink about this)
- use passed bootinfo to initialize ksyms(4) in kernel
- remove options SYMTAB_SPACE from kernel config files
- bump bootloader version
This commit is contained in:
tsutsui 2006-07-22 18:15:05 +00:00
parent 25ec6d007f
commit 84180e1158
8 changed files with 139 additions and 50 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.96 2006/06/25 16:29:14 tsutsui Exp $ */
/* $NetBSD: machdep.c,v 1.97 2006/07/22 18:15:05 tsutsui Exp $ */
/* $OpenBSD: machdep.c,v 1.36 1999/05/22 21:22:19 weingart Exp $ */
/*
@ -78,7 +78,7 @@
/* from: Utah Hdr: machdep.c 1.63 91/04/24 */
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.96 2006/06/25 16:29:14 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.97 2006/07/22 18:15:05 tsutsui Exp $");
#include "fs_mfs.h"
#include "opt_ddb.h"
@ -113,7 +113,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.96 2006/06/25 16:29:14 tsutsui Exp $")
#include <ufs/mfs/mfs_extern.h> /* mfs_initminiroot() */
#endif
#include <machine/bootinfo.h>
#include <machine/cpu.h>
#include <machine/reg.h>
#include <machine/pio.h>
@ -180,6 +180,10 @@ vsize_t kseg2iobufsize = 0; /* to reserve PTEs for KSEG2 I/O space */
struct arc_bus_space arc_bus_io;/* Bus tag for bus.h macros */
struct arc_bus_space arc_bus_mem;/* Bus tag for bus.h macros */
char *bootinfo; /* pointer to bootinfo structure */
static char bi_buf[BOOTINFO_SIZE]; /* buffer to store bootinfo data */
static const char *bootinfo_msg = NULL;
#if NCOM > 0
int com_freq = COM_FREQ; /* unusual clock frequency of dev/ic/com.c */
int com_console = COMCONSOLE;
@ -200,7 +204,7 @@ phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
int mem_cluster_cnt;
/* initialize bss, etc. from kernel start, before main() is called. */
void mach_init(int, char **argv, char **);
void mach_init(int, char *[], u_int, void *);
const char *firmware_getenv(const char *env);
void arc_sysreset(bus_addr_t, bus_size_t);
@ -231,16 +235,55 @@ extern struct user *proc0paddr;
* Return the first page address following the system.
*/
void
mach_init(int argc, char *argv[], char *envv[])
mach_init(int argc, char *argv[], u_int bim, void *bip)
{
const char *cp;
int i;
paddr_t kernstartpfn, kernendpfn, first, last;
caddr_t kernend, v;
#if NKSYMS > 0 || defined(DDB) || defined(LKM)
char *ssym = NULL;
char *esym = NULL;
struct btinfo_symtab *bi_syms;
#endif
/* set up bootinfo structures */
if (bim == BOOTINFO_MAGIC && bip != NULL) {
struct btinfo_magic *bi_magic;
memcpy(bi_buf, bip, BOOTINFO_SIZE);
bootinfo = bi_buf;
bi_magic = lookup_bootinfo(BTINFO_MAGIC);
if (bi_magic == NULL || bi_magic->magic != BOOTINFO_MAGIC)
bootinfo_msg =
"invalid magic number in bootinfo structure.\n";
else
bootinfo_msg = "bootinfo found.\n";
} else
bootinfo_msg = "no bootinfo found. (old bootblocks?)\n";
/* clear the BSS segment in kernel code */
kernend = (caddr_t)mips_round_page(end);
memset(edata, 0, kernend - edata);
#if NKSYM > 0 || defined(DDB) || defined(LKM)
bi_syms = lookup_bootinfo(BTINFO_SYMTAB);
/* check whether there is valid bootinfo symtab info */
if (bi_syms != NULL) {
ssym = (char *)bi_syms->ssym;
esym = (char *)bi_syms->esym;
kernend = (void *)mips_round_page(esym);
#if 0
/*
* Don't clear BSS here since bi_buf[] is allocated in BSS
* and it has been cleared by the bootloader in this case.
*/
memset(edata, 0, end - edata);
#endif
} else
#endif
{
kernend = (caddr_t)mips_round_page(end);
memset(edata, 0, kernend - edata);
}
environment = &argv[1];
@ -382,14 +425,12 @@ mach_init(int argc, char *argv[], char *envv[])
#endif
#if NKSYMS || defined(DDB) || defined(LKM)
#if 0 /* XXX */
/* init symbols if present */
if (esym)
ksyms_init(1000, &end, (int*)esym);
#else
ksyms_init(esym - ssym, ssym, esym);
#ifdef SYMTAB_SPACE
ksyms_init(0, NULL, NULL);
#endif
else
ksyms_init(0, NULL, NULL);
#endif
#endif
@ -529,6 +570,12 @@ cpu_startup(void)
int opmapdebug = pmapdebug;
pmapdebug = 0; /* Shut up pmap debug during bootstrap */
#endif
#ifdef BOOTINFO_DEBUG
if (bootinfo_msg)
printf(bootinfo_msg);
#endif
/*
@ -569,6 +616,29 @@ cpu_startup(void)
arc_bus_space_malloc_set_safe();
}
void *
lookup_bootinfo(int type)
{
struct btinfo_common *bt;
char *bip;
/* check for a bootinfo record first */
if (bootinfo == NULL)
return NULL;
bip = bootinfo;
do {
bt = (struct btinfo_common *)bip;
if (bt->type == type)
return (void *)bt;
bip += bt->next;
} while (bt->next != 0 &&
bt->next < BOOTINFO_SIZE /* sanity */ &&
(size_t)bip < (size_t)bootinfo + BOOTINFO_SIZE);
return NULL;
}
static int waittime = -1;
void

View File

@ -1,4 +1,4 @@
# $NetBSD: GENERIC,v 1.139 2006/07/09 16:52:54 he Exp $
# $NetBSD: GENERIC,v 1.140 2006/07/22 18:15:05 tsutsui Exp $
#
# GENERIC machine description file
#
@ -22,7 +22,7 @@ include "arch/arc/conf/std.arc"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
#ident "GENERIC-$Revision: 1.139 $"
#ident "GENERIC-$Revision: 1.140 $"
maxusers 32 # estimated number of users
@ -78,7 +78,6 @@ options DDB # in-kernel debugger
#options KGDB_DEVRATE=19200 # kernel gdb port rate (default 9600)
#options KGDB_DEV="17*256+0" # device for kernel gdb
#makeoptions DEBUG="-g" # compile full symbol table
options SYMTAB_SPACE=270336
# Compatibility options
#options TCP_COMPAT_42 # 4.2BSD TCP/IP bug compat. Not recommended.

View File

@ -1,4 +1,4 @@
# $NetBSD: RAMDISK,v 1.70 2006/04/15 12:58:26 tsutsui Exp $
# $NetBSD: RAMDISK,v 1.71 2006/07/22 18:15:06 tsutsui Exp $
#
# memory disk based configuration file for MIPS R4x00 ARC Systems
#
@ -7,7 +7,7 @@ include "arch/arc/conf/std.arc"
#options INCLUDE_CONFIG_FILE # embed config file in kernel binary
#ident "GENERIC-$Revision: 1.70 $"
#ident "GENERIC-$Revision: 1.71 $"
maxusers 32 # estimated number of users
@ -62,7 +62,6 @@ options DDB # in-kernel debugger
#options KGDB_DEVRATE=19200 # kernel gdb port rate (default 9600)
#options KGDB_DEV="17*256+0" # device for kernel gdb
#makeoptions DEBUG="-g" # compile full symbol table
options SYMTAB_SPACE=262144
# Compatibility options
#options TCP_COMPAT_42 # 4.2BSD TCP/IP bug compat. Not recommended.

View File

@ -1,4 +1,4 @@
/* $NetBSD: bootinfo.h,v 1.2 2005/12/11 12:16:39 christos Exp $ */
/* $NetBSD: bootinfo.h,v 1.3 2006/07/22 18:15:06 tsutsui Exp $ */
/*
* Copyright (c) 1997
@ -29,16 +29,17 @@
#ifndef _ARC_BOOTINFO_H_
#define _ARC_BOOTINFO_H_
#define BOOTINFO_MAGIC 0x20050415
#define BOOTINFO_MAGIC 0xb007babe
#define BOOTINFO_SIZE 1024
struct btinfo_common {
struct btinfo_common *next;
int type;
};
size_t next; /* offset of next item, or zero if end of data */
int type; /* type of bootinfo item */
#define BTINFO_NONE 0
#define BTINFO_MAGIC 1
#define BTINFO_BOOTPATH 2
#define BTINFO_BOOTPATH 2
#define BTINFO_SYMTAB 3
};
struct btinfo_magic {
struct btinfo_common common;

View File

@ -1,4 +1,4 @@
/* $NetBSD: boot.c,v 1.4 2005/12/11 12:16:41 christos Exp $ */
/* $NetBSD: boot.c,v 1.5 2006/07/22 18:15:06 tsutsui Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -118,6 +118,8 @@ static char **environment;
struct btinfo_symtab bi_syms;
struct btinfo_bootpath bi_bpath;
static char bootinfo[BOOTINFO_SIZE];
extern const struct arcbios_fv *ARCBIOS;
int main(int, char **);
@ -139,7 +141,7 @@ main(int argc, char **argv)
const char *kernel = NULL;
const char *bootpath = NULL;
char bootfile[PATH_MAX];
void (*entry)(int, char *[], int, void *);
void (*entry)(int, char *[], u_int, void *);
u_long marks[MARK_MAX];
int win = 0;
int i;
@ -153,7 +155,7 @@ main(int argc, char **argv)
memset(marks, 0, sizeof marks);
/* initialise bootinfo structure early */
bi_init();
bi_init(bootinfo);
#ifdef BOOT_DEBUG
for (i = 0; i < argc; i++)
@ -240,15 +242,14 @@ main(int argc, char **argv)
return 0;
}
#if 0
strncpy(bi_bpath.bootpath, kernel, BTINFO_BOOTPATH_LEN);
bi_add(&bi_bpath, BTINFO_BOOTPATH);
strlcpy(bi_bpath.bootpath, kernel, BTINFO_BOOTPATH_LEN);
bi_add(&bi_bpath, BTINFO_BOOTPATH, sizeof(bi_bpath));
bi_syms.nsym = marks[MARK_NSYM];
bi_syms.ssym = marks[MARK_SYM];
bi_syms.esym = marks[MARK_END];
bi_add(&bi_syms, BTINFO_SYMTAB);
#endif
bi_add(&bi_syms, BTINFO_SYMTAB, sizeof(bi_syms));
entry = (void *)marks[MARK_ENTRY];
if (debug) {
@ -256,7 +257,7 @@ main(int argc, char **argv)
printf("nsym 0x%lx ssym 0x%lx esym 0x%lx\n", marks[MARK_NSYM],
marks[MARK_SYM], marks[MARK_END]);
}
(*entry)(argc, argv, 0 /* BOOTINFO_MAGIC */, NULL);
(*entry)(argc, argv, BOOTINFO_MAGIC, bootinfo);
printf("Kernel returned! Halting...\n");
return 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bootinfo.c,v 1.2 2005/12/11 12:16:41 christos Exp $ */
/* $NetBSD: bootinfo.c,v 1.3 2006/07/22 18:15:06 tsutsui Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -42,26 +42,46 @@
#include "bootinfo.h"
struct btinfo_common *bootinfo;
struct btinfo_common *bootinfo; /* bootinfo address */
static struct btinfo_magic bi_magic;
static char *bi_next; /* pointer to next bootinfo data */
static int bi_size; /* current bootinfo size */
void
bi_init(void)
bi_init(void *bi_addr)
{
struct btinfo_magic bi_magic;
bootinfo = NULL;
bootinfo = bi_addr;
bootinfo->next = 0;
bootinfo->type = BTINFO_NONE;
bi_next = (void *)bootinfo;
bi_size = 0;
bi_magic.magic = BOOTINFO_MAGIC;
bi_add(&bi_magic, BTINFO_MAGIC);
bi_add(&bi_magic, BTINFO_MAGIC, sizeof(bi_magic));
}
void
bi_add(void *new, int type)
bi_add(void *new, int type, size_t size)
{
struct btinfo_common *bi = new;
struct btinfo_common *bi;
if (bi_size + size > BOOTINFO_SIZE)
return; /* XXX should report error? */
bi_size += size;
/* register new bootinfo data */
memcpy(bi_next, new, size);
bi = (void *)bi_next;
bi->next = size;
bi->type = type;
bi->next = bootinfo;
bootinfo = bi;
/* update pointer to next bootinfo data */
bi_next += size;
bi = (void *)bi_next;
bi->next = 0;
bi->type = BTINFO_NONE;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: bootinfo.h,v 1.2 2005/12/11 12:16:41 christos Exp $ */
/* $NetBSD: bootinfo.h,v 1.3 2006/07/22 18:15:06 tsutsui Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -38,7 +38,5 @@
#include <machine/bootinfo.h>
extern struct btinfo_common *bootinfo;
void bi_init(void);
void bi_add(void *, int);
void bi_init(void *);
void bi_add(void *, int, size_t);

View File

@ -1,7 +1,8 @@
$NetBSD: version,v 1.2 2005/12/11 12:16:41 christos Exp $
$NetBSD: version,v 1.3 2006/07/22 18:15:06 tsutsui Exp $
NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
file is important - make sure the entries are appended on end, last item
is taken as the current.
1.0: Initial arc booter, based on sgimips one
1.1: Add bootinfo support and pass bi_bpath and bi_syms