summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2017-06-28 18:56:16 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2017-06-28 18:56:16 +0200
commitbefdd7d7559f95734976d0ae127ac234eeb5b7d3 (patch)
tree0cdd942d2d6f396a35d1e8624e5f9f88145ef38b
parentc4b02ff9e6d86ae9522bcff4e847a88eb4336864 (diff)
downloadplan9front-befdd7d7559f95734976d0ae127ac234eeb5b7d3.tar.xz
kernel: pass bootargs also in multiboot command line, retire the bootline mechanism to pass arguments to /boot/boot
-rw-r--r--sys/man/8/boot30
-rwxr-xr-xsys/src/9/boot/bootrc36
-rw-r--r--sys/src/9/pc/bootargs.c23
-rw-r--r--sys/src/9/pc/main.c47
-rw-r--r--sys/src/9/pc64/main.c47
-rw-r--r--sys/src/9/port/rebootcmd.c16
6 files changed, 25 insertions, 174 deletions
diff --git a/sys/man/8/boot b/sys/man/8/boot
index 8dd972cd2..fbdf3be81 100644
--- 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 @@ 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:
diff --git a/sys/src/9/boot/bootrc b/sys/src/9/boot/bootrc
index cf712609a..cf899fb9b 100755
--- a/sys/src/9/boot/bootrc
+++ b/sys/src/9/boot/bootrc
@@ -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}
diff --git a/sys/src/9/pc/bootargs.c b/sys/src/9/pc/bootargs.c
index ece6f8e33..f642c8b29 100644
--- a/sys/src/9/pc/bootargs.c
+++ b/sys/src/9/pc/bootargs.c
@@ -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);
}
diff --git a/sys/src/9/pc/main.c b/sys/src/9/pc/main.c
index c69fb9769..61ae088f6 100644
--- 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 @@ machinit(void)
void
init0(void)
{
- char buf[2*KNAMELEN];
+ char buf[2*KNAMELEN], **sp;
up->nerrlab = 0;
@@ -139,43 +138,12 @@ init0(void)
poperror();
}
kproc("alarm", alarmkproc, 0);
- 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;
+ 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
@@ -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);
/*
diff --git a/sys/src/9/pc64/main.c b/sys/src/9/pc64/main.c
index 179c9e6d0..bced67787 100644
--- a/sys/src/9/pc64/main.c
+++ b/sys/src/9/pc64/main.c
@@ -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,46 +217,14 @@ 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)
{
void *v;
@@ -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);
/*
diff --git a/sys/src/9/port/rebootcmd.c b/sys/src/9/port/rebootcmd.c
index fc5186cf2..e130dc516 100644
--- a/sys/src/9/port/rebootcmd.c
+++ b/sys/src/9/port/rebootcmd.c
@@ -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);