diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2003-06-10 02:42:59 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2003-06-10 02:42:59 +0000 |
commit | f021052e96ddc17fb3f42d57b87fd8a9b4a792fc (patch) | |
tree | f1e9055b4719299c5e8243e65560ac9efdfd79dd /sys/arch | |
parent | f86a036a433947100034984665ebb5bc11d422b2 (diff) |
- rip out support for a.out and 32-bit kernels
- cleanup and simplify Makefile
jason@ ok
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/sparc64/stand/ofwboot/Makefile | 30 | ||||
-rw-r--r-- | sys/arch/sparc64/stand/ofwboot/boot.c | 261 | ||||
-rw-r--r-- | sys/arch/sparc64/stand/ofwboot/elfXX_exec.c | 8 | ||||
-rw-r--r-- | sys/arch/sparc64/stand/ofwboot/srt0.s | 15 |
4 files changed, 12 insertions, 302 deletions
diff --git a/sys/arch/sparc64/stand/ofwboot/Makefile b/sys/arch/sparc64/stand/ofwboot/Makefile index 28b26250e8d..28600b3765b 100644 --- a/sys/arch/sparc64/stand/ofwboot/Makefile +++ b/sys/arch/sparc64/stand/ofwboot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.6 2001/09/06 19:12:34 jason Exp $ +# $OpenBSD: Makefile,v 1.7 2003/06/10 02:42:58 brad Exp $ # $NetBSD: Makefile,v 1.2 2001/03/04 14:50:05 mrg Exp $ CURDIR= ${.CURDIR} @@ -16,19 +16,18 @@ SRCS= srt0.s Locore.c boot.c ofdev.c alloc.c net.c netif_of.c vers.c .PATH: ${S}/arch/sparc64/sparc64 CWARNFLAGS+= -Wno-main -CFLAGS+= ${COPTS} ${CEXTRAFLAGS} +AFLAGS+= -Wa,-Av9a +AFLAGS+= -x assembler-with-cpp -traditional-cpp -D_LOCORE -D__ELF__ +CFLAGS+= ${COPTS} CPPFLAGS+= -D_STANDALONE -DSUN4U -nostdinc #CPPFLAGS+= -DNETIF_DEBUG -MKMAN= no -STRIPFLAG= BINMODE= 444 -OBJCOPY?= objcopy NEWVERSWHAT= "OpenFirmware Boot" # -# Elf64 defaults to 1MB +# ELF64 defaults to 1MB # # We may get address conflicts with other bootloaders, say # Sun's ufsboot, so we'll pick a reasonably empty address. @@ -45,7 +44,6 @@ CPPFLAGS+= -DRELOC=0x${RELOC} # # XXXXX FIXME # -CPPFLAGS+= -DSPARC_BOOT_AOUT CPPFLAGS+= -DSPARC_BOOT_ELF CPPFLAGS+= -DSPARC_BOOT_UFS CPPFLAGS+= -DSPARC_BOOT_NFS @@ -64,25 +62,11 @@ ${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${OBJS} -L${LIBSADIR} ${LIBSA} -L${LIBKERNDIR} ${LIBKERN} \ -L${LIBZDIR} ${LIBZ} -.include <bsd.prog.mk> - -.if ${MACHINE_ARCH} == "sparc64" -AFLAGS+= -Wa,-Av9a -CEXTRAFLAGS?= -D_LP64 -.else -AFLAGS+= -Wa,-Av8plusa -.endif - -.if CROSS -AFLAGS+= -x assembler-with-cpp -traditional-cpp -D_LOCORE -D__ELF__ -CEXTRAFLAGS?= -D_LP64 -.else -AFLAGS+= -x assembler-with-cpp -traditional-cpp -D_LOCORE -D__ELF__ ${CEXTRAFLAGS} -.endif - NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $< srt0.o: srt0.s ${NORMAL_S} # Explicit dependency for this. boot.o: boot.c elfXX_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 f397f57ff0b..5bb8230a75f 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.9 2003/06/03 15:59:03 deraadt Exp $ */ +/* $OpenBSD: boot.c,v 1.10 2003/06/10 02:42:58 brad 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. @@ -43,9 +43,7 @@ * [promdev[{:|,}partition]]/[filename] [flags] */ -#ifdef ELFSIZE -#undef ELFSIZE /* We use both. */ -#endif +#define ELFSIZE 64 #include <lib/libsa/stand.h> @@ -80,14 +78,9 @@ int debug; #ifdef SPARC_BOOT_ELF -int elf32_exec(int, Elf32_Ehdr *, u_int64_t *, void **, void **); int elf64_exec(int, Elf64_Ehdr *, u_int64_t *, void **, void **); #endif -#ifdef SPARC_BOOT_AOUT -int aout_exec(int, struct exec *, u_int64_t *, void **); -#endif - #if 0 static void prom2boot(dev) @@ -223,11 +216,7 @@ loadfile(fd, args) char *args; { union { -#ifdef SPARC_BOOT_AOUT - struct exec aout; -#endif #ifdef SPARC_BOOT_ELF - Elf32_Ehdr elf32; Elf64_Ehdr elf64; #endif } hdr; @@ -254,16 +243,8 @@ loadfile(fd, args) } /* Determine file type, load kernel. */ -#ifdef SPARC_BOOT_AOUT - if (N_BADMAG(hdr.aout) == 0 && N_GETMID(hdr.aout) == MID_SPARC) { - rval = aout_exec(fd, &hdr.aout, &entry, &esym); - } else -#endif #ifdef SPARC_BOOT_ELF - if (bcmp(hdr.elf32.e_ident, ELFMAG, SELFMAG) == 0 && - hdr.elf32.e_ident[EI_CLASS] == ELFCLASS32) { - rval = elf32_exec(fd, &hdr.elf32, &entry, &ssym, &esym); - } else if (bcmp(hdr.elf64.e_ident, ELFMAG, SELFMAG) == 0 && + if (bcmp(hdr.elf64.e_ident, ELFMAG, SELFMAG) == 0 && hdr.elf64.e_ident[EI_CLASS] == ELFCLASS64) { rval = elf64_exec(fd, &hdr.elf64, &entry, &ssym, &esym); } else @@ -295,244 +276,8 @@ loadfile(fd, args) return (rval); } -#ifdef SPARC_BOOT_AOUT -int -aout_exec(fd, hdr, entryp, esymp) - int fd; - struct exec *hdr; - u_int64_t *entryp; - void **esymp; -{ - void *addr; - int n, *paddr; - -#ifdef DEBUG - printf("auout_exec: "); -#endif - /* Display the load address (entry point) for a.out. */ - printf("Booting %s @ 0x%lx\n", opened_name, hdr->a_entry); - addr = (void *)((u_int64_t)hdr->a_entry); - - /* - * Determine memory needed for kernel and allocate it from - * the firmware. - */ - n = hdr->a_text + hdr->a_data + hdr->a_bss + hdr->a_syms + sizeof(int); - if ((paddr = OF_claim(addr, n, 0)) == (int *)-1) - panic("cannot claim memory"); - - /* Load text. */ - lseek(fd, N_TXTOFF(*hdr), SEEK_SET); - printf("%lu", hdr->a_text); - if (read(fd, paddr, hdr->a_text) != hdr->a_text) { - printf("read text: %s\n", strerror(errno)); - return (1); - } - syncicache((void *)paddr, hdr->a_text); - - /* Load data. */ - printf("+%lu", hdr->a_data); - if (read(fd, (void *)paddr + hdr->a_text, hdr->a_data) != hdr->a_data) { - printf("read data: %s\n", strerror(errno)); - return (1); - } - - /* Zero BSS. */ - printf("+%lu", hdr->a_bss); - bzero((void *)paddr + hdr->a_text + hdr->a_data, hdr->a_bss); - - /* Symbols. */ - *esymp = paddr; - paddr = (int *)((void *)paddr + hdr->a_text + hdr->a_data + hdr->a_bss); - *paddr++ = hdr->a_syms; - if (hdr->a_syms) { - printf(" [%lu", hdr->a_syms); - if (read(fd, paddr, hdr->a_syms) != hdr->a_syms) { - printf("read symbols: %s\n", strerror(errno)); - return (1); - } - paddr = (int *)((void *)paddr + hdr->a_syms); - if (read(fd, &n, sizeof(int)) != sizeof(int)) { - printf("read symbols: %s\n", strerror(errno)); - return (1); - } - if (OF_claim((void *)paddr, n + sizeof(int), 0) == (void *)-1) - panic("cannot claim memory"); - *paddr++ = n; - if (read(fd, paddr, n - sizeof(int)) != n - sizeof(int)) { - printf("read symbols: %s\n", strerror(errno)); - return (1); - } - printf("+%d]", n - sizeof(int)); - *esymp = paddr + (n - sizeof(int)); - } - - *entryp = hdr->a_entry; - return (0); -} -#endif /* SPARC_BOOT_AOUT */ - #ifdef SPARC_BOOT_ELF -#if 1 -/* New style */ - -#ifdef ELFSIZE -#undef ELFSIZE -#endif - -#define ELFSIZE 32 #include "elfXX_exec.c" - -#undef ELFSIZE -#define ELFSIZE 64 -#include "elfXX_exec.c" - -#else -/* Old style */ -int -elf32_exec(fd, elf, entryp, ssymp, esymp) - int fd; - Elf32_Ehdr *elf; - u_int64_t *entryp; - void **ssymp; - void **esymp; -{ - Elf32_Shdr *shp; - Elf32_Off off; - void *addr; - size_t size; - int i, first = 1; - long align; - int n; - - /* - * Don't display load address for ELF; it's encoded in - * each section. - */ -#ifdef DEBUG - printf("elf_exec: "); -#endif - printf("Booting %s\n", opened_name); - - for (i = 0; i < elf->e_phnum; i++) { - Elf32_Phdr phdr; - (void)lseek(fd, elf->e_phoff + sizeof(phdr) * i, SEEK_SET); - if (read(fd, (void *)&phdr, sizeof(phdr)) != sizeof(phdr)) { - printf("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. */ - printf("%s%lu@0x%lx", first ? "" : "+", phdr.p_filesz, - (u_long)phdr.p_vaddr); - (void)lseek(fd, 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 - * alignment. - */ - align = phdr.p_align; - if ((phdr.p_vaddr & (4*MEG-1)) == 0) - align = 4*MEG; - if (OF_claim((void *)phdr.p_vaddr, phdr.p_memsz, phdr.p_align) == - (void *)-1) - panic("cannot claim memory"); - if (read(fd, (void *)phdr.p_vaddr, phdr.p_filesz) != - phdr.p_filesz) { - printf("read segment: %s\n", strerror(errno)); - return (1); - } - syncicache((void *)phdr.p_vaddr, phdr.p_filesz); - - /* Zero BSS. */ - if (phdr.p_filesz < phdr.p_memsz) { - printf("+%lu@0x%lx", phdr.p_memsz - phdr.p_filesz, - (u_long)(phdr.p_vaddr + phdr.p_filesz)); - bzero((void *)phdr.p_vaddr + phdr.p_filesz, - phdr.p_memsz - phdr.p_filesz); - } - first = 0; - } - - printf(" \n"); - -#if 1 /* I want to rethink this... --thorpej@netbsd.org */ - /* - * Compute the size of the symbol table. - */ - size = sizeof(Elf32_Ehdr) + (elf->e_shnum * sizeof(Elf32_Shdr)); - shp = addr = alloc(elf->e_shnum * sizeof(Elf32_Shdr)); - (void)lseek(fd, elf->e_shoff, SEEK_SET); - if (read(fd, addr, elf->e_shnum * sizeof(Elf32_Shdr)) != - elf->e_shnum * sizeof(Elf32_Shdr)) { - printf("read section headers: %s\n", strerror(errno)); - return (1); - } - for (i = 0; i < elf->e_shnum; i++, shp++) { - if (shp->sh_type == SHT_NULL) - continue; - if (shp->sh_type != SHT_SYMTAB && - shp->sh_type != SHT_STRTAB) { - shp->sh_offset = 0; - shp->sh_type = SHT_NOBITS; - continue; - } - size += shp->sh_size; - } - shp = addr; - - /* - * Reserve memory for the symbols. - */ - if ((addr = OF_claim(0, size, NBPG)) == (void *)-1) - panic("no space for symbol table"); - - /* - * Copy the headers. - */ - elf->e_phoff = 0; - elf->e_shoff = sizeof(Elf32_Ehdr); - elf->e_phentsize = 0; - elf->e_phnum = 0; - bcopy(elf, addr, sizeof(Elf32_Ehdr)); - bcopy(shp, addr + sizeof(Elf32_Ehdr), elf->e_shnum * sizeof(Elf32_Shdr)); - free(shp, elf->e_shnum * sizeof(Elf32_Shdr)); - *ssymp = addr; - - /* - * Now load the symbol sections themselves. - */ - shp = addr + sizeof(Elf32_Ehdr); - addr += sizeof(Elf32_Ehdr) + (elf->e_shnum * sizeof(Elf32_Shdr)); - off = sizeof(Elf32_Ehdr) + (elf->e_shnum * sizeof(Elf32_Shdr)); - for (first = 1, i = 0; i < elf->e_shnum; i++, shp++) { - if (shp->sh_type == SHT_SYMTAB || - shp->sh_type == SHT_STRTAB) { - if (first) - printf("symbols @ 0x%lx ", (u_long)addr); - printf("%s%d", first ? "" : "+", shp->sh_size); - (void)lseek(fd, shp->sh_offset, SEEK_SET); - if (read(fd, addr, shp->sh_size) != shp->sh_size) { - printf("read symbols: %s\n", strerror(errno)); - return (1); - } - addr += (shp->sh_size+3)&(~3); - shp->sh_offset = off; - off += (shp->sh_size+3)&(~3); - first = 0; - } - } - *esymp = addr; -#endif /* 0 */ - - *entryp = elf->e_entry; - return (0); -} -#endif #endif /* SPARC_BOOT_ELF */ void diff --git a/sys/arch/sparc64/stand/ofwboot/elfXX_exec.c b/sys/arch/sparc64/stand/ofwboot/elfXX_exec.c index d8ceeb14e1f..ed587d5dfe7 100644 --- a/sys/arch/sparc64/stand/ofwboot/elfXX_exec.c +++ b/sys/arch/sparc64/stand/ofwboot/elfXX_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: elfXX_exec.c,v 1.4 2002/03/14 03:16:01 millert Exp $ */ +/* $OpenBSD: elfXX_exec.c,v 1.5 2003/06/10 02:42:58 brad Exp $ */ /* $NetBSD: elfXX_exec.c,v 1.2 2001/08/15 20:08:15 eeh Exp $ */ /* @@ -51,13 +51,7 @@ #if 0 int CAT3(elf,ELFSIZE,_exec)(int, CAT3(Elf,ELFSIZE,_Ehdr) *, u_int64_t *, void **, void **); #endif -#if defined(ELFSIZE) && (ELFSIZE == 32) -#define ELF_ALIGN(x) (((x)+3)&(~3)) -#elif defined(ELFSIZE) && (ELFSIZE == 64) #define ELF_ALIGN(x) (((x)+7)&(~7)) -#else -#error ELFSIZE must be either 32 or 64! -#endif int CAT3(elf, ELFSIZE, _exec)(fd, elf, entryp, ssymp, esymp) diff --git a/sys/arch/sparc64/stand/ofwboot/srt0.s b/sys/arch/sparc64/stand/ofwboot/srt0.s index 8ffa5aa900b..edca81e7f88 100644 --- a/sys/arch/sparc64/stand/ofwboot/srt0.s +++ b/sys/arch/sparc64/stand/ofwboot/srt0.s @@ -1,4 +1,4 @@ -/* $OpenBSD: srt0.s,v 1.3 2002/03/14 03:16:01 millert Exp $ */ +/* $OpenBSD: srt0.s,v 1.4 2003/06/10 02:42:58 brad Exp $ */ /* $NetBSD: srt0.s,v 1.1 2000/08/20 14:58:42 mrg Exp $ */ /* @@ -67,7 +67,6 @@ _start: /* * Start by creating a stack for ourselves. */ -#ifdef _LP64 /* 64-bit stack */ btst 1, %sp set CC64FSZ, %g1 ! Frame Size (negative) @@ -78,18 +77,6 @@ _start: 1: sub %sp, %g1, %g1 save %g1, %g0, %sp -#else - /* 32-bit stack */ - btst 1, %sp - set CC64FSZ, %g1 ! Frame Size (negative) - bz 1f - set BIAS, %g2 - sub %g1, %g2, %g1 -1: - sub %sp, %g1, %g1 ! This is so we properly sign-extend things - andn %g1, 0x7, %g1 - save %g1, %g0, %sp -#endif ! mov %i0, %i4 ! Apparenty we get our CIF in i0 |