Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/newsmips Introduce bootinfo.
details: https://anonhg.NetBSD.org/src/rev/6213c7a7492e
branches: trunk
changeset: 479694:6213c7a7492e
user: tsubai <tsubai%NetBSD.org@localhost>
date: Sat Dec 18 08:01:25 1999 +0000
description:
Introduce bootinfo.
diffstat:
sys/arch/newsmips/include/bootinfo.h | 88 +++++++++++++++++++++++++++++++++
sys/arch/newsmips/newsmips/machdep.c | 83 +++++++++++++++++++++++++++----
sys/arch/newsmips/stand/boot/Makefile | 4 +-
sys/arch/newsmips/stand/boot/boot.c | 11 +++-
sys/arch/newsmips/stand/boot/bootinfo.c | 83 +++++++++++++++++++++++++++++++
5 files changed, 255 insertions(+), 14 deletions(-)
diffs (truncated from 395 to 300 lines):
diff -r 0ab0e3800569 -r 6213c7a7492e sys/arch/newsmips/include/bootinfo.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/newsmips/include/bootinfo.h Sat Dec 18 08:01:25 1999 +0000
@@ -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 -r 0ab0e3800569 -r 6213c7a7492e sys/arch/newsmips/newsmips/machdep.c
--- a/sys/arch/newsmips/newsmips/machdep.c Sat Dec 18 07:57:03 1999 +0000
+++ b/sys/arch/newsmips/newsmips/machdep.c Sat Dec 18 08:01:25 1999 +0000
@@ -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 @@
#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 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 @@
* 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 @@
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 @@
*(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 @@
* 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 @@
/* 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 -r 0ab0e3800569 -r 6213c7a7492e sys/arch/newsmips/stand/boot/Makefile
--- a/sys/arch/newsmips/stand/boot/Makefile Sat Dec 18 07:57:03 1999 +0000
+++ b/sys/arch/newsmips/stand/boot/Makefile Sat Dec 18 08:01:25 1999 +0000
@@ -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 -r 0ab0e3800569 -r 6213c7a7492e sys/arch/newsmips/stand/boot/boot.c
--- a/sys/arch/newsmips/stand/boot/boot.c Sat Dec 18 07:57:03 1999 +0000
+++ b/sys/arch/newsmips/stand/boot/boot.c Sat Dec 18 08:01:25 1999 +0000
@@ -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 @@
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 @@
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 @@
DPRINTF("ssym = 0x%x\n", (int)marks[MARK_SYM]);
DPRINTF("esym = 0x%x\n", (int)marks[MARK_END]);
Home |
Main Index |
Thread Index |
Old Index