diff mbox

[U-Boot,5/8] cmd: bootvx: Pass netmask and gatewayip to VxWorks bootline

Message ID 1443086484-26942-6-git-send-email-bmeng.cn@gmail.com
State Superseded
Delegated to: Tom Rini
Headers show

Commit Message

Bin Meng Sept. 24, 2015, 9:21 a.m. UTC
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@gmail.com>
---

 common/cmd_elf.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

Comments

Bin Meng Sept. 25, 2015, 2:34 a.m. UTC | #1
On Thu, Sep 24, 2015 at 5:21 PM, Bin Meng <bmeng.cn@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@gmail.com>
> ---
>
>  common/cmd_elf.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/common/cmd_elf.c b/common/cmd_elf.c
> index 62863df..5a34bde 100644
> --- a/common/cmd_elf.c
> +++ b/common/cmd_elf.c
> @@ -287,13 +287,24 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>                                 "%s:file ", CONFIG_SYS_VXWORKS_SERVERNAME);
>
>                 tmp = getenv("ipaddr");
> -               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)],
> +                                       ":%04x ", getenv_ip("netmask").s_addr);

There is an endian issue here for little endian targets. Also the %04x
is wrong, should be %08x. This will be fixed in v2.

> +                       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);
> --

Regards,
Bin
diff mbox

Patch

diff --git a/common/cmd_elf.c b/common/cmd_elf.c
index 62863df..5a34bde 100644
--- a/common/cmd_elf.c
+++ b/common/cmd_elf.c
@@ -287,13 +287,24 @@  int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 				"%s:file ", CONFIG_SYS_VXWORKS_SERVERNAME);
 
 		tmp = getenv("ipaddr");
-		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)],
+					":%04x ", 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);