From b1d1120084ba3295472aa30db37c68a27a8e8df7 Mon Sep 17 00:00:00 2001 From: tsubai Date: Mon, 13 Aug 2001 15:38:11 +0000 Subject: [PATCH] Search "/netbsd.gz" and "/netbsd.macppc" in addition to "/netbsd". --- sys/arch/macppc/stand/ofwboot/boot.c | 32 ++++++++++++++++++++++----- sys/arch/macppc/stand/ofwboot/ofdev.c | 8 +++---- sys/arch/macppc/stand/ofwboot/ofdev.h | 12 +++++----- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/sys/arch/macppc/stand/ofwboot/boot.c b/sys/arch/macppc/stand/ofwboot/boot.c index 3e01e33d7ed3..3eef90796294 100644 --- a/sys/arch/macppc/stand/ofwboot/boot.c +++ b/sys/arch/macppc/stand/ofwboot/boot.c @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.11 2001/07/22 11:29:48 wiz Exp $ */ +/* $NetBSD: boot.c,v 1.12 2001/08/13 15:38:11 tsubai Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -95,12 +95,19 @@ #include "ofdev.h" #include "openfirm.h" +#ifdef DEBUG +# define DPRINTF printf +#else +# define DPRINTF while (0) printf +#endif + char bootdev[128]; char bootfile[128]; int boothowto; int debug; static ofw_version = 0; +static char *kernels[] = { "/netbsd", "/netbsd.gz", "/netbsd.macppc", NULL }; static void prom2boot(dev) @@ -242,20 +249,33 @@ main() prom2boot(bootdev); parseargs(bootline, &boothowto); + DPRINTF("bootline=%s\n", bootline); for (;;) { + int i; + if (boothowto & RB_ASKNAME) { printf("Boot: "); gets(bootline); parseargs(bootline, &boothowto); } - marks[MARK_START] = 0; - if (loadfile(bootline, marks, LOAD_ALL) >= 0) - break; - if (errno) - printf("open %s: %s\n", opened_name, strerror(errno)); + + if (bootline[0]) { + kernels[0] = bootline; + kernels[1] = NULL; + } + + for (i = 0; kernels[i]; i++) { + DPRINTF("Trying %s\n", kernels[i]); + + marks[MARK_START] = 0; + if (loadfile(kernels[i], marks, LOAD_KERNEL) >= 0) + goto loaded; + } boothowto |= RB_ASKNAME; } +loaded: + #ifdef __notyet__ OF_setprop(chosen, "bootpath", opened_name, strlen(opened_name) + 1); cp = bootline; diff --git a/sys/arch/macppc/stand/ofwboot/ofdev.c b/sys/arch/macppc/stand/ofwboot/ofdev.c index 83f92eb868ec..bad2d2dad015 100644 --- a/sys/arch/macppc/stand/ofwboot/ofdev.c +++ b/sys/arch/macppc/stand/ofwboot/ofdev.c @@ -1,4 +1,4 @@ -/* $NetBSD: ofdev.c,v 1.6 2001/07/22 11:29:48 wiz Exp $ */ +/* $NetBSD: ofdev.c,v 1.7 2001/08/13 15:38:11 tsubai Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -41,11 +41,11 @@ #include #include -#include #include #include -#include +#include +#include "hfs.h" #include "ofdev.h" extern char bootdev[]; @@ -273,7 +273,7 @@ devopen(of, name, file) *cp = 0; } if (!cp || !*buf) - strcpy(buf, DEFAULT_KERNEL); + return ENOENT; if (!*fname) strcpy(fname, bootdev); strcpy(opened_name, fname); diff --git a/sys/arch/macppc/stand/ofwboot/ofdev.h b/sys/arch/macppc/stand/ofwboot/ofdev.h index 8db4e6a6d4c7..82f3529b908d 100644 --- a/sys/arch/macppc/stand/ofwboot/ofdev.h +++ b/sys/arch/macppc/stand/ofwboot/ofdev.h @@ -1,4 +1,4 @@ -/* $NetBSD: ofdev.h,v 1.2 1999/02/04 15:41:15 tsubai Exp $ */ +/* $NetBSD: ofdev.h,v 1.3 2001/08/13 15:38:11 tsubai Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -30,8 +30,8 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _STAND_DEV_H_ -#define _STAND_DEV_H_ +#ifndef _STAND_DEV_H_ +#define _STAND_DEV_H_ struct of_dev { int handle; @@ -42,10 +42,8 @@ struct of_dev { }; /* Known types: */ -#define OFDEV_NET 1 -#define OFDEV_DISK 2 - -#define DEFAULT_KERNEL "/netbsd" +#define OFDEV_NET 1 +#define OFDEV_DISK 2 extern char opened_name[]; extern int floppyboot;