Module Name: src
Committed By: jdc
Date: Tue Jun 5 16:22:24 UTC 2012
Modified Files:
src/sys/arch/sparc/include [netbsd-6]: bootinfo.h
src/sys/arch/sparc/sparc [netbsd-6]: autoconf.c
src/sys/arch/sparc/stand/boot [netbsd-6]: boot.c
src/sys/arch/sparc/stand/ofwboot [netbsd-6]: boot.c
src/sys/arch/sparc64/sparc64 [netbsd-6]: autoconf.c
Log Message:
Pull up revisions:
src/sys/arch/sparc/include/bootinfo.h revision 1.6
src/sys/arch/sparc/sparc/autoconf.c revision 1.243
src/sys/arch/sparc/stand/boot/boot.c revision 1.28
src/sys/arch/sparc/stand/ofwboot/boot.c revision 1.29
src/sys/arch/sparc64/include/bootinfo.h revision 1.6-1.7
src/sys/arch/sparc64/sparc64/autoconf.c revision 1.186
(requested by martin in ticket #289).
Pass the "boothowto" from the bootloader to the kernel.
If (an old) bootloader did not pass the flags, check explicitly if we
missed RB_USERCONF and invoke userconf_prompt() in MD code, as MI code
already missed it.
This fixes PR 46466.
Ooops, remove definitions duplicated in <sparc/bootinfo.h>
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.5.112.1 src/sys/arch/sparc/include/bootinfo.h
cvs rdiff -u -r1.242 -r1.242.8.1 src/sys/arch/sparc/sparc/autoconf.c
cvs rdiff -u -r1.27 -r1.27.10.1 src/sys/arch/sparc/stand/boot/boot.c
cvs rdiff -u -r1.28 -r1.28.10.1 src/sys/arch/sparc/stand/ofwboot/boot.c
cvs rdiff -u -r1.185 -r1.185.2.1 src/sys/arch/sparc64/sparc64/autoconf.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/sparc/include/bootinfo.h
diff -u src/sys/arch/sparc/include/bootinfo.h:1.5 src/sys/arch/sparc/include/bootinfo.h:1.5.112.1
--- src/sys/arch/sparc/include/bootinfo.h:1.5 Sat Mar 4 03:39:02 2006
+++ src/sys/arch/sparc/include/bootinfo.h Tue Jun 5 16:22:23 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: bootinfo.h,v 1.5 2006/03/04 03:39:02 uwe Exp $ */
+/* $NetBSD: bootinfo.h,v 1.5.112.1 2012/06/05 16:22:23 jdc Exp $ */
/*
* Copyright (c) 1997
@@ -42,6 +42,7 @@ struct btinfo_common {
#define BTINFO_MAGIC 1
#define BTINFO_SYMTAB 2
#define BTINFO_KERNELFILE 3
+#define BTINFO_BOOTHOWTO 4
struct btinfo_magic {
struct btinfo_common common;
@@ -60,6 +61,11 @@ struct btinfo_kernelfile {
char name[1]; /* variable length */
};
+struct btinfo_boothowto {
+ struct btinfo_common common;
+ int boothowto;
+};
+
#ifdef _KERNEL
void *lookup_bootinfo(int);
#endif
Index: src/sys/arch/sparc/sparc/autoconf.c
diff -u src/sys/arch/sparc/sparc/autoconf.c:1.242 src/sys/arch/sparc/sparc/autoconf.c:1.242.8.1
--- src/sys/arch/sparc/sparc/autoconf.c:1.242 Sun Jul 17 23:18:23 2011
+++ src/sys/arch/sparc/sparc/autoconf.c Tue Jun 5 16:22:23 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.242 2011/07/17 23:18:23 mrg Exp $ */
+/* $NetBSD: autoconf.c,v 1.242.8.1 2012/06/05 16:22:23 jdc Exp $ */
/*
* Copyright (c) 1996
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.242 2011/07/17 23:18:23 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.242.8.1 2012/06/05 16:22:23 jdc Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -75,6 +75,7 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
#include <sys/msgbuf.h>
#include <sys/boot_flag.h>
#include <sys/ksyms.h>
+#include <sys/userconf.h>
#include <net/if.h>
#include <net/if_ether.h>
@@ -270,6 +271,7 @@ bootstrap(void)
#else
extern int end[];
#endif
+ struct btinfo_boothowto *bi_howto;
prom_init();
@@ -352,6 +354,11 @@ bootstrap(void)
(void*)bi_sym->esym);
}
#endif
+
+ if ((bi_howto = lookup_bootinfo(BTINFO_BOOTHOWTO)) != NULL) {
+ boothowto = bi_howto->boothowto;
+printf("initialized boothowt from bootloader: %x\n", boothowto);
+ }
}
#if defined(SUN4M) && !defined(MSIIEP)
@@ -915,12 +922,21 @@ void
cpu_configure(void)
{
struct pcb *pcb0;
+ bool userconf = (boothowto & RB_USERCONF) != 0;
/* initialise the softintr system */
sparc_softintr_init();
/* build the bootpath */
bootpath_build();
+ if (((boothowto & RB_USERCONF) != 0) && !userconf)
+ /*
+ * Old bootloaders do not pass boothowto, and MI code
+ * has already handled userconfig before we get here
+ * and finally fetch the right options. So if we missed
+ * it, just do it here.
+ */
+ userconf_prompt();
#if defined(SUN4)
if (CPU_ISSUN4) {
Index: src/sys/arch/sparc/stand/boot/boot.c
diff -u src/sys/arch/sparc/stand/boot/boot.c:1.27 src/sys/arch/sparc/stand/boot/boot.c:1.27.10.1
--- src/sys/arch/sparc/stand/boot/boot.c:1.27 Sat Jan 22 19:19:23 2011
+++ src/sys/arch/sparc/stand/boot/boot.c Tue Jun 5 16:22:24 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: boot.c,v 1.27 2011/01/22 19:19:23 joerg Exp $ */
+/* $NetBSD: boot.c,v 1.27.10.1 2012/06/05 16:22:24 jdc Exp $ */
/*-
* Copyright (c) 1982, 1986, 1990, 1993
@@ -244,6 +244,7 @@ main(void)
const char *k;
u_long marks[MARK_MAX], bootinfo;
struct btinfo_symtab bi_sym;
+ struct btinfo_boothowto bi_howto;
void *arg;
#ifdef HEAP_VARIABLE
@@ -337,6 +338,10 @@ main(void)
bi_sym.esym = marks[MARK_END] & loadaddrmask;
bi_add(&bi_sym, BTINFO_SYMTAB, sizeof(bi_sym));
+ /* Add boothowto */
+ bi_howto.boothowto = boothowto;
+ bi_add(&bi_howto, BTINFO_BOOTHOWTO, sizeof(bi_howto));
+
/* Add kernel path to bootinfo */
i = sizeof(struct btinfo_common) + strlen(kernel) + 1;
/* Impose limit (somewhat arbitrary) */
Index: src/sys/arch/sparc/stand/ofwboot/boot.c
diff -u src/sys/arch/sparc/stand/ofwboot/boot.c:1.28 src/sys/arch/sparc/stand/ofwboot/boot.c:1.28.10.1
--- src/sys/arch/sparc/stand/ofwboot/boot.c:1.28 Sat May 21 15:50:42 2011
+++ src/sys/arch/sparc/stand/ofwboot/boot.c Tue Jun 5 16:22:24 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: boot.c,v 1.28 2011/05/21 15:50:42 tsutsui Exp $ */
+/* $NetBSD: boot.c,v 1.28.10.1 2012/06/05 16:22:24 jdc Exp $ */
/*
* Copyright (c) 1997, 1999 Eduardo E. Horvath. All rights reserved.
@@ -251,7 +251,8 @@ ksyms_copyout(void **ssym, void **esym)
* Prepare boot information and jump directly to the kernel.
*/
static void
-jump_to_kernel(u_long *marks, char *kernel, char *args, void *ofw)
+jump_to_kernel(u_long *marks, char *kernel, char *args, void *ofw,
+ int boothowto)
{
int l, machine_tag;
long newargs[4];
@@ -259,6 +260,7 @@ jump_to_kernel(u_long *marks, char *kern
vaddr_t bootinfo;
struct btinfo_symtab bi_sym;
struct btinfo_kernend bi_kend;
+ struct btinfo_boothowto bi_howto;
char *cp;
char bootline[PROM_MAX_PATH * 2];
@@ -279,6 +281,8 @@ jump_to_kernel(u_long *marks, char *kern
bi_add(&bi_sym, BTINFO_SYMTAB, sizeof(bi_sym));
bi_kend.addr= bootinfo + BOOTINFO_SIZE;
bi_add(&bi_kend, BTINFO_KERNEND, sizeof(bi_kend));
+ bi_howto.boothowto = boothowto;
+ bi_add(&bi_howto, BTINFO_BOOTHOWTO, sizeof(bi_howto));
if (bootinfo_pass_bootdev) {
struct {
struct btinfo_common common;
@@ -355,7 +359,8 @@ jump_to_kernel(u_long *marks, char *kern
}
static void
-start_kernel(char *kernel, char *bootline, void *ofw, int isfloppy)
+start_kernel(char *kernel, char *bootline, void *ofw, int isfloppy,
+ int boothowto)
{
int fd;
u_long marks[MARK_MAX];
@@ -381,7 +386,7 @@ start_kernel(char *kernel, char *bootlin
if (fdloadfile(fd, marks, flags) != -1) {
close(fd);
- jump_to_kernel(marks, kernel, bootline, ofw);
+ jump_to_kernel(marks, kernel, bootline, ofw, boothowto);
}
}
(void)printf("Failed to load '%s'.\n", kernel);
@@ -496,7 +501,7 @@ check_boot_config(void)
void
main(void *ofw)
{
- int boothowto, i = 0, isfloppy;
+ int boothowto, i = 0, isfloppy, kboothowto;
char kernel[PROM_MAX_PATH];
char bootline[PROM_MAX_PATH];
@@ -509,7 +514,8 @@ main(void *ofw)
/* Figure boot arguments */
strncpy(bootdev, prom_getbootpath(), sizeof(bootdev) - 1);
- boothowto = bootoptions(prom_getbootargs(), bootdev, kernel, bootline);
+ kboothowto = boothowto =
+ bootoptions(prom_getbootargs(), bootdev, kernel, bootline);
isfloppy = bootdev_isfloppy(bootdev);
for (;; *kernel = '\0') {
@@ -549,7 +555,7 @@ main(void *ofw)
}
check_boot_config();
- start_kernel(kernel, bootline, ofw, isfloppy);
+ start_kernel(kernel, bootline, ofw, isfloppy, kboothowto);
/*
* Try next name from kernel name list if not in askname mode,
Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.185 src/sys/arch/sparc64/sparc64/autoconf.c:1.185.2.1
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.185 Mon Jan 30 12:19:45 2012
+++ src/sys/arch/sparc64/sparc64/autoconf.c Tue Jun 5 16:22:24 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.185 2012/01/30 12:19:45 martin Exp $ */
+/* $NetBSD: autoconf.c,v 1.185.2.1 2012/06/05 16:22:24 jdc Exp $ */
/*
* Copyright (c) 1996
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.185 2012/01/30 12:19:45 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.185.2.1 2012/06/05 16:22:24 jdc Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -73,6 +73,7 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
#include <sys/boot_flag.h>
#include <sys/ksyms.h>
#include <sys/kauth.h>
+#include <sys/userconf.h>
#include <prop/proplib.h>
#include <net/if.h>
@@ -273,6 +274,7 @@ bootstrap(void *o0, void *bootargs, void
struct btinfo_count *bi_count;
struct btinfo_kernend *bi_kend;
struct btinfo_tlb *bi_tlb;
+ struct btinfo_boothowto *bi_howto;
extern void *romtba;
extern void* get_romtba(void);
@@ -348,6 +350,10 @@ die_old_boot_loader:
cputyp = CPU_SUN4V;
}
+ bi_howto = lookup_bootinfo(BTINFO_BOOTHOWTO);
+ if (bi_howto)
+ boothowto = bi_howto->boothowto;
+
LOOKUP_BOOTINFO(bi_count, BTINFO_DTLB_SLOTS);
kernel_tlb_slots = bi_count->count;
LOOKUP_BOOTINFO(bi_tlb, BTINFO_DTLB);
@@ -465,9 +471,18 @@ get_bootpath_from_prom(void)
void
cpu_configure(void)
{
+ bool userconf = (boothowto & RB_USERCONF) != 0;
/* fetch boot device settings */
get_bootpath_from_prom();
+ if (((boothowto & RB_USERCONF) != 0) && !userconf)
+ /*
+ * Old bootloaders do not pass boothowto, and MI code
+ * has already handled userconfig before we get here
+ * and finally fetch the right options. So if we missed
+ * it, just do it here.
+ */
+ userconf_prompt();
/* block clock interrupts and anything below */
splclock();