Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/luna68k/stand/boot Add support for "await key" to a...



details:   https://anonhg.NetBSD.org/src/rev/0795e118dfee
branches:  trunk
changeset: 784183:0795e118dfee
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Mon Jan 21 11:58:12 2013 +0000

description:
Add support for "await key" to abort autoboot and get boot menu.
Also add command help.  Bump version.

diffstat:

 sys/arch/luna68k/stand/boot/Makefile    |   4 +-
 sys/arch/luna68k/stand/boot/awaitkey.c  |  86 +++++++++++++++++++++++++++++++++
 sys/arch/luna68k/stand/boot/bmc.c       |   7 +-
 sys/arch/luna68k/stand/boot/boot.c      |   3 +-
 sys/arch/luna68k/stand/boot/init_main.c |  22 +++++++-
 sys/arch/luna68k/stand/boot/locore.S    |   6 +-
 sys/arch/luna68k/stand/boot/parse.c     |  30 +++++++++++-
 sys/arch/luna68k/stand/boot/prf.c       |   8 +-
 sys/arch/luna68k/stand/boot/samachdep.h |  11 ++-
 sys/arch/luna68k/stand/boot/sio.c       |   7 +-
 sys/arch/luna68k/stand/boot/version     |   3 +-
 11 files changed, 161 insertions(+), 26 deletions(-)

diffs (truncated from 413 to 300 lines):

diff -r 7f8f3f55cca1 -r 0795e118dfee sys/arch/luna68k/stand/boot/Makefile
--- a/sys/arch/luna68k/stand/boot/Makefile      Mon Jan 21 09:14:01 2013 +0000
+++ b/sys/arch/luna68k/stand/boot/Makefile      Mon Jan 21 11:58:12 2013 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.7 2013/01/20 02:35:13 tsutsui Exp $
+#      $NetBSD: Makefile,v 1.8 2013/01/21 11:58:12 tsutsui Exp $
 #      @(#)Makefile    8.2 (Berkeley) 8/15/93
 
 NOMAN= # defined
@@ -39,7 +39,7 @@
 SRCS+= machdep.c
 SRCS+= getline.c parse.c 
 SRCS+= boot.c
-SRCS+= cons.c prf.c
+SRCS+= cons.c prf.c awaitkey.c
 SRCS+= romcons.c
 SRCS+= sio.c
 SRCS+= bmc.c bmd.c screen.c font.c kbd.c
diff -r 7f8f3f55cca1 -r 0795e118dfee sys/arch/luna68k/stand/boot/awaitkey.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/luna68k/stand/boot/awaitkey.c    Mon Jan 21 11:58:12 2013 +0000
@@ -0,0 +1,86 @@
+/*     $NetBSD: awaitkey.c,v 1.1 2013/01/21 11:58:12 tsutsui Exp $     */
+
+/*-
+ * Copyright (c) 2013 Izumi Tsutsui.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <lib/libkern/libkern.h>
+#include <luna68k/stand/boot/samachdep.h>
+
+static void print_countdown(const char *, int);
+
+#define FMTLEN 40
+
+static void
+print_countdown(const char *pfmt, int n)
+{
+       int len, i;
+       char fmtbuf[FMTLEN];
+
+       len = snprintf(fmtbuf, FMTLEN, pfmt, n);
+       printf("%s", fmtbuf);
+       for (i = 0; i < len; i++)
+               putchar('\b');
+}
+
+/*
+ * awaitkey(const char *pfmt, int timeout, bool tell)
+ *
+ * Wait timeout seconds until any input from stdin.
+ * print countdown message using "pfmt" if tell is true.
+ * Requires tgetchar(), which returns 0 if there is no input.
+ */
+char
+awaitkey(const char *pfmt, int timeout, bool tell)
+{
+       uint32_t otick;
+       char c = 0;
+
+       if (timeout <= 0)
+               goto out;
+
+       if (tell)
+               print_countdown(pfmt, timeout);
+
+       otick = tick;
+
+       for (;;) {
+               c = tgetchar();
+               if (c != 0)
+                       break;
+               if (tick - otick >= hz) {
+                       otick = tick;
+                       if (--timeout == 0)
+                               break;
+                       if (tell)
+                               print_countdown(pfmt, timeout);
+               }
+       }
+
+ out:
+       if (tell) {
+               printf(pfmt, 0);
+               printf("\n");
+       }
+       return c;
+}
diff -r 7f8f3f55cca1 -r 0795e118dfee sys/arch/luna68k/stand/boot/bmc.c
--- a/sys/arch/luna68k/stand/boot/bmc.c Mon Jan 21 09:14:01 2013 +0000
+++ b/sys/arch/luna68k/stand/boot/bmc.c Mon Jan 21 11:58:12 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bmc.c,v 1.3 2013/01/20 14:03:40 tsutsui Exp $  */
+/*     $NetBSD: bmc.c,v 1.4 2013/01/21 11:58:12 tsutsui Exp $  */
 
 /*
  * Copyright (c) 1992 OMRON Corporation.
@@ -116,9 +116,8 @@
        int c;
        int unit = 1;
 
-       while (RBUF_EMPTY(unit)) {
-               DELAY(10);
-       }
+       if (RBUF_EMPTY(unit))
+               return 0;
 
        POP_RBUF(unit, c);
 
diff -r 7f8f3f55cca1 -r 0795e118dfee sys/arch/luna68k/stand/boot/boot.c
--- a/sys/arch/luna68k/stand/boot/boot.c        Mon Jan 21 09:14:01 2013 +0000
+++ b/sys/arch/luna68k/stand/boot/boot.c        Mon Jan 21 11:58:12 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot.c,v 1.1 2013/01/05 17:44:24 tsutsui Exp $ */
+/*     $NetBSD: boot.c,v 1.2 2013/01/21 11:58:12 tsutsui Exp $ */
 
 /*
  * Copyright (c) 1992 OMRON Corporation.
@@ -207,6 +207,7 @@
 
                (*entry)();
        }
+       printf("Booting kernel failed. (%s)\n", strerror(errno));
 
        return ST_ERROR;
 }
diff -r 7f8f3f55cca1 -r 0795e118dfee sys/arch/luna68k/stand/boot/init_main.c
--- a/sys/arch/luna68k/stand/boot/init_main.c   Mon Jan 21 09:14:01 2013 +0000
+++ b/sys/arch/luna68k/stand/boot/init_main.c   Mon Jan 21 11:58:12 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init_main.c,v 1.4 2013/01/20 13:35:43 tsutsui Exp $    */
+/*     $NetBSD: init_main.c,v 1.5 2013/01/21 11:58:12 tsutsui Exp $    */
 
 /*
  * Copyright (c) 1992 OMRON Corporation.
@@ -85,6 +85,7 @@
 static int reorder_dipsw(int);
 
 int cpuspeed;  /* for DELAY() macro */
+int hz = 60;
 int machtype;
 
 #define        VERS_LOCAL      "Phase-31"
@@ -106,6 +107,9 @@
 int   argc;
 char *argv[MAXARGS];
 
+#define BOOT_TIMEOUT 10
+int boot_timeout = BOOT_TIMEOUT;
+
 char  prompt[16] = "boot> ";
 
 void
@@ -121,10 +125,12 @@
                machtype = LUNA_I;
                machstr  = "LUNA-I";
                cpuspeed = MHZ_25;
+               hz = 60;
        } else {
                machtype = LUNA_II;
                machstr  = "LUNA-II";
                cpuspeed = MHZ_25 * 2;  /* XXX */
+               hz = 100;
        }
 
        nplane   = get_plane_numbers();
@@ -162,14 +168,24 @@
        howto = reorder_dipsw(dipsw2);
 
        if ((howto & 0xFE) == 0) {
-               printf("auto-boot %s\n", default_file);
-               bootnetbsd(default_file);
+               char c;
+
+               printf("Press return to boot now,"
+                   " any other key for boot menu\n");
+               printf("booting %s - starting in ", default_file);
+               c = awaitkey("%d seconds. ", boot_timeout, true);
+               if (c == '\r' || c == '\n' || c == 0) {
+                       printf("auto-boot %s\n", default_file);
+                       bootnetbsd(default_file);
+               }
        }
 
        /*
         * Main Loop
         */
 
+       printf("type \"help\" for help.\n");
+
        do {
                memset(buffer, 0, BUFFSIZE);
                if (getline(prompt, buffer) > 0) {
diff -r 7f8f3f55cca1 -r 0795e118dfee sys/arch/luna68k/stand/boot/locore.S
--- a/sys/arch/luna68k/stand/boot/locore.S      Mon Jan 21 09:14:01 2013 +0000
+++ b/sys/arch/luna68k/stand/boot/locore.S      Mon Jan 21 11:58:12 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.7 2013/01/20 03:40:55 tsutsui Exp $       */
+/*     $NetBSD: locore.S,v 1.8 2013/01/21 11:58:12 tsutsui Exp $       */
 
 /*
  * Copyright (c) 1992 OMRON Corporation.
@@ -535,9 +535,13 @@
        moveml  %sp@+,#0x0303           | restore scratch regs
        addql   #2,%sp                  | pop pad word
        jra     _ASM_LABEL(rei)         | all done
+
 ENTRY_NOPROFILE(hardclock)
+       addql   #1,_C_LABEL(tick)
        rts
 
+BSS(tick,4)
+
 ENTRY_NOPROFILE(lev6intr)
        clrw    %sp@-
        moveml  #0xC0C0,%sp@-
diff -r 7f8f3f55cca1 -r 0795e118dfee sys/arch/luna68k/stand/boot/parse.c
--- a/sys/arch/luna68k/stand/boot/parse.c       Mon Jan 21 09:14:01 2013 +0000
+++ b/sys/arch/luna68k/stand/boot/parse.c       Mon Jan 21 11:58:12 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.2 2013/01/16 15:15:01 tsutsui Exp $        */
+/*     $NetBSD: parse.c,v 1.3 2013/01/21 11:58:12 tsutsui Exp $        */
 
 /*
  * Copyright (c) 1992 OMRON Corporation.
@@ -79,6 +79,8 @@
 #include <luna68k/stand/boot/samachdep.h>
 #include <luna68k/stand/boot/status.h>
 
+static int cmd_help(int, char *[]);
+
 int
 check_args(int argc, char *argv[])
 {
@@ -96,6 +98,31 @@
        return(ST_EXIT);
 }
 
+static const char helpmsg[] =
+       "commands are:\n"
+       "boot [device(unit,part)filename]\n"
+       " (ex. \"boot sd(0,0)netbsd\", \"boot le(0,0)netbsd.old\" etc.)\n"
+       "ls [device(unit, part)[path]]\n"
+       " (ex. \"ls sd(0,0)/bin\")\n"
+       "help\n"
+       "exit\n"
+#if 0 /* debug commands */
+       "checkargs\n"
+       "disklabel\n"
+       "howto\n"
+       "screen\n"
+       "scsi\n"
+#endif
+;
+
+static int
+cmd_help(int argc, char *argv[])
+{
+
+       printf(helpmsg);
+       return ST_NORMAL;
+}
+
 struct command_entry {
        char *name;
        int (*func)(int, char **);
@@ -111,6 +138,7 @@
        { "fsdump",     fsdump       },
        { "fsrestore",  fsrestore    },
 #endif
+       { "help",       cmd_help     },
        { "howto",      how_to_boot  },
        { "ls",         cmd_ls       },
        { "screen",     screen       },
diff -r 7f8f3f55cca1 -r 0795e118dfee sys/arch/luna68k/stand/boot/prf.c
--- a/sys/arch/luna68k/stand/boot/prf.c Mon Jan 21 09:14:01 2013 +0000
+++ b/sys/arch/luna68k/stand/boot/prf.c Mon Jan 21 11:58:12 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: prf.c,v 1.1 2013/01/05 17:44:24 tsutsui Exp $  */
+/*     $NetBSD: prf.c,v 1.2 2013/01/21 11:58:12 tsutsui Exp $  */



Home | Main Index | Thread Index | Old Index