Mon Jan 21 11:58:12 2013 UTC ()
Add support for "await key" to abort autoboot and get boot menu.
Also add command help. Bump version.
(tsutsui)
diff -r1.7 -r1.8 src/sys/arch/luna68k/stand/boot/Makefile
diff -r1.7 -r1.8 src/sys/arch/luna68k/stand/boot/locore.S
diff -r1.7 -r1.8 src/sys/arch/luna68k/stand/boot/samachdep.h
diff -r0 -r1.1 src/sys/arch/luna68k/stand/boot/awaitkey.c
diff -r1.3 -r1.4 src/sys/arch/luna68k/stand/boot/bmc.c
diff -r1.1 -r1.2 src/sys/arch/luna68k/stand/boot/boot.c
diff -r1.1 -r1.2 src/sys/arch/luna68k/stand/boot/prf.c
diff -r1.4 -r1.5 src/sys/arch/luna68k/stand/boot/init_main.c
diff -r1.4 -r1.5 src/sys/arch/luna68k/stand/boot/version
diff -r1.2 -r1.3 src/sys/arch/luna68k/stand/boot/parse.c
diff -r1.2 -r1.3 src/sys/arch/luna68k/stand/boot/sio.c
--- src/sys/arch/luna68k/stand/boot/Makefile 2013/01/20 02:35:13 1.7
+++ src/sys/arch/luna68k/stand/boot/Makefile 2013/01/21 11:58:12 1.8
@@ -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
--- src/sys/arch/luna68k/stand/boot/locore.S 2013/01/20 03:40:55 1.7
+++ src/sys/arch/luna68k/stand/boot/locore.S 2013/01/21 11:58:12 1.8
@@ -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,8 +535,12 @@
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@-
--- src/sys/arch/luna68k/stand/boot/samachdep.h 2013/01/20 14:03:40 1.7
+++ src/sys/arch/luna68k/stand/boot/samachdep.h 2013/01/21 11:58:12 1.8
@@ -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 @@
} 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 leinit(void *);
/* init_main.c */
+extern int cpuspeed;
+extern int hz;
extern int nplane;
extern int machtype;
@@ -130,6 +134,7 @@
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 @@
char *hexstr(int, int);
/* prf.c */
-#if 0
int tgetchar(void);
-#endif
/* parse.c */
int check_args(int, char **);
/* $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;
}
--- src/sys/arch/luna68k/stand/boot/bmc.c 2013/01/20 14:03:40 1.3
+++ src/sys/arch/luna68k/stand/boot/bmc.c 2013/01/21 11:58:12 1.4
@@ -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);
--- src/sys/arch/luna68k/stand/boot/boot.c 2013/01/05 17:44:24 1.1
+++ src/sys/arch/luna68k/stand/boot/boot.c 2013/01/21 11:58:12 1.2
@@ -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;
}
--- src/sys/arch/luna68k/stand/boot/prf.c 2013/01/05 17:44:24 1.1
+++ src/sys/arch/luna68k/stand/boot/prf.c 2013/01/21 11:58:12 1.2
@@ -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 @@
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 @@
}
return c;
}
-#endif
void
putchar(int c)
--- src/sys/arch/luna68k/stand/boot/init_main.c 2013/01/20 13:35:43 1.4
+++ src/sys/arch/luna68k/stand/boot/init_main.c 2013/01/21 11:58:12 1.5
@@ -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,13 +168,23 @@
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);
--- src/sys/arch/luna68k/stand/boot/version 2013/01/16 15:46:20 1.4
+++ src/sys/arch/luna68k/stand/boot/version 2013/01/21 11:58:12 1.5
@@ -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 @@
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.
--- src/sys/arch/luna68k/stand/boot/parse.c 2013/01/16 15:15:01 1.2
+++ src/sys/arch/luna68k/stand/boot/parse.c 2013/01/21 11:58:12 1.3
@@ -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 },
--- src/sys/arch/luna68k/stand/boot/sio.c 2013/01/12 07:04:57 1.2
+++ src/sys/arch/luna68k/stand/boot/sio.c 2013/01/21 11:58:12 1.3
@@ -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 @@
{
int c, unit = siounit(dev);
- while (RBUF_EMPTY(unit)) {
- DELAY(10);
- }
+ if (RBUF_EMPTY(unit))
+ return 0;
POP_RBUF(unit, c);