* [PATCH] Supports SPLASH_STORAGE_MMC and SPLASH_STORAGE_RAW together
@ 2021-10-28 7:01 ` Federico Giovanardi
2021-10-28 11:31 ` Jaehoon Chung
0 siblings, 1 reply; 2+ messages in thread
From: Federico Giovanardi @ 2021-10-28 7:01 UTC (permalink / raw)
To: Fred Bloggs
Cc: Federico Giovanardi, Federico Giovanardi, Jaehoon Chung,
Simon Glass, u-boot
Allow to load splash images from raw location on the MMC.
Signed-off-by: Federico Giovanardi <fgiovanardi@aragnet.com>
---
common/splash_source.c | 60 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 59 insertions(+), 1 deletion(-)
diff --git a/common/splash_source.c b/common/splash_source.c
index d05670f5ee8..8404254f486 100644
--- a/common/splash_source.c
+++ b/common/splash_source.c
@@ -20,6 +20,7 @@
#include <spi_flash.h>
#include <splash.h>
#include <usb.h>
+#include <mmc.h>
#include <asm/global_data.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -63,6 +64,60 @@ static int splash_nand_read_raw(u32 bmp_load_addr, int offset, size_t read_size)
return -ENOSYS;
}
#endif
+#if CONFIG_CMD_MMC
+static int splash_load_raw_mmc(struct splash_location *location, u32 bmp_load_addr)
+{
+ struct bmp_header *bmp_hdr;
+ int res;
+ unsigned int boffset, bsize;
+ size_t bmp_size;
+
+ int mmc_dev = simple_strtoul(location->devpart, NULL, 16);
+ struct mmc *mmc = find_mmc_device(mmc_dev);
+
+ if (!mmc) {
+ printf("MMC Device %d not found\n", mmc_dev);
+ return -ENODEV;
+ }
+ if (mmc_init(mmc)) {
+ puts("MMC init failed\n");
+ return -EIO;
+ }
+
+ if (bmp_load_addr + sizeof(struct bmp_header) >= gd->start_addr_sp)
+ goto splash_address_too_high;
+
+ boffset = ALIGN(location->offset, mmc->read_bl_len) / mmc->read_bl_len;
+ bsize = round_up(sizeof(struct bmp_header), mmc->read_bl_len) / mmc->read_bl_len;
+
+ res = blk_dread(mmc_get_blk_desc(mmc), boffset, bsize, (uchar *)bmp_load_addr);
+ if (res < 0)
+ return res;
+
+ bmp_hdr = (struct bmp_header *)bmp_load_addr;
+ bmp_size = le32_to_cpu(bmp_hdr->file_size);
+
+ if (bmp_load_addr + bmp_size >= gd->start_addr_sp)
+ goto splash_address_too_high;
+
+ bsize = round_up(bmp_size, mmc->read_bl_len) / mmc->read_bl_len;
+ res = blk_dread(mmc_get_blk_desc(mmc), boffset, bsize, (uchar *)bmp_load_addr);
+ if (res < 0)
+ return res;
+ return 0;
+
+splash_address_too_high:
+ printf("Error: splashimage address too high. Data overwrites U-Boot and/or placed beyond DRAM boundaries.\n");
+
+ return -EFAULT;
+}
+#else
+static int splash_load_raw_mmc(struct splash_location *location, u32 bmp_load_addr)
+{
+ debug("%s: mmc support not available\n", __func__);
+ return -ENOSYS;
+}
+#endif
static int splash_storage_read_raw(struct splash_location *location,
u32 bmp_load_addr, size_t read_size)
@@ -424,7 +479,10 @@ 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 == SPLASH_STORAGE_RAW &&
+ splash_location->storage == SPLASH_STORAGE_MMC)
+ return splash_load_raw_mmc(splash_location, bmp_load_addr);
+ else if (splash_location->flags == SPLASH_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);
--
2.33.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Supports SPLASH_STORAGE_MMC and SPLASH_STORAGE_RAW together
2021-10-28 7:01 ` [PATCH] Supports SPLASH_STORAGE_MMC and SPLASH_STORAGE_RAW together Federico Giovanardi
@ 2021-10-28 11:31 ` Jaehoon Chung
0 siblings, 0 replies; 2+ messages in thread
From: Jaehoon Chung @ 2021-10-28 11:31 UTC (permalink / raw)
To: Federico Giovanardi, Fred Bloggs; +Cc: Federico Giovanardi, Simon Glass, u-boot
Hi,
On 10/28/21 4:01 PM, Federico Giovanardi wrote:
> Allow to load splash images from raw location on the MMC.
>
> Signed-off-by: Federico Giovanardi <fgiovanardi@aragnet.com>
> ---
>
> common/splash_source.c | 60 +++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 59 insertions(+), 1 deletion(-)
>
> diff --git a/common/splash_source.c b/common/splash_source.c
> index d05670f5ee8..8404254f486 100644
> --- a/common/splash_source.c
> +++ b/common/splash_source.c
> @@ -20,6 +20,7 @@
> #include <spi_flash.h>
> #include <splash.h>
> #include <usb.h>
> +#include <mmc.h>
> #include <asm/global_data.h>
>
> DECLARE_GLOBAL_DATA_PTR;
> @@ -63,6 +64,60 @@ static int splash_nand_read_raw(u32 bmp_load_addr, int offset, size_t read_size)
> return -ENOSYS;
> }
> #endif
> +#if CONFIG_CMD_MMC
> +static int splash_load_raw_mmc(struct splash_location *location, u32 bmp_load_addr)
I don't know exactly how to work about behavior, but I wonder something.
There are some splash_nand/sf_read_raw() that is called from splash_storage_read_raw().
I think that this function can be implemented a function similar to them.
Then splash_load_raw function can be reused.
static int splash_storage_read_raw() {
...
switch() {
case SPLASH_STORAGE_MMC:
return splash_mmc_read_raw();
...
}
}
It is impossible?
Best Regards,
Jaehoon Chung
> +{
> + struct bmp_header *bmp_hdr;
> + int res;
> + unsigned int boffset, bsize;
> + size_t bmp_size;
> +
> + int mmc_dev = simple_strtoul(location->devpart, NULL, 16);
> + struct mmc *mmc = find_mmc_device(mmc_dev);
> +
> + if (!mmc) {
> + printf("MMC Device %d not found\n", mmc_dev);
> + return -ENODEV;
> + }
> + if (mmc_init(mmc)) {
> + puts("MMC init failed\n");
> + return -EIO;
> + }
> +
> + if (bmp_load_addr + sizeof(struct bmp_header) >= gd->start_addr_sp)
> + goto splash_address_too_high;
> +
> + boffset = ALIGN(location->offset, mmc->read_bl_len) / mmc->read_bl_len;
> + bsize = round_up(sizeof(struct bmp_header), mmc->read_bl_len) / mmc->read_bl_len;
> +
> + res = blk_dread(mmc_get_blk_desc(mmc), boffset, bsize, (uchar *)bmp_load_addr);
> + if (res < 0)
> + return res;
> +
> + bmp_hdr = (struct bmp_header *)bmp_load_addr;
> + bmp_size = le32_to_cpu(bmp_hdr->file_size);
> +
> + if (bmp_load_addr + bmp_size >= gd->start_addr_sp)
> + goto splash_address_too_high;
> +
> + bsize = round_up(bmp_size, mmc->read_bl_len) / mmc->read_bl_len;
> + res = blk_dread(mmc_get_blk_desc(mmc), boffset, bsize, (uchar *)bmp_load_addr);
> + if (res < 0)
> + return res;
> + return 0;
> +
> +splash_address_too_high:
> + printf("Error: splashimage address too high. Data overwrites U-Boot and/or placed beyond DRAM boundaries.\n");
> +
> + return -EFAULT;
> +}
> +#else
> +static int splash_load_raw_mmc(struct splash_location *location, u32 bmp_load_addr)
> +{
> + debug("%s: mmc support not available\n", __func__);
> + return -ENOSYS;
> +}
> +#endif
>
> static int splash_storage_read_raw(struct splash_location *location,
> u32 bmp_load_addr, size_t read_size)
> @@ -424,7 +479,10 @@ 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 == SPLASH_STORAGE_RAW &&
> + splash_location->storage == SPLASH_STORAGE_MMC)
> + return splash_load_raw_mmc(splash_location, bmp_load_addr);
> + else if (splash_location->flags == SPLASH_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);
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-28 12:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20211028070130epcas1p423cef028dc83ca00923fe73b1ab339db@epcas1p4.samsung.com>
2021-10-28 7:01 ` [PATCH] Supports SPLASH_STORAGE_MMC and SPLASH_STORAGE_RAW together Federico Giovanardi
2021-10-28 11:31 ` Jaehoon Chung
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.