From ff3bd4983c1fe53975e44668619b07e10f8a0cd9 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 12 Jan 2022 19:26:16 -0700 Subject: bloblist: Put the magic number first It seems best to put the magic number right at the start of the bloblist header, so it is easier to check. This is how devicetree works. Make this change now, before other projects make use of bloblist. Other changes may be needed / discussed, but that is TBD. Add a checker function as well. Signed-off-by: Simon Glass --- test/bloblist.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/bloblist.c') diff --git a/test/bloblist.c b/test/bloblist.c index b48be38dc3e..525e94b7217 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -71,7 +71,9 @@ static int bloblist_test_init(struct unit_test_state *uts) hdr = clear_bloblist(); ut_asserteq(-ENOENT, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + ut_asserteq_ptr(NULL, bloblist_check_magic(TEST_ADDR)); ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_asserteq_ptr(hdr, bloblist_check_magic(TEST_ADDR)); hdr->version++; ut_asserteq(-EPROTONOSUPPORT, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); @@ -83,6 +85,11 @@ static int bloblist_test_init(struct unit_test_state *uts) ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); ut_assertok(bloblist_finish()); ut_assertok(bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + + hdr->magic++; + ut_asserteq_ptr(NULL, bloblist_check_magic(TEST_ADDR)); + hdr->magic--; + hdr->flags++; ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); -- cgit v1.2.3 From f9abc1cac1130279b486c51056b2e6fba99633b1 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 12 Jan 2022 19:26:18 -0700 Subject: bloblist: Drop unused tags The EC event log tag is no-longer used. The vboot handoff is now handled by the vboot context instead. Drop these unused tags. Signed-off-by: Simon Glass --- test/bloblist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/bloblist.c') diff --git a/test/bloblist.c b/test/bloblist.c index 525e94b7217..2e8e23d77dd 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -289,9 +289,9 @@ static int bloblist_test_cmd_list(struct unit_test_state *uts) console_record_reset(); run_command("bloblist list", 0); ut_assert_nextline("Address Size Tag Name"); - ut_assert_nextline("%08lx %8x 1 EC host event", + ut_assert_nextline("%08lx %8x 1 SPL hand-off", (ulong)map_to_sysmem(data), TEST_SIZE); - ut_assert_nextline("%08lx %8x 2 SPL hand-off", + ut_assert_nextline("%08lx %8x 2 Chrome OS vboot context", (ulong)map_to_sysmem(data2), TEST_SIZE2); ut_assert_console_end(); ut_unsilence_console(uts); -- cgit v1.2.3 From f16ec77784b4a2ffdba82bc4044581131aea44e4 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 12 Jan 2022 19:26:19 -0700 Subject: bloblist: Use explicit numbering for the tags At present if someone adds a tag in the middle of the list it works well enough within a U-Boot build. But if these tags are used in another project, or with an older version of SPL, the numbers make become inconsistent. Use explicit tag numbers that never change, to resolve this problem. Allocate areas for existing U-Boot tags and set up an area for use by projects and vendors, as well as for private use. Keep tags above 0x10000 unallocated for now. Update bloblist_tag_name() and the tests to work with this new setup. Signed-off-by: Simon Glass --- test/bloblist.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'test/bloblist.c') diff --git a/test/bloblist.c b/test/bloblist.c index 2e8e23d77dd..c5788d5cd82 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -19,9 +19,9 @@ DECLARE_GLOBAL_DATA_PTR; UNIT_TEST(_name, _flags, bloblist_test) enum { - TEST_TAG = 1, - TEST_TAG2 = 2, - TEST_TAG_MISSING = 3, + TEST_TAG = BLOBLISTT_U_BOOT_SPL_HANDOFF, + TEST_TAG2 = BLOBLISTT_VBOOT_CTX, + TEST_TAG_MISSING = 0x10000, TEST_SIZE = 10, TEST_SIZE2 = 20, @@ -288,10 +288,10 @@ static int bloblist_test_cmd_list(struct unit_test_state *uts) ut_silence_console(uts); console_record_reset(); run_command("bloblist list", 0); - ut_assert_nextline("Address Size Tag Name"); - ut_assert_nextline("%08lx %8x 1 SPL hand-off", + ut_assert_nextline("Address Size Tag Name"); + ut_assert_nextline("%08lx %8x 8000 SPL hand-off", (ulong)map_to_sysmem(data), TEST_SIZE); - ut_assert_nextline("%08lx %8x 2 Chrome OS vboot context", + ut_assert_nextline("%08lx %8x 106 Chrome OS vboot context", (ulong)map_to_sysmem(data2), TEST_SIZE2); ut_assert_console_end(); ut_unsilence_console(uts); -- cgit v1.2.3 From e50a24a0456c07d28c0d589e061dd0576f6bb917 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 12 Jan 2022 19:26:23 -0700 Subject: bloblist: Add functions to obtain base address and size Add a few convenience functions to obtain useful information about the bloblist. Signed-off-by: Simon Glass --- test/bloblist.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/bloblist.c') diff --git a/test/bloblist.c b/test/bloblist.c index c5788d5cd82..720be7e244f 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -107,6 +107,8 @@ static int bloblist_test_blob(struct unit_test_state *uts) hdr = clear_bloblist(); ut_assertnull(bloblist_find(TEST_TAG, TEST_BLOBLIST_SIZE)); ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_asserteq(TEST_BLOBLIST_SIZE, bloblist_get_size()); + ut_asserteq(TEST_ADDR, bloblist_get_base()); ut_asserteq(map_to_sysmem(hdr), TEST_ADDR); /* Add a record and check that we can find it */ -- cgit v1.2.3