Module Name: src
Committed By: tsutsui
Date: Mon Jan 21 11:58:12 UTC 2013
Modified Files:
src/sys/arch/luna68k/stand/boot: Makefile bmc.c boot.c init_main.c
locore.S parse.c prf.c samachdep.h sio.c version
Added Files:
src/sys/arch/luna68k/stand/boot: awaitkey.c
Log Message:
Add support for "await key" to abort autoboot and get boot menu.
Also add command help. Bump version.
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/luna68k/stand/boot/Makefile \
src/sys/arch/luna68k/stand/boot/locore.S \
src/sys/arch/luna68k/stand/boot/samachdep.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/luna68k/stand/boot/awaitkey.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/luna68k/stand/boot/bmc.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/luna68k/stand/boot/boot.c \
src/sys/arch/luna68k/stand/boot/prf.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/luna68k/stand/boot/init_main.c \
src/sys/arch/luna68k/stand/boot/version
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/luna68k/stand/boot/parse.c \
src/sys/arch/luna68k/stand/boot/sio.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/luna68k/stand/boot/Makefile
diff -u src/sys/arch/luna68k/stand/boot/Makefile:1.7 src/sys/arch/luna68k/stand/boot/Makefile:1.8
--- src/sys/arch/luna68k/stand/boot/Makefile:1.7 Sun Jan 20 02:35:13 2013
+++ src/sys/arch/luna68k/stand/boot/Makefile Mon Jan 21 11:58:12 2013
@@ -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+= conf.c
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
Index: src/sys/arch/luna68k/stand/boot/locore.S
diff -u src/sys/arch/luna68k/stand/boot/locore.S:1.7 src/sys/arch/luna68k/stand/boot/locore.S:1.8
--- src/sys/arch/luna68k/stand/boot/locore.S:1.7 Sun Jan 20 03:40:55 2013
+++ src/sys/arch/luna68k/stand/boot/locore.S Mon Jan 21 11:58:12 2013
@@ -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 @@ ENTRY_NOPROFILE(lev5intr)
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@-
Index: src/sys/arch/luna68k/stand/boot/samachdep.h
diff -u src/sys/arch/luna68k/stand/boot/samachdep.h:1.7 src/sys/arch/luna68k/stand/boot/samachdep.h:1.8
--- src/sys/arch/luna68k/stand/boot/samachdep.h:1.7 Sun Jan 20 14:03:40 2013
+++ src/sys/arch/luna68k/stand/boot/samachdep.h Mon Jan 21 11:58:12 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: samachdep.h,v 1.7 2013/01/20 14:03:40 tsutsui Exp $ */
+/* $NetBSD: samachdep.h,v 1.8 2013/01/21 11:58:12 tsutsui Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@@ -54,10 +54,12 @@ typedef struct label_t {
} label_t;
/* autoconf.c */
-extern int cpuspeed;
void configure(void);
void find_devs(void);
+/* awaitkey.c */
+char awaitkey(const char *, int, bool);
+
/* bmc.c */
void bmccnprobe(struct consdev *);
void bmccninit(struct consdev *);
@@ -110,6 +112,8 @@ int getline(char *, char *);
int leinit(void *);
/* init_main.c */
+extern int cpuspeed;
+extern int hz;
extern int nplane;
extern int machtype;
@@ -130,6 +134,7 @@ int lance_intr(void);
extern u_int bootdev;
extern int dipsw1, dipsw2;
extern int cputype;
+extern volatile uint32_t tick;
int setjmp(label_t *);
int splhigh(void);
void splx(int);
@@ -153,9 +158,7 @@ void regdump(int *, int);
char *hexstr(int, int);
/* prf.c */
-#if 0
int tgetchar(void);
-#endif
/* parse.c */
int check_args(int, char **);
Index: src/sys/arch/luna68k/stand/boot/bmc.c
diff -u src/sys/arch/luna68k/stand/boot/bmc.c:1.3 src/sys/arch/luna68k/stand/boot/bmc.c:1.4
--- src/sys/arch/luna68k/stand/boot/bmc.c:1.3 Sun Jan 20 14:03:40 2013
+++ src/sys/arch/luna68k/stand/boot/bmc.c Mon Jan 21 11:58:12 2013
@@ -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 @@ bmccngetc(dev_t dev)
int c;
int unit = 1;
- while (RBUF_EMPTY(unit)) {
- DELAY(10);
- }
+ if (RBUF_EMPTY(unit))
+ return 0;
POP_RBUF(unit, c);
Index: src/sys/arch/luna68k/stand/boot/boot.c
diff -u src/sys/arch/luna68k/stand/boot/boot.c:1.1 src/sys/arch/luna68k/stand/boot/boot.c:1.2
--- src/sys/arch/luna68k/stand/boot/boot.c:1.1 Sat Jan 5 17:44:24 2013
+++ src/sys/arch/luna68k/stand/boot/boot.c Mon Jan 21 11:58:12 2013
@@ -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 @@ bootnetbsd(char *line)
(*entry)();
}
+ printf("Booting kernel failed. (%s)\n", strerror(errno));
return ST_ERROR;
}
Index: src/sys/arch/luna68k/stand/boot/prf.c
diff -u src/sys/arch/luna68k/stand/boot/prf.c:1.1 src/sys/arch/luna68k/stand/boot/prf.c:1.2
--- src/sys/arch/luna68k/stand/boot/prf.c:1.1 Sat Jan 5 17:44:24 2013
+++ src/sys/arch/luna68k/stand/boot/prf.c Mon Jan 21 11:58:12 2013
@@ -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 $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@@ -50,14 +50,13 @@ getchar(void)
return c;
}
-#if 0
int
tgetchar(void)
{
int c;
- if ((c = cnscan()) == -1)
- return -1;
+ if ((c = cngetc()) == 0)
+ return 0;
if (c == '\r')
c = '\n';
@@ -67,7 +66,6 @@ tgetchar(void)
}
return c;
}
-#endif
void
putchar(int c)
Index: src/sys/arch/luna68k/stand/boot/init_main.c
diff -u src/sys/arch/luna68k/stand/boot/init_main.c:1.4 src/sys/arch/luna68k/stand/boot/init_main.c:1.5
--- src/sys/arch/luna68k/stand/boot/init_main.c:1.4 Sun Jan 20 13:35:43 2013
+++ src/sys/arch/luna68k/stand/boot/init_main.c Mon Jan 21 11:58:12 2013
@@ -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 get_plane_numbers(void);
static int reorder_dipsw(int);
int cpuspeed; /* for DELAY() macro */
+int hz = 60;
int machtype;
#define VERS_LOCAL "Phase-31"
@@ -106,6 +107,9 @@ char buffer[BUFFSIZE];
int argc;
char *argv[MAXARGS];
+#define BOOT_TIMEOUT 10
+int boot_timeout = BOOT_TIMEOUT;
+
char prompt[16] = "boot> ";
void
@@ -121,10 +125,12 @@ main(void)
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 @@ main(void)
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) {
Index: src/sys/arch/luna68k/stand/boot/version
diff -u src/sys/arch/luna68k/stand/boot/version:1.4 src/sys/arch/luna68k/stand/boot/version:1.5
--- src/sys/arch/luna68k/stand/boot/version:1.4 Wed Jan 16 15:46:20 2013
+++ src/sys/arch/luna68k/stand/boot/version Mon Jan 21 11:58:12 2013
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.4 2013/01/16 15:46:20 tsutsui Exp $
+$NetBSD: version,v 1.5 2013/01/21 11:58:12 tsutsui Exp $
NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
file is important - make sure the entries are appended on end, last item
@@ -8,3 +8,4 @@ is taken as the current.
1.1: Add netboot support.
1.2: Add support for secondary SPC SCSI on LUNA-II.
1.3: Add UFS2 support.
+1.4: Add support for "awaiting key" to abort autoboot and get boot menu.
Index: src/sys/arch/luna68k/stand/boot/parse.c
diff -u src/sys/arch/luna68k/stand/boot/parse.c:1.2 src/sys/arch/luna68k/stand/boot/parse.c:1.3
--- src/sys/arch/luna68k/stand/boot/parse.c:1.2 Wed Jan 16 15:15:01 2013
+++ src/sys/arch/luna68k/stand/boot/parse.c Mon Jan 21 11:58:12 2013
@@ -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 @@ exit_program(int argc, char *argv[])
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 @@ struct command_entry entries[] = {
{ "fsdump", fsdump },
{ "fsrestore", fsrestore },
#endif
+ { "help", cmd_help },
{ "howto", how_to_boot },
{ "ls", cmd_ls },
{ "screen", screen },
Index: src/sys/arch/luna68k/stand/boot/sio.c
diff -u src/sys/arch/luna68k/stand/boot/sio.c:1.2 src/sys/arch/luna68k/stand/boot/sio.c:1.3
--- src/sys/arch/luna68k/stand/boot/sio.c:1.2 Sat Jan 12 07:04:57 2013
+++ src/sys/arch/luna68k/stand/boot/sio.c Mon Jan 21 11:58:12 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: sio.c,v 1.2 2013/01/12 07:04:57 tsutsui Exp $ */
+/* $NetBSD: sio.c,v 1.3 2013/01/21 11:58:12 tsutsui Exp $ */
/*
* Copyright (c) 1992 OMRON Corporation.
@@ -167,9 +167,8 @@ siocngetc(dev_t dev)
{
int c, unit = siounit(dev);
- while (RBUF_EMPTY(unit)) {
- DELAY(10);
- }
+ if (RBUF_EMPTY(unit))
+ return 0;
POP_RBUF(unit, c);
Added files:
Index: src/sys/arch/luna68k/stand/boot/awaitkey.c
diff -u /dev/null src/sys/arch/luna68k/stand/boot/awaitkey.c:1.1
--- /dev/null Mon Jan 21 11:58:13 2013
+++ src/sys/arch/luna68k/stand/boot/awaitkey.c Mon Jan 21 11:58:12 2013
@@ -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;
+}