From: aoyama Date: Fri, 14 Oct 2022 20:53:18 +0000 (+0000) Subject: Pass boot device information from bootloader to kernel. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2a8992e01ae72d27e14d2868808c3481beaac352;p=openbsd Pass boot device information from bootloader to kernel. This brings the default root device is the same one of the kernel specified by bootloader, rather than NVRAM setting, like other architectures. "looks good to me" miod@, tested on LUNA-88K2 and nono (LUNA-88K capable emulator) by me. --- diff --git a/sys/arch/luna88k/luna88k/autoconf.c b/sys/arch/luna88k/luna88k/autoconf.c index 6c2e0a6bc83..1028a6141f0 100644 --- a/sys/arch/luna88k/luna88k/autoconf.c +++ b/sys/arch/luna88k/luna88k/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.27 2022/09/23 02:35:46 aoyama Exp $ */ +/* $OpenBSD: autoconf.c,v 1.28 2022/10/14 20:53:18 aoyama Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -62,6 +62,7 @@ void dumpconf(void); void get_autoboot_device(void); int cold = 1; /* 1 if still booting */ +dev_t bootdev; /* set by bootloader, retrieved in locore0.S */ struct device *bootdv; /* set by device drivers (if found) */ /* @@ -118,6 +119,38 @@ get_autoboot_device(void) int i, len, part; extern char *nvram_by_symbol(char *); /* machdep.c */ + if ((bootdev & B_MAGICMASK) == B_DEVMAGIC) { +#ifdef DEBUG + printf("bootdev = 0x%08x (t:%d, a:%d, c:%d, u:%d, p:%d)\n", + bootdev, B_TYPE(bootdev), B_ADAPTOR(bootdev), + B_CONTROLLER(bootdev), B_UNIT(bootdev), + B_PARTITION(bootdev)); +#endif + switch (B_TYPE(bootdev)) { + case 0: + snprintf(autoboot.cont, sizeof(autoboot.cont), + "spc%d", B_CONTROLLER(bootdev)); + break; +#if 0 /* not yet */ + case 1: + snprintf(autoboot.cont, sizeof(autoboot.cont), + "le%d", B_CONTROLLER(bootdev)); + break; +#endif + default: + goto use_nvram_info; + } + autoboot.targ = B_UNIT(bootdev); + autoboot.part = B_PARTITION(bootdev); + return; + } + +use_nvram_info: + /* + * Use old method if we can not get bootdev information from boot loader + */ + printf("%s: no bootdev information, use NVRAM setting\n", __func__); + /* Assume default controller is internal spc (spc0) */ strlcpy(autoboot.cont, "spc0", sizeof(autoboot.cont)); diff --git a/sys/arch/luna88k/luna88k/locore0.S b/sys/arch/luna88k/luna88k/locore0.S index 93fb93c0ff5..b05f7a0093c 100644 --- a/sys/arch/luna88k/luna88k/locore0.S +++ b/sys/arch/luna88k/luna88k/locore0.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore0.S,v 1.4 2022/08/08 11:27:18 aoyama Exp $ */ +/* $OpenBSD: locore0.S,v 1.5 2022/10/14 20:53:18 aoyama Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -121,10 +121,12 @@ ASLOCAL(main_start) cmp %r11, %r2, %r10 bb1 ne, %r11, 1f - or.u %r4, %r0, %hi16(_C_LABEL(esym)) - st %r3, %r4, %lo16(_C_LABEL(esym)) + or.u %r10, %r0, %hi16(_C_LABEL(esym)) + st %r3, %r10, %lo16(_C_LABEL(esym)) 1: #endif + or %r24, %r0, %r4 /* save bootdev */ + or %r25, %r0, %r5 /* save boothowto */ bsr _ASM_LABEL(setup_psr) @@ -195,6 +197,11 @@ ASLOCAL(main_init) or.u %r5, %r0, %hi16(_C_LABEL(first_addr)) st %r4, %r5, %lo16(_C_LABEL(first_addr)) + or.u %r5, %r0, %hi16(_C_LABEL(bootdev)) + st %r24, %r5, %lo16(_C_LABEL(bootdev)) + or.u %r5, %r0, %hi16(_C_LABEL(boothowto)) + st %r25, %r5, %lo16(_C_LABEL(boothowto)) + /* * Have curcpu() point to a valid cpuinfo structure, * and initialize cr17. diff --git a/sys/arch/luna88k/luna88k/machdep.c b/sys/arch/luna88k/luna88k/machdep.c index 040d9542ce7..44bc63c2b0c 100644 --- a/sys/arch/luna88k/luna88k/machdep.c +++ b/sys/arch/luna88k/luna88k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.138 2022/08/10 03:18:19 jsg Exp $ */ +/* $OpenBSD: machdep.c,v 1.139 2022/10/14 20:53:18 aoyama Exp $ */ /* * Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -187,7 +187,6 @@ extern char *esym; int machtype = LUNA_88K; /* may be overwritten in cpu_startup() */ int cputyp = CPU_88100; -int bootdev; /* XXX: should be set in boot loader and locore.S */ int cpuspeed = 33; /* safe guess */ int sysconsole = 0; /* 0 = ttya, may be overwritten in locore0.S */ u_int16_t dipswitch = 0; /* set in locore.S */ diff --git a/sys/arch/luna88k/stand/boot/boot.c b/sys/arch/luna88k/stand/boot/boot.c index 7b13cabc8d7..d6d384b2f0f 100644 --- a/sys/arch/luna88k/stand/boot/boot.c +++ b/sys/arch/luna88k/stand/boot/boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boot.c,v 1.10 2020/05/26 13:47:29 deraadt Exp $ */ +/* $OpenBSD: boot.c,v 1.11 2022/10/14 20:53:18 aoyama Exp $ */ /* $NetBSD: boot.c,v 1.3 2013/03/05 15:34:53 tsutsui Exp $ */ /* @@ -96,9 +96,11 @@ int loadrandom(const char *, char *, size_t); static int get_boot_device(const char *, int *, int *, int *); #endif -void (*cpu_boot)(uint32_t, uint32_t); +void (*cpu_boot)(uint32_t, uint32_t, uint32_t, uint32_t); uint32_t cpu_bootarg1; uint32_t cpu_bootarg2; +uint32_t cpu_bootarg3; +uint32_t cpu_bootarg4; char rnddata[BOOTRANDOM_MAX]; struct rc4_ctx randomctx; @@ -215,9 +217,16 @@ bootunix(char *line) cpu_bootarg1 = BOOT_MAGIC; cpu_bootarg2 = (uint32_t)marks[MARK_END]; - cpu_boot = (void (*)(uint32_t, uint32_t)) + /* cpu_bootarg3 is set in devopen() */ + cpu_bootarg4 = RB_AUTOBOOT; +#ifdef DEBUG + printf("bootarg: 0x%08x, 0x%08x, 0x%08x, 0x%08x\n", + cpu_bootarg1, cpu_bootarg2, cpu_bootarg3, cpu_bootarg4); +#endif + cpu_boot = (void (*)(uint32_t, uint32_t, uint32_t, uint32_t)) (uint32_t)marks[MARK_ENTRY]; - (*cpu_boot)(cpu_bootarg1, cpu_bootarg2); + (*cpu_boot)(cpu_bootarg1, cpu_bootarg2, cpu_bootarg3, + cpu_bootarg4); } printf("Booting kernel failed. (%s)\n", strerror(errno)); diff --git a/sys/arch/luna88k/stand/boot/devopen.c b/sys/arch/luna88k/stand/boot/devopen.c index c296f82c0ca..c1177c8975e 100644 --- a/sys/arch/luna88k/stand/boot/devopen.c +++ b/sys/arch/luna88k/stand/boot/devopen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: devopen.c,v 1.2 2013/10/29 21:49:07 miod Exp $ */ +/* $OpenBSD: devopen.c,v 1.3 2022/10/14 20:53:18 aoyama Exp $ */ /* $NetBSD: devopen.c,v 1.3 2013/01/16 15:46:20 tsutsui Exp $ */ /* @@ -71,6 +71,7 @@ * @(#)conf.c 8.1 (Berkeley) 6/10/93 */ +#include #include #include #include @@ -118,6 +119,9 @@ devopen(struct open_file *f, const char *fname, char **file) f->f_dev = dp; + /* Save boot device information to pass to the kernel */ + cpu_bootarg3 = MAKEBOOTDEV(dev, 0, unit / 10, 6 - unit % 10, part); + return 0; } diff --git a/sys/arch/luna88k/stand/boot/init_main.c b/sys/arch/luna88k/stand/boot/init_main.c index f7b5abc7d9d..a1c5e0af5c1 100644 --- a/sys/arch/luna88k/stand/boot/init_main.c +++ b/sys/arch/luna88k/stand/boot/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.8 2019/04/09 14:21:32 aoyama Exp $ */ +/* $OpenBSD: init_main.c,v 1.9 2022/10/14 20:53:19 aoyama Exp $ */ /* $NetBSD: init_main.c,v 1.6 2013/03/05 15:34:53 tsutsui Exp $ */ /* @@ -188,7 +188,7 @@ main(void) nplane = get_plane_numbers(); cninit(); - printf("\nOpenBSD/" MACHINE " (%s) boot 0.6\n\n", machstr); + printf("\nOpenBSD/" MACHINE " (%s) boot 0.7\n\n", machstr); #ifdef SUPPORT_ETHERNET try_bootp = 1; diff --git a/sys/arch/luna88k/stand/boot/locore.S b/sys/arch/luna88k/stand/boot/locore.S index cb3ae611e98..ed9db57f29a 100644 --- a/sys/arch/luna88k/stand/boot/locore.S +++ b/sys/arch/luna88k/stand/boot/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.2 2013/10/29 21:49:07 miod Exp $ */ +/* $OpenBSD: locore.S,v 1.3 2022/10/14 20:53:19 aoyama Exp $ */ /* * Copyright (c) 2013 Miodrag Vallat. @@ -128,6 +128,10 @@ ASLOCAL(cpu_park) ld %r2, %r2, %lo16(_C_LABEL(cpu_bootarg1)) or.u %r3, %r0, %hi16(_C_LABEL(cpu_bootarg2)) ld %r3, %r3, %lo16(_C_LABEL(cpu_bootarg2)) + or.u %r4, %r0, %hi16(_C_LABEL(cpu_bootarg3)) + ld %r4, %r4, %lo16(_C_LABEL(cpu_bootarg3)) + or.u %r5, %r0, %hi16(_C_LABEL(cpu_bootarg4)) + ld %r5, %r5, %lo16(_C_LABEL(cpu_bootarg4)) jmp %r1 diff --git a/sys/arch/luna88k/stand/boot/samachdep.h b/sys/arch/luna88k/stand/boot/samachdep.h index 26a4784ed5b..4932ae2a1db 100644 --- a/sys/arch/luna88k/stand/boot/samachdep.h +++ b/sys/arch/luna88k/stand/boot/samachdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: samachdep.h,v 1.4 2020/12/09 18:10:19 krw Exp $ */ +/* $OpenBSD: samachdep.h,v 1.5 2022/10/14 20:53:19 aoyama Exp $ */ /* $NetBSD: samachdep.h,v 1.10 2013/03/05 15:34:53 tsutsui Exp $ */ /* @@ -70,9 +70,11 @@ extern int howto; int boot(int, char **); int bootunix(char *); -extern void (*cpu_boot)(uint32_t, uint32_t); +extern void (*cpu_boot)(uint32_t, uint32_t, uint32_t, uint32_t); extern uint32_t cpu_bootarg1; extern uint32_t cpu_bootarg2; +extern uint32_t cpu_bootarg3; +extern uint32_t cpu_bootarg4; #define BOOT_MAGIC 0xf1abde3f /* cons.c */