pc, pc64: remove old B.COM command line parsing and just pass tokenized BOOTLINE to /boot/boot as argv[]
this change allows command line passing to /boot/boot from qemu like: qemu -kernel 9pcf -append "-u glenda tcp"
This commit is contained in:
parent
0e03a5f9fd
commit
06e6115044
3 changed files with 50 additions and 102 deletions
|
@ -1,23 +0,0 @@
|
||||||
#include "/sys/src/libc/9syscall/sys.h"
|
|
||||||
|
|
||||||
TEXT main(SB),$0
|
|
||||||
|
|
||||||
/*
|
|
||||||
* exec("/boot", bootv)
|
|
||||||
*/
|
|
||||||
LEAL 4(SP),AX
|
|
||||||
PUSHL AX
|
|
||||||
LEAL boot(SB),AX
|
|
||||||
PUSHL AX
|
|
||||||
PUSHL $0
|
|
||||||
MOVL $EXEC,AX
|
|
||||||
INT $64
|
|
||||||
|
|
||||||
/*
|
|
||||||
* should never get here
|
|
||||||
*/
|
|
||||||
here:
|
|
||||||
JMP here
|
|
||||||
|
|
||||||
GLOBL boot+0(SB),$6
|
|
||||||
DATA boot+0(SB)/5,$"/boot"
|
|
|
@ -29,7 +29,7 @@ Conf conf;
|
||||||
char *confname[MAXCONF];
|
char *confname[MAXCONF];
|
||||||
char *confval[MAXCONF];
|
char *confval[MAXCONF];
|
||||||
int nconf;
|
int nconf;
|
||||||
uchar *sp; /* user stack of init proc */
|
char *sp; /* user stack of init proc */
|
||||||
int delaylink;
|
int delaylink;
|
||||||
int idle_spin;
|
int idle_spin;
|
||||||
|
|
||||||
|
@ -321,53 +321,39 @@ userinit(void)
|
||||||
ready(p);
|
ready(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
uchar *
|
|
||||||
pusharg(char *p)
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
|
|
||||||
n = strlen(p)+1;
|
|
||||||
sp -= n;
|
|
||||||
memmove(sp, p, n);
|
|
||||||
return sp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
bootargs(void *base)
|
bootargs(void *base)
|
||||||
{
|
{
|
||||||
int i, ac;
|
char *argv[8];
|
||||||
uchar *av[32];
|
int i, argc;
|
||||||
uchar **lsp;
|
|
||||||
char *cp = BOOTLINE;
|
|
||||||
char buf[64];
|
|
||||||
|
|
||||||
sp = (uchar*)base + BY2PG - sizeof(Tos);
|
#define UA(ka) ((char*)(ka) + ((uintptr)(USTKTOP - BY2PG) - (uintptr)base))
|
||||||
|
sp = (char*)base + BY2PG - sizeof(Tos);
|
||||||
|
|
||||||
ac = 0;
|
/* push boot command line onto the stack */
|
||||||
av[ac++] = pusharg("boot");
|
sp -= BOOTLINELEN;
|
||||||
|
sp[BOOTLINELEN-1] = '\0';
|
||||||
|
memmove(sp, BOOTLINE, BOOTLINELEN-1);
|
||||||
|
|
||||||
/* when boot is changed to only use rc, this code can go away */
|
/* parse boot command line */
|
||||||
cp[BOOTLINELEN-1] = 0;
|
argc = tokenize(sp, argv, nelem(argv));
|
||||||
buf[0] = 0;
|
if(argc < 1){
|
||||||
if(strncmp(cp, "fd", 2) == 0){
|
strcpy(sp, "boot");
|
||||||
sprint(buf, "local!#f/fd%lddisk", strtol(cp+2, 0, 0));
|
argc = 0;
|
||||||
av[ac++] = pusharg(buf);
|
argv[argc++] = sp;
|
||||||
} else if(strncmp(cp, "sd", 2) == 0){
|
}
|
||||||
sprint(buf, "local!#S/sd%c%c/fs", *(cp+2), *(cp+3));
|
|
||||||
av[ac++] = pusharg(buf);
|
|
||||||
} else if(strncmp(cp, "ether", 5) == 0)
|
|
||||||
av[ac++] = pusharg("-n");
|
|
||||||
|
|
||||||
/* 4 byte word align stack */
|
/* 4 byte word align stack */
|
||||||
sp = (uchar*)((ulong)sp & ~3);
|
sp = (char*)((uintptr)sp & ~3);
|
||||||
|
|
||||||
/* build argc, argv on stack */
|
/* build argv on stack */
|
||||||
sp -= (ac+1)*sizeof(sp);
|
sp -= (argc+1)*BY2WD;
|
||||||
lsp = (uchar**)sp;
|
for(i=0; i<argc; i++)
|
||||||
for(i = 0; i < ac; i++)
|
((char**)sp)[i] = UA(argv[i]);
|
||||||
lsp[i] = av[i] + ((USTKTOP - BY2PG) - (ulong)base);
|
((char**)sp)[i] = nil;
|
||||||
lsp[i] = 0;
|
|
||||||
sp += (USTKTOP - BY2PG) - (ulong)base;
|
sp = UA(sp);
|
||||||
|
#undef UA
|
||||||
sp -= BY2WD;
|
sp -= BY2WD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ int nconf;
|
||||||
int delaylink;
|
int delaylink;
|
||||||
int idle_spin;
|
int idle_spin;
|
||||||
|
|
||||||
uchar *sp; /* user stack of init proc */
|
char *sp; /* user stack of init proc */
|
||||||
|
|
||||||
extern void (*i8237alloc)(void);
|
extern void (*i8237alloc)(void);
|
||||||
extern void bootscreeninit(void);
|
extern void bootscreeninit(void);
|
||||||
|
@ -330,54 +330,39 @@ mach0init(void)
|
||||||
active.exiting = 0;
|
active.exiting = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uchar *
|
|
||||||
pusharg(char *p)
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
|
|
||||||
n = strlen(p)+1;
|
|
||||||
sp -= n;
|
|
||||||
memmove(sp, p, n);
|
|
||||||
return sp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
bootargs(void *base)
|
bootargs(void *base)
|
||||||
{
|
{
|
||||||
int i, ac;
|
char *argv[8];
|
||||||
uchar *av[32];
|
int i, argc;
|
||||||
uchar **lsp;
|
|
||||||
char *cp = BOOTLINE;
|
|
||||||
char buf[64];
|
|
||||||
|
|
||||||
sp = (uchar*)base + BY2PG - sizeof(Tos);
|
#define UA(ka) ((char*)(ka) + ((uintptr)(USTKTOP - BY2PG) - (uintptr)base))
|
||||||
|
sp = (char*)base + BY2PG - sizeof(Tos);
|
||||||
|
|
||||||
ac = 0;
|
/* push boot command line onto the stack */
|
||||||
av[ac++] = pusharg("boot");
|
sp -= BOOTLINELEN;
|
||||||
|
sp[BOOTLINELEN-1] = '\0';
|
||||||
|
memmove(sp, BOOTLINE, BOOTLINELEN-1);
|
||||||
|
|
||||||
/* when boot is changed to only use rc, this code can go away */
|
/* parse boot command line */
|
||||||
cp[BOOTLINELEN-1] = 0;
|
argc = tokenize(sp, argv, nelem(argv));
|
||||||
buf[0] = 0;
|
if(argc < 1){
|
||||||
if(strncmp(cp, "fd", 2) == 0){
|
strcpy(sp, "boot");
|
||||||
sprint(buf, "local!#f/fd%lddisk", strtol(cp+2, 0, 0));
|
argc = 0;
|
||||||
av[ac++] = pusharg(buf);
|
argv[argc++] = sp;
|
||||||
} else if(strncmp(cp, "sd", 2) == 0){
|
}
|
||||||
sprint(buf, "local!#S/sd%c%c/fs", *(cp+2), *(cp+3));
|
|
||||||
av[ac++] = pusharg(buf);
|
|
||||||
} else if(strncmp(cp, "ether", 5) == 0)
|
|
||||||
av[ac++] = pusharg("-n");
|
|
||||||
|
|
||||||
/* 8 byte word align stack */
|
/* 8 byte word align stack */
|
||||||
sp = (uchar*)((uintptr)sp & ~7);
|
sp = (char*)((uintptr)sp & ~7);
|
||||||
|
|
||||||
/* build argc, argv on stack */
|
/* build argv on stack */
|
||||||
sp -= (ac+1)*sizeof(sp);
|
sp -= (argc+1)*BY2WD;
|
||||||
lsp = (uchar**)sp;
|
for(i=0; i<argc; i++)
|
||||||
for(i = 0; i < ac; i++)
|
((char**)sp)[i] = UA(argv[i]);
|
||||||
lsp[i] = av[i] + ((uintptr)(USTKTOP - BY2PG) - (uintptr)base);
|
((char**)sp)[i] = nil;
|
||||||
lsp[i] = 0;
|
|
||||||
sp += (uintptr)(USTKTOP - BY2PG) - (uintptr)base;
|
sp = UA(sp);
|
||||||
|
#undef UA
|
||||||
sp -= BY2WD;
|
sp -= BY2WD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue