]> git.sur5r.net Git - u-boot/blobdiff - common/cmd_pxe.c
ppc: Move mirror_hack to arch_global_data
[u-boot] / common / cmd_pxe.c
index 2b1115d7276d801d1b49454a745488847be87c03..ee75db96853345f503a5b569ff720caf0a49712c 100644 (file)
@@ -26,7 +26,6 @@
 
 #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
@@ -175,8 +174,6 @@ static int do_get_fat(char *file_path, char *file_addr)
        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
@@ -365,7 +362,6 @@ do_pxe_get(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        if (argc != 1)
                return CMD_RET_USAGE;
 
-
        pxefile_addr_str = from_env("pxefile_addr_r");
 
        if (!pxefile_addr_str)
@@ -454,6 +450,7 @@ struct pxe_label {
        char *kernel;
        char *append;
        char *initrd;
+       char *fdt;
        int attempted;
        int localboot;
        struct list_head list;
@@ -521,6 +518,9 @@ static void label_destroy(struct pxe_label *label)
        if (label->initrd)
                free(label->initrd);
 
+       if (label->fdt)
+               free(label->fdt);
+
        free(label);
 }
 
@@ -545,6 +545,9 @@ static void label_print(void *data)
 
        if (label->initrd)
                printf("\t\tinitrd: %s\n", label->initrd);
+
+       if (label->fdt)
+               printf("\tfdt: %s\n", label->fdt);
 }
 
 /*
@@ -558,33 +561,19 @@ static void label_print(void *data)
  */
 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);
-
-       ret = run_command(dupcmd, 0);
+       debug("running: %s\n", localcmd);
 
-       free(dupcmd);
-
-       return ret;
+       return run_command_list(localcmd, strlen(localcmd), 0);
 }
 
 /*
@@ -646,10 +635,29 @@ static void label_boot(struct pxe_label *label)
        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;
@@ -676,6 +684,7 @@ enum token_type {
        T_DEFAULT,
        T_PROMPT,
        T_INCLUDE,
+       T_FDT,
        T_INVALID
 };
 
@@ -703,6 +712,7 @@ static const struct token keywords[] = {
        {"append", T_APPEND},
        {"initrd", T_INITRD},
        {"include", T_INCLUDE},
+       {"fdt", T_FDT},
        {NULL, T_INVALID}
 };
 
@@ -1092,6 +1102,11 @@ static int parse_label(char **c, struct pxe_menu *cfg)
                                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;