From 7d73a3330371286c3b3b0c935dabb9f849aef4d1 Mon Sep 17 00:00:00 2001 From: benno Date: Fri, 10 Nov 2000 06:39:58 +0000 Subject: OpenFirmware/PowerPC loader, part 2. As of this patchset, the loader builds (under NetBSD/macppc), boots, interacts and talks to BOOTP/NFS servers. (main.c was moved from boot/ofw/libofw to boot/ofw/common but has no revision history) Reviewed by: obrien --- sys/boot/powerpc/loader/Makefile | 62 ++++++++++++++---------- sys/boot/powerpc/loader/conf.c | 9 ++-- sys/boot/powerpc/loader/start.c | 102 +++++++++++++++++++++++++++++++++++++++ sys/boot/powerpc/ofw/Makefile | 62 ++++++++++++++---------- sys/boot/powerpc/ofw/conf.c | 9 ++-- sys/boot/powerpc/ofw/start.c | 102 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 282 insertions(+), 64 deletions(-) create mode 100644 sys/boot/powerpc/loader/start.c create mode 100644 sys/boot/powerpc/ofw/start.c (limited to 'sys/boot/powerpc') diff --git a/sys/boot/powerpc/loader/Makefile b/sys/boot/powerpc/loader/Makefile index 8576fbf..b6d1835 100644 --- a/sys/boot/powerpc/loader/Makefile +++ b/sys/boot/powerpc/loader/Makefile @@ -4,15 +4,26 @@ BASE= loader PROG= ${BASE} NOMAN= MAN1= +STRIP= NEWVERSWHAT= "bootstrap loader" OpenFirmware/PowerPC BINDIR?= /boot -NOGCCERROR= YES +LOADER_DISK_SUPPORT?= yes +LOADER_NET_SUPPORT?= yes # architecture-specific loader code SRCS= conf.c +# Pull in common loader code +.PATH: ${.CURDIR}/../../ofw/common +.include <${.CURDIR}/../../ofw/common/Makefile.inc> + +.if defined(LOADER_DISK_SUPPORT) CFLAGS+= -DLOADER_DISK_SUPPORT +.endif +.if defined(LOADER_NET_SUPPORT) +CFLAGS+= -DLOADER_NET_SUPPORT +.endif .if !defined(NOFORTH) # Enable BootForth @@ -26,9 +37,10 @@ LIBFICL= ${.CURDIR}/../../ficl/libficl.a .endif # Always add MI sources -.PATH: ${.CURDIR}/../../common -.include <${.CURDIR}/../../common/Makefile.inc> -CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I. +.PATH: ${.CURDIR}/../../common +.include <${.CURDIR}/../../common/Makefile.inc> +CFLAGS+= -I${.CURDIR}/../../common +CFLAGS+= -I${.CURDIR}/../../.. -I. CLEANFILES+= vers.c vers.o ${BASE}.list ${BASE}.bin ${BASE}.sym ${BASE}.help @@ -56,13 +68,16 @@ CFLAGS+= -elf # New linker set code #CFLAGS+= -DNEW_LINKER_SET +# Debug me! +CFLAGS+= -g +LDFLAGS+= -g + vers.o: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} ${CC} -c vers.c ${BASE}.help: help.common help.ofw - cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk \ - > ${.TARGET} + cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} beforeinstall: .if exists(${DESTDIR}/boot/loader) @@ -70,45 +85,40 @@ beforeinstall: .endif .if exists(${.OBJDIR}/loader.help) ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${.OBJDIR}/${BASE}.help ${DESTDIR}/boot + ${.OBJDIR}/${BASE}.help ${DESTDIR}/boot .else ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${.CURDIR}/${BASE}.help ${DESTDIR}/boot + ${.CURDIR}/${BASE}.help ${DESTDIR}/boot .endif .if !exists(${DESTDIR}/boot/loader.rc) ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${.CURDIR}/../../forth/loader.rc ${DESTDIR}/boot + ${.CURDIR}/../../forth/loader.rc ${DESTDIR}/boot .endif ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${.CURDIR}/../../forth/loader.4th ${DESTDIR}/boot + ${.CURDIR}/../../forth/loader.4th ${DESTDIR}/boot ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${.CURDIR}/../../forth/support.4th ${DESTDIR}/boot + ${.CURDIR}/../../forth/support.4th ${DESTDIR}/boot ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${.CURDIR}/../../forth/loader.conf ${DESTDIR}/boot/defaults + ${.CURDIR}/../../forth/loader.conf ${DESTDIR}/boot/defaults + +${PROG}: ${OBJS} ${LIBOFW} ${LIBSTAND} ${LIBFICL} start.o vers.o setdef0.o setdef1.o + ${LD} ${LDFLAGS} -o ${.TARGET} setdef0.o start.o ${OBJS} setdef1.o \ + vers.o ${LIBFICL} ${LIBOFW} ${LIBSTAND} -${PROG}: ${OBJS} ${LIBOFW} ${LIBSTAND} ${LIBFICL} powerpc.o vers.o setdef0.o \ - setdef1.o - ${LD} ${LDFLAGS} -o ${.TARGET} setdef0.o powerpc.o ${OBJS} setdef1.o \ - vers.o ${LIBFICL} ${LIBOFW} ${LIBSTAND} +setdef0.o: setdefs.h -setdef0.o: setdefs.h +setdef1.o: setdefs.h -setdef1.o: setdefs.h +machine: + ln -sf ${.CURDIR}/../../../powerpc/include machine # Cannot use ${OBJS} above this line .include -# If it's not there, don't consider it a target -.if exists(${.CURDIR}/../../../ofw/include) beforedepend ${OBJS}: machine -machine: - ln -sf ${.CURDIR}/../../../ofw/include machine - -.endif - CLEANFILES+= machine setdefs.h setdef0.c setdef1.c setdef0.o setdef1.o \ - powerpc.o + start.o .ORDER: setdefs.h setdef0.c setdef1.c setdefs.h setdef0.c setdef1.c: ${OBJS} diff --git a/sys/boot/powerpc/loader/conf.c b/sys/boot/powerpc/loader/conf.c index 95a85f7..81ccbe7 100644 --- a/sys/boot/powerpc/loader/conf.c +++ b/sys/boot/powerpc/loader/conf.c @@ -48,8 +48,7 @@ struct devsw *devsw[] = { &ofwdisk, #endif #if defined(LOADER_NET_SUPPORT) - &ofwnet, - &ofwnet, + &netdev, #endif NULL }; @@ -71,13 +70,11 @@ struct fs_ops *file_system[] = { NULL }; -extern struct netif_driver of_net; - struct netif_driver *netif_drivers[] = { #ifdef LOADER_NET_SUPPORT - &of_net, + &ofwnet, #endif - NULL, + NULL, }; /* Exported for PowerPC only */ diff --git a/sys/boot/powerpc/loader/start.c b/sys/boot/powerpc/loader/start.c new file mode 100644 index 0000000..a9aef2a --- /dev/null +++ b/sys/boot/powerpc/loader/start.c @@ -0,0 +1,102 @@ +/* $FreeBSD$ */ +/* $NetBSD: Locore.c,v 1.7 2000/08/20 07:04:59 tsubai Exp $ */ + +/* + * Copyright (C) 1995, 1996 Wolfgang Solfrank. + * Copyright (C) 1995, 1996 TooLs GmbH. + * All rights reserved. + * + * 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 TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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. + */ + +#include +#include "libofw.h" + +void startup(void *, int, int (*)(void *), char *, int); + +static int stack[8192/4 + 4]; + +#ifdef XCOFF_GLUE +asm(" + .text + .globl _entry +_entry: + .long _start,0,0 +"); +#endif + +asm(" + .text + .globl _start +_start: + li 8,0 + li 9,0x100 + mtctr 9 +1: + dcbf 0,8 + icbi 0,8 + addi 8,8,0x20 + bdnz 1b + sync + isync + + lis 1,stack@ha + addi 1,1,stack@l + addi 1,1,8192 + + mfmsr 8 + li 0,0 + mtmsr 0 + isync + + mtibatu 0,0 + mtibatu 1,0 + mtibatu 2,0 + mtibatu 3,0 + mtdbatu 0,0 + mtdbatu 1,0 + mtdbatu 2,0 + mtdbatu 3,0 + + li 9,0x12 /* BATL(0, BAT_M, BAT_PP_RW) */ + mtibatl 0,9 + mtdbatl 0,9 + li 9,0x1ffe /* BATU(0, BAT_BL_256M, BAT_Vs) */ + mtibatu 0,9 + mtdbatu 0,9 + isync + + mtmsr 8 + isync + + b startup +"); + +void +startup(void *vpd, int res, int (*openfirm)(void *), char *arg, int argl) +{ + main(openfirm); +} diff --git a/sys/boot/powerpc/ofw/Makefile b/sys/boot/powerpc/ofw/Makefile index 8576fbf..b6d1835 100644 --- a/sys/boot/powerpc/ofw/Makefile +++ b/sys/boot/powerpc/ofw/Makefile @@ -4,15 +4,26 @@ BASE= loader PROG= ${BASE} NOMAN= MAN1= +STRIP= NEWVERSWHAT= "bootstrap loader" OpenFirmware/PowerPC BINDIR?= /boot -NOGCCERROR= YES +LOADER_DISK_SUPPORT?= yes +LOADER_NET_SUPPORT?= yes # architecture-specific loader code SRCS= conf.c +# Pull in common loader code +.PATH: ${.CURDIR}/../../ofw/common +.include <${.CURDIR}/../../ofw/common/Makefile.inc> + +.if defined(LOADER_DISK_SUPPORT) CFLAGS+= -DLOADER_DISK_SUPPORT +.endif +.if defined(LOADER_NET_SUPPORT) +CFLAGS+= -DLOADER_NET_SUPPORT +.endif .if !defined(NOFORTH) # Enable BootForth @@ -26,9 +37,10 @@ LIBFICL= ${.CURDIR}/../../ficl/libficl.a .endif # Always add MI sources -.PATH: ${.CURDIR}/../../common -.include <${.CURDIR}/../../common/Makefile.inc> -CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I. +.PATH: ${.CURDIR}/../../common +.include <${.CURDIR}/../../common/Makefile.inc> +CFLAGS+= -I${.CURDIR}/../../common +CFLAGS+= -I${.CURDIR}/../../.. -I. CLEANFILES+= vers.c vers.o ${BASE}.list ${BASE}.bin ${BASE}.sym ${BASE}.help @@ -56,13 +68,16 @@ CFLAGS+= -elf # New linker set code #CFLAGS+= -DNEW_LINKER_SET +# Debug me! +CFLAGS+= -g +LDFLAGS+= -g + vers.o: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} ${CC} -c vers.c ${BASE}.help: help.common help.ofw - cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk \ - > ${.TARGET} + cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} beforeinstall: .if exists(${DESTDIR}/boot/loader) @@ -70,45 +85,40 @@ beforeinstall: .endif .if exists(${.OBJDIR}/loader.help) ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${.OBJDIR}/${BASE}.help ${DESTDIR}/boot + ${.OBJDIR}/${BASE}.help ${DESTDIR}/boot .else ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${.CURDIR}/${BASE}.help ${DESTDIR}/boot + ${.CURDIR}/${BASE}.help ${DESTDIR}/boot .endif .if !exists(${DESTDIR}/boot/loader.rc) ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${.CURDIR}/../../forth/loader.rc ${DESTDIR}/boot + ${.CURDIR}/../../forth/loader.rc ${DESTDIR}/boot .endif ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${.CURDIR}/../../forth/loader.4th ${DESTDIR}/boot + ${.CURDIR}/../../forth/loader.4th ${DESTDIR}/boot ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${.CURDIR}/../../forth/support.4th ${DESTDIR}/boot + ${.CURDIR}/../../forth/support.4th ${DESTDIR}/boot ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${.CURDIR}/../../forth/loader.conf ${DESTDIR}/boot/defaults + ${.CURDIR}/../../forth/loader.conf ${DESTDIR}/boot/defaults + +${PROG}: ${OBJS} ${LIBOFW} ${LIBSTAND} ${LIBFICL} start.o vers.o setdef0.o setdef1.o + ${LD} ${LDFLAGS} -o ${.TARGET} setdef0.o start.o ${OBJS} setdef1.o \ + vers.o ${LIBFICL} ${LIBOFW} ${LIBSTAND} -${PROG}: ${OBJS} ${LIBOFW} ${LIBSTAND} ${LIBFICL} powerpc.o vers.o setdef0.o \ - setdef1.o - ${LD} ${LDFLAGS} -o ${.TARGET} setdef0.o powerpc.o ${OBJS} setdef1.o \ - vers.o ${LIBFICL} ${LIBOFW} ${LIBSTAND} +setdef0.o: setdefs.h -setdef0.o: setdefs.h +setdef1.o: setdefs.h -setdef1.o: setdefs.h +machine: + ln -sf ${.CURDIR}/../../../powerpc/include machine # Cannot use ${OBJS} above this line .include -# If it's not there, don't consider it a target -.if exists(${.CURDIR}/../../../ofw/include) beforedepend ${OBJS}: machine -machine: - ln -sf ${.CURDIR}/../../../ofw/include machine - -.endif - CLEANFILES+= machine setdefs.h setdef0.c setdef1.c setdef0.o setdef1.o \ - powerpc.o + start.o .ORDER: setdefs.h setdef0.c setdef1.c setdefs.h setdef0.c setdef1.c: ${OBJS} diff --git a/sys/boot/powerpc/ofw/conf.c b/sys/boot/powerpc/ofw/conf.c index 95a85f7..81ccbe7 100644 --- a/sys/boot/powerpc/ofw/conf.c +++ b/sys/boot/powerpc/ofw/conf.c @@ -48,8 +48,7 @@ struct devsw *devsw[] = { &ofwdisk, #endif #if defined(LOADER_NET_SUPPORT) - &ofwnet, - &ofwnet, + &netdev, #endif NULL }; @@ -71,13 +70,11 @@ struct fs_ops *file_system[] = { NULL }; -extern struct netif_driver of_net; - struct netif_driver *netif_drivers[] = { #ifdef LOADER_NET_SUPPORT - &of_net, + &ofwnet, #endif - NULL, + NULL, }; /* Exported for PowerPC only */ diff --git a/sys/boot/powerpc/ofw/start.c b/sys/boot/powerpc/ofw/start.c new file mode 100644 index 0000000..a9aef2a --- /dev/null +++ b/sys/boot/powerpc/ofw/start.c @@ -0,0 +1,102 @@ +/* $FreeBSD$ */ +/* $NetBSD: Locore.c,v 1.7 2000/08/20 07:04:59 tsubai Exp $ */ + +/* + * Copyright (C) 1995, 1996 Wolfgang Solfrank. + * Copyright (C) 1995, 1996 TooLs GmbH. + * All rights reserved. + * + * 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 TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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. + */ + +#include +#include "libofw.h" + +void startup(void *, int, int (*)(void *), char *, int); + +static int stack[8192/4 + 4]; + +#ifdef XCOFF_GLUE +asm(" + .text + .globl _entry +_entry: + .long _start,0,0 +"); +#endif + +asm(" + .text + .globl _start +_start: + li 8,0 + li 9,0x100 + mtctr 9 +1: + dcbf 0,8 + icbi 0,8 + addi 8,8,0x20 + bdnz 1b + sync + isync + + lis 1,stack@ha + addi 1,1,stack@l + addi 1,1,8192 + + mfmsr 8 + li 0,0 + mtmsr 0 + isync + + mtibatu 0,0 + mtibatu 1,0 + mtibatu 2,0 + mtibatu 3,0 + mtdbatu 0,0 + mtdbatu 1,0 + mtdbatu 2,0 + mtdbatu 3,0 + + li 9,0x12 /* BATL(0, BAT_M, BAT_PP_RW) */ + mtibatl 0,9 + mtdbatl 0,9 + li 9,0x1ffe /* BATU(0, BAT_BL_256M, BAT_Vs) */ + mtibatu 0,9 + mtdbatu 0,9 + isync + + mtmsr 8 + isync + + b startup +"); + +void +startup(void *vpd, int res, int (*openfirm)(void *), char *arg, int argl) +{ + main(openfirm); +} -- cgit v1.1