[U-Boot] [PATCH v2 09/13] cmd: bootvx: Pass netmask and gatewayip to VxWorks bootline
Simon Glass
sjg at chromium.org
Fri Oct 2 01:01:03 CEST 2015
Hi Bin,
On Monday, 28 September 2015, Bin Meng <bmeng.cn at gmail.com> wrote:
>
> There are fields in VxWorks bootline for netmask and gatewayip.
> We can get these from U-Boot environment variables and pass them
> to VxWorks, just like ipaddr and serverip.
>
> Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
>
> ---
>
> Changes in v2:
> - Fix the endian issue for netmask
>
> common/cmd_elf.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/common/cmd_elf.c b/common/cmd_elf.c
> index 62863df..9e6aa01 100644
> --- a/common/cmd_elf.c
> +++ b/common/cmd_elf.c
> @@ -287,13 +287,25 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> "%s:file ", CONFIG_SYS_VXWORKS_SERVERNAME);
>
> tmp = getenv("ipaddr");
Can we avoid all these calls to strlen() by having a ptr variable?
ptr = sprintf(...)
ptr += sprintf(build_buf + ptr, ...)
ptr += sprintf(build_buf + ptr, ...)
>
> - if (tmp)
> - sprintf(&build_buf[strlen(build_buf)], "e=%s ", tmp);
> + if (tmp) {
> + sprintf(&build_buf[strlen(build_buf)], "e=%s", tmp);
> + tmp = getenv("netmask");
> + if (tmp)
> + sprintf(&build_buf[strlen(build_buf)],
> + ":%08x ",
> + ntohl(getenv_ip("netmask").s_addr));
> + else
> + sprintf(&build_buf[strlen(build_buf)], " ");
> + }
>
> tmp = getenv("serverip");
> if (tmp)
> sprintf(&build_buf[strlen(build_buf)], "h=%s ", tmp);
>
> + tmp = getenv("gatewayip");
> + if (tmp)
> + sprintf(&build_buf[strlen(build_buf)], "g=%s ", tmp);
> +
> tmp = getenv("hostname");
> if (tmp)
> sprintf(&build_buf[strlen(build_buf)], "tn=%s ", tmp);
> --
> 1.8.2.1
>
Regards,
Simon
More information about the U-Boot
mailing list