]> 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 d2e23bf2d80a0f0660759fb31745c97c3923f7a7..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,46 +373,24 @@ 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);
 
-       switch (boot_device) {
-#if defined(CONFIG_SPL_SPI_SUPPORT) || defined(CONFIG_SPL_SPI_FLASH_SUPPORT)
-       case BOOT_DEVICE_SPI:
-               return spl_spi_load_image(&bootdev);
-#endif
-#ifdef CONFIG_SPL_ETH_SUPPORT
-       case BOOT_DEVICE_CPGMAC:
-#ifdef CONFIG_SPL_ETH_DEVICE
-               bootdev.boot_device_name = CONFIG_SPL_ETH_DEVICE;
-#endif
-               return spl_net_load_image(&bootdev);
-#endif
-#ifdef CONFIG_SPL_USBETH_SUPPORT
-       case BOOT_DEVICE_USBETH:
-               bootdev.boot_device_name = "usb_ether";
-               return spl_net_load_image(&bootdev);
-#endif
-#endif
-#ifdef CONFIG_SPL_SATA_SUPPORT
-       case BOOT_DEVICE_SATA:
-               return spl_sata_load_image(&bootdev);
-#endif
-#ifdef CONFIG_SPL_BOARD_LOAD_IMAGE
-       case BOOT_DEVICE_BOARD:
-               return spl_board_load_image(&bootdev);
-#endif
-       default:
 #if defined(CONFIG_SPL_SERIAL_SUPPORT) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
-               puts("SPL: Unsupported Boot Device!\n");
+       puts("SPL: Unsupported Boot Device!\n");
 #endif
-               return -ENODEV;
-       }
-
-       return -EINVAL;
+       return -ENODEV;
 }
 
 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");
@@ -446,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;
        }