Module Name: src Committed By: mlelstv Date: Sun May 30 05:59:23 UTC 2021
Modified Files: src/sys/arch/i386/stand/boot: boot2.c src/sys/arch/i386/stand/efiboot: boot.c src/sys/arch/i386/stand/lib: biosdisk.c biosdisk.h exec.c src/sys/lib/libsa: bootcfg.c bootcfg.h Log Message: Add "root" command to provide a BTINFO_ROOTDEVICE parameter. To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/sys/arch/i386/stand/boot/boot2.c cvs rdiff -u -r1.17 -r1.18 src/sys/arch/i386/stand/efiboot/boot.c cvs rdiff -u -r1.54 -r1.55 src/sys/arch/i386/stand/lib/biosdisk.c cvs rdiff -u -r1.12 -r1.13 src/sys/arch/i386/stand/lib/biosdisk.h cvs rdiff -u -r1.76 -r1.77 src/sys/arch/i386/stand/lib/exec.c cvs rdiff -u -r1.5 -r1.6 src/sys/lib/libsa/bootcfg.c cvs rdiff -u -r1.3 -r1.4 src/sys/lib/libsa/bootcfg.h 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/i386/stand/boot/boot2.c diff -u src/sys/arch/i386/stand/boot/boot2.c:1.74 src/sys/arch/i386/stand/boot/boot2.c:1.75 --- src/sys/arch/i386/stand/boot/boot2.c:1.74 Wed Jul 15 12:36:30 2020 +++ src/sys/arch/i386/stand/boot/boot2.c Sun May 30 05:59:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: boot2.c,v 1.74 2020/07/15 12:36:30 kim Exp $ */ +/* $NetBSD: boot2.c,v 1.75 2021/05/30 05:59:22 mlelstv Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -83,6 +83,9 @@ #include <vbe.h> #include "devopen.h" +#ifdef _STANDALONE +#include <bootinfo.h> +#endif #ifdef SUPPORT_PS2 #include <biosmca.h> #endif @@ -130,6 +133,7 @@ void command_boot(char *); void command_pkboot(char *); void command_dev(char *); void command_consdev(char *); +void command_root(char *); #ifndef SMALL void command_menu(char *); #endif @@ -147,6 +151,7 @@ const struct bootblk_command commands[] { "pkboot", command_pkboot }, { "dev", command_dev }, { "consdev", command_consdev }, + { "root", command_root }, #ifndef SMALL { "menu", command_menu }, #endif @@ -450,6 +455,9 @@ command_help(char *arg) #endif "dev [dev:]\n" "consdev {pc|{com[0123]|com[0123]kbd|auto}[,{speed}]}\n" + "root {spec}\n" + " spec can be disk, e.g. wd0, sd0\n" + " or string like wedge:name\n" "vesa {modenum|on|off|enabled|disabled|list}\n" #ifndef SMALL "menu (reenters boot menu, if defined in boot.cfg)\n" @@ -610,6 +618,18 @@ error: printf("invalid console device.\n"); } +void +command_root(char *arg) +{ + struct btinfo_rootdevice *biv = &bi_root; + + strncpy(biv->devname, arg, sizeof(biv->devname)); + if (biv->devname[sizeof(biv->devname)-1] != '\0') { + biv->devname[sizeof(biv->devname)-1] = '\0'; + printf("truncated to %s\n",biv->devname); + } +} + #ifndef SMALL /* ARGSUSED */ void Index: src/sys/arch/i386/stand/efiboot/boot.c diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.17 src/sys/arch/i386/stand/efiboot/boot.c:1.18 --- src/sys/arch/i386/stand/efiboot/boot.c:1.17 Thu Sep 26 12:21:03 2019 +++ src/sys/arch/i386/stand/efiboot/boot.c Sun May 30 05:59:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.17 2019/09/26 12:21:03 nonaka Exp $ */ +/* $NetBSD: boot.c,v 1.18 2021/05/30 05:59:22 mlelstv Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka <non...@netbsd.org> @@ -38,6 +38,10 @@ #include "biosdisk.h" #include "devopen.h" +#ifdef _STANDALONE +#include <bootinfo.h> +#endif + int errno; int boot_biosdev; daddr_t boot_biossector; @@ -65,6 +69,7 @@ void command_quit(char *); void command_boot(char *); void command_pkboot(char *); void command_consdev(char *); +void command_root(char *); void command_dev(char *); void command_devpath(char *); void command_efivar(char *); @@ -88,6 +93,7 @@ const struct bootblk_command commands[] { "boot", command_boot }, { "pkboot", command_pkboot }, { "consdev", command_consdev }, + { "root", command_root }, { "dev", command_dev }, { "devpath", command_devpath }, { "efivar", command_efivar }, @@ -396,6 +402,9 @@ command_help(char *arg) "pkboot [dev:][filename] [-12acdqsvxz]\n" "dev [dev:]\n" "consdev {pc|com[0123][,{speed}]|com,{ioport}[,{speed}]}\n" + "root {spec}\n" + " spec can be disk, e.g. wd0, sd0\n" + " or string like wedge:name\n" "devpath\n" "efivar\n" "gop [{modenum|list}]\n" @@ -590,6 +599,19 @@ error: printf("invalid console device.\n"); } +void +command_root(char *arg) +{ + struct btinfo_rootdevice *biv = &bi_root; + + strncpy(biv->devname, arg, sizeof(biv->devname)); + if (biv->devname[sizeof(biv->devname)-1] != '\0') { + biv->devname[sizeof(biv->devname)-1] = '\0'; + printf("truncated to %s\n",biv->devname); + } +} + + #ifndef SMALL /* ARGSUSED */ void Index: src/sys/arch/i386/stand/lib/biosdisk.c diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.54 src/sys/arch/i386/stand/lib/biosdisk.c:1.55 --- src/sys/arch/i386/stand/lib/biosdisk.c:1.54 Tue Dec 17 01:37:53 2019 +++ src/sys/arch/i386/stand/lib/biosdisk.c Sun May 30 05:59:23 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: biosdisk.c,v 1.54 2019/12/17 01:37:53 manu Exp $ */ +/* $NetBSD: biosdisk.c,v 1.55 2021/05/30 05:59:23 mlelstv Exp $ */ /* * Copyright (c) 1996, 1998 @@ -186,6 +186,7 @@ const struct gpt_part gpt_parts[] = { struct btinfo_bootdisk bi_disk; struct btinfo_bootwedge bi_wedge; +struct btinfo_rootdevice bi_root; #define MBR_PARTS(buf) ((char *)(buf) + offsetof(struct mbr_sector, mbr_parts)) Index: src/sys/arch/i386/stand/lib/biosdisk.h diff -u src/sys/arch/i386/stand/lib/biosdisk.h:1.12 src/sys/arch/i386/stand/lib/biosdisk.h:1.13 --- src/sys/arch/i386/stand/lib/biosdisk.h:1.12 Fri Sep 13 02:19:46 2019 +++ src/sys/arch/i386/stand/lib/biosdisk.h Sun May 30 05:59:23 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: biosdisk.h,v 1.12 2019/09/13 02:19:46 manu Exp $ */ +/* $NetBSD: biosdisk.h,v 1.13 2021/05/30 05:59:23 mlelstv Exp $ */ /* * Copyright (c) 1996 @@ -43,6 +43,7 @@ struct biosdisk_partition { extern struct btinfo_bootdisk bi_disk; extern struct btinfo_bootwedge bi_wedge; +extern struct btinfo_rootdevice bi_root; int biosdisk_strategy(void *, int, daddr_t, size_t, void *, size_t *); int biosdisk_open(struct open_file *, ...); Index: src/sys/arch/i386/stand/lib/exec.c diff -u src/sys/arch/i386/stand/lib/exec.c:1.76 src/sys/arch/i386/stand/lib/exec.c:1.77 --- src/sys/arch/i386/stand/lib/exec.c:1.76 Sat Apr 4 19:50:54 2020 +++ src/sys/arch/i386/stand/lib/exec.c Sun May 30 05:59:23 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: exec.c,v 1.76 2020/04/04 19:50:54 christos Exp $ */ +/* $NetBSD: exec.c,v 1.77 2021/05/30 05:59:23 mlelstv Exp $ */ /* * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -122,6 +122,7 @@ #define MAXMODNAME 32 /* from <sys/module.h> */ extern struct btinfo_console btinfo_console; +extern struct btinfo_rootdevice bi_root; boot_module_t *boot_modules; bool boot_modules_enabled = true; @@ -477,6 +478,8 @@ exec_netbsd(const char *file, physaddr_t BI_ALLOC(BTINFO_MAX); BI_ADD(&btinfo_console, BTINFO_CONSOLE, sizeof(struct btinfo_console)); + if (bi_root.devname[0]) + BI_ADD(&bi_root, BTINFO_ROOTDEVICE, sizeof(struct btinfo_rootdevice)); howto = boothowto; Index: src/sys/lib/libsa/bootcfg.c diff -u src/sys/lib/libsa/bootcfg.c:1.5 src/sys/lib/libsa/bootcfg.c:1.6 --- src/sys/lib/libsa/bootcfg.c:1.5 Sat Jun 27 17:22:12 2020 +++ src/sys/lib/libsa/bootcfg.c Sun May 30 05:59:23 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: bootcfg.c,v 1.5 2020/06/27 17:22:12 jmcneill Exp $ */ +/* $NetBSD: bootcfg.c,v 1.6 2021/05/30 05:59:23 mlelstv Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -80,6 +80,7 @@ bootcfg_do_noop(const char *cmd, char *a * timeout: Timeout in seconds (overrides that set by installboot) * default: the default menu option to use if Return is pressed * consdev: the console device to use + * root: the root device to use * format: how menu choices are displayed: (a)utomatic, (n)umbers or (l)etters * clear: whether to clear the screen or not * @@ -222,6 +223,8 @@ perform_bootcfg(const char *conf, bootcf bootcfg_info.def = atoi(value) - 1; } else if (!strncmp(key, "consdev", 7)) { bootcfg_info.consdev = value; + } else if (!strncmp(key, "root", 4)) { + bootcfg_info.root = value; } else if (!strncmp(key, BOOTCFG_CMD_LOAD, 4)) { command(BOOTCFG_CMD_LOAD, value); } else if (!strncmp(key, "format", 6)) { Index: src/sys/lib/libsa/bootcfg.h diff -u src/sys/lib/libsa/bootcfg.h:1.3 src/sys/lib/libsa/bootcfg.h:1.4 --- src/sys/lib/libsa/bootcfg.h:1.3 Sun Mar 31 20:08:45 2019 +++ src/sys/lib/libsa/bootcfg.h Sun May 30 05:59:23 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: bootcfg.h,v 1.3 2019/03/31 20:08:45 christos Exp $ */ +/* $NetBSD: bootcfg.h,v 1.4 2021/05/30 05:59:23 mlelstv Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -42,6 +42,7 @@ struct bootcfg_def { char *banner[BOOTCFG_MAXBANNER]; /* Banner text */ char *command[BOOTCFG_MAXMENU]; /* Menu commands per entry*/ char *consdev; /* Console device */ + char *root; /* Root specification */ int def; /* Default menu option */ char *desc[BOOTCFG_MAXMENU]; /* Menu text per entry */ int nummenu; /* Number of menu items */