Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/i386/stand use new loadfile
details: https://anonhg.NetBSD.org/src/rev/a649d9c45a6a
branches: trunk
changeset: 472364:a649d9c45a6a
user: christos <christos%NetBSD.org@localhost>
date: Wed Apr 28 09:14:22 1999 +0000
description:
use new loadfile
diffstat:
sys/arch/i386/stand/installboot/Makefile | 8 +-
sys/arch/i386/stand/lib/Makefile | 4 +-
sys/arch/i386/stand/lib/exec.c | 6 +-
sys/arch/i386/stand/lib/loadfile.c | 603 -------------------------------
sys/arch/i386/stand/lib/loadfile.h | 108 -----
5 files changed, 10 insertions(+), 719 deletions(-)
diffs (truncated from 792 to 300 lines):
diff -r ba9057dc8f63 -r a649d9c45a6a sys/arch/i386/stand/installboot/Makefile
--- a/sys/arch/i386/stand/installboot/Makefile Wed Apr 28 09:14:07 1999 +0000
+++ b/sys/arch/i386/stand/installboot/Makefile Wed Apr 28 09:14:22 1999 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.12 1999/03/14 05:50:39 sommerfe Exp $
+# $NetBSD: Makefile,v 1.13 1999/04/28 09:14:22 christos Exp $
# XXX: bsd.own.mk included so LDSTATIC can be overwridden
.include <bsd.own.mk>
@@ -6,14 +6,16 @@
CFLAGS=-g
BINDIR= /usr/mdec
PROG= installboot
-.PATH.c: ${.CURDIR}/../lib
+LIBSA=${.CURDIR}/../../../../lib/libsa
+
+.PATH.c: ${LIBSA}
SRCS= installboot.c bootblks.c getmount.c loadfile.c
MKMAN= no
CPPFLAGS+= -I${.CURDIR}/../lib/crt/bootsect
-CPPFLAGS+= -I${.CURDIR}/../lib
+CPPFLAGS+= -I${LIBSA}
CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes
LDSTATIC?=-static
diff -r ba9057dc8f63 -r a649d9c45a6a sys/arch/i386/stand/lib/Makefile
--- a/sys/arch/i386/stand/lib/Makefile Wed Apr 28 09:14:07 1999 +0000
+++ b/sys/arch/i386/stand/lib/Makefile Wed Apr 28 09:14:22 1999 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.11 1999/03/08 21:44:48 drochner Exp $
+# $NetBSD: Makefile,v 1.12 1999/04/28 09:15:05 christos Exp $
S?= ${.CURDIR}/../../../../
@@ -20,7 +20,7 @@
SRCS+= biosmem.S getextmemx.c biosmemx.S
SRCS+= pread.c menuutils.c parseutils.c
SRCS+= bootinfo.c bootinfo_biosgeom.c bootinfo_memmap.c
-SRCS+= loadfile.c startprog.S netbsd_opts.c panic.c
+SRCS+= startprog.S netbsd_opts.c panic.c
.if (${I386_INCLUDE_DISK} == "yes")
SRCS+= biosdisk.c biosdisk_ll.c bios_disk.S
.endif
diff -r ba9057dc8f63 -r a649d9c45a6a sys/arch/i386/stand/lib/exec.c
--- a/sys/arch/i386/stand/lib/exec.c Wed Apr 28 09:14:07 1999 +0000
+++ b/sys/arch/i386/stand/lib/exec.c Wed Apr 28 09:14:22 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: exec.c,v 1.11 1999/04/14 11:19:23 drochner Exp $ */
+/* $NetBSD: exec.c,v 1.12 1999/04/28 09:15:05 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@@ -133,7 +133,7 @@
* Get the size of the kernel
*/
marks[MARK_START] = loadaddr;
- if ((fd = loadfile(file, marks, COUNT_ALL)) == -1)
+ if ((fd = loadfile(file, marks, COUNT_KERNEL)) == -1)
goto out;
close(fd);
@@ -146,7 +146,7 @@
}
#endif
marks[MARK_START] = loadaddr;
- if ((fd = loadfile(file, marks, LOAD_ALL)) == -1)
+ if ((fd = loadfile(file, marks, LOAD_KERNEL)) == -1)
goto out;
boot_argv[0] = boothowto;
diff -r ba9057dc8f63 -r a649d9c45a6a sys/arch/i386/stand/lib/loadfile.c
--- a/sys/arch/i386/stand/lib/loadfile.c Wed Apr 28 09:14:07 1999 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,603 +0,0 @@
-/* $NetBSD: loadfile.c,v 1.9 1999/04/17 11:18:36 drochner Exp $ */
-
-/*-
- * Copyright (c) 1997 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
- * NASA Ames Research Center and 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.
- */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Ralph Campbell.
- *
- * 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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University 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 REGENTS 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 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.
- *
- * @(#)boot.c 8.1 (Berkeley) 6/10/93
- */
-
-#ifdef _STANDALONE
-#include <lib/libsa/stand.h>
-#include <lib/libkern/libkern.h>
-#else
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <err.h>
-#endif
-
-#include <sys/param.h>
-#include <sys/exec.h>
-
-#include "loadfile.h"
-
-#ifdef BOOT_ECOFF
-#include <sys/exec_ecoff.h>
-static int coff_exec __P((int, struct ecoff_exechdr *, u_long *, int));
-#endif
-#ifdef BOOT_ELF
-#include <sys/exec_elf.h>
-static int elf_exec __P((int, Elf_Ehdr *, u_long *, int));
-#endif
-#ifdef BOOT_AOUT
-#include <sys/exec_aout.h>
-static int aout_exec __P((int, struct exec *, u_long *, int));
-#endif
-
-/*
- * Open 'filename', read in program and and return 0 if ok 1 on error.
- * Fill in marks
- */
-int
-loadfile(fname, marks, flags)
- const char *fname;
- u_long *marks;
- int flags;
-{
- union {
-#ifdef BOOT_ECOFF
- struct ecoff_exechdr coff;
-#endif
-#ifdef BOOT_ELF
- Elf_Ehdr elf;
-#endif
-#ifdef BOOT_AOUT
- struct exec aout;
-#endif
-
- } hdr;
- ssize_t nr;
- int fd, rval;
-
- /* Open the file. */
- if ((fd = open(fname, 0)) < 0) {
- WARN(("open %s", fname ? fname : "<default>"));
- return -1;
- }
-
- /* Read the exec header. */
- if ((nr = read(fd, &hdr, sizeof(hdr))) != sizeof(hdr)) {
- WARN(("read header"));
- goto err;
- }
-
-#ifdef BOOT_ECOFF
- if (!ECOFF_BADMAG(&hdr.coff)) {
- rval = coff_exec(fd, &hdr.coff, marks, flags);
- } else
-#endif
-#ifdef BOOT_ELF
- if (memcmp(Elf_e_ident, hdr.elf.e_ident, Elf_e_siz) == 0) {
- rval = elf_exec(fd, &hdr.elf, marks, flags);
- } else
-#endif
-#ifdef BOOT_AOUT
- if (OKMAGIC(N_GETMAGIC(hdr.aout)) &&
- N_GETMID(hdr.aout) == MID_MACHINE) {
- rval = aout_exec(fd, &hdr.aout, marks, flags);
- } else
-#endif
- {
- rval = 1;
- errno = EFTYPE;
- WARN(("%s", fname ? fname : "<default>"));
- }
-
- if (rval == 0) {
- PROGRESS(("=0x%lx\n", marks[MARK_END] - marks[MARK_START]));
- return fd;
- }
-err:
- (void)close(fd);
- return -1;
-}
-
-#ifdef BOOT_ECOFF
-static int
-coff_exec(fd, coff, marks, flags)
- int fd;
- struct ecoff_exechdr *coff;
- u_long *marks;
- int flags;
-{
- paddr_t offset = marks[MARK_START];
- paddr_t minp = ~0, maxp = 0, pos;
-
- /* Read in text. */
- if (lseek(fd, ECOFF_TXTOFF(coff), SEEK_SET) == -1) {
- WARN(("lseek text"));
- return 1;
- }
-
- if (coff->a.tsize != 0) {
- if (flags & LOAD_TEXT) {
- PROGRESS(("%lu", coff->a.tsize));
- if (READ(fd, coff->a.text_start, coff->a.tsize) !=
- coff->a.tsize) {
- return 1;
- }
- }
- else {
- if (lseek(fd, coff->a.tsize, SEEK_CUR) == -1) {
- WARN(("read text"));
- return 1;
- }
- }
- if (flags & (COUNT_TEXT|LOAD_TEXT)) {
- pos = coff->a.text_start;
- if (minp > pos)
- minp = pos;
- pos += coff->a.tsize;
- if (maxp < pos)
- maxp = pos;
- }
- }
-
- /* Read in data. */
- if (coff->a.dsize != 0) {
- if (flags & LOAD_DATA) {
- PROGRESS(("+%lu", coff->a.dsize));
- if (READ(fd, coff->a.data_start, coff->a.dsize) !=
- coff->a.dsize) {
Home |
Main Index |
Thread Index |
Old Index