[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [Minios-devel] [PATCH 17/22] mini-os: add get_cmdline() function
Juergen Gross, on Tue 23 Aug 2016 17:16:03 +0200, wrote: > The command line parameters are passed in start_info structure for pv, > but via hvm_start_info for HVMlite. Add a generic function to fill a > local cmdline variable with the command line string. > > Signed-off-by: Juergen Gross <jgross@xxxxxxxx> Reviewed-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx> > --- > arch/x86/setup.c | 20 ++++++++++++++++++-- > include/kernel.h | 3 +++ > kernel.c | 1 + > main.c | 5 +++-- > 4 files changed, 25 insertions(+), 4 deletions(-) > > diff --git a/arch/x86/setup.c b/arch/x86/setup.c > index 6645784..13633f0 100644 > --- a/arch/x86/setup.c > +++ b/arch/x86/setup.c > @@ -31,6 +31,7 @@ > #include <mini-os/kernel.h> > #include <xen/xen.h> > #include <xen/arch-x86/cpuid.h> > +#include <xen/arch-x86/hvm/start_info.h> > > /* > * Shared page for communicating with the hypervisor. > @@ -88,6 +89,13 @@ static inline void sse_init(void) { > > #ifdef CONFIG_PARAVIRT > #define hpc_init() > + > +static void get_cmdline(void *p) > +{ > + start_info_t *si = p; > + > + strncpy(cmdline, (char *)si->cmd_line, MAX_CMDLINE_SIZE - 1); > +} > #else > static void hpc_init(void) > { > @@ -109,6 +117,14 @@ static void hpc_init(void) > wrmsrl(ebx, (unsigned long)&hypercall_page); > barrier(); > } > + > +static void get_cmdline(void *p) > +{ > + struct hvm_start_info *si = p; > + > + if ( si->cmdline_paddr ) > + strncpy(cmdline, to_virt(si->cmdline_paddr), MAX_CMDLINE_SIZE - 1); > +} > #endif > > /* > @@ -139,6 +155,7 @@ arch_init(void *par) > shared_info. Use xprintk instead. */ > get_console(par); > get_xenbus(par); > + get_cmdline(par); > si = par; > memcpy(&start_info, si, sizeof(*si)); > > @@ -153,8 +170,7 @@ arch_init(void *par) > printk(" mod_start: 0x%lx(VA)\n", si->mod_start); > printk(" mod_len: %lu\n", si->mod_len); > printk(" flags: 0x%x\n", (unsigned int)si->flags); > - printk(" cmd_line: %s\n", > - si->cmd_line ? (const char *)si->cmd_line : "NULL"); > + printk(" cmd_line: %s\n", cmdline); > printk(" stack: %p-%p\n", stack, stack + sizeof(stack)); > > /* Grab the shared_info pointer and put it in a safe place. */ > diff --git a/include/kernel.h b/include/kernel.h > index 13e3274..d37ddda 100644 > --- a/include/kernel.h > +++ b/include/kernel.h > @@ -1,6 +1,9 @@ > #ifndef _KERNEL_H_ > #define _KERNEL_H_ > > +#define MAX_CMDLINE_SIZE 1024 > +extern char cmdline[MAX_CMDLINE_SIZE]; > + > void start_kernel(void); > void do_exit(void) __attribute__((noreturn)); > void arch_do_exit(void); > diff --git a/kernel.c b/kernel.c > index 437e5b4..f22997e 100644 > --- a/kernel.c > +++ b/kernel.c > @@ -48,6 +48,7 @@ > #include <xen/version.h> > > uint8_t xen_features[XENFEAT_NR_SUBMAPS * 32]; > +char cmdline[MAX_CMDLINE_SIZE]; > > void setup_xen_features(void) > { > diff --git a/main.c b/main.c > index 4ec40b5..71e3be3 100644 > --- a/main.c > +++ b/main.c > @@ -6,6 +6,7 @@ > > #ifdef HAVE_LIBC > #include <os.h> > +#include <kernel.h> > #include <sched.h> > #include <console.h> > #include <netfront.h> > @@ -134,7 +135,7 @@ static void call_main(void *p) > #define PARSE_ARGS_COUNT(ARGS) PARSE_ARGS(ARGS, argc++, c++, ) > #define PARSE_ARGS_STORE(ARGS) PARSE_ARGS(ARGS, argv[argc++] = c, memmove(c, > c + 1, strlen(c + 1) + 1), *c++ = 0) > > - PARSE_ARGS_COUNT((char*)start_info.cmd_line); > + PARSE_ARGS_COUNT(cmdline); > #ifdef CONFIG_QEMU_XS_ARGS > PARSE_ARGS_COUNT(domargs); > #endif > @@ -143,7 +144,7 @@ static void call_main(void *p) > argv[0] = "main"; > argc = 1; > > - PARSE_ARGS_STORE((char*)start_info.cmd_line) > + PARSE_ARGS_STORE(cmdline) > #ifdef CONFIG_QEMU_XS_ARGS > PARSE_ARGS_STORE(domargs) > #endif > -- > 2.6.6 > > > _______________________________________________ > Minios-devel mailing list > Minios-devel@xxxxxxxxxxxxxxxxxxxx > https://lists.xenproject.org/cgi-bin/mailman/listinfo/minios-devel -- Samuel <T> csp.tar.gz: ascii text -+- #ens-mim - vive les browsers qui prennent des initiatives à la con -+- _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |