Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc/stand Add bootinfo struct to pass symtab argu...
details: https://anonhg.NetBSD.org/src/rev/81e15cf07bcb
branches: trunk
changeset: 472475:81e15cf07bcb
user: christos <christos%NetBSD.org@localhost>
date: Fri Apr 30 09:29:40 1999 +0000
description:
Add bootinfo struct to pass symtab arguments.
XXX: This does not work with ELF yet, but I don't understand why...
diffstat:
sys/arch/sparc/stand/boot/Makefile | 4 +-
sys/arch/sparc/stand/boot/boot.c | 109 +++++----------------------------
sys/arch/sparc/stand/boot/bootinfo.c | 95 +++++++++++++++++++++++++++++
sys/arch/sparc/stand/boot/bootinfo.h | 42 +++++++++++++
sys/arch/sparc/stand/boot/version | 6 +-
sys/arch/sparc/stand/common/promdev.h | 3 +-
6 files changed, 161 insertions(+), 98 deletions(-)
diffs (truncated from 337 to 300 lines):
diff -r 0b31985cd82f -r 81e15cf07bcb sys/arch/sparc/stand/boot/Makefile
--- a/sys/arch/sparc/stand/boot/Makefile Fri Apr 30 09:26:16 1999 +0000
+++ b/sys/arch/sparc/stand/boot/Makefile Fri Apr 30 09:29:40 1999 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.12 1999/04/28 15:22:25 christos Exp $
+# $NetBSD: Makefile,v 1.13 1999/04/30 09:29:40 christos Exp $
STRIPFLAG=
PROG= boot
-PROGSOURCE= boot.c net.c netif_sun.c conf.c openfirm.c
+PROGSOURCE= boot.c net.c netif_sun.c conf.c openfirm.c bootinfo.c
FILES= boot.net
NEWVERSWHAT= "Secondary Boot"
CLEANFILES+= vers.c vers.o boot.net
diff -r 0b31985cd82f -r 81e15cf07bcb sys/arch/sparc/stand/boot/boot.c
--- a/sys/arch/sparc/stand/boot/boot.c Fri Apr 30 09:26:16 1999 +0000
+++ b/sys/arch/sparc/stand/boot/boot.c Fri Apr 30 09:29:40 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: boot.c,v 1.5 1999/04/28 15:22:25 christos Exp $ */
+/* $NetBSD: boot.c,v 1.6 1999/04/30 09:29:40 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1990, 1993
@@ -45,6 +45,8 @@
#include <machine/promlib.h>
#include <sparc/stand/common/promdev.h>
+#include "bootinfo.h"
+
static int bootoptions __P((char *));
#if 0
static void promsyms __P((int, struct exec *));
@@ -117,7 +119,8 @@
int io, i;
char *kernel;
int how;
- u_long marks[MARK_MAX];
+ u_long marks[MARK_MAX], bootinfo;
+ struct btinfo_symtab bi_sym;
void *arg;
prom_init();
@@ -184,99 +187,21 @@
marks[MARK_END] = (((u_long)marks[MARK_END] + sizeof(int) - 1)) &
(-sizeof(int));
- /*
- * XXX: Fix me properly (struct bootinfo)
- */
+ arg = (prom_version() == PROM_OLDMON) ? PROM_LOADADDR : romp;
+#if 0
+ /* Old style cruft; works only with a.out */
marks[MARK_END] |= 0xf0000000;
- arg = (prom_version() == PROM_OLDMON) ? PROM_LOADADDR : romp;
-printf("entry = 0x%lx, arg = 0x%lx, end = 0x%lx\n", marks[MARK_ENTRY], (u_long)arg, marks[MARK_END]);
(*(entry_t)marks[MARK_ENTRY])(arg, 0, 0, 0, marks[MARK_END],
DDB_MAGIC1);
+#else
+ /* Should work with both a.out and ELF, but somehow ELF is busted */
+ bootinfo = bi_init(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_t)marks[MARK_ENTRY])(arg, 0, 0, 0, bootinfo, DDB_MAGIC2);
+#endif
_rtt();
}
-
-#if 0
-struct syms {
- u_int32_t value;
- u_int32_t index;
-};
-
-static void
-sort(syms, n)
- struct syms *syms;
- int n;
-{
- register struct syms *sj;
- register int i, j, k;
- register u_int32_t value, index;
-
- /* Insertion sort. This is O(n^2), but so what? */
- for (i = 1; i < n; i++) {
- /* save i'th entry */
- value = syms[i].value;
- index = syms[i].index;
- /* find j such that i'th entry goes before j'th */
- for (j = 0, sj = syms; j < i; j++, sj++)
- if (value < sj->value)
- break;
- /* slide up any additional entries */
- for (k = 0; k < (i - j); k++) {
- sj[k+1].value = sj[k].value;
- sj[k+1].index = sj[k].index;
- }
- sj->value = value;
- sj->index = index;
- }
-}
-
-void
-promsyms(fd, hp)
- int fd;
- struct exec *hp;
-{
- int i, n, strtablen;
- char *str, *p, *cp, buf[128];
- struct syms *syms;
-
- lseek(fd, sizeof(*hp)+hp->a_text+hp->a_data, SEEK_SET);
- n = hp->a_syms/sizeof(struct nlist);
- if (n == 0)
- return;
- syms = (struct syms *)alloc(n * sizeof(struct syms));
-
- printf("+[%x+", hp->a_syms);
- for (i = 0; i < n; i++) {
- struct nlist nlist;
-
- if (read(fd, &nlist, sizeof(nlist)) != sizeof(nlist)) {
- printf("promsyms: read failed\n");
- return;
- }
- syms[i].value = nlist.n_value;
- syms[i].index = nlist.n_un.n_strx - sizeof(strtablen);
- }
-
- sort(syms, n);
-
- if (read(fd, &strtablen, sizeof(strtablen)) != sizeof(strtablen)) {
- printf("promsym: read failed (strtablen)\n");
- return;
- }
- if (strtablen < sizeof(strtablen)) {
- printf("promsym: string table corrupted\n");
- return;
- }
- strtablen -= sizeof(strtablen);
- str = (char *)alloc(strtablen);
-
- printf("%x]", strtablen);
- if (read(fd, str, strtablen) != strtablen) {
- printf("promsym: read failed (strtab)\n");
- return;
- }
-
- sprintf(buf, "%x %d %x loadsyms", syms, n, str);
- prom_interpret(buf);
-}
-#endif
diff -r 0b31985cd82f -r 81e15cf07bcb sys/arch/sparc/stand/boot/bootinfo.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sparc/stand/boot/bootinfo.c Fri Apr 30 09:29:40 1999 +0000
@@ -0,0 +1,95 @@
+/* $NetBSD: bootinfo.c,v 1.1 1999/04/30 09:29:40 christos 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 <sys/param.h>
+#include <machine/types.h>
+#include <lib/libsa/stand.h>
+#include <lib/libkern/libkern.h>
+
+#include "bootinfo.h"
+
+static char *bootinfo = NULL;
+static char *bi_next;
+static int bi_size;
+
+u_long
+bi_init(addr)
+ u_long addr;
+{
+ struct btinfo_common *bi;
+ struct btinfo_magic bi_magic;
+ u_long *endp;
+
+ endp = (u_long *)ALIGN(addr);
+ /*
+ * For the first word we load our end address,
+ * giving enough space for the bootinfo structure.
+ */
+ endp[0] = (u_long)((char *)endp + BOOTINFO_SIZE);
+ bootinfo = (char *)ALIGN(&endp[2]);
+ endp[1] = (u_long)bootinfo;
+ 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));
+ return (u_long) endp;
+}
+
+void
+bi_add(new, type, size)
+ void *new;
+ int type;
+ size_t size;
+{
+ struct btinfo_common *bi;
+
+ if (bi_size + size > BOOTINFO_SIZE)
+ return; /* XXX error? */
+
+ bi = new;
+ bi->next = ALIGN(size);
+ bi->type = type;
+ memcpy(bi_next, new, size);
+ bi_next += ALIGN(size);
+
+ bi = (struct btinfo_common *)bi_next;
+ bi->next = bi->type = 0;
+}
diff -r 0b31985cd82f -r 81e15cf07bcb sys/arch/sparc/stand/boot/bootinfo.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sparc/stand/boot/bootinfo.h Fri Apr 30 09:29:40 1999 +0000
@@ -0,0 +1,42 @@
+/* $NetBSD: bootinfo.h,v 1.1 1999/04/30 09:29:40 christos 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 <machine/bootinfo.h>
+
+u_long bi_init __P((u_long));
+void bi_add __P((void *, int, size_t));
diff -r 0b31985cd82f -r 81e15cf07bcb sys/arch/sparc/stand/boot/version
Home |
Main Index |
Thread Index |
Old Index