9boot: preserve configuration on boot error, add show command
This commit is contained in:
parent
b8990cfbb4
commit
3da5b76c0b
2 changed files with 59 additions and 28 deletions
|
@ -19,33 +19,32 @@ gets pressed on the keyboard or the kernel file was not
|
|||
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
|
||||
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
|
||||
|
|
|
@ -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;
|
||||
memset(BOOTLINE, 0, BOOTLINELEN);
|
||||
|
||||
confend = BOOTARGS;
|
||||
memset(confend, 0, BOOTARGSLEN);
|
||||
|
||||
e820conf();
|
||||
}
|
||||
nowait = 1;
|
||||
inblock = 0;
|
||||
|
||||
memset(BOOTLINE, 0, BOOTLINELEN);
|
||||
|
||||
confend = BOOTARGS;
|
||||
memset(confend, 0, BOOTARGSLEN);
|
||||
|
||||
e820conf();
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue