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

View file

@ -189,42 +189,6 @@ for(i in /rc/lib/*.rc){
# add partitions and binds # add partitions and binds
configlocal 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(){ while(){
@{main} @{main}

View file

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

View file

@ -13,7 +13,6 @@
Mach *m; Mach *m;
Conf conf; Conf conf;
char *sp; /* user stack of init proc */
int delaylink; int delaylink;
int idle_spin; int idle_spin;
@ -110,7 +109,7 @@ machinit(void)
void void
init0(void) init0(void)
{ {
char buf[2*KNAMELEN]; char buf[2*KNAMELEN], **sp;
up->nerrlab = 0; up->nerrlab = 0;
@ -139,45 +138,14 @@ init0(void)
poperror(); poperror();
} }
kproc("alarm", alarmkproc, 0); 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); 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 void
userinit(void) userinit(void)
{ {
@ -219,10 +187,9 @@ userinit(void)
s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG); s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG);
p->seg[SSEG] = s; p->seg[SSEG] = s;
pg = newpage(0, 0, USTKTOP-BY2PG); pg = newpage(0, 0, USTKTOP-BY2PG);
segpage(s, pg);
v = tmpmap(pg); v = tmpmap(pg);
memset(v, 0, BY2PG); memset(v, 0, BY2PG);
segpage(s, pg);
userbootargs(v);
tmpunmap(v); tmpunmap(v);
/* /*

View file

@ -14,8 +14,6 @@ Conf conf;
int delaylink; int delaylink;
int idle_spin; int idle_spin;
char *sp; /* user stack of init proc */
extern void (*i8237alloc)(void); extern void (*i8237alloc)(void);
extern void bootscreeninit(void); extern void bootscreeninit(void);
@ -189,7 +187,7 @@ mach0init(void)
void void
init0(void) init0(void)
{ {
char buf[2*KNAMELEN]; char buf[2*KNAMELEN], **sp;
up->nerrlab = 0; up->nerrlab = 0;
@ -219,45 +217,13 @@ init0(void)
} }
kproc("alarm", alarmkproc, 0); 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); 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 void
userinit(void) userinit(void)
{ {
@ -299,10 +265,9 @@ userinit(void)
s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG); s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG);
p->seg[SSEG] = s; p->seg[SSEG] = s;
pg = newpage(0, 0, USTKTOP-BY2PG); pg = newpage(0, 0, USTKTOP-BY2PG);
segpage(s, pg);
v = kmap(pg); v = kmap(pg);
memset(v, 0, BY2PG); memset(v, 0, BY2PG);
segpage(s, pg);
userbootargs(v);
kunmap(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 void
rebootcmd(int argc, char *argv[]) rebootcmd(int argc, char *argv[])
{ {
@ -100,7 +85,6 @@ rebootcmd(int argc, char *argv[])
readn(c, p + rtext, data); readn(c, p + rtext, data);
ksetenv("bootfile", argv[0], 1); ksetenv("bootfile", argv[0], 1);
setbootcmd(argc-1, argv+1);
reboot((void*)entry, p, size); reboot((void*)entry, p, size);
error(Egreg); error(Egreg);