diff options
author | Rob Herring <rob.herring@calxeda.com> | 2012-09-17 21:54:05 -0500 |
---|---|---|
committer | John Rigby <john.rigby@linaro.org> | 2012-12-06 13:51:52 -0700 |
commit | dfba6105773e337b6cb73678efdecd1874e4fc7b (patch) | |
tree | 8ecf02db81696d3fd64683f31756c37136129d64 | |
parent | fb293b87dd4dd27f1700394d35d9b3c60ab45a2b (diff) | |
download | u-boot-linaro-stable-dfba6105773e337b6cb73678efdecd1874e4fc7b.tar.gz |
cmd_pxe: add ipappend support
Add ipappend support to pass network device information to the kernel.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
-rw-r--r-- | common/cmd_pxe.c | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c index a314275b1..a1aa69aed 100644 --- a/common/cmd_pxe.c +++ b/common/cmd_pxe.c @@ -469,6 +469,7 @@ struct pxe_label { char *append; char *initrd; char *fdt; + int ipappend; int attempted; int localboot; int localboot_val; @@ -602,7 +603,11 @@ static int label_boot(struct pxe_label *label) { char *bootm_argv[] = { "bootm", NULL, NULL, NULL, NULL }; char initrd_str[22]; + char mac_str[29] = ""; + char ip_str[68] = ""; + char *bootargs; int bootm_argc = 3; + int len = 0; label_print(label); @@ -641,9 +646,39 @@ static int label_boot(struct pxe_label *label) return 1; } - if (label->append) { - setenv("bootargs", label->append); - printf("append: %s\n", label->append); + if (label->ipappend & 0x1) { + sprintf(ip_str, " ip=%s:%s:%s:%s", + getenv("ipaddr"), getenv("serverip"), + getenv("gatewayip"), getenv("netmask")); + len += strlen(ip_str); + } + + if (label->ipappend & 0x2) { + int err; + strcpy(mac_str, " BOOTIF="); + err = format_mac_pxe(mac_str + 8, sizeof(mac_str) - 8); + if (err < 0) + mac_str[0] = '\0'; + len += strlen(mac_str); + } + + if (label->append) + len += strlen(label->append); + + if (len) { + bootargs = malloc(len); + if (!bootargs) + return 1; + bootargs[0] ='\0'; + if (label->append) + strcpy(bootargs, label->append); + strcat(bootargs, ip_str); + strcat(bootargs, mac_str); + + setenv("bootargs", bootargs); + printf("append: %s\n", bootargs); + + free(bootargs); } bootm_argv[1] = getenv("kernel_addr_r"); @@ -705,6 +740,7 @@ enum token_type { T_INCLUDE, T_FDT, T_ONTIMEOUT, + T_IPAPPEND, T_INVALID }; @@ -734,6 +770,7 @@ static const struct token keywords[] = { {"include", T_INCLUDE}, {"fdt", T_FDT}, {"ontimeout", T_ONTIMEOUT,}, + {"ipappend", T_IPAPPEND,}, {NULL, T_INVALID} }; @@ -1127,6 +1164,10 @@ static int parse_label(char **c, struct pxe_menu *cfg) err = parse_integer(c, &label->localboot_val); break; + case T_IPAPPEND: + err = parse_integer(c, &label->ipappend); + break; + case T_EOL: break; |