summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2010-08-25 12:53:39 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2010-08-25 12:53:39 +0000
commit836d6d551c04cf252e4e99feb88919d54f525a30 (patch)
treeaf201990da7360c55224ea27f66abb4d7e43ed4a
parent1371ccb648a8117f22bba9a125f7a14cda2c3d7c (diff)
Remove the SPARC_BOOT_ELF define and associated machinery since it does
not make sense to compile ofwboot without support for ELF. Whilst here, nuke the unused SPARC_BOOT_NFS define and compile elf64_exec.c as an object rather than including it in boot.c. ok miod@
-rw-r--r--sys/arch/sparc64/stand/ofwboot/Makefile10
-rw-r--r--sys/arch/sparc64/stand/ofwboot/boot.c17
-rw-r--r--sys/arch/sparc64/stand/ofwboot/elf64_exec.c18
3 files changed, 17 insertions, 28 deletions
diff --git a/sys/arch/sparc64/stand/ofwboot/Makefile b/sys/arch/sparc64/stand/ofwboot/Makefile
index 249994e1d9b..16212eee795 100644
--- a/sys/arch/sparc64/stand/ofwboot/Makefile
+++ b/sys/arch/sparc64/stand/ofwboot/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.15 2010/08/21 17:22:42 jsing Exp $
+# $OpenBSD: Makefile,v 1.16 2010/08/25 12:53:38 jsing Exp $
# $NetBSD: Makefile,v 1.2 2001/03/04 14:50:05 mrg Exp $
CURDIR= ${.CURDIR}
@@ -14,7 +14,8 @@ PROG?= ofwboot
NOMAN= ja, man!
.PATH: ${S}/arch/sparc64/sparc64
-SRCS= srt0.s Locore.c boot.c ofdev.c alloc.c net.c netif_of.c vers.c
+SRCS= srt0.s Locore.c alloc.c boot.c elf64_exec.c net.c netif_of.c \
+ ofdev.c vers.c
.PATH: ${S}/lib/libkern/arch/sparc64 ${S}/lib/libkern
SRCS+= strlcpy.c strcmp.c strlcat.c strlen.c
@@ -45,9 +46,7 @@ CPPFLAGS+= -DRELOC=0x${RELOC}
#
# XXXXX FIXME
#
-CPPFLAGS+= -DSPARC_BOOT_ELF
CPPFLAGS+= -DSPARC_BOOT_UFS
-CPPFLAGS+= -DSPARC_BOOT_NFS
#CPPFLAGS+= -DSPARC_BOOT_HSFS
.if !make(libdep) && !make(sadep) && !make(salibdir) && !make(obj)
@@ -64,7 +63,4 @@ NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $<
srt0.o: srt0.s
${NORMAL_S}
-# Explicit dependency for this.
-boot.o: boot.c elf64_exec.c
-
.include <bsd.prog.mk>
diff --git a/sys/arch/sparc64/stand/ofwboot/boot.c b/sys/arch/sparc64/stand/ofwboot/boot.c
index 957becf48a6..eae7ac736a8 100644
--- a/sys/arch/sparc64/stand/ofwboot/boot.c
+++ b/sys/arch/sparc64/stand/ofwboot/boot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: boot.c,v 1.17 2010/08/21 17:22:42 jsing Exp $ */
+/* $OpenBSD: boot.c,v 1.18 2010/08/25 12:53:38 jsing Exp $ */
/* $NetBSD: boot.c,v 1.3 2001/05/31 08:55:19 mrg Exp $ */
/*
* Copyright (c) 1997, 1999 Eduardo E. Horvath. All rights reserved.
@@ -82,10 +82,7 @@ char bootfile[128];
int boothowto;
int debug;
-
-#ifdef SPARC_BOOT_ELF
int elf64_exec(int, Elf64_Ehdr *, u_int64_t *, void **, void **);
-#endif
#if 0
static void
@@ -213,9 +210,7 @@ int
loadfile(int fd, char *args)
{
union {
-#ifdef SPARC_BOOT_ELF
Elf64_Ehdr elf64;
-#endif
} hdr;
int rval;
u_int64_t entry = 0;
@@ -240,13 +235,11 @@ loadfile(int fd, char *args)
}
/* Determine file type, load kernel. */
-#ifdef SPARC_BOOT_ELF
if (bcmp(hdr.elf64.e_ident, ELFMAG, SELFMAG) == 0 &&
hdr.elf64.e_ident[EI_CLASS] == ELFCLASS64) {
+ printf("Booting %s\n", opened_name);
rval = elf64_exec(fd, &hdr.elf64, &entry, &ssym, &esym);
- } else
-#endif
- {
+ } else {
rval = 1;
printf("unknown executable format\n");
}
@@ -266,10 +259,6 @@ loadfile(int fd, char *args)
return (rval);
}
-#ifdef SPARC_BOOT_ELF
-#include "elf64_exec.c"
-#endif /* SPARC_BOOT_ELF */
-
int
main()
{
diff --git a/sys/arch/sparc64/stand/ofwboot/elf64_exec.c b/sys/arch/sparc64/stand/ofwboot/elf64_exec.c
index ba25baaeea4..56ba5a27c2f 100644
--- a/sys/arch/sparc64/stand/ofwboot/elf64_exec.c
+++ b/sys/arch/sparc64/stand/ofwboot/elf64_exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: elf64_exec.c,v 1.1 2010/08/21 17:22:42 jsing Exp $ */
+/* $OpenBSD: elf64_exec.c,v 1.2 2010/08/25 12:53:38 jsing Exp $ */
/* $NetBSD: elfXX_exec.c,v 1.2 2001/08/15 20:08:15 eeh Exp $ */
/*
@@ -49,6 +49,13 @@
#define ELF_ALIGN(x) (((x) + 7) & (~7))
+#include <lib/libsa/stand.h>
+
+#include <sys/param.h>
+#include <sys/exec_elf.h>
+
+#include "openfirm.h"
+
int
elf64_exec(int fd, Elf_Ehdr *elf, u_int64_t *entryp, void **ssymp, void **esymp){
Elf_Shdr *shp;
@@ -63,11 +70,6 @@ elf64_exec(int fd, Elf_Ehdr *elf, u_int64_t *entryp, void **ssymp, void **esymp)
* Don't display load address for ELF; it's encoded in
* each section.
*/
-#ifdef DEBUG
- printf("elf%d_exec: ", ELFSIZE);
-#endif
- printf("Booting %s\n", opened_name);
-
for (i = 0; i < elf->e_phnum; i++) {
Elf_Phdr phdr;
size = lseek(fd, (size_t)(elf->e_phoff + sizeof(phdr) * i),
@@ -84,6 +86,7 @@ elf64_exec(int fd, Elf_Ehdr *elf, u_int64_t *entryp, void **ssymp, void **esymp)
printf("%s%lu@0x%lx", first ? "" : "+", (u_long)phdr.p_filesz,
(u_long)phdr.p_vaddr);
(void)lseek(fd, (size_t)phdr.p_offset, SEEK_SET);
+
/*
* If the segment's VA is aligned on a 4MB boundary, align its
* request 4MB aligned physical memory. Otherwise use default
@@ -107,7 +110,8 @@ elf64_exec(int fd, Elf_Ehdr *elf, u_int64_t *entryp, void **ssymp, void **esymp)
/* Zero BSS. */
if (phdr.p_filesz < phdr.p_memsz) {
- printf("+%lu@0x%lx", (u_long)phdr.p_memsz - phdr.p_filesz,
+ printf("+%lu@0x%lx",
+ (u_long)phdr.p_memsz - phdr.p_filesz,
(u_long)(phdr.p_vaddr + phdr.p_filesz));
bzero((void *)(long)phdr.p_vaddr + phdr.p_filesz,
(size_t)phdr.p_memsz - phdr.p_filesz);