Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/stand/efiboot Remove banner printing code from bootloade...



details:   https://anonhg.NetBSD.org/src/rev/458723639a50
branches:  trunk
changeset: 985783:458723639a50
user:      nia <nia%NetBSD.org@localhost>
date:      Tue Sep 07 11:41:31 2021 +0000

description:
Remove banner printing code from bootloaders, add it to libsa.

This harmonizes efiboot and the various x86 bootloaders to use shared
code for printing the banner. By friendly coincidence, it also adds
support for specifying 'banner=' in arm efiboot's boot.cfg, as on x86.

diffstat:

 sys/arch/i386/stand/boot/boot2.c      |  46 +++++---------------------
 sys/arch/i386/stand/efiboot/boot.c    |  38 ++++-----------------
 sys/arch/i386/stand/efiboot/efiboot.h |   3 +-
 sys/arch/i386/stand/pxeboot/main.c    |  30 +++++-----------
 sys/lib/libsa/bootcfg.c               |  25 ++++++++++++++-
 sys/lib/libsa/bootcfg.h               |   3 +-
 sys/stand/efiboot/boot.c              |  59 +---------------------------------
 sys/stand/efiboot/efiboot.h           |   3 +-
 8 files changed, 58 insertions(+), 149 deletions(-)

diffs (truncated from 388 to 300 lines):

diff -r f585dba7aa4d -r 458723639a50 sys/arch/i386/stand/boot/boot2.c
--- a/sys/arch/i386/stand/boot/boot2.c  Tue Sep 07 11:00:13 2021 +0000
+++ b/sys/arch/i386/stand/boot/boot2.c  Tue Sep 07 11:41:31 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot2.c,v 1.77 2021/06/21 19:52:17 nia Exp $   */
+/*     $NetBSD: boot2.c,v 1.78 2021/09/07 11:41:31 nia Exp $   */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -121,7 +121,6 @@
 
 char *sprint_bootsel(const char *);
 static void bootit(const char *, int);
-void print_banner(void);
 void boot2(int, uint64_t);
 
 void   command_help(char *);
@@ -298,35 +297,6 @@
                printf("boot returned\n");
 }
 
-void
-print_banner(void)
-{
-
-       clearit();
-#ifndef SMALL
-       int n;
-       if (bootcfg_info.banner[0]) {
-               for (n = 0; n < BOOTCFG_MAXBANNER && bootcfg_info.banner[n];
-                   n++) 
-                       printf("%s\n", bootcfg_info.banner[n]);
-       } else {
-#endif /* !SMALL */
-               printf("\n"
-                      "  \\-__,------,___.\n"
-                      "   \\        __,---`  %s (from NetBSD %s)\n"
-                      "    \\       `---,_.  Revision %s\n"
-                      "     \\-,_____,.---`  Memory: %d/%d k\n"
-                      "      \\\n"
-                      "       \\\n"
-                      "        \\\n",
-                      bootprog_name, bootprog_kernrev,
-                      bootprog_rev,
-                      getbasemem(), getextmem());
-#ifndef SMALL
-       }
-#endif /* !SMALL */
-}
-
 /*
  * Called from the initial entry point boot_start in biosboot.S
  *
@@ -379,10 +349,12 @@
         * If console set in boot.cfg, switch to it.
         * This will print the banner, so we don't need to explicitly do it
         */
-       if (bootcfg_info.consdev)
+       if (bootcfg_info.consdev) {
                command_consdev(bootcfg_info.consdev);
-       else 
-               print_banner();
+       } else {
+               clearit();
+               print_bootcfg_banner(bootprog_name, bootprog_rev);
+       }
 
        /* Display the menu, if applicable */
        twiddle_toggle = 0;
@@ -393,7 +365,8 @@
 
 #else
        twiddle_toggle = 0;
-       print_banner();
+       clearit();
+       print_bootcfg_banner(bootprog_name, bootprog_rev);
 #endif
 
        printf("Press return to boot now, any other key for boot menu\n");
@@ -616,7 +589,8 @@
                }
 
                initio(cdp->tag);
-               print_banner();
+               clearit();
+               print_bootcfg_banner(bootprog_name, bootprog_rev);
                return;
        }
 error:
diff -r f585dba7aa4d -r 458723639a50 sys/arch/i386/stand/efiboot/boot.c
--- a/sys/arch/i386/stand/efiboot/boot.c        Tue Sep 07 11:00:13 2021 +0000
+++ b/sys/arch/i386/stand/efiboot/boot.c        Tue Sep 07 11:41:31 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot.c,v 1.19 2021/06/22 19:53:58 nia Exp $    */
+/*     $NetBSD: boot.c,v 1.20 2021/09/07 11:41:31 nia Exp $    */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -278,31 +278,6 @@
 }
 
 void
-print_banner(void)
-{
-       int n;
-
-       clearit();
-       if (bootcfg_info.banner[0]) {
-               for (n = 0; n < BOOTCFG_MAXBANNER && bootcfg_info.banner[n];
-                   n++)
-                       printf("%s\n", bootcfg_info.banner[n]);
-       } else {
-               printf("\n"
-                  "  \\-__,------,___.\n"
-                  "   \\        __,---`  %s (from NetBSD %s)\n"
-                  "    \\       `---,_.  Revision %s\n"
-                  "     \\-,_____,.---`  Memory: %d/%d k\n"
-                  "      \\\n"  
-                  "       \\\n"
-                  "        \\\n",
-                  bootprog_name, bootprog_kernrev,
-                  bootprog_rev,               
-                  getbasemem(), getextmem());
-       }
-}
-
-void
 boot(void)
 {
        int currname;
@@ -344,10 +319,12 @@
         * If console set in boot.cfg, switch to it.
         * This will print the banner, so we don't need to explicitly do it
         */
-       if (bootcfg_info.consdev)
+       if (bootcfg_info.consdev) {
                command_consdev(bootcfg_info.consdev);
-       else
-               print_banner();
+       } else {
+               clearit();
+               print_bootcfg_banner(bootprog_name, bootprog_rev);
+       }
 
        /* Display the menu, if applicable */
        twiddle_toggle = 0;
@@ -602,7 +579,8 @@
                                }
                        }
                        efi_consinit(cdp->tag, ioport, speed);
-                       print_banner();
+                       clearit();
+                       print_bootcfg_banner(bootprog_name, bootprog_rev);
                        return;
                }
        }
diff -r f585dba7aa4d -r 458723639a50 sys/arch/i386/stand/efiboot/efiboot.h
--- a/sys/arch/i386/stand/efiboot/efiboot.h     Tue Sep 07 11:00:13 2021 +0000
+++ b/sys/arch/i386/stand/efiboot/efiboot.h     Tue Sep 07 11:41:31 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: efiboot.h,v 1.10 2019/09/13 02:19:45 manu Exp $        */
+/*     $NetBSD: efiboot.h,v 1.11 2021/09/07 11:41:31 nia Exp $ */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -41,7 +41,6 @@
 /* boot.c */
 void boot(void);
 void clearit(void);
-void print_banner(void);
 
 /* efiboot.c */
 extern EFI_HANDLE IH;
diff -r f585dba7aa4d -r 458723639a50 sys/arch/i386/stand/pxeboot/main.c
--- a/sys/arch/i386/stand/pxeboot/main.c        Tue Sep 07 11:00:13 2021 +0000
+++ b/sys/arch/i386/stand/pxeboot/main.c        Tue Sep 07 11:41:31 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.31 2014/06/28 09:16:18 rtr Exp $    */
+/*     $NetBSD: main.c,v 1.32 2021/09/07 11:41:32 nia Exp $    */
 
 /*
  * Copyright (c) 1996
@@ -106,20 +106,6 @@
        return (-1);
 }
 
-static void
-print_banner(void)
-{
-       int base = getbasemem();
-       int ext = getextmem();
-
-       clearit();
-       printf("\n"
-              ">> NetBSD/x86 PXE boot, Revision %s (from NetBSD %s)\n"
-              ">> Memory: %d/%d k\n",
-              bootprog_rev, bootprog_kernrev,
-              base, ext);
-}
-
 int
 main(void)
 {
@@ -148,10 +134,12 @@
         * If console set in boot.cfg, switch to it.
         * This will print the banner, so we don't need to explicitly do it
         */
-       if (bootcfg_info.consdev)
+       if (bootcfg_info.consdev) {
                command_consdev(bootcfg_info.consdev);
-       else 
-               print_banner();
+       } else {
+               clearit();
+               print_bootcfg_banner(bootprog_name, bootprog_rev);
+       }
 
        /* Display the menu, if applicable */
        twiddle_toggle = 0;
@@ -161,7 +149,8 @@
        }
 #else
        twiddle_toggle = 0;
-       print_banner();
+       clearit();
+       print_bootcfg_banner(bootprog_name, bootprog_rev);
 #endif
 
        printf("Press return to boot now, any other key for boot menu\n");
@@ -254,7 +243,8 @@
        for (cdp = cons_devs; cdp->name; cdp++) {
                if (!strcmp(arg, cdp->name)) {
                        initio(cdp->tag);
-                       print_banner();
+                       clearit();
+                       print_bootcfg_banner(bootprog_name, bootprog_rev);
                        return;
                }
        }
diff -r f585dba7aa4d -r 458723639a50 sys/lib/libsa/bootcfg.c
--- a/sys/lib/libsa/bootcfg.c   Tue Sep 07 11:00:13 2021 +0000
+++ b/sys/lib/libsa/bootcfg.c   Tue Sep 07 11:41:31 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bootcfg.c,v 1.6 2021/05/30 05:59:23 mlelstv Exp $      */
+/*     $NetBSD: bootcfg.c,v 1.7 2021/09/07 11:41:31 nia Exp $  */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -278,3 +278,26 @@
 
        return 0;
 }
+
+void
+print_bootcfg_banner(const char *bootprog_name, const char *bootprog_rev)
+{
+       int n = 0;
+
+       if (bootcfg_info.banner[0]) {  
+               for (; n < BOOTCFG_MAXBANNER && bootcfg_info.banner[n]; n++) 
+                       printf("%s\n", bootcfg_info.banner[n]);
+               return;
+       }
+
+       /* If the user has not specified a banner, print a default one. */
+
+       printf("\n");
+       printf("  \\\\-__,------,___.\n");
+       printf("   \\\\        __,---`  %s\n", bootprog_name);
+       printf("    \\\\       `---,_.  Revision %s\n", bootprog_rev);
+       printf("     \\\\-,_____,.---`\n");
+       printf("      \\\\\n");
+       printf("       \\\\\n");
+       printf("        \\\\\n\n");
+}
diff -r f585dba7aa4d -r 458723639a50 sys/lib/libsa/bootcfg.h
--- a/sys/lib/libsa/bootcfg.h   Tue Sep 07 11:00:13 2021 +0000
+++ b/sys/lib/libsa/bootcfg.h   Tue Sep 07 11:41:31 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bootcfg.h,v 1.4 2021/05/30 05:59:23 mlelstv Exp $      */
+/*     $NetBSD: bootcfg.h,v 1.5 2021/09/07 11:41:31 nia Exp $  */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -54,5 +54,6 @@
 
 int perform_bootcfg(const char *, bootcfg_command, const off_t);
 void bootcfg_do_noop(const char *, char *);
+void print_bootcfg_banner(const char *, const char *);
 
 #endif /* !_BOOTCFG_H */
diff -r f585dba7aa4d -r 458723639a50 sys/stand/efiboot/boot.c
--- a/sys/stand/efiboot/boot.c  Tue Sep 07 11:00:13 2021 +0000
+++ b/sys/stand/efiboot/boot.c  Tue Sep 07 11:41:31 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot.c,v 1.35 2021/07/24 10:22:28 jmcneill Exp $       */
+/*     $NetBSD: boot.c,v 1.36 2021/09/07 11:41:31 nia Exp $    */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>



Home | Main Index | Thread Index | Old Index