From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH v3 37/41] spl: Convert spl_fit to work with sandbox
Date: Wed, 3 Feb 2021 05:44:43 -0700 [thread overview]
Message-ID: <20210203124447.2458527-36-sjg@chromium.org> (raw)
In-Reply-To: <20210203124447.2458527-1-sjg@chromium.org>
At present this casts addresses to pointers so cannot work with sandbox.
Update the code to use map_sysmem() instead.
As part of this change, the existing load_ptr is renamed to src_ptr since
it is not a pointer to load_addr. It is confusing to use a similar name
for something that is not actually related. For the alignment code,
ALIGN() is used instead of open-coded alignment. Add a comment to the line
that casts away a const.
Use a (new) load_ptr variable to access memory at address load_addr.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
(no changes since v1)
common/spl/spl.c | 3 ++-
common/spl/spl_fit.c | 27 +++++++++++++++------------
2 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/common/spl/spl.c b/common/spl/spl.c
index cdd7b05f279..8461293a517 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -16,6 +16,7 @@
#include <init.h>
#include <irq_func.h>
#include <log.h>
+#include <mapmem.h>
#include <serial.h>
#include <spl.h>
#include <asm/u-boot.h>
@@ -167,7 +168,7 @@ __weak void spl_board_prepare_for_boot(void)
__weak struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
{
- return (struct image_header *)(CONFIG_SYS_TEXT_BASE + offset);
+ return map_sysmem(CONFIG_SYS_TEXT_BASE + offset, 0);
}
void spl_set_header_raw_uboot(struct spl_image_info *spl_image)
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index a6ad094e91a..d84e0569cf6 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -11,6 +11,7 @@
#include <image.h>
#include <log.h>
#include <malloc.h>
+#include <mapmem.h>
#include <spl.h>
#include <sysinfo.h>
#include <asm/cache.h>
@@ -245,11 +246,11 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
size_t length;
int len;
ulong size;
- ulong load_addr, load_ptr;
+ ulong load_addr;
+ void *load_ptr;
void *src;
ulong overhead;
int nr_sectors;
- int align_len = ARCH_DMA_MINALIGN - 1;
uint8_t image_comp = -1, type = -1;
const void *data;
bool external_data = false;
@@ -278,11 +279,13 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
}
if (external_data) {
+ void *src_ptr;
+
/* External data */
if (fit_image_get_data_size(fit, node, &len))
return -ENOENT;
- load_ptr = (load_addr + align_len) & ~align_len;
+ src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
length = len;
overhead = get_aligned_image_overhead(info, offset);
@@ -290,12 +293,12 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
if (info->read(info,
sector + get_aligned_image_offset(info, offset),
- nr_sectors, (void *)load_ptr) != nr_sectors)
+ nr_sectors, src_ptr) != nr_sectors)
return -EIO;
- debug("External data: dst=%lx, offset=%x, size=%lx\n",
- load_ptr, offset, (unsigned long)length);
- src = (void *)load_ptr + overhead;
+ debug("External data: dst=%p, offset=%x, size=%lx\n",
+ src_ptr, offset, (unsigned long)length);
+ src = src_ptr + overhead;
} else {
/* Embedded data */
if (fit_image_get_data(fit, node, &data, &length)) {
@@ -304,7 +307,7 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
}
debug("Embedded data: dst=%lx, size=%lx\n", load_addr,
(unsigned long)length);
- src = (void *)data;
+ src = (void *)data; /* cast away const */
}
#ifdef CONFIG_SPL_FIT_SIGNATURE
@@ -320,16 +323,16 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
board_fit_image_post_process(&src, &length);
#endif
+ load_ptr = map_sysmem(load_addr, length);
if (IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP) {
size = length;
- if (gunzip((void *)load_addr, CONFIG_SYS_BOOTM_LEN,
- src, &size)) {
+ if (gunzip(load_ptr, CONFIG_SYS_BOOTM_LEN, src, &size)) {
puts("Uncompressing error\n");
return -EIO;
}
length = size;
} else {
- memcpy((void *)load_addr, src, length);
+ memcpy(load_ptr, src, length);
}
if (image_info) {
@@ -382,7 +385,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
}
/* Make the load-address of the FDT available for the SPL framework */
- spl_image->fdt_addr = (void *)image_info.load_addr;
+ spl_image->fdt_addr = map_sysmem(image_info.load_addr, 0);
#if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
if (CONFIG_IS_ENABLED(LOAD_FIT_APPLY_OVERLAY)) {
void *tmpbuffer = NULL;
--
2.30.0.365.g02bc693789-goog
next prev parent reply other threads:[~2021-02-03 12:44 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-03 12:44 [PATCH v3 00/41] test: Refactor tests to have a single test runner Simon Glass
2021-02-03 12:44 ` [PATCH v3 01/41] doc: Tidy up testing section Simon Glass
2021-02-03 12:44 ` [PATCH v3 02/41] doc: Document make tcheck Simon Glass
2021-02-03 12:44 ` [PATCH v3 03/41] sandbox: Drop the 'starting...' message unless testing Simon Glass
2021-02-03 12:44 ` [PATCH v3 04/41] test: Re-enable test_ofplatdata Simon Glass
2021-02-03 12:44 ` [PATCH v3 05/41] doc: Explain how to run tests without pytest Simon Glass
2021-02-03 12:44 ` [PATCH v3 06/41] doc: Document how sandbox_spl_tests are run Simon Glass
2021-02-03 14:40 ` Pratyush Yadav
2021-02-03 12:44 ` [PATCH v3 07/41] test: Correct setexpr test prefix Simon Glass
2021-02-03 12:44 ` [PATCH v3 08/41] test: Mark all driver model tests with a flag Simon Glass
2021-02-03 12:44 ` [PATCH v3 09/41] test: Rename test-main.c to test-dm.c Simon Glass
2021-02-03 12:44 ` [PATCH v3 10/41] test: Add an overall test runner Simon Glass
2021-02-03 12:44 ` [PATCH v3 11/41] test: Create pre/post-run functions Simon Glass
2021-02-03 12:44 ` [PATCH v3 12/41] test: Call test_pre/post_run() from driver model tests Simon Glass
2021-02-03 12:44 ` [PATCH v3 13/41] test: Move dm_extended_scan() to test_pre_run() Simon Glass
2021-02-03 12:44 ` [PATCH v3 14/41] test: Move do_autoprobe() " Simon Glass
2021-02-03 12:44 ` [PATCH v3 15/41] test: Move dm_scan_plat() " Simon Glass
2021-02-03 12:44 ` [PATCH v3 16/41] test: Drop mallinfo() work-around Simon Glass
2021-02-03 12:44 ` [PATCH v3 17/41] test: Move console silencing to test_pre_run() Simon Glass
2021-02-03 12:44 ` [PATCH v3 18/41] test: Move delay skipping " Simon Glass
2021-02-03 12:44 ` [PATCH v3 19/41] test: Handle driver model reinit in test_pre_run() Simon Glass
2021-02-03 12:44 ` [PATCH v3 20/41] test: Drop struct dm_test_state Simon Glass
2021-02-03 12:44 ` [PATCH v3 21/41] test: Move dm_test_init() into test-main.c Simon Glass
2021-02-03 12:44 ` [PATCH v3 22/41] test: Move dm_test_destroy() " Simon Glass
2021-02-03 12:44 ` [PATCH v3 23/41] test: Move test running into a separate function Simon Glass
2021-02-03 12:44 ` [PATCH v3 24/41] test: Use ut_run_test() to run driver model tests Simon Glass
2021-02-03 12:44 ` [PATCH v3 25/41] test: Drop dm_do_test() Simon Glass
2021-02-03 12:44 ` [PATCH v3 26/41] test: Add ut_run_test_live_flat() to run tests twice Simon Glass
2021-02-03 12:44 ` [PATCH v3 27/41] test: Use a local variable for test state Simon Glass
2021-02-03 12:44 ` [PATCH v3 28/41] test: Run driver-model tests using ut_run_list() Simon Glass
2021-02-03 12:44 ` [PATCH v3 29/41] test: Use return values in dm_test_run() Simon Glass
2021-02-03 12:44 ` [PATCH v3 30/41] test: Move the devicetree check into ut_run_list() Simon Glass
2021-02-03 12:44 ` [PATCH v3 31/41] test: Move restoring of driver model state to ut_run_list() Simon Glass
2021-02-03 12:44 ` [PATCH v3 32/41] test: log: Rename log main test file to log_ut.c Simon Glass
2021-02-03 12:44 ` [PATCH v3 33/41] test: Add a macros for finding tests in linker_lists Simon Glass
2021-02-03 12:44 ` [PATCH v3 34/41] test: Rename all linker lists to have a ut_ prefix Simon Glass
2021-02-03 12:44 ` [PATCH v3 35/41] test: Allow SPL to run any available test Simon Glass
2021-02-03 12:44 ` [PATCH v3 36/41] sandbox: Update os_find_u_boot() to find the .img file Simon Glass
2021-02-03 12:44 ` Simon Glass [this message]
2021-02-03 12:44 ` [PATCH v3 38/41] doc: Move coccinelle into its own section Simon Glass
2021-02-03 12:44 ` [PATCH v3 39/41] spl: test: Add a test for spl_load_simple_fit() Simon Glass
2021-02-03 12:44 ` [PATCH v3 40/41] test: sandbox: Move sandbox test docs into doc/develop Simon Glass
2021-02-03 12:44 ` [PATCH v3 41/41] doc: Explain briefly how to write new tests Simon Glass
2021-03-03 19:37 ` [PATCH v3 00/41] test: Refactor tests to have a single test runner Tom Rini
2021-03-03 20:18 ` Tom Rini
2021-03-03 20:37 ` Tom Rini
2021-03-04 3:06 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210203124447.2458527-36-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.