diff options
author | Tushar Behera <tushar.behera@linaro.org> | 2013-02-05 10:34:56 +0530 |
---|---|---|
committer | Tushar Behera <tushar.behera@linaro.org> | 2013-02-05 10:39:13 +0530 |
commit | ce520b570699ddfc741eebeb4d0ecb436124ec24 (patch) | |
tree | 52e0c683c4e745600e8dc7425f07698ebe508b3f /common/cmd_bootm.c | |
parent | 616ce94ce413a5122f8ffa26318a36226c9231e7 (diff) |
cmd_bootm: Add support to append MAC address to bootargs
Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
Diffstat (limited to 'common/cmd_bootm.c')
-rw-r--r-- | common/cmd_bootm.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 717e9a821..7181634c2 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -579,6 +579,33 @@ static int do_bootm_subcommand(cmd_tbl_t *cmdtp, int flag, int argc, return ret; } +#ifdef CONFIG_BOOTM_BOOTARGS_APPEND_MAC +static void append_mac_addr() +{ + char *bootarg, *ethaddr; + size_t bootarg_len, ethaddr_len; + + ethaddr = getenv("ethaddr"); + + if (!ethaddr) + ethaddr = getenv("usbethaddr"); + + if (!ethaddr) + return; + + ethaddr_len = strlen(ethaddr); + + bootarg_len = strlen(getenv("bootargs")) + ethaddr_len + 6; + + bootarg = malloc(bootarg_len); + if (!bootarg) + return; + + sprintf(bootarg, "%s mac=%s", getenv("bootargs"), ethaddr); + setenv("bootargs", bootarg); +} +#endif + /*******************************************************************/ /* bootm - boot application image from image in memory */ /*******************************************************************/ @@ -602,6 +629,9 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } #endif +#ifdef CONFIG_BOOTM_BOOTARGS_APPEND_MAC + append_mac_addr(); +#endif /* determine if we have a sub command */ if (argc > 1) { char *endp; |