summaryrefslogtreecommitdiff
path: root/sys/src/boot
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-02-17 09:30:02 +0100
committercinap_lenrek <cinap_lenrek@gmx.de>2013-02-17 09:30:02 +0100
commit3da5b76c0bf518bda641f5fbcf466d18e86c61dd (patch)
tree243d22149c342e37ef14892d9b534c0600365cd8 /sys/src/boot
parentb8990cfbb4f5aede73e01dc1838c1c5c19dc072a (diff)
9boot: preserve configuration on boot error, add show command
Diffstat (limited to 'sys/src/boot')
-rw-r--r--sys/src/boot/pc/sub.c52
1 files changed, 42 insertions, 10 deletions
diff --git a/sys/src/boot/pc/sub.c b/sys/src/boot/pc/sub.c
index 70138377a..25fd37746 100644
--- a/sys/src/boot/pc/sub.c
+++ b/sys/src/boot/pc/sub.c
@@ -160,6 +160,28 @@ char *confend;
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 @@ configure(void *f, char *path)
{
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 @@ Loop:
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 @@ Loop:
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 @@ Loop:
*confend++ = '\n';
*confend = 0;
}
+ kern = getconf("bootfile=", path);
if(f){
close(f);