net: Remove CONFIG_SYS_DIRECT_FLASH_TFTP
[platform/kernel/u-boot.git] / common / splash_source.c
index 8f276a3..2c03cbd 100644 (file)
@@ -7,16 +7,21 @@
 
 #include <common.h>
 #include <bmp_layout.h>
+#include <command.h>
+#include <env.h>
 #include <errno.h>
 #include <fs.h>
 #include <fdt_support.h>
 #include <image.h>
+#include <log.h>
 #include <nand.h>
 #include <sata.h>
 #include <spi.h>
 #include <spi_flash.h>
 #include <splash.h>
 #include <usb.h>
+#include <virtio.h>
+#include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -33,7 +38,7 @@ static int splash_sf_read_raw(u32 bmp_load_addr, int offset, size_t read_size)
                        return -ENODEV;
        }
 
-       return spi_flash_read(sf, offset, read_size, (void *)bmp_load_addr);
+       return spi_flash_read(sf, offset, read_size, (void *)(uintptr_t)bmp_load_addr);
 }
 #else
 static int splash_sf_read_raw(u32 bmp_load_addr, int offset, size_t read_size)
@@ -94,7 +99,7 @@ static int splash_load_raw(struct splash_location *location, u32 bmp_load_addr)
        if (res < 0)
                return res;
 
-       bmp_hdr = (struct bmp_header *)bmp_load_addr;
+       bmp_hdr = (struct bmp_header *)(uintptr_t)bmp_load_addr;
        bmp_size = le32_to_cpu(bmp_hdr->file_size);
 
        if (bmp_load_addr + bmp_size >= gd->start_addr_sp)
@@ -175,6 +180,16 @@ static inline int splash_init_sata(void)
 }
 #endif
 
+static int splash_init_virtio(void)
+{
+       if (!IS_ENABLED(CONFIG_VIRTIO)) {
+               printf("Cannot load splash image: no virtio support\n");
+               return -ENOSYS;
+       } else {
+               return virtio_init();
+       }
+}
+
 #ifdef CONFIG_CMD_UBIFS
 static int splash_mount_ubifs(struct splash_location *location)
 {
@@ -229,6 +244,9 @@ static int splash_load_fs(struct splash_location *location, u32 bmp_load_addr)
        if (location->storage == SPLASH_STORAGE_SATA)
                res = splash_init_sata();
 
+       if (location->storage == SPLASH_STORAGE_VIRTIO)
+               res = splash_init_virtio();
+
        if (location->ubivol != NULL)
                res = splash_mount_ubifs(location);
 
@@ -333,10 +351,10 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
        if (res < 0)
                return res;
 
-       res = fit_check_format(fit_header);
-       if (!res) {
+       res = fit_check_format(fit_header, IMAGE_SIZE_INVAL);
+       if (res) {
                debug("Could not find valid FIT image\n");
-               return -EINVAL;
+               return res;
        }
 
        /* Get the splash image node */
@@ -410,7 +428,7 @@ int splash_source_load(struct splash_location *locations, uint size)
        if (env_splashimage_value == NULL)
                return -ENOENT;
 
-       bmp_load_addr = simple_strtoul(env_splashimage_value, 0, 16);
+       bmp_load_addr = hextoul(env_splashimage_value, 0);
        if (bmp_load_addr == 0) {
                printf("Error: bad splashimage address specified\n");
                return -EFAULT;