Subject: idea to fix problem where OBP boot-file setting is sometimes ignored
To: NetBSD/sparc Discussion List <port-sparc@NetBSD.ORG>
From: Greg A. Woods <woods@weird.com>
List: port-sparc
Date: 10/07/2003 19:00:07
The OBP boot-file setting is ignored when boot parameters are given but
no filename is given, e.g. when you say "boot -s".

(boot-file is currently only honoured for automatic boots and when the
boot command is simply "boot", presumably because OBP stuffs the value
of boot-file into bootargs if it is given nothing else to use)

Does this (untested) change look right?  (I'm unsure of the use of
prom_rootnode(), and indeed to me the implementation of prom_rootnode()
looks wrong to me -- shouldn't it return "rootnode"?)

Index: sys/arch/sparc/sparc/promlib.c
===================================================================
RCS file: /cvs/master/m-NetBSD/main/src/sys/arch/sparc/sparc/promlib.c,v
retrieving revision 1.13
diff -u -r1.13 promlib.c
--- sys/arch/sparc/sparc/promlib.c	7 Dec 2001 11:00:39 -0000	1.13
+++ sys/arch/sparc/sparc/promlib.c	7 Oct 2003 22:51:44 -0000
@@ -683,8 +683,20 @@
 obp_v2_getbootfile()
 {
 	struct v2bootargs *ba = promops.po_bootcookie;
+	char *kernel = parse_bootfile(*ba->v2_bootargs);
+	static char boot_file[128];
 
-	return (parse_bootfile(*ba->v2_bootargs));
+	/*
+	 * if we get an empty string from parse_bootfile() then we look up the
+	 * "boot-file" property and if it is set then we return its value.
+	 */
+	if (!kernel[0]) {
+		PROM_getpropstringA(prom_rootnode(), "boot-file", boot_file, sizeof(boot_file));
+		if (boot_file[0])
+			kernel = boot_file;
+	}
+
+	return (kernel);
 }
 
 void

-- 
						Greg A. Woods

+1 416 218-0098                  VE3TCP            RoboHack <woods@robohack.ca>
Planix, Inc. <woods@planix.com>          Secrets of the Weird <woods@weird.com>