kernel: pass bootargs also in multiboot command line, retire the bootline mechanism to pass arguments to /boot/boot

This commit is contained in:
cinap_lenrek 2017-06-28 18:56:16 +02:00
parent c4b02ff9e6
commit befdd7d755
6 changed files with 25 additions and 174 deletions

View file

@ -3,18 +3,6 @@
boot, bootrc \- connect to the root file server
.SH SYNOPSIS
.B /boot/boot
[
.B -fkm
]
[
.BI -u username
]
[
.IB method ! device
]
[
.I args
]
.SH DESCRIPTION
.I Boot
is the first program run after a kernel has been loaded. It
@ -71,10 +59,6 @@ of the form
.IB name = value
is passed to the boot program as an environment
variable with the same name and value.
The command line is
.IP
.B /boot/boot
.IB method ! device
.PP
After
.I boot
@ -125,9 +109,7 @@ set.
If not specified with the
.B user=
.IR plan9.ini (8)
parameter or the
.B -u
option,
parameter,
.I boot
will prompt for one on the console:
.IP
@ -186,22 +168,12 @@ then
will insert a user level cache
process between the remote server and the local namespace
that caches all remote accesses on the local partition.
The
.B -f
flag commands
.IR cfs (4)
to reformat the cache partition.
.SS CPU Servers
The user owning devices and console processes on CPU servers
and that user's domain and encryption key are
read from NVRAM on all machines except PCs.
PCs keep the information in the disk partition
.BI /dev/sd XX /nvram.
If a
.B -k
option is given or if no stored information is found
.I boot
will prompt for all three items and store them.
.IP
.EX
password:

View file

@ -189,42 +189,6 @@ for(i in /rc/lib/*.rc){
# add partitions and binds
configlocal
# boot(8) command line arguments
ff=()
aa=()
while(! ~ $#* 0){
if(~ $1 -*){
if(~ $1 -u*){
if(~ $1 -u){
user=$2
shift
}
if not {
user=`{echo $1 | sed 's,^-u,,g'}
}
}
if not {
if(~ $1 -*f*)
ff=($ff -f)
if(~ $1 -*k*)
ff=($ff -k)
if(~ $1 -*m*)
ff=($ff -m)
}
shift
}
if not {
while(! ~ $#* 0){
aa=($aa $1)
shift
}
}
}
if(! ~ $#aa 0 && ~ $#bootargs 0 && ~ $#nobootprompt 0){
bootargs=$aa
nobootprompt=$aa
}
while(){
@{main}

View file

@ -28,10 +28,6 @@ multibootargs(void)
multiboot = (ulong*)KADDR(multibootptr);
/* command line */
if((multiboot[0] & (1<<2)) != 0)
strncpy(BOOTLINE, KADDR(multiboot[4]), BOOTLINELEN-1);
cp = BOOTARGS;
ep = cp + BOOTARGSLEN-1;
@ -79,15 +75,18 @@ multibootargs(void)
cp = vesabootscreenconf(cp, ep, KADDR(multiboot[19]));
/* plan9.ini passed as the first module */
if((multiboot[0] & (1<<3)) != 0 && multiboot[5] > 0){
if((multiboot[0] & (1<<3)) != 0 && multiboot[5] > 0 && multiboot[6] != 0){
m = KADDR(multiboot[6]);
l = m[1] - m[0];
m = KADDR(m[0]);
if(cp+l > ep)
l = ep - cp;
memmove(cp, m, l);
cp += l;
cp = seprint(cp, ep, "%.*s\n", (int)(m[1] - m[0]), (char*)KADDR(m[0]));
}
/* command line */
if((multiboot[0] & (1<<2)) != 0 && multiboot[4] != 0){
int i, n = tokenize(KADDR(multiboot[4]), confval, MAXCONF);
for(i=0; i<n; i++)
cp = seprint(cp, ep, "%s\n", confval[i]);
}
*cp = 0;
}
@ -182,8 +181,8 @@ writeconf(void)
n = q - p + 1;
if(n >= BOOTARGSLEN)
error("kernel configuration too large");
memset(BOOTLINE, 0, BOOTLINELEN);
memmove(BOOTARGS, p, n);
memset(BOOTLINE, 0, BOOTLINELEN);
poperror();
free(p);
}

View file

@ -13,7 +13,6 @@
Mach *m;
Conf conf;
char *sp; /* user stack of init proc */
int delaylink;
int idle_spin;
@ -110,7 +109,7 @@ machinit(void)
void
init0(void)
{
char buf[2*KNAMELEN];
char buf[2*KNAMELEN], **sp;
up->nerrlab = 0;
@ -139,45 +138,14 @@ init0(void)
poperror();
}
kproc("alarm", alarmkproc, 0);
sp = (char**)(USTKTOP - sizeof(Tos) - 8 - sizeof(sp[0])*4);
sp[3] = sp[2] = nil;
strcpy(sp[1] = (char*)&sp[4], "boot");
sp[0] = nil;
touser(sp);
}
void
userbootargs(void *base)
{
char *argv[8];
int i, argc;
#define UA(ka) ((char*)(ka) + ((uintptr)(USTKTOP - BY2PG) - (uintptr)base))
sp = (char*)base + BY2PG - sizeof(Tos);
/* push boot command line onto the stack */
sp -= BOOTLINELEN;
sp[BOOTLINELEN-1] = '\0';
memmove(sp, BOOTLINE, BOOTLINELEN-1);
/* parse boot command line */
argc = tokenize(sp, argv, nelem(argv));
if(argc < 1){
strcpy(sp, "boot");
argc = 0;
argv[argc++] = sp;
}
/* 4 byte word align stack */
sp = (char*)((uintptr)sp & ~3);
/* build argv on stack */
sp -= (argc+1)*BY2WD;
for(i=0; i<argc; i++)
((char**)sp)[i] = UA(argv[i]);
((char**)sp)[i] = nil;
sp = UA(sp);
#undef UA
sp -= BY2WD;
}
void
userinit(void)
{
@ -219,10 +187,9 @@ userinit(void)
s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG);
p->seg[SSEG] = s;
pg = newpage(0, 0, USTKTOP-BY2PG);
segpage(s, pg);
v = tmpmap(pg);
memset(v, 0, BY2PG);
segpage(s, pg);
userbootargs(v);
tmpunmap(v);
/*

View file

@ -14,8 +14,6 @@ Conf conf;
int delaylink;
int idle_spin;
char *sp; /* user stack of init proc */
extern void (*i8237alloc)(void);
extern void bootscreeninit(void);
@ -189,7 +187,7 @@ mach0init(void)
void
init0(void)
{
char buf[2*KNAMELEN];
char buf[2*KNAMELEN], **sp;
up->nerrlab = 0;
@ -219,45 +217,13 @@ init0(void)
}
kproc("alarm", alarmkproc, 0);
sp = (char**)(USTKTOP - sizeof(Tos) - 8 - sizeof(sp[0])*4);
sp[3] = sp[2] = nil;
strcpy(sp[1] = (char*)&sp[4], "boot");
sp[0] = nil;
touser(sp);
}
void
userbootargs(void *base)
{
char *argv[8];
int i, argc;
#define UA(ka) ((char*)(ka) + ((uintptr)(USTKTOP - BY2PG) - (uintptr)base))
sp = (char*)base + BY2PG - sizeof(Tos);
/* push boot command line onto the stack */
sp -= BOOTLINELEN;
sp[BOOTLINELEN-1] = '\0';
memmove(sp, BOOTLINE, BOOTLINELEN-1);
/* parse boot command line */
argc = tokenize(sp, argv, nelem(argv));
if(argc < 1){
strcpy(sp, "boot");
argc = 0;
argv[argc++] = sp;
}
/* 8 byte word align stack */
sp = (char*)((uintptr)sp & ~7);
/* build argv on stack */
sp -= (argc+1)*BY2WD;
for(i=0; i<argc; i++)
((char**)sp)[i] = UA(argv[i]);
((char**)sp)[i] = nil;
sp = UA(sp);
#undef UA
sp -= BY2WD;
}
void
userinit(void)
{
@ -299,10 +265,9 @@ userinit(void)
s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG);
p->seg[SSEG] = s;
pg = newpage(0, 0, USTKTOP-BY2PG);
segpage(s, pg);
v = kmap(pg);
memset(v, 0, BY2PG);
segpage(s, pg);
userbootargs(v);
kunmap(v);
/*

View file

@ -32,21 +32,6 @@ readn(Chan *c, void *vp, long n)
}
}
static void
setbootcmd(int argc, char *argv[])
{
char *buf, *p, *ep;
int i;
p = buf = smalloc(1024);
ep = buf + 1024;
for(i=0; i<argc; i++)
p = seprint(p, ep, "%q ", argv[i]);
*p = 0;
ksetenv("bootcmd", buf, 1);
free(buf);
}
void
rebootcmd(int argc, char *argv[])
{
@ -100,7 +85,6 @@ rebootcmd(int argc, char *argv[])
readn(c, p + rtext, data);
ksetenv("bootfile", argv[0], 1);
setbootcmd(argc-1, argv+1);
reboot((void*)entry, p, size);
error(Egreg);