summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2011-06-05 21:49:37 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2011-06-05 21:49:37 +0000
commit5ecb0b2b05c6f7768e3577d36cba4c67291b3ed1 (patch)
treedeea311e4cb00e13413acc3a966f4c3a3266ac36 /sys/arch
parentaa9df001af58923a7ab1e4476f900543e923c127 (diff)
Update alpha bootblocks to use MI loadfile code instead of rolling our own;
also print a meaningful message if the kernel load address conflicts with the SRM memory areas, so that we can know which kernel load address to use. Requires `make includes' before attempting to build bootblocks. Tweaks mk@, `nice' deraadt@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/alpha/include/loadfile_machdep.h51
-rw-r--r--sys/arch/alpha/stand/Makefile.inc4
-rw-r--r--sys/arch/alpha/stand/boot/Makefile18
-rw-r--r--sys/arch/alpha/stand/boot/boot.c49
-rw-r--r--sys/arch/alpha/stand/boot/version13
-rw-r--r--sys/arch/alpha/stand/bootxx/Makefile11
-rw-r--r--sys/arch/alpha/stand/libsa/Makefile.inc3
-rw-r--r--sys/arch/alpha/stand/loadfile.c230
-rw-r--r--sys/arch/alpha/stand/netboot/Makefile17
-rw-r--r--sys/arch/alpha/stand/netboot/devopen.c5
-rw-r--r--sys/arch/alpha/stand/netboot/getsecs.c4
-rw-r--r--sys/arch/alpha/stand/netboot/netboot.c28
-rw-r--r--sys/arch/alpha/stand/netboot/version7
-rw-r--r--sys/arch/alpha/stand/start.S4
14 files changed, 149 insertions, 295 deletions
diff --git a/sys/arch/alpha/include/loadfile_machdep.h b/sys/arch/alpha/include/loadfile_machdep.h
new file mode 100644
index 00000000000..d54ca52adf9
--- /dev/null
+++ b/sys/arch/alpha/include/loadfile_machdep.h
@@ -0,0 +1,51 @@
+/* $OpenBSD: loadfile_machdep.h,v 1.1 2011/06/05 21:49:32 miod Exp $ */
+/* $NetBSD: loadfile_machdep.h,v 1.2 2001/10/31 17:20:49 thorpej 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.
+ *
+ * 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_ELF
+#define ELFSIZE 64
+
+#define LOAD_KERNEL (LOAD_ALL & ~LOAD_TEXTA)
+#define COUNT_KERNEL (COUNT_ALL & ~COUNT_TEXTA)
+
+#define LOADADDR(a) (((u_long)(a)) + offset)
+#define READ(f, b, c) read((f), (void *)LOADADDR(b), (c))
+#define BCOPY(s, d, c) bcopy((void *)s, (void *)LOADADDR(d), (c))
+#define BZERO(d, c) bzero((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)
+
+extern int check_phdr(void *);
+#define CHECK_PHDR(sz,phdr) check_phdr(phdr)
diff --git a/sys/arch/alpha/stand/Makefile.inc b/sys/arch/alpha/stand/Makefile.inc
index 09fba827e80..a5c9383a844 100644
--- a/sys/arch/alpha/stand/Makefile.inc
+++ b/sys/arch/alpha/stand/Makefile.inc
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.inc,v 1.11 2010/05/14 21:08:28 naddy Exp $
+# $OpenBSD: Makefile.inc,v 1.12 2011/06/05 21:49:36 miod Exp $
# $NetBSD: Makefile.inc,v 1.8 1997/04/06 08:39:38 cgd Exp $
.include <bsd.own.mk> # for ELF_TOOLCHAIN definition
@@ -18,7 +18,7 @@ CPPFLAGS+= -DSECONDARY_LOAD_ADDRESS="0x${SECONDARY_LOAD_ADDRESS}"
CPPFLAGS+= -D_STANDALONE
-XCPPFLAGS+= -DHEAP_LIMIT="0x${HEAP_LIMIT}"
+EXTRACFLAGS+= -DHEAP_LIMIT="0x${HEAP_LIMIT}"
CFLAGS+= -fno-stack-protector -fno-builtin-printf \
-fno-builtin-vprintf -fno-builtin-putchar \
diff --git a/sys/arch/alpha/stand/boot/Makefile b/sys/arch/alpha/stand/boot/Makefile
index 035155b6936..0f5e39e69b1 100644
--- a/sys/arch/alpha/stand/boot/Makefile
+++ b/sys/arch/alpha/stand/boot/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.16 2007/11/25 18:25:29 deraadt Exp $
+# $OpenBSD: Makefile,v 1.17 2011/06/05 21:49:36 miod Exp $
# $NetBSD: Makefile,v 1.17 1997/04/17 07:27:46 thorpej Exp $
S= ${.CURDIR}/../../../..
@@ -7,22 +7,24 @@ S= ${.CURDIR}/../../../..
PROG = boot
-SRCS = start.S boot.c loadfile.c disk.c conf.c prom.c prom_disp.S OSFpal.c
-SRCS+= devopen.c filesystem.c prom_swpal.S
+SRCS = start.S boot.c disk.c conf.c prom.c prom_disp.S OSFpal.c
+SRCS+= devopen.c filesystem.c loadfile_subr.c prom_swpal.S
NOMAN=
INSTALL_STRIP=
BINMODE= 444
BOOT_RELOC = ${SECONDARY_LOAD_ADDRESS}
-HEADERSIZE_PROG = headersize
-CLEANFILES+= vers.c vers.o ${PROG}.sym ${PROG}.nosym ${HEADERSIZE_PROG}
+CLEANFILES+= vers.c vers.o ${PROG}.sym ${PROG}.nosym
.PATH: ${S}/lib/libkern/arch/alpha ${S}/lib/libkern
SRCS+= __divlu.S __remqu.S __reml.S strlen.c bzero.c __divl.S __divqu.S \
__remlu.S
-DEFNS= -DCOMPAT_UFS -DALPHA_BOOT_ELF
+.PATH: ${S}/lib/libkern/arch/alpha ${S}/lib/libsa
+SRCS+= loadfile.c
+
+DEFNS= -DCOMPAT_UFS
AFLAGS += -DASSEMBLER ${DEFNS}
CPPFLAGS += -I${.CURDIR}/../../../../lib/libsa -I${.CURDIR}/../.. -I${S} ${DEFNS}
@@ -32,10 +34,8 @@ ${PROG}.nosym: ${PROG}.sym
cp ${PROG}.sym ${PROG}.nosym
strip ${PROG}.nosym
-${PROG}: ${PROG}.nosym #${HEADERSIZE_PROG}
+${PROG}: ${PROG}.nosym
objcopy --output-target=binary ${PROG}.nosym ${PROG}
-# dd if=${PROG}.nosym of=${PROG} \
-# bs=`./${HEADERSIZE_PROG} ${BOOT_RELOC} ${PROG}.nosym` skip=1
# no lint here (yet?)
lint:
diff --git a/sys/arch/alpha/stand/boot/boot.c b/sys/arch/alpha/stand/boot/boot.c
index 07bd4300ca9..648ddc9a8c6 100644
--- a/sys/arch/alpha/stand/boot/boot.c
+++ b/sys/arch/alpha/stand/boot/boot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: boot.c,v 1.19 2005/05/30 01:41:33 deraadt Exp $ */
+/* $OpenBSD: boot.c,v 1.20 2011/06/05 21:49:36 miod Exp $ */
/* $NetBSD: boot.c,v 1.10 1997/01/18 01:58:33 cgd Exp $ */
/*
@@ -37,20 +37,15 @@
#include <lib/libkern/libkern.h>
#include <lib/libsa/stand.h>
+#include <lib/libsa/loadfile.h>
#include <sys/param.h>
#include <sys/exec.h>
-#include <sys/exec_ecoff.h>
#include <machine/rpb.h>
#include <machine/prom.h>
#include <machine/autoconf.h>
-#define _KERNEL
-#include "include/pte.h"
-
-int loadfile(char *, u_int64_t *);
-
char boot_file[128];
char boot_flags[128];
@@ -58,9 +53,7 @@ extern char bootprog_name[];
struct bootinfo_v1 bootinfo_v1;
-extern paddr_t ffp_save, ptbr_save;
-
-extern vaddr_t ssym, esym;
+paddr_t ptbr_save;
int debug;
@@ -69,7 +62,14 @@ main()
{
char *name, **namep;
u_int64_t entry;
- int win;
+ int rc;
+ u_long marks[MARK_MAX];
+#ifdef DEBUG
+ struct rpb *r;
+ struct mddt *mddtp;
+ struct mddt_cluster *memc;
+ int i;
+#endif
/* Init prom callback vector. */
init_prom_calls();
@@ -80,6 +80,17 @@ main()
/* switch to OSF pal code. */
OSFpal();
+#ifdef DEBUG
+ r = (struct rpb *)HWRPB_ADDR;
+ mddtp = (struct mddt *)(HWRPB_ADDR + r->rpb_memdat_off);
+ printf("%d memory clusters\n", mddtp->mddt_cluster_cnt);
+ for (i = 0; i < mddtp->mddt_cluster_cnt; i++) {
+ memc = &mddtp->mddt_clusters[i];
+ printf("%d: (%d) %lx-%lx\n", i, memc->mddt_usage,
+ memc->mddt_pfn << PAGE_SHIFT,
+ (memc->mddt_pfn + memc->mddt_pg_cnt) << PAGE_SHIFT);
+ }
+#endif
prom_getenv(PROM_E_BOOTED_FILE, boot_file, sizeof(boot_file));
prom_getenv(PROM_E_BOOTED_OSFLAGS, boot_flags, sizeof(boot_flags));
@@ -88,16 +99,20 @@ main()
name = boot_file;
} else
name = "bsd";
- win = (loadfile(name, &entry) == 0);
- if (!win)
+
+ (void)printf("Loading %s...\n", name);
+ marks[MARK_START] = 0;
+ rc = loadfile(name, marks, LOAD_KERNEL | COUNT_KERNEL);
+ (void)printf("\n");
+ if (rc != 0)
goto fail;
/*
* Fill in the bootinfo for the kernel.
*/
bzero(&bootinfo_v1, sizeof(bootinfo_v1));
- bootinfo_v1.ssym = ssym;
- bootinfo_v1.esym = esym;
+ bootinfo_v1.ssym = marks[MARK_SYM];
+ bootinfo_v1.esym = marks[MARK_END];
bcopy(name, bootinfo_v1.booted_kernel,
sizeof(bootinfo_v1.booted_kernel));
bcopy(boot_flags, bootinfo_v1.boot_flags,
@@ -108,9 +123,9 @@ main()
bootinfo_v1.cnputc = NULL;
bootinfo_v1.cnpollc = NULL;
+ entry = marks[MARK_START];
(*(void (*)(u_int64_t, u_int64_t, u_int64_t, void *, u_int64_t,
- u_int64_t))entry)(ffp_save, ptbr_save, BOOTINFO_MAGIC,
- &bootinfo_v1, 1, 0);
+ u_int64_t))entry)(0, ptbr_save, BOOTINFO_MAGIC, &bootinfo_v1, 1, 0);
fail:
halt();
diff --git a/sys/arch/alpha/stand/boot/version b/sys/arch/alpha/stand/boot/version
index 1d0185a2d65..ef4e5e2268e 100644
--- a/sys/arch/alpha/stand/boot/version
+++ b/sys/arch/alpha/stand/boot/version
@@ -1,15 +1,26 @@
-$OpenBSD: version,v 1.7 2002/02/10 23:15:05 deraadt Exp $
+$OpenBSD: version,v 1.8 2011/06/05 21:49:36 miod Exp $
$NetBSD: version,v 1.9 1997/01/23 23:10:38 cgd Exp $
1.1: Initial version
1.2: don't forget the Id string!
1.3: make it work on AlphaStations
+(OpenBSD 1.1)
+
1.4-1: Re-import from master sources
1.4-2: Complete rewrite of boot block code
+(OpenBSD 1.2)
+
1.5: Update for new ECOFF headers
+(OpenBSD 1.3/1.4)
+
1.6: Don't pass arguments to the kernel, trim unnecessary environment
calls, kill 'ask' loop (i.e. if boot fails, halt), separate
ECOFF and a.out support into separate options.
+(OpenBSD 1.5)
+
1.7: Use libsa and libkern rather than building the objects locally.
1.8: Search for a kernel, if none specified.
1.9: Add support for gzipped kernels.
+(OpenBSD 1.6/1.7)
+
+1.8: Use MI loadfile, warn if kernel image would overlap SRM
diff --git a/sys/arch/alpha/stand/bootxx/Makefile b/sys/arch/alpha/stand/bootxx/Makefile
index ed5728b1864..6c1378759c4 100644
--- a/sys/arch/alpha/stand/bootxx/Makefile
+++ b/sys/arch/alpha/stand/bootxx/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.10 2009/10/01 15:42:14 miod Exp $
+# $OpenBSD: Makefile,v 1.11 2011/06/05 21:49:36 miod Exp $
# $NetBSD: Makefile,v 1.12 1997/04/17 07:27:49 thorpej Exp $
S= ${.CURDIR}/../../../..
@@ -13,15 +13,13 @@ INSTALL_STRIP=
BINMODE= 444
BOOT_RELOC = ${PRIMARY_LOAD_ADDRESS}
-HEADERSIZE_PROG = headersize
-CLEANFILES+= ${PROG}.sym ${PROG}.nosym ${PROG}.trunc ${HEADERSIZE_PROG}
+CLEANFILES+= ${PROG}.sym ${PROG}.nosym ${PROG}.trunc
.PATH: ${S}/lib/libkern/arch/alpha ${S}/lib/libkern
SRCS+= bzero.c memcpy.c
DEFNS= -DPRIMARY_BOOTBLOCK
-DEFNS+= -DALPHA_BOOT_ELF
AFLAGS += -DASSEMBLER ${DEFNS}
CPPFLAGS += -I${.CURDIR}/../.. -I${S} ${DEFNS}
@@ -31,12 +29,9 @@ ${PROG}.nosym: ${PROG}.sym
cp ${PROG}.sym ${PROG}.nosym
strip ${PROG}.nosym
-${PROG}: ${PROG}.nosym #${HEADERSIZE_PROG}
+${PROG}: ${PROG}.nosym
objcopy --output-target=binary ${PROG}.nosym ${PROG}.trunc
dd if=${PROG}.trunc of=${PROG} obs=`expr 15 \* 512` conv=osync
-# dd if=${PROG}.nosym of=${PROG} \
-# ibs=`./${HEADERSIZE_PROG} ${BOOT_RELOC} ${PROG}.nosym` skip=1 \
-# obs=`expr 15 \* 512` conv=osync
# no lint here (yet?)
lint:
diff --git a/sys/arch/alpha/stand/libsa/Makefile.inc b/sys/arch/alpha/stand/libsa/Makefile.inc
index 6c4e21b9bca..537496ea87f 100644
--- a/sys/arch/alpha/stand/libsa/Makefile.inc
+++ b/sys/arch/alpha/stand/libsa/Makefile.inc
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.inc,v 1.1 1997/05/05 06:01:57 millert Exp $
+# $OpenBSD: Makefile.inc,v 1.2 2011/06/05 21:49:36 miod Exp $
# $NetBSD: Makefile.inc,v 1.5 1996/09/30 16:01:18 ws Exp $
#
# NOTE: $S must correspond to the top of the 'sys' tree
@@ -13,7 +13,6 @@ SAMAKE= \
CC="${CC}" XCFLAGS="${CFLAGS}" \
AS='${AS}' XAFLAGS='${AFLAGS}' \
LD='${LD}' \
- XCPPFLAGS="${CPPFLAGS}" \
SAREL="${SAREL}" \
SADIR="${SADIR}" \
EXTRACFLAGS="${EXTRACFLAGS}"
diff --git a/sys/arch/alpha/stand/loadfile.c b/sys/arch/alpha/stand/loadfile.c
deleted file mode 100644
index fe1e25c6953..00000000000
--- a/sys/arch/alpha/stand/loadfile.c
+++ /dev/null
@@ -1,230 +0,0 @@
-/* $OpenBSD: loadfile.c,v 1.17 2005/08/10 16:58:42 todd Exp $ */
-/* $NetBSD: loadfile.c,v 1.3 1997/04/06 08:40:59 cgd Exp $ */
-
-/*
- * 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. 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
- */
-
-#define ELFSIZE 64
-
-#include <lib/libkern/libkern.h>
-#include <lib/libsa/stand.h>
-
-#include <sys/param.h>
-#include <sys/exec.h>
-#include <sys/exec_ecoff.h>
-#include <sys/exec_elf.h>
-
-#include <machine/rpb.h>
-#include <machine/prom.h>
-
-#include <ddb/db_aout.h>
-
-#define _KERNEL
-#include "include/pte.h"
-
-#ifdef ALPHA_BOOT_ELF
-static int elf_exec(int, Elf64_Ehdr *, u_int64_t *);
-#endif
-int loadfile(char *, u_int64_t *);
-
-paddr_t ffp_save, ptbr_save;
-vaddr_t ssym, esym;
-
-#define WARN(...)
-
-/*
- * Open 'filename', read in program and return the entry point or -1 if error.
- */
-int
-loadfile(fname, entryp)
- char *fname;
- u_int64_t *entryp;
-{
- struct devices *dp;
- union {
-#ifdef ALPHA_BOOT_ELF
- Elf64_Ehdr elf;
-#endif
- } hdr;
- int fd, rval;
-
- (void)printf("Loading %s...\n", fname);
-
- /* Open the file. */
- rval = 1;
- if ((fd = open(fname, 0)) < 0) {
- WARN(("open %s: errno %d\n", fname, errno));
- goto err;
- }
-
- /* Read the exec header. */
- if (read(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) {
- WARN(("read header: %s\n", strerror(errno)));
- goto err;
- }
-
-#ifdef ALPHA_BOOT_ELF
- if (memcmp(ELFMAG, hdr.elf.e_ident, SELFMAG) == 0) {
- rval = elf_exec(fd, &hdr.elf, entryp);
- } else
-#endif
- {
- (void)printf("%s: unknown executable format\n", fname);
- }
-
-err:
- if (fd >= 0)
- (void)close(fd);
- return (rval);
-}
-
-#ifdef ALPHA_BOOT_ELF
-static int
-elf_exec(fd, elf, entryp)
- int fd;
- Elf64_Ehdr *elf;
- u_int64_t *entryp;
-{
- int i;
- int first = 1, havesyms;
- Elf64_Shdr *shp;
- Elf64_Off off;
- size_t sz;
-
- for (i = 0; i < elf->e_phnum; i++) {
- Elf64_Phdr phdr;
- (void)lseek(fd, elf->e_phoff + sizeof(phdr) * i, SEEK_SET);
- if (read(fd, (void *)&phdr, sizeof(phdr)) != sizeof(phdr)) {
- WARN(("read phdr: %s\n", strerror(errno)));
- return (1);
- }
- if (phdr.p_type != PT_LOAD ||
- (phdr.p_flags & (PF_W|PF_X)) == 0)
- continue;
-
- /* Read in segment. */
- (void)printf("%s%lu", first ? "" : "+", phdr.p_filesz);
- (void)lseek(fd, phdr.p_offset, SEEK_SET);
- if (read(fd, (void *)phdr.p_vaddr, phdr.p_filesz) !=
- phdr.p_filesz) {
- WARN(("read text: %s\n", strerror(errno)));
- return (1);
- }
- if (first || ffp_save < phdr.p_vaddr + phdr.p_memsz)
- ffp_save = phdr.p_vaddr + phdr.p_memsz;
-
- /* Zero out bss. */
- if (phdr.p_filesz < phdr.p_memsz) {
- (void)printf("+%lu", phdr.p_memsz - phdr.p_filesz);
- bzero((caddr_t)phdr.p_vaddr + phdr.p_filesz,
- phdr.p_memsz - phdr.p_filesz);
- }
- first = 0;
- }
-
- ffp_save = roundup(ffp_save, sizeof(long));
-
- /*
- * Retrieve symbols.
- */
- ssym = ffp_save;
- ffp_save += sizeof(Elf64_Ehdr);
-
- if (lseek(fd, elf->e_shoff, SEEK_SET) == -1) {
- WARN(("seek to section headers: %s\n", strerror(errno)));
- return (1);
- }
-
- sz = elf->e_shnum * sizeof(Elf64_Shdr);
- shp = (Elf64_Shdr *)ffp_save;
- ffp_save += roundup(sz, sizeof(long));
-
- if (read(fd, shp, sz) != sz) {
- WARN(("read section headers: %d\n", strerror(errno)));
- return (1);
- }
-
- /*
- * Now load the symbol sections themselves. Make sure the
- * sections are aligned. Don't bother with string tables if
- * there are no symbol sections.
- */
- off = roundup((sizeof(Elf64_Ehdr) + sz), sizeof(long));
-
- for (havesyms = i = 0; i < elf->e_shnum; i++)
- if (shp[i].sh_type == SHT_SYMTAB)
- havesyms = 1;
-
- if (!havesyms)
- goto no_syms;
-
- for (first = 1, i = 0; i < elf->e_shnum; i++) {
- if (shp[i].sh_type == SHT_SYMTAB ||
- shp[i].sh_type == SHT_STRTAB) {
- printf("%s%ld", first ? " [" : "+",
- (u_long)shp[i].sh_size);
- if (lseek(fd, shp[i].sh_offset, SEEK_SET) == -1) {
- WARN(("lseek symbols: %s\n", strerror(errno)));
- return (1);
- }
- if (read(fd, (void *)ffp_save, shp[i].sh_size) !=
- shp[i].sh_size) {
- WARN(("read symbols: %s\n", strerror(errno)));
- return (1);
- }
- ffp_save += roundup(shp[i].sh_size, sizeof(long));
- shp[i].sh_offset = off;
- off += roundup(shp[i].sh_size, sizeof(long));
- first = 0;
- }
- }
- if (havesyms && first == 0)
- printf("]");
-
- elf->e_phoff = 0;
- elf->e_shoff = sizeof(Elf64_Ehdr);
- elf->e_phentsize = 0;
- elf->e_phnum = 0;
- bcopy(elf, (void *)ssym, sizeof(*elf));
-
-no_syms:
- esym = ffp_save;
- ffp_save = ALPHA_K0SEG_TO_PHYS((ffp_save + PGOFSET & ~PGOFSET)) >> PGSHIFT;
- ffp_save += 2; /* XXX OSF/1 does this, no idea why. */
-
- (void)printf("\n");
- *entryp = elf->e_entry;
- return (0);
-}
-#endif /* ALPHA_BOOT_ELF */
diff --git a/sys/arch/alpha/stand/netboot/Makefile b/sys/arch/alpha/stand/netboot/Makefile
index cd05582efb8..52890e31ed5 100644
--- a/sys/arch/alpha/stand/netboot/Makefile
+++ b/sys/arch/alpha/stand/netboot/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.9 2007/11/25 19:12:59 martin Exp $
+# $OpenBSD: Makefile,v 1.10 2011/06/05 21:49:36 miod Exp $
# $NetBSD: Makefile,v 1.11 1997/04/17 07:27:50 thorpej Exp $
S= ${.CURDIR}/../../../..
@@ -10,20 +10,23 @@ PROG = netboot
SRCS = start.S boot.c prom.c prom_disp.S OSFpal.c prom_swpal.S
SRCS+= rpcc.S
SRCS+= dev_net.c conf.c devopen.c
-SRCS+= if_prom.c loadfile.c getsecs.c
+SRCS+= if_prom.c getsecs.c
+SRCS+= loadfile_subr.c
NOMAN=
INSTALL_STRIP=
BINMODE= 444
BOOT_RELOC = ${PRIMARY_LOAD_ADDRESS}
-HEADERSIZE_PROG = headersize
-CLEANFILES+= vers.c vers.o ${PROG}.sym ${PROG}.nosym ${HEADERSIZE_PROG}
+CLEANFILES+= vers.c vers.o ${PROG}.sym ${PROG}.nosym
.PATH: ${S}/lib/libkern/arch/alpha ${S}/lib/libkern
SRCS+= bzero.c __divqu.S strlen.c __remqu.S
-DEFNS= -DPRIMARY_BOOTBLOCK -DALPHA_BOOT_ELF -DSUN_BOOTPARAMS
+.PATH: ${S}/lib/libkern/arch/alpha ${S}/lib/libsa
+SRCS+= loadfile.c
+
+DEFNS= -DPRIMARY_BOOTBLOCK -DSUN_BOOTPARAMS
AFLAGS += -DASSEMBLER ${DEFNS}
CPPFLAGS += -I${.CURDIR}/../.. -I${S} ${DEFNS}
@@ -33,10 +36,8 @@ ${PROG}.nosym: ${PROG}.sym
cp ${PROG}.sym ${PROG}.nosym
strip ${PROG}.nosym
-${PROG}: ${PROG}.nosym #${HEADERSIZE_PROG}
+${PROG}: ${PROG}.nosym
objcopy --output-target=binary ${PROG}.nosym ${PROG}
-# dd if=${PROG}.nosym of=${PROG} \
-# bs=`./${HEADERSIZE_PROG} ${BOOT_RELOC} ${PROG}.nosym` skip=1
# no lint here (yet?)
lint:
diff --git a/sys/arch/alpha/stand/netboot/devopen.c b/sys/arch/alpha/stand/netboot/devopen.c
index d8434cf8d1a..10252db0fe6 100644
--- a/sys/arch/alpha/stand/netboot/devopen.c
+++ b/sys/arch/alpha/stand/netboot/devopen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: devopen.c,v 1.4 2003/06/02 23:27:44 millert Exp $ */
+/* $OpenBSD: devopen.c,v 1.5 2011/06/05 21:49:36 miod Exp $ */
/* $NetBSD: devopen.c,v 1.3 1997/04/06 08:41:25 cgd Exp $ */
/*-
@@ -41,6 +41,7 @@
* Decode the string 'fname', open the device and return the remaining
* file name if any.
*/
+int
devopen(f, fname, file)
struct open_file *f;
const char *fname;
@@ -49,7 +50,9 @@ devopen(f, fname, file)
register char *cp;
register char *ncp;
register struct devsw *dp;
+#if 0
register int c, i;
+#endif
int ctlr = 0, unit = 0, part = 0;
char namebuf[20];
int rc;
diff --git a/sys/arch/alpha/stand/netboot/getsecs.c b/sys/arch/alpha/stand/netboot/getsecs.c
index 16b8ab95da2..8d7cabd396c 100644
--- a/sys/arch/alpha/stand/netboot/getsecs.c
+++ b/sys/arch/alpha/stand/netboot/getsecs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getsecs.c,v 1.2 1996/11/27 19:54:55 niklas Exp $ */
+/* $OpenBSD: getsecs.c,v 1.3 2011/06/05 21:49:36 miod Exp $ */
#include <sys/param.h>
#include "include/rpb.h"
@@ -9,7 +9,7 @@ getsecs()
{
static long tnsec;
static long lastpcc, wrapsecs;
- long curpcc, pccdiff;
+ long curpcc;
if (tnsec == 0) {
tnsec = 1;
diff --git a/sys/arch/alpha/stand/netboot/netboot.c b/sys/arch/alpha/stand/netboot/netboot.c
index c058c3f7f5e..c39fc3b5b7d 100644
--- a/sys/arch/alpha/stand/netboot/netboot.c
+++ b/sys/arch/alpha/stand/netboot/netboot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netboot.c,v 1.7 2005/12/17 07:31:25 miod Exp $ */
+/* $OpenBSD: netboot.c,v 1.8 2011/06/05 21:49:36 miod Exp $ */
/* $NetBSD: netboot.c,v 1.1 1996/09/18 20:03:12 cgd Exp $ */
/*
@@ -40,22 +40,16 @@
#include <sys/param.h>
#include <sys/exec.h>
-#include <sys/exec_ecoff.h>
#include <machine/rpb.h>
#include <machine/prom.h>
-#define _KERNEL
-#include "include/pte.h"
-
-int loadfile(char *, u_int64_t *);
-
char boot_file[128];
char boot_flags[128];
extern char bootprog_name[], bootprog_rev[];
-vaddr_t ffp_save, ptbr_save;
+vaddr_t ptbr_save;
int debug;
@@ -63,6 +57,8 @@ void
main()
{
u_int64_t entry;
+ u_long marks[MARK_MAX];
+ int rc;
/* Init prom callback vector. */
init_prom_calls();
@@ -78,12 +74,18 @@ main()
if (boot_file[0] == '\0')
bcopy("bsd", boot_file, sizeof "bsd");
-
- (void)printf("Boot: %s %s\n", boot_file, boot_flags);
-
- if (!loadfile(boot_file, &entry)) {
+ else
+ (void)printf("Boot: %s %s\n", boot_file, boot_flags);
+
+ (void)printf("Loading %s...\n", boot_file);
+ marks[MARK_START] = 0;
+ rc = loadfile(boot_file, &marks, LOAD_KERNEL | COUNT_KERNEL);
+ (void)printf("\n");
+ if (rc == 0) {
+ entry = marks[MARK_START];
(void)printf("Entering kernel at 0x%lx...\n", entry);
- (*(void (*)())entry)(ffp_save, ptbr_save, 0);
+ (*(void (*)(u_int64_t, u_int64_t, u_int64_t))entry)
+ (0, ptbr_save, 0);
}
(void)printf("Boot failed! Halting...\n");
diff --git a/sys/arch/alpha/stand/netboot/version b/sys/arch/alpha/stand/netboot/version
index 78dd6c7767a..11304222405 100644
--- a/sys/arch/alpha/stand/netboot/version
+++ b/sys/arch/alpha/stand/netboot/version
@@ -1,9 +1,14 @@
-$OpenBSD: version,v 1.2 1997/05/05 06:02:02 millert Exp $
+$OpenBSD: version,v 1.3 2011/06/05 21:49:36 miod Exp $
$NetBSD: version,v 1.6 1997/01/23 23:10:41 cgd Exp $
1.1: Initial version
1.2: Cleaned and polished a bit
+(OpenBSD 1.1)
+
1.3: Use libsa and libkern rather than building the objects locally.
1.4: Allow ethernet address to be hardcoded with setnetbootinfo(8).
1.5: Search for a kernel, if none specified.
1.6: Add support for gzipped kernels.
+(OpenBSD 1.2)
+
+1.3: Use MI loadfile, warn if kernel image would overlap SRM
diff --git a/sys/arch/alpha/stand/start.S b/sys/arch/alpha/stand/start.S
index b3cd857544a..bf94a232765 100644
--- a/sys/arch/alpha/stand/start.S
+++ b/sys/arch/alpha/stand/start.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: start.S,v 1.5 2005/08/29 11:20:55 mickey Exp $ */
+/* $OpenBSD: start.S,v 1.6 2011/06/05 21:49:36 miod Exp $ */
/* $NetBSD: start.S,v 1.4 1996/10/17 02:50:40 cgd Exp $ */
/*
@@ -56,10 +56,12 @@ Lstartgp:
lda sp,-ENTRY_FRAME(sp) /* start stack below text */
#endif
+ or a0,zero,s0
lda a0,_edata
lda a1,_end
subq a1,a0,a1
CALL(bzero)
+ or s0,zero,a0
CALL(main) /* transfer to C */