]> git.sur5r.net Git - u-boot/blobdiff - common/spl/spl.c
spl: Make spl_boot_list a local variable
[u-boot] / common / spl / spl.c
index 84c80345b695c41212916e3002f2e811ec380cf5..bdb165ac2841829e317eb5b733214742cd6eb74c 100644 (file)
@@ -29,7 +29,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #endif
 
 u32 *boot_params_ptr = NULL;
-struct spl_image_info spl_image;
 
 /* Define board data structure */
 static bd_t bdata __attribute__ ((section(".data")));
@@ -185,7 +184,8 @@ static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,
        return count;
 }
 
-static int spl_ram_load_image(struct spl_boot_device *bootdev)
+static int spl_ram_load_image(struct spl_image_info *spl_image,
+                             struct spl_boot_device *bootdev)
 {
        struct image_header *header;
 
@@ -203,7 +203,7 @@ static int spl_ram_load_image(struct spl_boot_device *bootdev)
                debug("Found FIT\n");
                load.bl_len = 1;
                load.read = spl_ram_load_read;
-               spl_load_simple_fit(&load, 0, header);
+               spl_load_simple_fit(spl_image, &load, 0, header);
        } else {
                debug("Legacy image\n");
                /*
@@ -215,7 +215,7 @@ static int spl_ram_load_image(struct spl_boot_device *bootdev)
                header = (struct image_header *)
                        (CONFIG_SYS_TEXT_BASE - sizeof(struct image_header));
 
-               spl_parse_image_header(&spl_image, header);
+               spl_parse_image_header(spl_image, header);
        }
 
        return 0;
@@ -262,14 +262,6 @@ int spl_init(void)
 #define BOOT_DEVICE_NONE 0xdeadbeef
 #endif
 
-static u32 spl_boot_list[] = {
-       BOOT_DEVICE_NONE,
-       BOOT_DEVICE_NONE,
-       BOOT_DEVICE_NONE,
-       BOOT_DEVICE_NONE,
-       BOOT_DEVICE_NONE,
-};
-
 __weak void board_boot_order(u32 *spl_boot_list)
 {
        spl_boot_list[0] = spl_boot_device();
@@ -373,7 +365,7 @@ static struct spl_image_loader *spl_ll_find_loader(uint boot_device)
        return NULL;
 }
 
-static int spl_load_image(u32 boot_device)
+static int spl_load_image(struct spl_image_info *spl_image, u32 boot_device)
 {
        struct spl_boot_device bootdev;
        struct spl_image_loader *loader = spl_ll_find_loader(boot_device);
@@ -381,7 +373,7 @@ static int spl_load_image(u32 boot_device)
        bootdev.boot_device = boot_device;
        bootdev.boot_device_name = NULL;
        if (loader)
-               return loader->load_image(&bootdev);
+               return loader->load_image(spl_image, &bootdev);
 
 #if defined(CONFIG_SPL_SERIAL_SUPPORT) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
        puts("SPL: Unsupported Boot Device!\n");
@@ -391,6 +383,14 @@ static int spl_load_image(u32 boot_device)
 
 void board_init_r(gd_t *dummy1, ulong dummy2)
 {
+       u32 spl_boot_list[] = {
+               BOOT_DEVICE_NONE,
+               BOOT_DEVICE_NONE,
+               BOOT_DEVICE_NONE,
+               BOOT_DEVICE_NONE,
+               BOOT_DEVICE_NONE,
+       };
+       struct spl_image_info spl_image;
        int i;
 
        debug(">>spl:board_init_r()\n");
@@ -416,11 +416,12 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
        spl_board_init();
 #endif
 
+       memset(&spl_image, '\0', sizeof(spl_image));
        board_boot_order(spl_boot_list);
        for (i = 0; i < ARRAY_SIZE(spl_boot_list) &&
                        spl_boot_list[i] != BOOT_DEVICE_NONE; i++) {
                announce_boot_device(spl_boot_list[i]);
-               if (!spl_load_image(spl_boot_list[i]))
+               if (!spl_load_image(&spl_image, spl_boot_list[i]))
                        break;
        }