From: rahnds Date: Tue, 18 Feb 1997 22:36:40 +0000 (+0000) Subject: Add the necessary pieces to boot on a PowerMAC, does not currently work, X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6ee3e529610fe7b86e1dc488bfc38ac303bdbbf2;p=openbsd Add the necessary pieces to boot on a PowerMAC, does not currently work, Debugging in progress. --- diff --git a/sys/arch/powerpc/stand/Locore.c b/sys/arch/powerpc/stand/Locore.c index 9992209d0f5..239ddf23926 100644 --- a/sys/arch/powerpc/stand/Locore.c +++ b/sys/arch/powerpc/stand/Locore.c @@ -1,4 +1,4 @@ -/* $OpenBSD: Locore.c,v 1.3 1997/02/06 23:44:54 rahnds Exp $ */ +/* $OpenBSD: Locore.c,v 1.4 1997/02/18 22:36:40 rahnds Exp $ */ /* $NetBSD: Locore.c,v 1.1 1996/09/30 16:34:58 ws Exp $ */ /* @@ -43,8 +43,12 @@ static int (*openfirmware)(void *); static void setup(); +void _start(); + #define __dead +void const *__start[3] = { &_start, 0, 0}; + __dead void _start(vpd, res, openfirm, arg, argl) void *vpd; @@ -61,6 +65,7 @@ _start(vpd, res, openfirm, arg, argl) exit(); } + __dead void _rtt() { diff --git a/sys/arch/powerpc/stand/Makefile b/sys/arch/powerpc/stand/Makefile index 8d1b8d6b7b3..946e8d5e59d 100644 --- a/sys/arch/powerpc/stand/Makefile +++ b/sys/arch/powerpc/stand/Makefile @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile,v 1.4 1997/02/06 23:44:55 rahnds Exp $ +# $OpenBSD: Makefile,v 1.5 1997/02/18 22:36:40 rahnds Exp $ # $NetBSD: Makefile,v 1.1 1996/09/30 16:34:59 ws Exp $ -SUBDIR= boot +SUBDIR= boot boot.mac SAREL= KERNREL= diff --git a/sys/arch/powerpc/stand/Makefile.inc b/sys/arch/powerpc/stand/Makefile.inc index 4c210d72c06..d54183cc6f4 100644 --- a/sys/arch/powerpc/stand/Makefile.inc +++ b/sys/arch/powerpc/stand/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.2 1996/12/28 06:31:09 rahnds Exp $ +# $OpenBSD: Makefile.inc,v 1.3 1997/02/18 22:36:40 rahnds Exp $ # $NetBSD: Makefile.inc,v 1.1 1996/09/30 16:34:59 ws Exp $ .if !defined(__stand_makefile_inc) @@ -25,7 +25,7 @@ INCLUDES+= -I. -I$(.CURDIR)/.. -I$(S)/arch -I$(S) -I$(S)/lib/libsa DEFS+= -DSTANDALONE -DRELOC=0x$(RELOC) -DLOADADDR=0x$(LOADADDR) \ -DFIREPOWERBUGS CFLAGS+= $(INCLUDES) $(DEFS) $(EXTRACFLAGS) -LDFLAGS= -X -N -Ttext $(RELOC) -e $(ENTRY) +LDFLAGS?= -X -N -Ttext $(RELOC) -e $(ENTRY) cleandir: rm -rf lib machine diff --git a/sys/arch/powerpc/stand/boot.mac/Makefile b/sys/arch/powerpc/stand/boot.mac/Makefile new file mode 100644 index 00000000000..5c6a6e55145 --- /dev/null +++ b/sys/arch/powerpc/stand/boot.mac/Makefile @@ -0,0 +1,32 @@ +# $OpenBSD: Makefile,v 1.1 1997/02/18 22:36:41 rahnds Exp $ +# $NetBSD: Makefile,v 1.1 1996/09/30 16:35:05 ws Exp $ + +R= .. +.PATH: $(.CURDIR)/$(R) +RELOC= 4000 +ENTRY= __start +LOADADDR= 4000 +PROG= boot.mac +SRCS= Locore.c boot.c ofdev.c net.c netif_of.c alloc.c +#CFLAGS+= -DDEBUG -DNETIF_DEBUG +CFLAGS+= -DEXEC_ELF +NOMAN= +STRIP= +MAKEELF= makeelf +BINDIR= /usr/mdec +OBJCOPY?= objcopy +OBJCOPY_ARGS= -O aixcoff-rs6000 -R .stab -R .stabstr -R .comment +LDFLAGS= -X -Ttext $(RELOC) -e $(ENTRY) -T ${.CURDIR}/ld.script + +LIBS!= cd $(.CURDIR)/$(R); $(MAKE) libdep + +$(PROG): $(OBJS) $(LIBS) hack-coff + $(LD) $(LDFLAGS) $(OBJS) $(LIBS) -o ${.TARGET} + ${OBJCOPY} ${OBJCOPY_ARGS} ${.TARGET} + hack-coff ${.TARGET} +# ${MAKEELF} $(REAL_VIRT) a.out $(.TARGET) + +hack-coff: hack-coff.c + ${HOSTCC} -o hack-coff ${.CURDIR}/hack-coff.c + +.include diff --git a/sys/arch/powerpc/stand/boot.mac/hack-coff.c b/sys/arch/powerpc/stand/boot.mac/hack-coff.c new file mode 100644 index 00000000000..989dd033314 --- /dev/null +++ b/sys/arch/powerpc/stand/boot.mac/hack-coff.c @@ -0,0 +1,27 @@ +#include + +char magic[2] = { 1, 0xb }; +char snos[12] = { 0, 1, 0, 1, 0, 2, 0, 0, 0, 0, 0, 3 }; + +main(int ac, char **av) +{ + int fd; + + if (ac != 2) { + fprintf(stderr, "Usage: hack-coff coff-file\n"); + exit(1); + } + if ((fd = open(av[1], 2)) == -1) { + perror(av[2]); + exit(1); + } + if (lseek(fd, (long) 0x14, 0) == -1 + || write(fd, magic, sizeof(magic)) != sizeof(magic) + || lseek(fd, (long) 0x34, 0) == -1 + || write(fd, snos, sizeof(snos)) != sizeof(snos)) { + fprintf(stderr, "%s: write error\n", av[1]); + exit(1); + } + close(fd); + exit(0); +} diff --git a/sys/arch/powerpc/stand/boot.mac/ld.script b/sys/arch/powerpc/stand/boot.mac/ld.script new file mode 100644 index 00000000000..2469ed65dcb --- /dev/null +++ b/sys/arch/powerpc/stand/boot.mac/ld.script @@ -0,0 +1,68 @@ +OUTPUT_ARCH(powerpc) +SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/powerpc-any-elf/lib); +/* Do we need any of these for elf? + __DYNAMIC = 0; */ +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = + SIZEOF_HEADERS; + .interp : { *(.interp) } + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .rel.text : { *(.rel.text) } + .rela.text : { *(.rela.text) } + .rel.data : { *(.rel.data) } + .rela.data : { *(.rela.data) } + .rel.rodata : { *(.rel.rodata) } + .rela.rodata : { *(.rela.rodata) } + .rel.got : { *(.rel.got) } + .rela.got : { *(.rela.got) } + .rel.ctors : { *(.rel.ctors) } + .rela.ctors : { *(.rela.ctors) } + .rel.dtors : { *(.rel.dtors) } + .rela.dtors : { *(.rela.dtors) } + .rel.bss : { *(.rel.bss) } + .rela.bss : { *(.rela.bss) } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + .init : { *(.init) } =0 + .plt : { *(.plt) } + .text : + { + *(.text) + *(.rodata) + *(.rodata1) + *(.got1) + } + .fini : { *(.fini) } =0 + .ctors : { *(.ctors) } + .dtors : { *(.dtors) } + _etext = .; + PROVIDE (etext = .); + /* Read-write section, merged into data segment: */ + . = (. + 0x0FFF) & 0xFFFFF000; + .data : + { + *(.data) + *(.data1) + *(.sdata) + *(.sdata2) + *(.got.plt) *(.got) + *(.dynamic) + CONSTRUCTORS + } + _edata = .; + PROVIDE (edata = .); + __bss_start = .; + .bss : + { + *(.sbss) *(.scommon) + *(.dynbss) + *(.bss) + *(COMMON) + } + _end = . ; + PROVIDE (end = .); +} +