ref: befdd7d7559f95734976d0ae127ac234eeb5b7d3
parent: c4b02ff9e6d86ae9522bcff4e847a88eb4336864
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Jun 28 14:56:16 EDT 2017
kernel: pass bootargs also in multiboot command line, retire the bootline mechanism to pass arguments to /boot/boot
--- a/sys/man/8/boot
+++ b/sys/man/8/boot
@@ -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 @@
.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 @@
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,11 +168,6 @@
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
@@ -197,11 +174,6 @@
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:
--- a/sys/src/9/boot/bootrc
+++ b/sys/src/9/boot/bootrc
@@ -189,42 +189,6 @@
# 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}
--- a/sys/src/9/pc/bootargs.c
+++ b/sys/src/9/pc/bootargs.c
@@ -28,10 +28,6 @@
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 @@
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 @@
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);
}
--- a/sys/src/9/pc/main.c
+++ b/sys/src/9/pc/main.c
@@ -13,7 +13,6 @@
Mach *m;
Conf conf;
-char *sp; /* user stack of init proc */
int delaylink;
int idle_spin;
@@ -110,7 +109,7 @@
void
init0(void)
{
- char buf[2*KNAMELEN];
+ char buf[2*KNAMELEN], **sp;
up->nerrlab = 0;
@@ -139,46 +138,15 @@
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)
{
void *v;
@@ -219,10 +187,9 @@
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);
/*
--- a/sys/src/9/pc64/main.c
+++ b/sys/src/9/pc64/main.c
@@ -14,8 +14,6 @@
int delaylink;
int idle_spin;
-char *sp; /* user stack of init proc */
-
extern void (*i8237alloc)(void);
extern void bootscreeninit(void);
@@ -189,7 +187,7 @@
void
init0(void)
{
- char buf[2*KNAMELEN];
+ char buf[2*KNAMELEN], **sp;
up->nerrlab = 0;
@@ -219,46 +217,14 @@
}
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)
{
void *v;
@@ -299,10 +265,9 @@
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);
/*
--- a/sys/src/9/port/rebootcmd.c
+++ b/sys/src/9/port/rebootcmd.c
@@ -32,21 +32,6 @@
}
}
-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 @@
readn(c, p + rtext, data);
ksetenv("bootfile", argv[0], 1);
- setbootcmd(argc-1, argv+1);
reboot((void*)entry, p, size);
error(Egreg);