From befdd7d7559f95734976d0ae127ac234eeb5b7d3 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Wed, 28 Jun 2017 18:56:16 +0200 Subject: kernel: pass bootargs also in multiboot command line, retire the bootline mechanism to pass arguments to /boot/boot --- sys/man/8/boot | 30 +---------------------------- sys/src/9/boot/bootrc | 36 ----------------------------------- sys/src/9/pc/bootargs.c | 23 +++++++++++------------ sys/src/9/pc/main.c | 47 +++++++--------------------------------------- sys/src/9/pc64/main.c | 47 ++++++---------------------------------------- sys/src/9/port/rebootcmd.c | 16 ---------------- 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= 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; iseg[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,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; iseg[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