ref: 5b818358f913c5691781597259ee9c4915ae7dc7
parent: 7e8de4e2f03ec1fd241d0d513bdb2717fadb5ef5
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Sun Feb 17 04:30:02 EST 2013
9boot: preserve configuration on boot error, add show command
--- a/sys/man/8/9boot
+++ b/sys/man/8/9boot
@@ -19,17 +19,15 @@
found then the loader enters the interactive
boot console.
-The syntax of the boot console is the same as in
-the
+The syntax of the boot console is the same as in the
.IR plan9.ini (8)
-file.
-.BR
-The word
-.B clear
-[
-.I prefix
-]
-can be used to remove parameters from the current configuration.
+file with
+.IB key = value
+pairs setting boot parameters. In addition a few command
+words are recognized that are intended for interactive use:
+.TP
+.BI clear [prefix]
+can be used to remove parameters from the configuration.
If a
.IR prefix
is specified, the first parameter that matches the prefix
@@ -36,16 +34,17 @@
is removed. If the
.IR prefix
argument is omitted, the whole configuration will be reset.
-If the word
+.TP
+.B show
+displays the current configuration in memory.
+.TP
.B wait
-appears in the configuration then
-.IR 9boot
-will return to the console prompt after processing the file.
-
-The word
+will return to the console prompt after processing the
+configuration file preventing automatic boot.
+.TP
.B boot
-will end the console and resume booting the kernel.
-
+will end the console and attempt booting the kernel.
+.SS
There are many ways to boot a PC so
.IR 9boot
was split into a number of distinct programs one for each boot
--- a/sys/src/boot/pc/sub.c
+++ b/sys/src/boot/pc/sub.c
@@ -160,6 +160,28 @@
static void apmconf(int);
static void e820conf(void);
+static char*
+getconf(char *s, char *buf)
+{+ char *p, *e;
+ int n;
+
+ n = strlen(s);
+ for(p = BOOTARGS; p < confend; p = e+1){+ for(e = p+1; e < confend; e++)
+ if(*e == '\n')
+ break;
+ if(!memcmp(p, s, n)){+ p += n;
+ n = e - p;
+ buf[n] = 0;
+ memmove(buf, p, n);
+ return buf;
+ }
+ }
+ return 0;
+}
+
static int
delconf(char *s)
{@@ -187,18 +209,20 @@
{char line[64], *kern, *s, *p;
int inblock, nowait, n;
+ static int once = 1;
+ if(once){+ once = 0;
Clear:
- kern = 0;
- nowait = 1;
- inblock = 0;
+ memset(BOOTLINE, 0, BOOTLINELEN);
- memset(BOOTLINE, 0, BOOTLINELEN);
+ confend = BOOTARGS;
+ memset(confend, 0, BOOTARGSLEN);
- confend = BOOTARGS;
- memset(confend, 0, BOOTARGSLEN);
-
- e820conf();
+ e820conf();
+ }
+ nowait = 1;
+ inblock = 0;
Loop:
while(readline(f, line) > 0){ if(*line == 0 || strchr("#;=", *line))@@ -215,6 +239,15 @@
nowait=0;
continue;
}
+ if(!memcmp("show", line, 5)){+ for(p = BOOTARGS; p < confend; p++){+ if(*p == '\n')
+ print(crnl);
+ else
+ putc(*p);
+ }
+ continue;
+ }
if(!memcmp("clear", line, 5)){ if(line[5] == 0){ print("ok");@@ -234,8 +267,6 @@
apmconf('0' - line[3]);continue;
}
- if(!memcmp("bootfile", line, 8))- memmove(kern = path, p, strlen(p)+1);
s = confend;
memmove(confend, line, n = strlen(line)); confend += n;
@@ -248,6 +279,7 @@
*confend++ = '\n';
*confend = 0;
}
+ kern = getconf("bootfile=", path); if(f){close(f);
--
⑨