Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sandpoint/stand/altboot Enter interactive mode, whe...
details: https://anonhg.NetBSD.org/src/rev/05490dedcbf5
branches: trunk
changeset: 763204:05490dedcbf5
user: phx <phx%NetBSD.org@localhost>
date: Sun Mar 13 01:56:21 2011 +0000
description:
Enter interactive mode, when a key is pressed within two seconds.
diffstat:
sys/arch/sandpoint/stand/altboot/brdsetup.c | 23 ++++++++++++++++++++-
sys/arch/sandpoint/stand/altboot/globals.h | 3 +-
sys/arch/sandpoint/stand/altboot/main.c | 30 ++++++++++++++++++++++++++++-
3 files changed, 52 insertions(+), 4 deletions(-)
diffs (133 lines):
diff -r 01ee46d56e63 -r 05490dedcbf5 sys/arch/sandpoint/stand/altboot/brdsetup.c
--- a/sys/arch/sandpoint/stand/altboot/brdsetup.c Sat Mar 12 23:04:16 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/brdsetup.c Sun Mar 13 01:56:21 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.10 2011/03/12 16:41:23 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.11 2011/03/13 01:56:21 phx Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -141,6 +141,7 @@
unsigned uart1base; /* console */
unsigned uart2base; /* optional satellite processor */
+#define RBR 0
#define THR 0
#define DLB 0
#define DMB 1
@@ -156,6 +157,7 @@
#define MCR_DTR 0x01
#define LSR 5
#define LSR_THRE 0x20
+#define LSR_DRDY 0x01
#define DCR 0x11
#define UART_READ(base, r) *(volatile char *)(base + (r))
#define UART_WRITE(base, r, v) *(volatile char *)(base + (r)) = (v)
@@ -663,7 +665,7 @@
{
send_sat("C");
- /*NOTRECHED*/
+ /*NOTREACHED*/
}
void
@@ -878,6 +880,23 @@
UART_WRITE(uart1base, THR, c);
}
+int
+getchar(void)
+{
+ unsigned lsr;
+
+ do {
+ lsr = UART_READ(uart1base, LSR);
+ } while ((lsr & LSR_DRDY) == 0);
+ return UART_READ(uart1base, RBR);
+}
+
+int
+tstchar(void)
+{
+ return (UART_READ(uart1base, LSR) & LSR_DRDY) != 0;
+}
+
unsigned
mpc107memsize()
{
diff -r 01ee46d56e63 -r 05490dedcbf5 sys/arch/sandpoint/stand/altboot/globals.h
--- a/sys/arch/sandpoint/stand/altboot/globals.h Sat Mar 12 23:04:16 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/globals.h Sun Mar 13 01:56:21 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.10 2011/03/12 16:41:23 phx Exp $ */
+/* $NetBSD: globals.h,v 1.11 2011/03/13 01:56:21 phx Exp $ */
#ifdef DEBUG
#define DPRINTF(x) printf x
@@ -42,6 +42,7 @@
/* board specific support code */
struct brdprop *brd_lookup(int);
+int tstchar(void);
unsigned mpc107memsize(void);
void read_mac_from_flash(uint8_t *);
diff -r 01ee46d56e63 -r 05490dedcbf5 sys/arch/sandpoint/stand/altboot/main.c
--- a/sys/arch/sandpoint/stand/altboot/main.c Sat Mar 12 23:04:16 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/main.c Sun Mar 13 01:56:21 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.10 2011/03/12 16:41:23 phx Exp $ */
+/* $NetBSD: main.c,v 1.11 2011/03/13 01:56:21 phx Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -100,6 +100,7 @@
uint32_t busclock, cpuclock;
static int check_bootname(char *);
+static int input_cmdline(char **, int);
static int parse_cmdline(char **, int, char *, char *);
static int is_space(char);
@@ -185,6 +186,21 @@
bootargs_end);
}
+ /* wait 2s for user to enter interactive mode */
+ for (n = 200; n >= 0; n--) {
+ if (n % 100 == 0)
+ printf("Hit any key to enter interactive mode: %d\r",
+ n / 100);
+ if (tstchar()) {
+ (void)getchar();
+ argv = new_argv;
+ argc = input_cmdline(argv, MAX_ARGS);
+ break;
+ }
+ delay(10000);
+ }
+ putchar('\n');
+
howto = RB_AUTOBOOT; /* default is autoboot = 0 */
/* get boot options and determine bootname */
@@ -537,6 +553,18 @@
return 0;
}
+static int input_cmdline(char **argv, int maxargc)
+{
+ char *cmdline;
+
+ printf("\nbootargs> ");
+ cmdline = alloc(256);
+ gets(cmdline);
+
+ return parse_cmdline(argv, maxargc, cmdline,
+ cmdline + strlen(cmdline));
+}
+
static int
parse_cmdline(char **argv, int maxargc, char *p, char *end)
{
Home |
Main Index |
Thread Index |
Old Index