diff options
author | Simon Glass <sjg@chromium.org> | 2021-01-13 20:29:43 -0700 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-01-27 17:03:16 -0500 |
commit | 9fe064646d2c9f3914cd5ceae51c34020aa77599 (patch) | |
tree | 971f208a76257181d735a00c200ff04a7c2591b1 /test/bloblist.c | |
parent | 09d9ba9097ceb374f2802506c9e755fd8d5dd861 (diff) |
bloblist: Support relocating to a larger space
Typically in TPL/SPL the bloblist is quite small. But U-Boot proper may
want to add a lot more to it, such as ACPI tables.
Add a way to expand the bloblist by relocating it in U-Boot proper, along
with the other relocation activities.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/bloblist.c')
-rw-r--r-- | test/bloblist.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/bloblist.c b/test/bloblist.c index 900299dd68e..85a6c39680e 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -347,6 +347,42 @@ static int bloblist_test_align(struct unit_test_state *uts) } BLOBLIST_TEST(bloblist_test_align, 0); +/* Test relocation of a bloblist */ +static int bloblist_test_reloc(struct unit_test_state *uts) +{ + const uint large_size = TEST_BLOBLIST_SIZE; + const uint small_size = 0x20; + void *old_ptr, *new_ptr; + void *blob1, *blob2; + ulong new_addr; + ulong new_size; + + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + old_ptr = map_sysmem(TEST_ADDR, TEST_BLOBLIST_SIZE); + + /* Add one blob and then one that won't fit */ + blob1 = bloblist_add(TEST_TAG, small_size, 0); + ut_assertnonnull(blob1); + blob2 = bloblist_add(TEST_TAG2, large_size, 0); + ut_assertnull(blob2); + + /* Relocate the bloblist somewhere else, a bit larger */ + new_addr = TEST_ADDR + TEST_BLOBLIST_SIZE; + new_size = TEST_BLOBLIST_SIZE + 0x100; + new_ptr = map_sysmem(new_addr, TEST_BLOBLIST_SIZE); + bloblist_reloc(new_ptr, new_size, old_ptr, TEST_BLOBLIST_SIZE); + gd->bloblist = new_ptr; + + /* Check the old blob is there and that we can now add the bigger one */ + ut_assertnonnull(bloblist_find(TEST_TAG, small_size)); + ut_assertnull(bloblist_find(TEST_TAG2, small_size)); + blob2 = bloblist_add(TEST_TAG2, large_size, 0); + ut_assertnonnull(blob2); + + return 0; +} +BLOBLIST_TEST(bloblist_test_reloc, 0); + int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { |