summaryrefslogtreecommitdiff
path: root/sys/arch/mvme88k
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/mvme88k')
-rw-r--r--sys/arch/mvme88k/include/loadfile_machdep.h56
-rw-r--r--sys/arch/mvme88k/stand/bootsd/version.c8
-rw-r--r--sys/arch/mvme88k/stand/bootst/version.c8
-rw-r--r--sys/arch/mvme88k/stand/libsa/Makefile13
-rw-r--r--sys/arch/mvme88k/stand/libsa/exec_mvme.c163
-rw-r--r--sys/arch/mvme88k/stand/netboot/version.c8
-rw-r--r--sys/arch/mvme88k/stand/tftpboot/version.c9
7 files changed, 108 insertions, 157 deletions
diff --git a/sys/arch/mvme88k/include/loadfile_machdep.h b/sys/arch/mvme88k/include/loadfile_machdep.h
new file mode 100644
index 00000000000..0dda8857e11
--- /dev/null
+++ b/sys/arch/mvme88k/include/loadfile_machdep.h
@@ -0,0 +1,56 @@
+/* $OpenBSD: loadfile_machdep.h,v 1.1 2008/03/31 22:14:41 miod Exp $ */
+
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * 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.
+ */
+
+#define BOOT_AOUT
+#define BOOT_ELF
+
+#define LOAD_KERNEL LOAD_ALL
+#define COUNT_KERNEL COUNT_ALL
+
+#define LOADADDR(a) (((u_long)(a)) + offset)
+#define ALIGNENTRY(a) ((u_long)(a) & ~0x0fff)
+#define READ(f, b, c) read((f), (void *)LOADADDR(b), (c))
+#define BCOPY(s, d, c) memcpy((void *)LOADADDR(d), (void *)(s), (c))
+#define BZERO(d, c) memset((void *)LOADADDR(d), 0, (c))
+#define WARN(a) (void)(printf a, \
+ printf((errno ? ": %s\n" : "\n"), \
+ strerror(errno)))
+#define PROGRESS(a) (void) printf a
+#define ALLOC(a) alloc(a)
+#define FREE(a, b) free(a, b)
+#define OKMAGIC(a) ((a) == ZMAGIC)
diff --git a/sys/arch/mvme88k/stand/bootsd/version.c b/sys/arch/mvme88k/stand/bootsd/version.c
index c69d27c0270..96a409cad51 100644
--- a/sys/arch/mvme88k/stand/bootsd/version.c
+++ b/sys/arch/mvme88k/stand/bootsd/version.c
@@ -1,3 +1,7 @@
-/* $OpenBSD: version.c,v 1.3 2006/05/16 22:52:53 miod Exp $ */
+/* $OpenBSD: version.c,v 1.4 2008/03/31 22:14:43 miod Exp $ */
-char *version = "1.3";
+/*
+ * 1.4 kernel loaded with loadfile, a.out and ELF formats
+ * 1.3 rewritten startup code and general cleanup
+ */
+char *version = "1.4";
diff --git a/sys/arch/mvme88k/stand/bootst/version.c b/sys/arch/mvme88k/stand/bootst/version.c
index 5962a07683f..96a409cad51 100644
--- a/sys/arch/mvme88k/stand/bootst/version.c
+++ b/sys/arch/mvme88k/stand/bootst/version.c
@@ -1,3 +1,7 @@
-/* $OpenBSD: version.c,v 1.3 2006/05/16 22:52:55 miod Exp $ */
+/* $OpenBSD: version.c,v 1.4 2008/03/31 22:14:43 miod Exp $ */
-char *version = "1.3";
+/*
+ * 1.4 kernel loaded with loadfile, a.out and ELF formats
+ * 1.3 rewritten startup code and general cleanup
+ */
+char *version = "1.4";
diff --git a/sys/arch/mvme88k/stand/libsa/Makefile b/sys/arch/mvme88k/stand/libsa/Makefile
index 46ea4b9698c..3e805c080ae 100644
--- a/sys/arch/mvme88k/stand/libsa/Makefile
+++ b/sys/arch/mvme88k/stand/libsa/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.10 2008/03/31 22:11:37 miod Exp $
+# $OpenBSD: Makefile,v 1.11 2008/03/31 22:14:43 miod Exp $
LIB=sa
@@ -19,6 +19,7 @@ SRCS+= alloc.c memcpy.c exit.c getfile.c gets.c globals.c \
ufs.c cread.c
SRCS+= arp.c ether.c in_cksum.c net.c netif.c rpc.c nfs.c \
rarp.c bootparam.c
+SRCS+= loadfile.c
.PATH: ${S}/lib/libkern/arch/m88k ${S}/lib/libkern
SRCS+= ashrdi3.c bzero.c
@@ -29,7 +30,7 @@ SRCS+= ashrdi3.c bzero.c
#DEFS= -DCOMPAT_UFS
DEFS= -D__INTERNAL_LIBSA_CREAD -D_STANDALONE
#DEFS+=-DNETIF_DEBUG
-INCL= -I${.CURDIR} -I${.CURDIR}/../libbug -I${S}/lib/libsa -I${S}
+INCL= -I${.CURDIR} -I${.CURDIR}/../libbug -I${S}/lib/libsa -I${S} -I.
CFLAGS+= ${XCFLAGS} ${COPTS} ${DEFS} ${DBG} ${INCL}
all: libsa.a
@@ -37,3 +38,11 @@ all: libsa.a
install:
.include <bsd.lib.mk>
+
+.if !make(obj)
+.BEGIN:
+ @([ -h machine ] || ln -s ${.CURDIR}/../../../${MACHINE}/include machine)
+ @([ -h m88k ] || ln -s ${.CURDIR}/../../../m88k/include m88k)
+.NOPATH: machine m88k
+CLEANFILES+= machine m88k
+.endif
diff --git a/sys/arch/mvme88k/stand/libsa/exec_mvme.c b/sys/arch/mvme88k/stand/libsa/exec_mvme.c
index bc2a787d64e..21996f68be0 100644
--- a/sys/arch/mvme88k/stand/libsa/exec_mvme.c
+++ b/sys/arch/mvme88k/stand/libsa/exec_mvme.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec_mvme.c,v 1.13 2006/05/17 06:21:34 miod Exp $ */
+/* $OpenBSD: exec_mvme.c,v 1.14 2008/03/31 22:14:43 miod Exp $ */
/*-
@@ -35,22 +35,11 @@
#include <sys/param.h>
#include <sys/reboot.h>
#include <machine/prom.h>
-#include <a.out.h>
#include "stand.h"
#include "libsa.h"
-struct kernel {
- void *entry;
- void *symtab;
- void *esym;
- int bflags;
- int bdev;
- char *kname;
- void *smini;
- void *emini;
- u_int end_loaded;
-} kernel;
+#include <lib/libsa/loadfile.h>
/*ARGSUSED*/
void
@@ -58,153 +47,33 @@ exec_mvme(file, flag)
char *file;
int flag;
{
- char *loadaddr;
- int io;
- struct exec x;
- int cc, magic;
- void (*entry)();
- char *cp;
- int *ip;
+ u_long marks[MARK_MAX];
+ int options;
+ int rc;
+ void (*entry)(int, int, int, int, int, int, int);
int bootdev;
struct mvmeprom_brdid *id;
id = mvmeprom_brdid();
+ options = LOAD_KERNEL | COUNT_KERNEL;
+ if ((flag & RB_NOSYM) != 0)
+ options &= ~(LOAD_SYM | COUNT_SYM);
-#ifdef DEBUG
- printf("exec_mvme: file=%s flag=0x%x cputyp=%x\n", file, flag, id->model);
-#endif
-
- io = open(file, 0);
- if (io < 0)
+ marks[MARK_START] = 0;
+ rc = loadfile(file, marks, options);
+ if (rc != 0)
return;
- /*
- * Read in the exec header, and validate it.
- */
- if (read(io, (char *)&x, sizeof(x)) != sizeof(x))
- goto shread;
-
- if (N_BADMAG(x)) {
- errno = EFTYPE;
- goto closeout;
- }
-
- /*
- * note: on the mvme ports, the kernel is linked in such a way that
- * its entry point is the first item in .text, and thus a_entry can
- * be used to determine both the load address and the entry point.
- * (also note that we make use of the fact that the kernel will live
- * in a VA == PA range of memory ... otherwise we would take
- * loadaddr as a parameter and let the kernel relocate itself!)
- *
- * note that ZMAGIC files included the a.out header in the text area
- * so we must mask that off (has no effect on the other formats)
- */
- loadaddr = (void *)(x.a_entry & ~sizeof(x));
-
- cp = loadaddr;
- magic = N_GETMAGIC(x);
- if (magic == ZMAGIC)
- cp += sizeof(x);
- entry = (void (*)())cp;
-
- /*
- * Leave a copy of the exec header before the text.
- * The sun3 kernel uses this to verify that the
- * symbols were loaded by this boot program.
- */
- bcopy(&x, cp - sizeof(x), sizeof(x));
-
- /*
- * Read in the text segment.
- */
- printf("%d", x.a_text);
- cc = x.a_text;
- if (magic == ZMAGIC)
- cc = cc - sizeof(x); /* a.out header part of text in zmagic */
- if (read(io, cp, cc) != cc)
- goto shread;
- cp += cc;
-
- /*
- * NMAGIC may have a gap between text and data.
- */
- if (magic == NMAGIC) {
- register int mask = N_PAGSIZ(x) - 1;
- while ((int)cp & mask)
- *cp++ = 0;
- }
-
- /*
- * Read in the data segment.
- */
- printf("+%d", x.a_data);
- if (read(io, cp, x.a_data) != x.a_data)
- goto shread;
- cp += x.a_data;
-
- /*
- * Zero out the BSS section.
- * (Kernel doesn't care, but do it anyway.)
- */
- printf("+%d", x.a_bss);
- cc = x.a_bss;
- while ((int)cp & 3) {
- *cp++ = 0;
- --cc;
- }
- ip = (int *)cp;
- cp += cc;
- while ((char *)ip < cp)
- *ip++ = 0;
-
- /*
- * Read in the symbol table and strings.
- * (Always set the symtab size word.)
- */
- *ip++ = x.a_syms;
- cp = (char *) ip;
-
- if (x.a_syms > 0 && (flag & RB_NOSYM) == 0) {
-
- /* Symbol table and string table length word. */
- cc = x.a_syms;
- printf("+[%d", cc);
- cc += sizeof(int); /* strtab length too */
- if (read(io, cp, cc) != cc)
- goto shread;
- cp += x.a_syms;
- ip = (int *)cp; /* points to strtab length */
- cp += sizeof(int);
-
- /* String table. Length word includes itself. */
- cc = *ip;
- printf("+%d]", cc);
- cc -= sizeof(int);
- if (cc <= 0)
- goto shread;
- if (read(io, cp, cc) != cc)
- goto shread;
- cp += cc;
- }
- printf("=0x%lx\n", cp - loadaddr);
- close(io);
-
- printf("Start @ 0x%x\n", (int)entry);
+ printf("Start @ 0x%lx\n", marks[MARK_START]);
printf("Controller Address 0x%x\n", bugargs.ctrl_addr);
if (flag & RB_HALT)
_rtt();
bootdev = (bugargs.ctrl_lun << 8) | (bugargs.dev_lun & 0xFF);
+ entry = (void(*)(int, int, int, int, int, int, int))marks[MARK_START];
+ (*entry)(flag, bugargs.ctrl_addr, marks[MARK_END], marks[MARK_SYM],
+ 0, bootdev, id->model);
- (*entry)(flag, bugargs.ctrl_addr, cp, kernel.smini, kernel.emini, bootdev, id->model);
printf("exec: kernel returned!\n");
return;
-
-shread:
- printf("exec: short read\n");
- errno = EIO;
-closeout:
- close(io);
- return;
}
diff --git a/sys/arch/mvme88k/stand/netboot/version.c b/sys/arch/mvme88k/stand/netboot/version.c
index 5962a07683f..96a409cad51 100644
--- a/sys/arch/mvme88k/stand/netboot/version.c
+++ b/sys/arch/mvme88k/stand/netboot/version.c
@@ -1,3 +1,7 @@
-/* $OpenBSD: version.c,v 1.3 2006/05/16 22:52:55 miod Exp $ */
+/* $OpenBSD: version.c,v 1.4 2008/03/31 22:14:43 miod Exp $ */
-char *version = "1.3";
+/*
+ * 1.4 kernel loaded with loadfile, a.out and ELF formats
+ * 1.3 rewritten startup code and general cleanup
+ */
+char *version = "1.4";
diff --git a/sys/arch/mvme88k/stand/tftpboot/version.c b/sys/arch/mvme88k/stand/tftpboot/version.c
index a88e18984ae..1189c587101 100644
--- a/sys/arch/mvme88k/stand/tftpboot/version.c
+++ b/sys/arch/mvme88k/stand/tftpboot/version.c
@@ -1,3 +1,8 @@
-/* $OpenBSD: version.c,v 1.2 2006/05/16 22:52:55 miod Exp $ */
+/* $OpenBSD: version.c,v 1.3 2008/03/31 22:14:43 miod Exp $ */
-char *version = "1.2";
+/*
+ * 1.3 kernel loaded with loadfile, a.out and ELF formats
+ * 1.2 rewritten startup code and general cleanup
+ * 1.1 initial revision
+ */
+char *version = "1.3";