|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCHv5 35/46] plat/kvm: Parse command line from device tree for Arm64
> -----Original Message-----
> From: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
> Sent: 2018年9月12日 4:03
> To: Wei Chen (Arm Technology China) <Wei.Chen@xxxxxxx>; minios-
> devel@xxxxxxxxxxxxxxxxxxxx
> Cc: Kaly Xin (Arm Technology China) <Kaly.Xin@xxxxxxx>; nd <nd@xxxxxxx>
> Subject: Re: [Minios-devel] [UNIKRAFT PATCHv5 35/46] plat/kvm: Parse command
> line from device tree for Arm64
>
> This code is from arm32 Xen port, right? It looks familiar to me. ;-)
>
Haha, yes.
> Reviewed-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
>
> On 10.08.2018 09:08, Wei Chen wrote:
> > From: Wei Chen <Wei.Chen@xxxxxxx>
> >
> > Device tree has a "chosen" node, this node can be used to pass
> > parameters to virtual machine through bootargs property. We can
> > use this feature to pass command line to unikraft application,
> > and then parse it from device tree for further usage.
> >
> > The command line will be modified in uk_argparse, but the memory
> > attribute of DTB is readonly, we need a copy of this command line.
> >
> > Signed-off-by: Wei Chen <Wei.Chen@xxxxxxx>
> > ---
> > plat/kvm/arm/setup.c | 32 ++++++++++++++++++++++++++++++++
> > 1 file changed, 32 insertions(+)
> >
> > diff --git a/plat/kvm/arm/setup.c b/plat/kvm/arm/setup.c
> > index aca3444..d59956a 100644
> > --- a/plat/kvm/arm/setup.c
> > +++ b/plat/kvm/arm/setup.c
> > @@ -24,6 +24,9 @@
> >
> > void *_libkvmplat_dtb;
> >
> > +#define MAX_CMDLINE_SIZE 1024
> > +static char cmdline[MAX_CMDLINE_SIZE];
> > +
> > static void _init_dtb(void *dtb_pointer)
> > {
> > int ret;
> > @@ -35,10 +38,39 @@ static void _init_dtb(void *dtb_pointer)
> > uk_printd(DLVL_INFO, "Found device tree on: %p\n", dtb_pointer);
> > }
> >
> > +static void _dtb_get_cmdline(char *cmdline, size_t maxlen)
> > +{
> > + int fdtchosen, len;
> > + const char *fdtcmdline;
> > +
> > + /* TODO: Proper error handling */
> > + fdtchosen = fdt_path_offset(_libkvmplat_dtb, "/chosen");
> > + if (!fdtchosen)
> > + goto enocmdl;
> > + fdtcmdline = fdt_getprop(_libkvmplat_dtb, fdtchosen, "bootargs", &len);
> > + if (!fdtcmdline || (len <= 0))
> > + goto enocmdl;
> > +
> > + strncpy(cmdline, fdtcmdline, MIN(maxlen, (unsigned int) len));
> > + /* ensure null termination */
> > + cmdline[((unsigned int) len - 1) <= (maxlen - 1) ?
> > + ((unsigned int) len - 1) : (maxlen - 1)] = '\0';
> > +
> > + uk_printd(DLVL_INFO, "Command line: %s\n", cmdline);
> > + return;
> > +
> > +enocmdl:
> > + uk_printd(DLVL_INFO, "No command line found\n");
> > + strcpy(cmdline, CONFIG_UK_NAME);
> > +}
> > +
> > void _libkvmplat_start(void *dtb_pointer)
> > {
> > _init_dtb(dtb_pointer);
> > _libkvmplat_init_console();
> >
> > uk_printd(DLVL_INFO, "Entering from KVM (arm64)...\n");
> > +
> > + /* Get command line from DTB */
> > + _dtb_get_cmdline(cmdline, sizeof(cmdline));
> > }
> >
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |