diff options
| author | tsubai <tsubai@NetBSD.org> | 1999-12-18 08:01:25 +0000 |
|---|---|---|
| committer | tsubai <tsubai@NetBSD.org> | 1999-12-18 08:01:25 +0000 |
| commit | 3b2d2cffe1c19d1058dd0e2f0ee2e796cccd2893 (patch) | |
| tree | 9d42bb98315a97cf0103bac7c606f17d5d416d1b /sys | |
| parent | 7374a44f77041b7423da8e06f48d304d6acf05fe (diff) | |
Introduce bootinfo.
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/arch/newsmips/include/bootinfo.h | 88 | ||||
| -rw-r--r-- | sys/arch/newsmips/newsmips/machdep.c | 83 | ||||
| -rw-r--r-- | sys/arch/newsmips/stand/boot/Makefile | 4 | ||||
| -rw-r--r-- | sys/arch/newsmips/stand/boot/boot.c | 11 | ||||
| -rw-r--r-- | sys/arch/newsmips/stand/boot/bootinfo.c | 83 |
5 files changed, 255 insertions, 14 deletions
diff --git a/sys/arch/newsmips/include/bootinfo.h b/sys/arch/newsmips/include/bootinfo.h new file mode 100644 index 00000000000..4fce2aeb469 --- /dev/null +++ b/sys/arch/newsmips/include/bootinfo.h @@ -0,0 +1,88 @@ +/* $NetBSD: bootinfo.h,v 1.1 1999/12/18 08:01:25 tsubai Exp $ */ + +/* + * Copyright (c) 1997 + * 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. + * + */ + +#define BOOTINFO_MAGIC 0xb007babe +#define BOOTINFO_SIZE 1024 +#define BOOTINFO_ADDR 0x80000200 + +struct btinfo_common { + int next; /* offset of next item, or zero */ + int type; +}; + +#define BTINFO_MAGIC 1 +#define BTINFO_SYMTAB 2 +#define BTINFO_BOOTARG 3 +#define BTINFO_BOOTPATH 4 +#define BTINFO_SYSTYPE 5 + +struct btinfo_magic { + struct btinfo_common common; + int magic; +}; + +struct btinfo_symtab { + struct btinfo_common common; + int nsym; + int ssym; + int esym; +}; + +struct btinfo_bootarg { + struct btinfo_common common; + int howto; + int bootdev; + int maxmem; + int sip; /* APbus only */ +}; + +#define BTINFO_BOOTPATH_LEN 80 +struct btinfo_bootpath { + struct btinfo_common common; + char bootpath[BTINFO_BOOTPATH_LEN]; +}; + +struct btinfo_systype { + struct btinfo_common common; + int type; +}; + +#ifdef _KERNEL +void *lookup_bootinfo __P((int)); +#endif + +#ifdef _STANDALONE +void bi_init __P((paddr_t)); +void bi_add __P((void *, int, int)); +#endif diff --git a/sys/arch/newsmips/newsmips/machdep.c b/sys/arch/newsmips/newsmips/machdep.c index 078323bc4cb..fb903134244 100644 --- a/sys/arch/newsmips/newsmips/machdep.c +++ b/sys/arch/newsmips/newsmips/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.31 1999/12/04 21:21:00 ragge Exp $ */ +/* $NetBSD: machdep.c,v 1.32 1999/12/18 08:01:26 tsubai 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.31 1999/12/04 21:21:00 ragge Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.32 1999/12/18 08:01:26 tsubai Exp $"); /* from: Utah Hdr: machdep.c 1.63 91/04/24 */ @@ -86,11 +86,16 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.31 1999/12/04 21:21:00 ragge Exp $"); #include <machine/psl.h> #include <machine/pte.h> #include <machine/autoconf.h> +#include <machine/bootinfo.h> #include <mips/locore.h> /* wbflush() */ #ifdef DDB #include <machine/db_machdep.h> +#include <ddb/db_access.h> +#include <ddb/db_extern.h> +#include <ddb/db_sym.h> #endif + #include <machine/adrsmap.h> #include <machine/machConst.h> #include <machine/intr.h> @@ -109,6 +114,7 @@ vm_map_t exec_map = NULL; vm_map_t mb_map = NULL; vm_map_t phys_map = NULL; +char *bootinfo = NULL; /* pointer to bootinfo structure */ int maxmem; /* max memory per process */ int physmem; /* max supported memory, changes to actual */ @@ -167,14 +173,13 @@ extern void stacktrace __P((void)); /*XXX*/ * XXX disables interrupt 5 to disable mips3 on-chip clock, which also * disables mips1 FPU interrupts. */ -int safepri = MIPS3_PSL_LOWIPL; /* XXX */ +int safepri = MIPS3_PSL_LOWIPL; /* XXX */ struct idrom idrom; -/* locore callback-vector setup */ -extern void mips_vector_init __P((void)); - extern struct user *proc0paddr; +extern u_long bootdev; +extern char edata[], end[]; /* * Do all the stuff that locore normally does before calling main(). @@ -192,8 +197,35 @@ mach_init(x_boothowto, x_bootdev, x_bootname, x_maxmem) u_long first, last; caddr_t kernend, v; vsize_t size; - extern u_long bootdev; - extern char edata[], end[]; + struct btinfo_magic *bi_magic; + struct btinfo_bootarg *bi_arg; +#ifdef DDB + struct btinfo_symtab *bi_sym; + int nsym = 0; + char *ssym, *esym; +#endif + + /* clear the BSS segment */ + bzero(edata, end - edata); + + bootinfo = (char *)BOOTINFO_ADDR; /* XXX */ + bi_magic = lookup_bootinfo(BTINFO_MAGIC); + if (bi_magic && bi_magic->magic == BOOTINFO_MAGIC) { + bi_arg = lookup_bootinfo(BTINFO_BOOTARG); + if (bi_arg) { + x_boothowto = bi_arg->howto; + x_bootdev = bi_arg->bootdev; + x_maxmem = bi_arg->maxmem; + } +#ifdef DDB + bi_sym = lookup_bootinfo(BTINFO_SYMTAB); + if (bi_sym) { + nsym = bi_sym->nsym; + ssym = (void *)bi_sym->ssym; + esym = (void *)bi_sym->esym; + } +#endif + } /* * Save parameters into kernel work area. @@ -202,9 +234,10 @@ mach_init(x_boothowto, x_bootdev, x_bootname, x_maxmem) *(int *)(MIPS_PHYS_TO_KSEG1(MACH_BOOTDEV_ADDR)) = x_bootdev; *(int *)(MIPS_PHYS_TO_KSEG1(MACH_BOOTSW_ADDR)) = x_boothowto; - /* clear the BSS segment */ - kernend = (caddr_t)mips_round_page(end); - bzero(edata, kernend - edata); + if (nsym) + kernend = (caddr_t)mips_round_page(esym); + else + kernend = (caddr_t)mips_round_page(end); /* * Set the VM page size. @@ -235,6 +268,8 @@ mach_init(x_boothowto, x_bootdev, x_bootname, x_maxmem) * Initialize machine-dependent DDB commands, in case of early panic. */ db_machine_init(); + if (nsym) + ddb_init(esym - ssym, ssym, esym); #endif boothowto &= ~RB_ASKNAME; /* for lack of cn_getc */ @@ -456,6 +491,32 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) /* NOTREACHED */ } +/* + * lookup_bootinfo: + * 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; /* diff --git a/sys/arch/newsmips/stand/boot/Makefile b/sys/arch/newsmips/stand/boot/Makefile index b5850608f10..e2966635f9c 100644 --- a/sys/arch/newsmips/stand/boot/Makefile +++ b/sys/arch/newsmips/stand/boot/Makefile @@ -1,9 +1,9 @@ -# $NetBSD: Makefile,v 1.2 1999/12/17 07:40:10 tsubai Exp $ +# $NetBSD: Makefile,v 1.3 1999/12/18 08:02:05 tsubai Exp $ S= ${.CURDIR}/../../../.. PROG= boot -SRCS= locore.S boot.c devopen.c +SRCS= locore.S boot.c bootinfo.c devopen.c MKMAN= no STRIPFLAG= BINMODE= 444 diff --git a/sys/arch/newsmips/stand/boot/boot.c b/sys/arch/newsmips/stand/boot/boot.c index f74a0c1a428..b2c652ddc81 100644 --- a/sys/arch/newsmips/stand/boot/boot.c +++ b/sys/arch/newsmips/stand/boot/boot.c @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.1 1999/07/08 11:48:05 tsubai Exp $ */ +/* $NetBSD: boot.c,v 1.2 1999/12/18 08:02:05 tsubai Exp $ */ /*- * Copyright (C) 1999 Tsubai Masanari. All rights reserved. @@ -30,6 +30,7 @@ #include <lib/libsa/stand.h> #include <lib/libsa/loadfile.h> +#include <machine/bootinfo.h> #include <machine/romcall.h> void flushicache __P((void *, int)); @@ -55,6 +56,7 @@ boot(a0, a1, a2, a3, a4, a5) u_long marks[MARK_MAX]; char devname[32], file[32]; void (*entry)(); + struct btinfo_symtab bi_sym; /* Clear BSS. */ bzero(_edata, _end - _edata); @@ -62,6 +64,8 @@ boot(a0, a1, a2, a3, a4, a5) printf("\n"); printf("NetBSD/newsmips Secondary Boot\n"); + bi_init(BOOTINFO_ADDR); + /* bootname is "/boot" by default. */ if (netbsd == NULL || strcmp(netbsd, "/boot") == 0) netbsd = ""; @@ -106,6 +110,11 @@ boot(a0, a1, a2, a3, a4, a5) DPRINTF("ssym = 0x%x\n", (int)marks[MARK_SYM]); DPRINTF("esym = 0x%x\n", (int)marks[MARK_END]); + bi_sym.nsym = marks[MARK_NSYM]; + bi_sym.ssym = marks[MARK_SYM]; + bi_sym.esym = marks[MARK_END]; + bi_add(&bi_sym, BTINFO_SYMTAB, sizeof(bi_sym)); + entry = (void *)marks[MARK_ENTRY]; flushicache(entry, marks[MARK_SYM] - marks[MARK_ENTRY]); diff --git a/sys/arch/newsmips/stand/boot/bootinfo.c b/sys/arch/newsmips/stand/boot/bootinfo.c new file mode 100644 index 00000000000..dc22c170377 --- /dev/null +++ b/sys/arch/newsmips/stand/boot/bootinfo.c @@ -0,0 +1,83 @@ +/* $NetBSD: bootinfo.c,v 1.1 1999/12/18 08:02:05 tsubai Exp $ */ + +/*- + * Copyright (c) 1999 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jonathan Stone, Michael Hitch and Simon Burge. + * + * 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 by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +#include <lib/libsa/stand.h> +#include <lib/libkern/libkern.h> + +#include <machine/bootinfo.h> + +static char *bootinfo = NULL; +static char *bi_next; +static int bi_size; + +void +bi_init(addr) + paddr_t addr; +{ + struct btinfo_common *bi; + struct btinfo_magic bi_magic; + + bootinfo = (char *)addr; + bi = (struct btinfo_common *)bootinfo; + bi->next = bi->type = 0; + bi_next = bootinfo; + bi_size = 0; + + bi_magic.magic = BOOTINFO_MAGIC; + bi_add(&bi_magic, BTINFO_MAGIC, sizeof(bi_magic)); +} + +void +bi_add(new, type, size) + void *new; + int type, size; +{ + struct btinfo_common *bi; + + if (bi_size + size > BOOTINFO_SIZE) + return; /* XXX error? */ + + bi = new; + bi->next = size; + bi->type = type; + bcopy(new, bi_next, size); + bi_next += size; + + bi = (struct btinfo_common *)bi_next; + bi->next = bi->type = 0; +} |
