@@ -40,29 +40,28 @@
DECLARE_GLOBAL_DATA_PTR;
#ifdef CONFIG_SPLASH_SCREEN
-static struct splash_location cm_fx6_splash_locations[] = {
+static struct flash_location cm_fx6_splash_locations[] = {
{
.name = "sf",
- .storage = SPLASH_STORAGE_SF,
- .flags = SPLASH_STORAGE_RAW,
+ .storage = FLASH_STORAGE_SF,
+ .flags = FLASH_STORAGE_RAW,
.offset = 0x100000,
},
{
.name = "mmc_fs",
- .storage = SPLASH_STORAGE_MMC,
- .flags = SPLASH_STORAGE_FS,
+ .storage = FLASH_STORAGE_MMC,
+ .flags = FLASH_STORAGE_FS,
.devpart = "2:1",
},
{
.name = "usb_fs",
- .storage = SPLASH_STORAGE_USB,
- .flags = SPLASH_STORAGE_FS,
+ .storage = FLASH_STORAGE_USB,
+ .flags = FLASH_STORAGE_FS,
.devpart = "0:1",
},
{
.name = "sata_fs",
- .storage = SPLASH_STORAGE_SATA,
- .flags = SPLASH_STORAGE_FS,
+ .storage = FLASH_STORAGE_SATA,
.devpart = "0:1",
},
};
@@ -60,11 +60,11 @@ void get_board_mem_timings(struct board_sdrc_timings *timings)
}
#endif
-struct splash_location splash_locations[] = {
+struct flash_location splash_locations[] = {
{
.name = "nand",
- .storage = SPLASH_STORAGE_NAND,
- .flags = SPLASH_STORAGE_RAW,
+ .storage = FLASH_STORAGE_NAND,
+ .flags = FLASH_STORAGE_RAW,
.offset = 0x100000,
},
};
@@ -24,29 +24,29 @@
#include <splash.h>
#include <lcd.h>
-static struct splash_location default_splash_locations[] = {
+static struct flash_location default_splash_locations[] = {
{
.name = "sf",
- .storage = SPLASH_STORAGE_SF,
- .flags = SPLASH_STORAGE_RAW,
+ .storage = FLASH_STORAGE_SF,
+ .flags = FLASH_STORAGE_RAW,
.offset = 0x0,
},
{
.name = "mmc_fs",
- .storage = SPLASH_STORAGE_MMC,
- .flags = SPLASH_STORAGE_FS,
+ .storage = FLASH_STORAGE_MMC,
+ .flags = FLASH_STORAGE_FS,
.devpart = "0:1",
},
{
.name = "usb_fs",
- .storage = SPLASH_STORAGE_USB,
- .flags = SPLASH_STORAGE_FS,
+ .storage = FLASH_STORAGE_USB,
+ .flags = FLASH_STORAGE_FS,
.devpart = "0:1",
},
{
.name = "sata_fs",
- .storage = SPLASH_STORAGE_SATA,
- .flags = SPLASH_STORAGE_FS,
+ .storage = FLASH_STORAGE_SATA,
+ .flags = FLASH_STORAGE_FS,
.devpart = "0:1",
},
};
@@ -61,7 +61,7 @@ static int splash_nand_read_raw(u32 bmp_load_addr, int offset, size_t read_size)
}
#endif
-static int splash_storage_read_raw(struct splash_location *location,
+static int splash_storage_read_raw(struct flash_location *location,
u32 bmp_load_addr, size_t read_size)
{
u32 offset;
@@ -71,9 +71,9 @@ static int splash_storage_read_raw(struct splash_location *location,
offset = location->offset;
switch (location->storage) {
- case SPLASH_STORAGE_NAND:
+ case FLASH_STORAGE_NAND:
return splash_nand_read_raw(bmp_load_addr, offset, read_size);
- case SPLASH_STORAGE_SF:
+ case FLASH_STORAGE_SF:
return splash_sf_read_raw(bmp_load_addr, offset, read_size);
default:
printf("Unknown splash location\n");
@@ -82,7 +82,7 @@ static int splash_storage_read_raw(struct splash_location *location,
return -EINVAL;
}
-static int splash_load_raw(struct splash_location *location, u32 bmp_load_addr)
+static int splash_load_raw(struct flash_location *location, u32 bmp_load_addr)
{
struct bmp_header *bmp_hdr;
int res;
@@ -109,159 +109,53 @@ splash_address_too_high:
return -EFAULT;
}
-static int splash_select_fs_dev(struct splash_location *location)
-{
- int res;
-
- switch (location->storage) {
- case SPLASH_STORAGE_MMC:
- res = fs_set_blk_dev("mmc", location->devpart, FS_TYPE_ANY);
- break;
- case SPLASH_STORAGE_USB:
- res = fs_set_blk_dev("usb", location->devpart, FS_TYPE_ANY);
- break;
- case SPLASH_STORAGE_SATA:
- res = fs_set_blk_dev("sata", location->devpart, FS_TYPE_ANY);
- break;
- case SPLASH_STORAGE_NAND:
- if (location->ubivol != NULL)
- res = fs_set_blk_dev("ubi", NULL, FS_TYPE_UBIFS);
- else
- res = -ENODEV;
- break;
- default:
- printf("Error: unsupported location storage.\n");
- return -ENODEV;
- }
-
- if (res)
- printf("Error: could not access storage.\n");
-
- return res;
-}
-
-#ifdef CONFIG_USB_STORAGE
-static int splash_init_usb(void)
-{
- int err;
-
- err = usb_init();
- if (err)
- return err;
-
-#ifndef CONFIG_DM_USB
- err = usb_stor_scan(1) < 0 ? -ENODEV : 0;
-#endif
-
- return err;
-}
-#else
-static inline int splash_init_usb(void)
-{
- printf("Cannot load splash image: no USB support\n");
- return -ENOSYS;
-}
-#endif
+#define FLASH_SOURCE_DEFAULT_FILE_NAME "splash.bmp"
-#ifdef CONFIG_SATA
-static int splash_init_sata(void)
-{
- return sata_probe(0);
-}
-#else
-static inline int splash_init_sata(void)
-{
- printf("Cannot load splash image: no SATA support\n");
- return -ENOSYS;
-}
-#endif
-
-#ifdef CONFIG_CMD_UBIFS
-static int splash_mount_ubifs(struct splash_location *location)
-{
- int res;
- char cmd[32];
-
- sprintf(cmd, "ubi part %s", location->mtdpart);
- res = run_command(cmd, 0);
- if (res)
- return res;
-
- sprintf(cmd, "ubifsmount %s", location->ubivol);
- res = run_command(cmd, 0);
-
- return res;
-}
-
-static inline int splash_umount_ubifs(void)
-{
- return run_command("ubifsumount", 0);
-}
-#else
-static inline int splash_mount_ubifs(struct splash_location *location)
-{
- printf("Cannot load splash image: no UBIFS support\n");
- return -ENOSYS;
-}
-
-static inline int splash_umount_ubifs(void)
-{
- printf("Cannot unmount UBIFS: no UBIFS support\n");
- return -ENOSYS;
-}
-#endif
-
-#define SPLASH_SOURCE_DEFAULT_FILE_NAME "splash.bmp"
-
-static int splash_load_fs(struct splash_location *location, u32 bmp_load_addr)
+int fsloader_preprocess(struct flash_location *location,
+ void *file_info, char **filename,
+ u32 load_addr)
{
int res = 0;
- loff_t bmp_size;
- loff_t actread;
- char *splash_file;
-
- splash_file = env_get("splashfile");
- if (!splash_file)
- splash_file = SPLASH_SOURCE_DEFAULT_FILE_NAME;
-
- if (location->storage == SPLASH_STORAGE_USB)
- res = splash_init_usb();
+ loff_t file_size;
+ char *flash_file;
- if (location->storage == SPLASH_STORAGE_SATA)
- res = splash_init_sata();
+ flash_file = env_get((char *)file_info);
- if (location->ubivol != NULL)
- res = splash_mount_ubifs(location);
+ if (!flash_file)
+ flash_file = FLASH_SOURCE_DEFAULT_FILE_NAME;
- if (res)
- return res;
-
- res = splash_select_fs_dev(location);
- if (res)
- goto out;
+ res = flash_select_fs_dev(location);
+ if (res) {
+ error("Error : Failed to select FS device\n");
+ return -EPERM;
+ }
- res = fs_size(splash_file, &bmp_size);
+ res = fs_size(flash_file, &file_size);
if (res) {
- printf("Error (%d): cannot determine file size\n", res);
- goto out;
+ error("Error (%d): cannot determine file size\n", res);
+ return -ENOENT;
}
- if (bmp_load_addr + bmp_size >= gd->start_addr_sp) {
- printf("Error: splashimage address too high. Data overwrites U-Boot and/or placed beyond DRAM boundaries.\n");
+ if ((u32)load_addr + file_size >= gd->start_addr_sp) {
+ error("Error: Flashimage address too high. Data overwrites ");
+ error("U-Boot and/or placed beyond DRAM boundaries.\n");
res = -EFAULT;
- goto out;
+ return -EFAULT;
}
- splash_select_fs_dev(location);
- res = fs_read(splash_file, bmp_load_addr, 0, 0, &actread);
-
-out:
- if (location->ubivol != NULL)
- splash_umount_ubifs();
+ *filename = flash_file;
return res;
}
+int fs_loading(struct flash_location *location, void *file_info,
+ char *filename, u32 load_addr, size_t bsize)
+{
+ loff_t actread;
+
+ return fs_read(filename, (u32)load_addr, 0, 0, &actread);
+}
+
/**
* select_splash_location - return the splash location based on board support
* and env variable "splashsource".
@@ -277,8 +171,8 @@ out:
* If splashsource env variable contains a supported value
* return the location selected by splashsource.
*/
-static struct splash_location *select_splash_location(
- struct splash_location *locations, uint size)
+static struct flash_location *select_splash_location(
+ struct flash_location *locations, uint size)
{
int i;
char *env_splashsource;
@@ -300,7 +194,7 @@ static struct splash_location *select_splash_location(
}
#ifdef CONFIG_FIT
-static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
+static int splash_load_fit(struct flash_location *location, u32 bmp_load_addr)
{
int res;
int node_offset;
@@ -382,9 +276,9 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
*
* @return: 0 on success, negative value on failure.
*/
-int splash_source_load(struct splash_location *locations, uint size)
+int splash_source_load(struct flash_location *locations, uint size)
{
- struct splash_location *splash_location;
+ struct flash_location *splash_location;
char *env_splashimage_value;
u32 bmp_load_addr;
@@ -402,12 +296,13 @@ int splash_source_load(struct splash_location *locations, uint size)
if (!splash_location)
return -EINVAL;
- if (splash_location->flags == SPLASH_STORAGE_RAW)
+ if (splash_location->flags == FLASH_STORAGE_RAW)
return splash_load_raw(splash_location, bmp_load_addr);
- else if (splash_location->flags == SPLASH_STORAGE_FS)
- return splash_load_fs(splash_location, bmp_load_addr);
+ else if (splash_location->flags == FLASH_STORAGE_FS)
+ return flash_load_fs(splash_location, "splashfile",
+ bmp_load_addr, 0);
#ifdef CONFIG_FIT
- else if (splash_location->flags == SPLASH_STORAGE_FIT)
+ else if (splash_location->flags == FLASH_STORAGE_FIT)
return splash_load_fit(splash_location, bmp_load_addr);
#endif
return -EINVAL;
@@ -23,35 +23,12 @@
#define _SPLASH_H_
#include <errno.h>
-
-enum splash_storage {
- SPLASH_STORAGE_NAND,
- SPLASH_STORAGE_SF,
- SPLASH_STORAGE_MMC,
- SPLASH_STORAGE_USB,
- SPLASH_STORAGE_SATA,
-};
-
-enum splash_flags {
- SPLASH_STORAGE_RAW, /* Stored in raw memory */
- SPLASH_STORAGE_FS, /* Stored within a file system */
- SPLASH_STORAGE_FIT, /* Stored inside a FIT image */
-};
-
-struct splash_location {
- char *name;
- enum splash_storage storage;
- enum splash_flags flags;
- u32 offset; /* offset from start of storage */
- char *devpart; /* Use the load command dev:part conventions */
- char *mtdpart; /* MTD partition for ubi part */
- char *ubivol; /* UBI volume-name for ubifsmount */
-};
+#include <load_fs.h>
#ifdef CONFIG_SPLASH_SOURCE
-int splash_source_load(struct splash_location *locations, uint size);
+int splash_source_load(struct flash_location *locations, uint size);
#else
-static inline int splash_source_load(struct splash_location *locations,
+static inline int splash_source_load(struct flash_location *locations,
uint size)
{
return 0;