#define MAX_TFTP_PATH_LEN 127
-
/*
* Like getenv, but prints an error if envvar isn't defined in the
* environment. It always returns what getenv does, so it can be used in
*/
static int format_mac_pxe(char *outbuf, size_t outbuf_len)
{
- size_t ethaddr_len;
- char *p, *ethaddr;
-
- ethaddr = from_env("ethaddr");
+ uchar ethaddr[6];
- if (!ethaddr)
- return -ENOENT;
-
- ethaddr_len = strlen(ethaddr);
-
- /*
- * ethaddr_len + 4 gives room for "01-", ethaddr, and a NUL byte at
- * the end.
- */
- if (outbuf_len < ethaddr_len + 4) {
- printf("outbuf is too small (%d < %d)\n",
- outbuf_len, ethaddr_len + 4);
+ if (outbuf_len < 21) {
+ printf("outbuf is too small (%d < 21)\n", outbuf_len);
return -EINVAL;
}
- strcpy(outbuf, "01-");
-
- for (p = outbuf + 3; *ethaddr; ethaddr++, p++) {
- if (*ethaddr == ':')
- *p = '-';
- else
- *p = tolower(*ethaddr);
- }
+ if (!eth_getenv_enetaddr_by_index("eth", eth_get_dev_index(),
+ ethaddr))
+ return -ENOENT;
- *p = '\0';
+ sprintf(outbuf, "01-%02x-%02x-%02x-%02x-%02x-%02x",
+ ethaddr[0], ethaddr[1], ethaddr[2],
+ ethaddr[3], ethaddr[4], ethaddr[5]);
return 1;
}
return -ENOENT;
}
-
-
/*
* As in pxelinux, paths to files referenced from files we retrieve are
* relative to the location of bootfile. get_relfile takes such a path and
if (argc != 1)
return CMD_RET_USAGE;
-
pxefile_addr_str = from_env("pxefile_addr_r");
if (!pxefile_addr_str)
char *kernel;
char *append;
char *initrd;
+ char *fdt;
int attempted;
int localboot;
struct list_head list;
if (label->initrd)
free(label->initrd);
+ if (label->fdt)
+ free(label->fdt);
+
free(label);
}
if (label->initrd)
printf("\t\tinitrd: %s\n", label->initrd);
+
+ if (label->fdt)
+ printf("\tfdt: %s\n", label->fdt);
}
/*
*/
static int label_localboot(struct pxe_label *label)
{
- char *localcmd, *dupcmd;
- int ret;
+ char *localcmd;
localcmd = from_env("localcmd");
if (!localcmd)
return -ENOENT;
- /*
- * dup the command to avoid any issues with the version of it existing
- * in the environment changing during the execution of the command.
- */
- dupcmd = strdup(localcmd);
-
- if (!dupcmd)
- return -ENOMEM;
-
if (label->append)
setenv("bootargs", label->append);
- printf("running: %s\n", dupcmd);
+ debug("running: %s\n", localcmd);
- ret = run_command(dupcmd, 0);
-
- free(dupcmd);
-
- return ret;
+ return run_command_list(localcmd, strlen(localcmd), 0);
}
/*
bootm_argv[1] = getenv("kernel_addr_r");
/*
- * fdt usage is optional. If there is an fdt_addr specified, we will
- * pass it along to bootm, and adjust argc appropriately.
+ * fdt usage is optional:
+ * It handles the following scenarios. All scenarios are exclusive
+ *
+ * Scenario 1: If fdt_addr_r specified and "fdt" label is defined in
+ * pxe file, retrieve fdt blob from server. Pass fdt_addr_r to bootm,
+ * and adjust argc appropriately.
+ *
+ * Scenario 2: If there is an fdt_addr specified, pass it along to
+ * bootm, and adjust argc appropriately.
+ *
+ * Scenario 3: fdt blob is not available.
*/
- bootm_argv[3] = getenv("fdt_addr");
+ bootm_argv[3] = getenv("fdt_addr_r");
+
+ /* if fdt label is defined then get fdt from server */
+ if (bootm_argv[3] && label->fdt) {
+ if (get_relfile_envaddr(label->fdt, "fdt_addr_r") < 0) {
+ printf("Skipping %s for failure retrieving fdt\n",
+ label->name);
+ return;
+ }
+ } else
+ bootm_argv[3] = getenv("fdt_addr");
if (bootm_argv[3])
bootm_argc = 4;
T_DEFAULT,
T_PROMPT,
T_INCLUDE,
+ T_FDT,
T_INVALID
};
{"append", T_APPEND},
{"initrd", T_INITRD},
{"include", T_INCLUDE},
+ {"fdt", T_FDT},
{NULL, T_INVALID}
};
err = parse_sliteral(c, &label->initrd);
break;
+ case T_FDT:
+ if (!label->fdt)
+ err = parse_sliteral(c, &label->fdt);
+ break;
+
case T_LOCALBOOT:
err = parse_integer(c, &label->localboot);
break;
/*
* Create a menu and add items for all the labels.
*/
- m = menu_create(cfg->title, cfg->timeout, cfg->prompt, label_print);
+ m = menu_create(cfg->title, cfg->timeout, cfg->prompt, label_print,
+ NULL, NULL);
if (!m)
return NULL;