Add support for bootinfo structure to be passed from 2nd stage bootstrap.

Pass symbol table information to DDB if available.
This commit is contained in:
wdk 2000-09-16 08:34:26 +00:00
parent 780256a327
commit da962aaad5
2 changed files with 154 additions and 9 deletions

View File

@ -0,0 +1,78 @@
/* $NetBSD: bootinfo.h,v 1.1 2000/09/16 08:34:26 wdk Exp $ */
/*
* Copyright (c) 1997, 2000
* Matthias Drochner. 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
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the NetBSD Project
* by Matthias Drochner.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
*
*/
#ifndef _MIPSCO_BOOTINFO_H_
#define _MIPSCO_BOOTINFO_H_
#define BOOTINFO_MAGIC 0xb007babe
#define BOOTINFO_SIZE 1024
/*
* The bootinfo structure is at the end of the 64kB hole between
* 0x80010000 to 0x8001ffff that neither NetBSD nor the PROM uses.
*/
#define BOOTINFO_ADDR 0x8001fc00
struct btinfo_common {
int next; /* offset of next item, or zero */
int type;
};
#define BTINFO_MAGIC 1
#define BTINFO_BOOTPATH 2
#define BTINFO_SYMTAB 3
struct btinfo_magic {
struct btinfo_common common;
int magic;
};
#define BTINFO_BOOTPATH_LEN 80
struct btinfo_bootpath {
struct btinfo_common common;
char bootpath[BTINFO_BOOTPATH_LEN];
};
struct btinfo_symtab {
struct btinfo_common common;
int nsym;
int ssym;
int esym;
};
#ifdef _KERNEL
void *lookup_bootinfo __P((int));
#endif
#endif /* !_MIPSCO_BOOTINFO_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.8 2000/09/10 06:26:51 nisimura Exp $ */
/* $NetBSD: machdep.c,v 1.9 2000/09/16 08:34:26 wdk Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -43,7 +43,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.8 2000/09/10 06:26:51 nisimura Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.9 2000/09/16 08:34:26 wdk Exp $");
/* from: Utah Hdr: machdep.c 1.63 91/04/24 */
@ -81,12 +81,14 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.8 2000/09/10 06:26:51 nisimura Exp $")
#ifdef DDB
#include <machine/db_machdep.h>
#include <ddb/db_extern.h>
#endif
#include <machine/intr.h>
#include <machine/mainboard.h>
#include <machine/sysconf.h>
#include <machine/autoconf.h>
#include <machine/bootinfo.h>
#include <machine/prom.h>
#include <dev/clock_subr.h>
#include <dev/cons.h>
@ -110,7 +112,8 @@ vm_map_t exec_map = NULL;
vm_map_t mb_map = NULL;
vm_map_t phys_map = NULL;
int physmem; /* max supported memory, changes to actual */
int physmem; /* max supported memory, changes to actual */
char *bootinfo = NULL; /* pointer to bootinfo structure */
phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
int mem_cluster_cnt;
@ -126,7 +129,7 @@ struct evcnt soft_evcnt[IPL_NSOFT];
int initcpu __P((void));
void configure __P((void));
void mach_init __P((int, char *[], char*[]));
void mach_init __P((int, char *[], char*[], u_int, char *));
void softintr_init __P((void));
int memsize_scan __P((caddr_t));
@ -147,7 +150,7 @@ extern struct user *proc0paddr;
/* locore callback-vector setup */
extern void mips_vector_init __P((void));
extern void prom_init __P((void));
void pizazz_init __P((void));
extern void pizazz_init __P((void));
/* platform-specific initialization vector */
static void unimpl_cons_init __P((void));
@ -193,10 +196,12 @@ struct consdev consdev_prom = {
* Return the first page address following the system.
*/
void
mach_init(argc, argv, envp)
mach_init(argc, argv, envp, bim, bip)
int argc;
char *argv[];
char *envp[];
u_int bim;
char *bip;
{
u_long first, last;
caddr_t kernend, v;
@ -204,20 +209,55 @@ mach_init(argc, argv, envp)
char *cp;
int i;
extern char edata[], end[];
char *bi_msg;
#ifdef DDB
int nsym = 0;
caddr_t ssym = 0;
caddr_t esym = 0;
struct btinfo_symtab *bi_syms;
#endif
/* Check for valid bootinfo passed from bootstrap */
if (bim == BOOTINFO_MAGIC) {
struct btinfo_magic *bi_magic;
bootinfo = (char *)BOOTINFO_ADDR; /* XXX */
bi_magic = lookup_bootinfo(BTINFO_MAGIC);
if (bi_magic == NULL || bi_magic->magic != BOOTINFO_MAGIC)
bi_msg = "invalid bootinfo structure.\n";
else
bi_msg = NULL;
} else
bi_msg = "invalid bootinfo (standalone boot?)\n";
/* clear the BSS segment */
kernend = (caddr_t)mips_round_page(end);
bzero(edata, kernend - edata);
#ifdef DDB
bi_syms = lookup_bootinfo(BTINFO_SYMTAB);
/* Load sysmbol table if present */
if (bi_syms != NULL) {
nsym = bi_syms->nsym;
ssym = (caddr_t)bi_syms->ssym;
esym = (caddr_t)bi_syms->esym;
kernend = (caddr_t)mips_round_page(esym);
}
#endif
prom_init();
consinit();
if (bi_msg != NULL)
printf(bi_msg);
/*
* Set the VM page size.
*/
uvm_setpagesize();
consinit();
/* Find out how much memory is available. */
physmem = memsize_scan(kernend);
@ -279,7 +319,9 @@ mach_init(argc, argv, envp)
* Initialize machine-dependent DDB commands, in case of early panic.
*/
db_machine_init();
/* init symbols if present */
if (esym)
ddb_init(esym - ssym, ssym, esym);
if (boothowto & RB_KDB)
Debugger();
#endif
@ -475,6 +517,31 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
/* NOTREACHED */
}
/*
* Look up information in bootinfo of boot loader.
*/
void *
lookup_bootinfo(type)
int type;
{
struct btinfo_common *bt;
char *help = bootinfo;
/* Check for a bootinfo record first. */
if (help == NULL)
return (NULL);
do {
bt = (struct btinfo_common *)help;
if (bt->type == type)
return ((void *)help);
help += bt->next;
} while (bt->next != 0 &&
(size_t)help < (size_t)bootinfo + BOOTINFO_SIZE);
return (NULL);
}
int waittime = -1;
/*