9boot: preserve configuration on boot error, add show command
This commit is contained in:
parent
b8990cfbb4
commit
3da5b76c0b
|
@ -19,33 +19,32 @@ gets pressed on the keyboard or the kernel file was not
|
||||||
found then the loader enters the interactive
|
found then the loader enters the interactive
|
||||||
boot console.
|
boot console.
|
||||||
|
|
||||||
The syntax of the boot console is the same as in
|
The syntax of the boot console is the same as in the
|
||||||
the
|
|
||||||
.IR plan9.ini (8)
|
.IR plan9.ini (8)
|
||||||
file.
|
file with
|
||||||
.BR
|
.IB key = value
|
||||||
The word
|
pairs setting boot parameters. In addition a few command
|
||||||
.B clear
|
words are recognized that are intended for interactive use:
|
||||||
[
|
.TP
|
||||||
.I prefix
|
.BI clear [prefix]
|
||||||
]
|
can be used to remove parameters from the configuration.
|
||||||
can be used to remove parameters from the current configuration.
|
|
||||||
If a
|
If a
|
||||||
.IR prefix
|
.IR prefix
|
||||||
is specified, the first parameter that matches the prefix
|
is specified, the first parameter that matches the prefix
|
||||||
is removed. If the
|
is removed. If the
|
||||||
.IR prefix
|
.IR prefix
|
||||||
argument is omitted, the whole configuration will be reset.
|
argument is omitted, the whole configuration will be reset.
|
||||||
If the word
|
.TP
|
||||||
|
.B show
|
||||||
|
displays the current configuration in memory.
|
||||||
|
.TP
|
||||||
.B wait
|
.B wait
|
||||||
appears in the configuration then
|
will return to the console prompt after processing the
|
||||||
.IR 9boot
|
configuration file preventing automatic boot.
|
||||||
will return to the console prompt after processing the file.
|
.TP
|
||||||
|
|
||||||
The word
|
|
||||||
.B boot
|
.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
|
There are many ways to boot a PC so
|
||||||
.IR 9boot
|
.IR 9boot
|
||||||
was split into a number of distinct programs one for each boot
|
was split into a number of distinct programs one for each boot
|
||||||
|
|
|
@ -160,6 +160,28 @@ char *confend;
|
||||||
static void apmconf(int);
|
static void apmconf(int);
|
||||||
static void e820conf(void);
|
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
|
static int
|
||||||
delconf(char *s)
|
delconf(char *s)
|
||||||
{
|
{
|
||||||
|
@ -187,18 +209,20 @@ configure(void *f, char *path)
|
||||||
{
|
{
|
||||||
char line[64], *kern, *s, *p;
|
char line[64], *kern, *s, *p;
|
||||||
int inblock, nowait, n;
|
int inblock, nowait, n;
|
||||||
|
static int once = 1;
|
||||||
|
|
||||||
|
if(once){
|
||||||
|
once = 0;
|
||||||
Clear:
|
Clear:
|
||||||
kern = 0;
|
memset(BOOTLINE, 0, BOOTLINELEN);
|
||||||
|
|
||||||
|
confend = BOOTARGS;
|
||||||
|
memset(confend, 0, BOOTARGSLEN);
|
||||||
|
|
||||||
|
e820conf();
|
||||||
|
}
|
||||||
nowait = 1;
|
nowait = 1;
|
||||||
inblock = 0;
|
inblock = 0;
|
||||||
|
|
||||||
memset(BOOTLINE, 0, BOOTLINELEN);
|
|
||||||
|
|
||||||
confend = BOOTARGS;
|
|
||||||
memset(confend, 0, BOOTARGSLEN);
|
|
||||||
|
|
||||||
e820conf();
|
|
||||||
Loop:
|
Loop:
|
||||||
while(readline(f, line) > 0){
|
while(readline(f, line) > 0){
|
||||||
if(*line == 0 || strchr("#;=", *line))
|
if(*line == 0 || strchr("#;=", *line))
|
||||||
|
@ -215,6 +239,15 @@ Loop:
|
||||||
nowait=0;
|
nowait=0;
|
||||||
continue;
|
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(!memcmp("clear", line, 5)){
|
||||||
if(line[5] == 0){
|
if(line[5] == 0){
|
||||||
print("ok");
|
print("ok");
|
||||||
|
@ -234,8 +267,6 @@ Loop:
|
||||||
apmconf('0' - line[3]);
|
apmconf('0' - line[3]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(!memcmp("bootfile", line, 8))
|
|
||||||
memmove(kern = path, p, strlen(p)+1);
|
|
||||||
|
|
||||||
s = confend;
|
s = confend;
|
||||||
memmove(confend, line, n = strlen(line)); confend += n;
|
memmove(confend, line, n = strlen(line)); confend += n;
|
||||||
|
@ -248,6 +279,7 @@ Loop:
|
||||||
*confend++ = '\n';
|
*confend++ = '\n';
|
||||||
*confend = 0;
|
*confend = 0;
|
||||||
}
|
}
|
||||||
|
kern = getconf("bootfile=", path);
|
||||||
|
|
||||||
if(f){
|
if(f){
|
||||||
close(f);
|
close(f);
|
||||||
|
|
Loading…
Reference in a new issue