summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2002-10-24 19:27:17 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2002-10-24 19:27:17 +0000
commit510e5df86100444fda56ed35121c152c835e25de (patch)
tree2a8037976c4a1ff2372df2a7d5652823d8c89034 /sys
parentb727e7d5d9c39307b7729cd7debb94414dc16874 (diff)
use loadfile
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/hppa/include/loadfile_machdep.h82
-rw-r--r--sys/arch/hppa/stand/boot/Makefile5
-rw-r--r--sys/arch/hppa/stand/boot/conf.c9
-rw-r--r--sys/arch/hppa/stand/boot/exec.c (renamed from sys/arch/hppa/stand/libsa/exec_som.c)75
-rw-r--r--sys/arch/hppa/stand/libsa/Makefile6
-rw-r--r--sys/arch/hppa/stand/libsa/exec_hppa.c90
6 files changed, 111 insertions, 156 deletions
diff --git a/sys/arch/hppa/include/loadfile_machdep.h b/sys/arch/hppa/include/loadfile_machdep.h
new file mode 100644
index 00000000000..631ebcd5615
--- /dev/null
+++ b/sys/arch/hppa/include/loadfile_machdep.h
@@ -0,0 +1,82 @@
+/* $OpenBSD: loadfile_machdep.h,v 1.1 2002/10/24 19:27:15 mickey Exp $ */
+
+/*-
+ * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas and Jason R. Thorpe.
+ *
+ * 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.
+ */
+
+#ifndef _HPPA_LOADFILE_MACHDEP_H_
+#define _HPPA_LOADFILE_MACHDEP_H_
+
+#define BOOT_ELF
+
+#define LOAD_KERNEL LOAD_ALL
+#define COUNT_KERNEL COUNT_ALL
+
+#ifdef _STANDALONE
+
+#define LOADADDR(a) ((a) + offset)
+#define ALIGNENTRY(a) 0
+#define READ(f, b, c) pread((f), (void *)LOADADDR(b), (c))
+#define BCOPY(s, d, c) vpbcopy((s), (void *)LOADADDR(d), (c))
+#define BZERO(d, c) pbzero((void *)LOADADDR(d), (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 vpbcopy bcopy
+#define pbzero bzero
+#define pread read
+
+#else
+
+#define LOADADDR(a) (((u_long)(a)) + offset)
+#define ALIGNENTRY(a) ((u_long)(a))
+#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) warn a
+#define PROGRESS(a) /* nothing */
+#define ALLOC(a) malloc(a)
+#define FREE(a, b) free(a)
+
+ssize_t vread __P((int, u_long, u_long *, size_t));
+void vcopy __P((u_long, u_long, u_long *, size_t));
+void vzero __P((u_long, u_long *, size_t));
+
+#endif
+#endif /* ! _HPPA_LOADFILE_MACHDEP_H_ */
diff --git a/sys/arch/hppa/stand/boot/Makefile b/sys/arch/hppa/stand/boot/Makefile
index bc7d21b76e5..8ea8d29d939 100644
--- a/sys/arch/hppa/stand/boot/Makefile
+++ b/sys/arch/hppa/stand/boot/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.10 2000/05/31 19:56:51 mickey Exp $
+# $OpenBSD: Makefile,v 1.11 2002/10/24 19:27:15 mickey Exp $
MAN= boot.8
MANSUBDIR=/hppa
@@ -8,11 +8,12 @@ CLEANFILES+= boot.gdb boot.map boot.lif bsd
.if ${MACHINE} == "hppa"
PROG= boot
-SRCS= srt0.S boot.c cmd.c vars.c bootarg.c conf.c
+SRCS= srt0.S exec.c boot.c cmd.c vars.c bootarg.c conf.c
LD?= ld
LDFLAGS+=-Bstatic -nostartfiles -nostdlib -N -Ttext $(LINKADDR)
LDFLAGS+=-T ${.CURDIR}/ld.script -Map boot.map
SIZE?= size
+STRIP?= strip
SADIR= ${.CURDIR}/..
LDADD= ${LIBSA} ${LIBZ} ${LIBKERN}
diff --git a/sys/arch/hppa/stand/boot/conf.c b/sys/arch/hppa/stand/boot/conf.c
index 73d54584a9f..394ff1185b5 100644
--- a/sys/arch/hppa/stand/boot/conf.c
+++ b/sys/arch/hppa/stand/boot/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.14 2002/03/02 20:26:50 mickey Exp $ */
+/* $OpenBSD: conf.c,v 1.15 2002/10/24 19:27:15 mickey Exp $ */
/*
* Copyright (c) 1998 Michael Shalayeff
@@ -34,18 +34,11 @@
#include <libsa.h>
#include <lib/libsa/ufs.h>
#include <lib/libsa/cd9660.h>
-#include <lib/libsa/exec.h>
#include <dev/cons.h>
const char version[] = "0.7";
int debug = 0;
-const struct x_sw execsw[] = {
- { "elf", elf_probe, elf_load, elf_ldsym },
-/* { "som", som_probe, som_load, som_ldsym }, */
- { "" , NULL, NULL, NULL },
-};
-
struct fs_ops file_system[] = {
{ lif_open, lif_close, lif_read, lif_write, lif_seek,
lif_stat, lif_readdir },
diff --git a/sys/arch/hppa/stand/libsa/exec_som.c b/sys/arch/hppa/stand/boot/exec.c
index a0f29fa8dff..10ce60d00b3 100644
--- a/sys/arch/hppa/stand/libsa/exec_som.c
+++ b/sys/arch/hppa/stand/boot/exec.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: exec_som.c,v 1.1 1999/12/23 04:10:30 mickey Exp $ */
+/* $OpenBSD: exec.c,v 1.1 2002/10/24 19:27:15 mickey Exp $ */
/*
- * Copyright (c) 1999 Michael Shalayeff
+ * Copyright (c) 2002 Michael Shalayeff
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,65 +31,34 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-
#include <sys/param.h>
+#include <machine/pdc.h>
#include "libsa.h"
-#include <machine/exec.h>
-#include <lib/libsa/exec.h>
-
-int
-som_probe(fd, hdr)
- int fd;
- union x_header *hdr;
-{
- return !SOM_BADMAGIC(&hdr->x_som);
-}
+#include <lib/libsa/loadfile.h>
+#include <stand/boot/bootarg.h>
+#include "dev_hppa.h"
+typedef void (*startfuncp) __P((int, int, int, int, int, int, caddr_t))
+ __attribute__ ((noreturn));
-int
-som_load(fd, xp)
- int fd;
- register struct x_param *xp;
+void
+exec(char *file, void *addr, int howto)
{
- register struct som_filehdr *xf = &xp->xp_hdr->x_som;
- struct som_exec_aux x;
+ u_long marks[MARK_MAX];
- if (lseek(fd, xf->aux_loc, SEEK_SET) < 0 ||
- read (fd, &x, sizeof(x)) != sizeof(x)) {
- if (!errno)
- errno = EIO;
- return -1;
- }
+ marks[MARK_START] = (u_long)addr;
- xp->xp_entry = x.a_entry;
+ if (loadfile(file, marks, LOAD_KERNEL))
+ return;
- xp->text.size = hppa_round_page(x.a_tsize);
- xp->data.size = hppa_round_page(x.a_dsize);
- xp->bss.size = x.a_bsize;
- xp->sym.size = xf->sym_total * sizeof(struct som_sym);
- xp->str.size = xf->strings_size;
+ marks[MARK_END] = ALIGN(marks[MARK_END] - (u_long)addr);
+ fcacheall();
- xp->text.foff = x.a_tfile;
- xp->data.foff = x.a_dfile;
- xp->bss.foff = 0;
- if (xf->sym_total) {
- xp->sym.foff = xf->sym_loc;
- xp->str.foff = xf->strings_loc;
- }
+ __asm("mtctl %r0, %cr17");
+ __asm("mtctl %r0, %cr17");
+ /* stack and the gung is ok at this point, so, no need for asm setup */
+ (*(startfuncp)(marks[MARK_ENTRY]))((int)pdc, howto, bootdev,
+ marks[MARK_END], BOOTARG_APIVER, BOOTARG_LEN, (caddr_t)BOOTARG_OFF);
- xp->text.addr = x.a_tmem;
- xp->data.addr = x.a_dmem;
- xp->bss.addr = xp->data.addr + x.a_dsize;
- xp->sym.addr = xp->bss.addr + xp->bss.size;
- xp->str.addr = xp->sym.addr + xp->sym.size;
-
- return 0;
-}
-
-int
-som_ldsym(fd, xp)
- int fd;
- register struct x_param *xp;
-{
- return -1;
+ /* not reached */
}
diff --git a/sys/arch/hppa/stand/libsa/Makefile b/sys/arch/hppa/stand/libsa/Makefile
index 31d1a25902e..e6cfacac862 100644
--- a/sys/arch/hppa/stand/libsa/Makefile
+++ b/sys/arch/hppa/stand/libsa/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.9 2002/03/02 09:36:43 miod Exp $
+# $OpenBSD: Makefile,v 1.10 2002/10/24 19:27:16 mickey Exp $
.include "${.CURDIR}/../Makefile.inc"
@@ -16,13 +16,13 @@ NOPIC=nopic
#AS+= -a
# hppa stuff
-SRCS= machdep.c pdc.c itecons.c dev_hppa.c exec_hppa.c time.c \
+SRCS= machdep.c pdc.c itecons.c dev_hppa.c time.c \
ct.c dk.c lf.c lif.c cmd_hppa.c
# stand routines
SRCS+= alloc.c exit.c getfile.c gets.c globals.c strcmp.c strlen.c \
strncmp.c memcmp.c memcpy.c printf.c strerror.c strncpy.c \
- strtol.c strchr.c ctime.c exec.new.c exec_elf.c exec_som.c
+ strtol.c strchr.c ctime.c loadfile.c
# io routines
SRCS+= close.c closeall.c dev.c disklabel.c dkcksum.c fstat.c ioctl.c lseek.c \
diff --git a/sys/arch/hppa/stand/libsa/exec_hppa.c b/sys/arch/hppa/stand/libsa/exec_hppa.c
deleted file mode 100644
index 9b28dad76bf..00000000000
--- a/sys/arch/hppa/stand/libsa/exec_hppa.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* $OpenBSD: exec_hppa.c,v 1.8 2002/03/14 01:26:32 millert Exp $ */
-
-/*
- * Copyright (c) 1998 Michael Shalayeff
- * 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 by Michael Shalayeff.
- * This product includes software developed by Tobias Weingartner.
- * 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 AUTHORS ``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 REGENTS 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 <sys/exec.h>
-#include <sys/reboot.h>
-#include <dev/cons.h>
-#include <stand/boot/bootarg.h>
-#include <sys/disklabel.h>
-#include "libsa.h"
-#include <lib/libsa/exec.h>
-
-#include <machine/pdc.h>
-#include "dev_hppa.h"
-
-typedef void (*startfuncp)(int, int, int, int, int, int, caddr_t)
- __attribute__ ((noreturn));
-
-void
-machdep_exec(xp, howto, loadaddr)
- struct x_param *xp;
- int howto;
- void *loadaddr;
-{
-#ifdef EXEC_DEBUG
- extern int debug;
- register int i;
-#endif
- size_t ac = BOOTARG_LEN;
- caddr_t av = (caddr_t)BOOTARG_OFF;
-#ifdef notyet
- makebootargs(av, &ac);
-#endif
-
-#ifdef EXEC_DEBUG
- if (debug) {
- printf("ep=0x%x [", xp->xp_entry);
- for (i = 0; i < 10240; i++) {
- if (!(i % 8)) {
- printf("\b\n%p:", &((u_int *)xp->xp_entry)[i]);
- if (getchar() != ' ')
- break;
- }
- printf("%x,", ((int *)xp->xp_entry)[i]);
- }
- printf("\b\b ]\n");
- }
-#endif
-
- fcacheall();
-
- __asm("mtctl %r0, %cr17");
- __asm("mtctl %r0, %cr17");
- /* stack and the gung is ok at this point, so, no need for asm setup */
- (*(startfuncp)(xp->xp_entry)) ((int)pdc, howto, bootdev, xp->xp_end,
- BOOTARG_APIVER, ac, av);
- /* not reached */
-}