All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/12] bloblist: Enhancements for standard passage
@ 2022-01-13  2:26 Simon Glass
  2022-01-13  2:26 ` [PATCH v2 01/12] stddef: Avoid warning with clang with offsetof() Simon Glass
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13  2:26 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Tom Rini, Simon Glass, Jerry Van Baren

This series collects together the prerequisites for standard passage.
The only change is to drop the CONFIG_IF_ENABLED_INT() macro.

Changes in v2:
- Create an accessor for CONFIG_BLOBLIST_ADDR instead of the Kconfig macro

Simon Glass (12):
  stddef: Avoid warning with clang with offsetof()
  fdt: Drop SPL_BUILD macro
  bloblist: Put the magic number first
  bloblist: Rename the SPL tag
  bloblist: Drop unused tags
  bloblist: Use explicit numbering for the tags
  bloblist: Use LOG_CATEGORY to simply logging
  bloblist: Use 'phase' consistently for bloblists
  bloblist: Refactor Kconfig to support alloc or fixed
  bloblist: Add functions to obtain base address and size
  bloblist: doc: Bring in the API documentation
  bloblist: Relicense to allow BSD-3-Clause

 arch/x86/cpu/broadwell/cpu_from_spl.c |   4 +-
 common/Kconfig                        |  95 +++++++++++--
 common/bloblist.c                     | 119 +++++++++++------
 common/board_f.c                      |   2 +-
 common/spl/spl.c                      |   4 +-
 doc/develop/bloblist.rst              |   8 +-
 drivers/serial/serial-uclass.c        |   3 +-
 include/bloblist.h                    | 184 +++++++++++++++++++-------
 include/fdtdec.h                      |   6 -
 include/linux/stddef.h                |   8 +-
 test/bloblist.c                       |  21 ++-
 11 files changed, 333 insertions(+), 121 deletions(-)

-- 
2.34.1.575.g55b058a8bb-goog


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 01/12] stddef: Avoid warning with clang with offsetof()
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
@ 2022-01-13  2:26 ` Simon Glass
  2022-01-13  2:26 ` [PATCH v2 02/12] fdt: Drop SPL_BUILD macro Simon Glass
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13  2:26 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Tom Rini, Simon Glass

Some bright sparks have decided that a cast on a constant cannot be a
constant, so offsetof() produces this warning on clang-10:

include/intel_gnvs.h:113:1: error: static_assert expression is not an
	integral constant expression
check_member(acpi_global_nvs, unused2, GNVS_CHROMEOS_ACPI_OFFSET);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/kernel.h:284:2: note: expanded from macro 'check_member'
        offsetof(struct structure, member) == (offset), \
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/stddef.h:20:32: note: expanded from macro 'offsetof'
                                ^
include/intel_gnvs.h:113:1: note: cast that performs the conversions of
	a reinterpret_cast is ot allowed in a constant expression
include/linux/stddef.h:20:33: note: expanded from macro 'offsetof'

Fix it by using the compiler built-in version, if available.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 include/linux/stddef.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/linux/stddef.h b/include/linux/stddef.h
index c540f6100d4..a7f546fdfe5 100644
--- a/include/linux/stddef.h
+++ b/include/linux/stddef.h
@@ -1,6 +1,8 @@
 #ifndef _LINUX_STDDEF_H
 #define _LINUX_STDDEF_H
 
+#include <linux/compiler_types.h>
+
 #undef NULL
 #if defined(__cplusplus)
 #define NULL 0
@@ -14,7 +16,11 @@
 
 #ifndef __CHECKER__
 #undef offsetof
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#ifdef __compiler_offsetof
+#define offsetof(TYPE, MEMBER)	__compiler_offsetof(TYPE, MEMBER)
+#else
+#define offsetof(TYPE, MEMBER)	((size_t)&((TYPE *)0)->MEMBER)
+#endif
 #endif
 
 #endif
-- 
2.34.1.575.g55b058a8bb-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 02/12] fdt: Drop SPL_BUILD macro
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
  2022-01-13  2:26 ` [PATCH v2 01/12] stddef: Avoid warning with clang with offsetof() Simon Glass
@ 2022-01-13  2:26 ` Simon Glass
  2022-01-13  2:26 ` [PATCH v2 03/12] bloblist: Put the magic number first Simon Glass
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13  2:26 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Tom Rini, Simon Glass, Jerry Van Baren

This old macro is not needed anymore since we can use IS_ENABLED() now.
Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 drivers/serial/serial-uclass.c | 3 ++-
 include/fdtdec.h               | 6 ------
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 30d44214d7d..96a1cb65ba2 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -104,7 +104,8 @@ static void serial_find_console_or_panic(void)
 			}
 		}
 	}
-	if (!SPL_BUILD || !CONFIG_IS_ENABLED(OF_CONTROL) || !blob) {
+	if (!IS_ENABLED(CONFIG_SPL_BUILD) || !CONFIG_IS_ENABLED(OF_CONTROL) ||
+	    !blob) {
 		/*
 		 * Try to use CONFIG_CONS_INDEX if available (it is numbered
 		 * from 1!).
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 09525ce510a..15f2d2bbbaa 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -49,12 +49,6 @@ struct fdt_memory {
 
 struct bd_info;
 
-#ifdef CONFIG_SPL_BUILD
-#define SPL_BUILD	1
-#else
-#define SPL_BUILD	0
-#endif
-
 /**
  * enum fdt_source_t - indicates where the devicetree came from
  *
-- 
2.34.1.575.g55b058a8bb-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 03/12] bloblist: Put the magic number first
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
  2022-01-13  2:26 ` [PATCH v2 01/12] stddef: Avoid warning with clang with offsetof() Simon Glass
  2022-01-13  2:26 ` [PATCH v2 02/12] fdt: Drop SPL_BUILD macro Simon Glass
@ 2022-01-13  2:26 ` Simon Glass
  2022-01-13  2:26 ` [PATCH v2 04/12] bloblist: Rename the SPL tag Simon Glass
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13  2:26 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Tom Rini, Simon Glass

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 <sjg@chromium.org>
---

(no changes since v1)

 include/bloblist.h | 25 +++++++++++++++++++++++--
 test/bloblist.c    |  7 +++++++
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/include/bloblist.h b/include/bloblist.h
index 9f007c7a94d..29ea5a768a6 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -13,6 +13,8 @@
 #ifndef __BLOBLIST_H
 #define __BLOBLIST_H
 
+#include <mapmem.h>
+
 enum {
 	BLOBLIST_VERSION	= 0,
 	BLOBLIST_MAGIC		= 0xb00757a3,
@@ -59,11 +61,11 @@ enum bloblist_tag_t {
  * Each bloblist record is aligned to a 16-byte boundary and follows immediately
  * from the last.
  *
+ * @magic: BLOBLIST_MAGIC
  * @version: BLOBLIST_VERSION
  * @hdr_size: Size of this header, normally sizeof(struct bloblist_hdr). The
  *	first bloblist_rec starts at this offset from the start of the header
  * @flags: Space for BLOBLISTF_... flags (none yet)
- * @magic: BLOBLIST_MAGIC
  * @size: Total size of the bloblist (non-zero if valid) including this header.
  *	The bloblist extends for this many bytes from the start of this header.
  *	When adding new records, the bloblist can grow up to this size.
@@ -78,10 +80,10 @@ enum bloblist_tag_t {
  *	calculation.
  */
 struct bloblist_hdr {
+	u32 magic;
 	u32 version;
 	u32 hdr_size;
 	u32 flags;
-	u32 magic;
 
 	u32 size;
 	u32 alloced;
@@ -111,6 +113,25 @@ struct bloblist_rec {
 	u32 spare;
 };
 
+/**
+ * bloblist_check_magic() - return a bloblist if the magic matches
+ *
+ * @addr: Address to check
+ * @return pointer to bloblist, if the magic matches, else NULL
+ */
+static inline void *bloblist_check_magic(ulong addr)
+{
+	u32 *ptr;
+
+	if (!addr)
+		return NULL;
+	ptr = map_sysmem(addr, 0);
+	if (*ptr != BLOBLIST_MAGIC)
+		return NULL;
+
+	return ptr;
+}
+
 /**
  * bloblist_find() - Find a blob
  *
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));
 
-- 
2.34.1.575.g55b058a8bb-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 04/12] bloblist: Rename the SPL tag
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (2 preceding siblings ...)
  2022-01-13  2:26 ` [PATCH v2 03/12] bloblist: Put the magic number first Simon Glass
@ 2022-01-13  2:26 ` Simon Glass
  2022-01-13  2:26 ` [PATCH v2 05/12] bloblist: Drop unused tags Simon Glass
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13  2:26 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Tom Rini, Simon Glass

Add a U_BOOT prefix to this tag since it is specific to the U-Boot
project.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/x86/cpu/broadwell/cpu_from_spl.c | 4 ++--
 common/bloblist.c                     | 2 +-
 common/board_f.c                      | 2 +-
 common/spl/spl.c                      | 4 ++--
 include/bloblist.h                    | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/x86/cpu/broadwell/cpu_from_spl.c b/arch/x86/cpu/broadwell/cpu_from_spl.c
index e5f62e7187c..df5a9675ee4 100644
--- a/arch/x86/cpu/broadwell/cpu_from_spl.c
+++ b/arch/x86/cpu/broadwell/cpu_from_spl.c
@@ -23,7 +23,7 @@ int dram_init(void)
 {
 	struct spl_handoff *ho;
 
-	ho = bloblist_find(BLOBLISTT_SPL_HANDOFF, sizeof(*ho));
+	ho = bloblist_find(BLOBLISTT_U_BOOT_SPL_HANDOFF, sizeof(*ho));
 	if (!ho)
 		return log_msg_ret("Missing SPL hand-off info", -ENOENT);
 	handoff_load_dram_size(ho);
@@ -56,7 +56,7 @@ int dram_init_banksize(void)
 {
 	struct spl_handoff *ho;
 
-	ho = bloblist_find(BLOBLISTT_SPL_HANDOFF, sizeof(*ho));
+	ho = bloblist_find(BLOBLISTT_U_BOOT_SPL_HANDOFF, sizeof(*ho));
 	if (!ho)
 		return log_msg_ret("Missing SPL hand-off info", -ENOENT);
 	handoff_load_dram_banks(ho);
diff --git a/common/bloblist.c b/common/bloblist.c
index 01b04103d91..89b415d6178 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -32,7 +32,7 @@ DECLARE_GLOBAL_DATA_PTR;
 static const char *const tag_name[] = {
 	[BLOBLISTT_NONE]		= "(none)",
 	[BLOBLISTT_EC_HOSTEVENT]	= "EC host event",
-	[BLOBLISTT_SPL_HANDOFF]		= "SPL hand-off",
+	[BLOBLISTT_U_BOOT_SPL_HANDOFF]		= "SPL hand-off",
 	[BLOBLISTT_VBOOT_CTX]		= "Chrome OS vboot context",
 	[BLOBLISTT_VBOOT_HANDOFF]	= "Chrome OS vboot hand-off",
 	[BLOBLISTT_ACPI_GNVS]		= "ACPI GNVS",
diff --git a/common/board_f.c b/common/board_f.c
index dd69c3b6b77..a68760092ac 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -283,7 +283,7 @@ static int setup_mon_len(void)
 static int setup_spl_handoff(void)
 {
 #if CONFIG_IS_ENABLED(HANDOFF)
-	gd->spl_handoff = bloblist_find(BLOBLISTT_SPL_HANDOFF,
+	gd->spl_handoff = bloblist_find(BLOBLISTT_U_BOOT_SPL_HANDOFF,
 					sizeof(struct spl_handoff));
 	debug("Found SPL hand-off info %p\n", gd->spl_handoff);
 #endif
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 4c101ec5d34..f51d1f32052 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -408,7 +408,7 @@ static int setup_spl_handoff(void)
 {
 	struct spl_handoff *ho;
 
-	ho = bloblist_ensure(BLOBLISTT_SPL_HANDOFF, sizeof(struct spl_handoff));
+	ho = bloblist_ensure(BLOBLISTT_U_BOOT_SPL_HANDOFF, sizeof(struct spl_handoff));
 	if (!ho)
 		return -ENOENT;
 
@@ -425,7 +425,7 @@ static int write_spl_handoff(void)
 	struct spl_handoff *ho;
 	int ret;
 
-	ho = bloblist_find(BLOBLISTT_SPL_HANDOFF, sizeof(struct spl_handoff));
+	ho = bloblist_find(BLOBLISTT_U_BOOT_SPL_HANDOFF, sizeof(struct spl_handoff));
 	if (!ho)
 		return -ENOENT;
 	handoff_save_dram(ho);
diff --git a/include/bloblist.h b/include/bloblist.h
index 29ea5a768a6..d4d48f76ff4 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -27,7 +27,7 @@ enum bloblist_tag_t {
 
 	/* Vendor-specific tags are permitted here */
 	BLOBLISTT_EC_HOSTEVENT,		/* Chromium OS EC host-event mask */
-	BLOBLISTT_SPL_HANDOFF,		/* Hand-off info from SPL */
+	BLOBLISTT_U_BOOT_SPL_HANDOFF,		/* Hand-off info from SPL */
 	BLOBLISTT_VBOOT_CTX,		/* Chromium OS verified boot context */
 	BLOBLISTT_VBOOT_HANDOFF,	/* Chromium OS internal handoff info */
 	/*
-- 
2.34.1.575.g55b058a8bb-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 05/12] bloblist: Drop unused tags
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (3 preceding siblings ...)
  2022-01-13  2:26 ` [PATCH v2 04/12] bloblist: Rename the SPL tag Simon Glass
@ 2022-01-13  2:26 ` Simon Glass
  2022-01-13  2:26 ` [PATCH v2 06/12] bloblist: Use explicit numbering for the tags Simon Glass
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13  2:26 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Tom Rini, Simon Glass

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 <sjg@chromium.org>
---

(no changes since v1)

 common/bloblist.c  | 4 +---
 include/bloblist.h | 2 --
 test/bloblist.c    | 4 ++--
 3 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/common/bloblist.c b/common/bloblist.c
index 89b415d6178..784eff61dea 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -31,10 +31,8 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static const char *const tag_name[] = {
 	[BLOBLISTT_NONE]		= "(none)",
-	[BLOBLISTT_EC_HOSTEVENT]	= "EC host event",
-	[BLOBLISTT_U_BOOT_SPL_HANDOFF]		= "SPL hand-off",
+	[BLOBLISTT_U_BOOT_SPL_HANDOFF]	= "SPL hand-off",
 	[BLOBLISTT_VBOOT_CTX]		= "Chrome OS vboot context",
-	[BLOBLISTT_VBOOT_HANDOFF]	= "Chrome OS vboot hand-off",
 	[BLOBLISTT_ACPI_GNVS]		= "ACPI GNVS",
 	[BLOBLISTT_INTEL_VBT]		= "Intel Video-BIOS table",
 	[BLOBLISTT_TPM2_TCG_LOG]	= "TPM v2 log space",
diff --git a/include/bloblist.h b/include/bloblist.h
index d4d48f76ff4..fac25907c07 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -26,10 +26,8 @@ enum bloblist_tag_t {
 	BLOBLISTT_NONE = 0,
 
 	/* Vendor-specific tags are permitted here */
-	BLOBLISTT_EC_HOSTEVENT,		/* Chromium OS EC host-event mask */
 	BLOBLISTT_U_BOOT_SPL_HANDOFF,		/* Hand-off info from SPL */
 	BLOBLISTT_VBOOT_CTX,		/* Chromium OS verified boot context */
-	BLOBLISTT_VBOOT_HANDOFF,	/* Chromium OS internal handoff info */
 	/*
 	 * Advanced Configuration and Power Interface Global Non-Volatile
 	 * Sleeping table. This forms part of the ACPI tables passed to Linux.
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);
-- 
2.34.1.575.g55b058a8bb-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 06/12] bloblist: Use explicit numbering for the tags
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (4 preceding siblings ...)
  2022-01-13  2:26 ` [PATCH v2 05/12] bloblist: Drop unused tags Simon Glass
@ 2022-01-13  2:26 ` Simon Glass
  2022-01-13  2:26 ` [PATCH v2 07/12] bloblist: Use LOG_CATEGORY to simply logging Simon Glass
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13  2:26 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Tom Rini, Simon Glass

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 <sjg@chromium.org>
---

(no changes since v1)

 common/bloblist.c  | 45 +++++++++++++++++++++++------------
 include/bloblist.h | 58 +++++++++++++++++++++++++++++++++++++---------
 test/bloblist.c    | 12 +++++-----
 3 files changed, 83 insertions(+), 32 deletions(-)

diff --git a/common/bloblist.c b/common/bloblist.c
index 784eff61dea..baf1d371b71 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -29,24 +29,39 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static const char *const tag_name[] = {
-	[BLOBLISTT_NONE]		= "(none)",
-	[BLOBLISTT_U_BOOT_SPL_HANDOFF]	= "SPL hand-off",
-	[BLOBLISTT_VBOOT_CTX]		= "Chrome OS vboot context",
-	[BLOBLISTT_ACPI_GNVS]		= "ACPI GNVS",
-	[BLOBLISTT_INTEL_VBT]		= "Intel Video-BIOS table",
-	[BLOBLISTT_TPM2_TCG_LOG]	= "TPM v2 log space",
-	[BLOBLISTT_TCPA_LOG]		= "TPM log space",
-	[BLOBLISTT_ACPI_TABLES]		= "ACPI tables for x86",
-	[BLOBLISTT_SMBIOS_TABLES]	= "SMBIOS tables for x86",
+static struct tag_name {
+	enum bloblist_tag_t tag;
+	const char *name;
+} tag_name[] = {
+	{ BLOBLISTT_NONE, "(none)" },
+
+	/* BLOBLISTT_AREA_FIRMWARE_TOP */
+
+	/* BLOBLISTT_AREA_FIRMWARE */
+	{ BLOBLISTT_ACPI_GNVS, "ACPI GNVS" },
+	{ BLOBLISTT_INTEL_VBT, "Intel Video-BIOS table" },
+	{ BLOBLISTT_TPM2_TCG_LOG, "TPM v2 log space" },
+	{ BLOBLISTT_TCPA_LOG, "TPM log space" },
+	{ BLOBLISTT_ACPI_TABLES, "ACPI tables for x86" },
+	{ BLOBLISTT_SMBIOS_TABLES, "SMBIOS tables for x86" },
+	{ BLOBLISTT_VBOOT_CTX, "Chrome OS vboot context" },
+
+	/* BLOBLISTT_PROJECT_AREA */
+	{ BLOBLISTT_U_BOOT_SPL_HANDOFF, "SPL hand-off" },
+
+	/* BLOBLISTT_VENDOR_AREA */
 };
 
 const char *bloblist_tag_name(enum bloblist_tag_t tag)
 {
-	if (tag < 0 || tag >= BLOBLISTT_COUNT)
-		return "invalid";
+	int i;
 
-	return tag_name[tag];
+	for (i = 0; i < ARRAY_SIZE(tag_name); i++) {
+		if (tag_name[i].tag == tag)
+			return tag_name[i].name;
+	}
+
+	return "invalid";
 }
 
 static struct bloblist_rec *bloblist_first_blob(struct bloblist_hdr *hdr)
@@ -381,10 +396,10 @@ void bloblist_show_list(void)
 	struct bloblist_hdr *hdr = gd->bloblist;
 	struct bloblist_rec *rec;
 
-	printf("%-8s  %8s  Tag Name\n", "Address", "Size");
+	printf("%-8s  %8s   Tag Name\n", "Address", "Size");
 	for (rec = bloblist_first_blob(hdr); rec;
 	     rec = bloblist_next_blob(hdr, rec)) {
-		printf("%08lx  %8x  %3d %s\n",
+		printf("%08lx  %8x  %4x %s\n",
 		       (ulong)map_to_sysmem((void *)rec + rec->hdr_size),
 		       rec->size, rec->tag, bloblist_tag_name(rec->tag));
 	}
diff --git a/include/bloblist.h b/include/bloblist.h
index fac25907c07..5de4545160e 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -25,21 +25,57 @@ enum {
 enum bloblist_tag_t {
 	BLOBLISTT_NONE = 0,
 
-	/* Vendor-specific tags are permitted here */
-	BLOBLISTT_U_BOOT_SPL_HANDOFF,		/* Hand-off info from SPL */
-	BLOBLISTT_VBOOT_CTX,		/* Chromium OS verified boot context */
+	/*
+	 * Standard area to allocate blobs used across firmware components, for
+	 * things that are very commonly used, particularly in multiple
+	 * projects.
+	 */
+	BLOBLISTT_AREA_FIRMWARE_TOP = 0x1,
+
+	/* Standard area to allocate blobs used across firmware components */
+	BLOBLISTT_AREA_FIRMWARE = 0x100,
 	/*
 	 * Advanced Configuration and Power Interface Global Non-Volatile
 	 * Sleeping table. This forms part of the ACPI tables passed to Linux.
 	 */
-	BLOBLISTT_ACPI_GNVS,
-	BLOBLISTT_INTEL_VBT,		/* Intel Video-BIOS table */
-	BLOBLISTT_TPM2_TCG_LOG,		/* TPM v2 log space */
-	BLOBLISTT_TCPA_LOG,		/* TPM log space */
-	BLOBLISTT_ACPI_TABLES,		/* ACPI tables for x86 */
-	BLOBLISTT_SMBIOS_TABLES,	/* SMBIOS tables for x86 */
-
-	BLOBLISTT_COUNT
+	BLOBLISTT_ACPI_GNVS = 0x100,
+	BLOBLISTT_INTEL_VBT = 0x101,	/* Intel Video-BIOS table */
+	BLOBLISTT_TPM2_TCG_LOG = 0x102,	/* TPM v2 log space */
+	BLOBLISTT_TCPA_LOG = 0x103,	/* TPM log space */
+	BLOBLISTT_ACPI_TABLES = 0x104,	/* ACPI tables for x86 */
+	BLOBLISTT_SMBIOS_TABLES = 0x105, /* SMBIOS tables for x86 */
+	BLOBLISTT_VBOOT_CTX = 0x106,	/* Chromium OS verified boot context */
+
+	/*
+	 * Project-specific tags are permitted here. Projects can be open source
+	 * or not, but the format of the data must be fuily documented in an
+	 * open source project, including all fields, bits, etc. Naming should
+	 * be: BLOBLISTT_<project>_<purpose_here>
+	 */
+	BLOBLISTT_PROJECT_AREA = 0x8000,
+	BLOBLISTT_U_BOOT_SPL_HANDOFF = 0x8000, /* Hand-off info from SPL */
+
+	/*
+	 * Vendor-specific tags are permitted here. Projects can be open source
+	 * or not, but the format of the data must be fuily documented in an
+	 * open source project, including all fields, bits, etc. Naming should
+	 * be BLOBLISTT_<vendor>_<purpose_here>
+	 */
+	BLOBLISTT_VENDOR_AREA = 0xc000,
+
+	/* Tags after this are not allocated for now */
+	BLOBLISTT_EXPANSION = 0x10000,
+
+	/*
+	 * Tags from here are on reserved for private use within a single
+	 * firmware binary (i.e. a single executable or phase of a project).
+	 * These tags can be passed between binaries within a local
+	 * implementation, but cannot be used in upstream code. Allocate a
+	 * tag in one of the areas above if you want that.
+	 *
+	 * This area may move in future.
+	 */
+	BLOBLISTT_PRIVATE_AREA = 0xffff0000,
 };
 
 /**
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);
-- 
2.34.1.575.g55b058a8bb-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 07/12] bloblist: Use LOG_CATEGORY to simply logging
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (5 preceding siblings ...)
  2022-01-13  2:26 ` [PATCH v2 06/12] bloblist: Use explicit numbering for the tags Simon Glass
@ 2022-01-13  2:26 ` Simon Glass
  2022-01-13  2:26 ` [PATCH v2 08/12] bloblist: Use 'phase' consistently for bloblists Simon Glass
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13  2:26 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Tom Rini, Simon Glass

Use the convenience functions to improve readability.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/bloblist.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/common/bloblist.c b/common/bloblist.c
index baf1d371b71..b5fea12b697 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -4,6 +4,8 @@
  * Written by Simon Glass <sjg@chromium.org>
  */
 
+#define LOG_CATEGORY	LOGC_BLOBLIST
+
 #include <common.h>
 #include <bloblist.h>
 #include <log.h>
@@ -133,9 +135,8 @@ static int bloblist_addrec(uint tag, int size, int align,
 	new_alloced = data_start + ALIGN(size, align);
 
 	if (new_alloced > hdr->size) {
-		log(LOGC_BLOBLIST, LOGL_ERR,
-		    "Failed to allocate %x bytes size=%x, need size=%x\n",
-		    size, hdr->size, new_alloced);
+		log_err("Failed to allocate %x bytes size=%x, need size=%x\n",
+			size, hdr->size, new_alloced);
 		return log_msg_ret("bloblist add", -ENOSPC);
 	}
 	rec = (void *)hdr + hdr->alloced;
@@ -249,14 +250,13 @@ static int bloblist_resize_rec(struct bloblist_hdr *hdr,
 	expand_by = ALIGN(new_size - rec->size, BLOBLIST_ALIGN);
 	new_alloced = ALIGN(hdr->alloced + expand_by, BLOBLIST_ALIGN);
 	if (new_size < 0) {
-		log(LOGC_BLOBLIST, LOGL_DEBUG,
-		    "Attempt to shrink blob size below 0 (%x)\n", new_size);
+		log_debug("Attempt to shrink blob size below 0 (%x)\n",
+			  new_size);
 		return log_msg_ret("size", -EINVAL);
 	}
 	if (new_alloced > hdr->size) {
-		log(LOGC_BLOBLIST, LOGL_ERR,
-		    "Failed to allocate %x bytes size=%x, need size=%x\n",
-		    new_size, hdr->size, new_alloced);
+		log_err("Failed to allocate %x bytes size=%x, need size=%x\n",
+			new_size, hdr->size, new_alloced);
 		return log_msg_ret("alloc", -ENOSPC);
 	}
 
@@ -347,8 +347,7 @@ int bloblist_check(ulong addr, uint size)
 		return log_msg_ret("Bad size", -EFBIG);
 	chksum = bloblist_calc_chksum(hdr);
 	if (hdr->chksum != chksum) {
-		log(LOGC_BLOBLIST, LOGL_ERR, "Checksum %x != %x\n", hdr->chksum,
-		    chksum);
+		log_err("Checksum %x != %x\n", hdr->chksum, chksum);
 		return log_msg_ret("Bad checksum", -EIO);
 	}
 	gd->bloblist = hdr;
@@ -446,7 +445,7 @@ int bloblist_init(void)
 		}
 		ret = bloblist_new(addr, CONFIG_BLOBLIST_SIZE, 0);
 	} else {
-		log(LOGC_BLOBLIST, LOGL_DEBUG, "Found existing bloblist\n");
+		log_debug("Found existing bloblist\n");
 	}
 
 	return ret;
-- 
2.34.1.575.g55b058a8bb-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 08/12] bloblist: Use 'phase' consistently for bloblists
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (6 preceding siblings ...)
  2022-01-13  2:26 ` [PATCH v2 07/12] bloblist: Use LOG_CATEGORY to simply logging Simon Glass
@ 2022-01-13  2:26 ` Simon Glass
  2022-01-13  2:26 ` [PATCH v2 09/12] bloblist: Refactor Kconfig to support alloc or fixed Simon Glass
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13  2:26 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Tom Rini, Simon Glass

We typically refer to the different U-Boot builds that a board runs
through as phases. This avoids confusion with the word 'stage' which is
used with bootstage, for example. Fix up some bloblist Kconfig help
which uses the wrong term.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/Kconfig | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index 0892d9be362..ca136b1ac7f 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -717,7 +717,7 @@ config BLOBLIST
 	  from TPL to SPL to U-Boot proper (and potentially to Linux). The
 	  blob list supports multiple binary blobs of data, each with a tag,
 	  so that different U-Boot components can store data which can survive
-	  through to the next stage of the boot.
+	  through to the next phase of the boot.
 
 config SPL_BLOBLIST
 	bool "Support for a bloblist in SPL"
@@ -746,7 +746,7 @@ config BLOBLIST_SIZE
 	  Sets the size of the bloblist in bytes. This must include all
 	  overhead (alignment, bloblist header, record header). The bloblist
 	  is set up in the first part of U-Boot to run (TPL, SPL or U-Boot
-	  proper), and this sane bloblist is used for subsequent stages.
+	  proper), and this sane bloblist is used for subsequent phases.
 
 config BLOBLIST_ALLOC
 	bool "Allocate bloblist"
@@ -760,7 +760,7 @@ config BLOBLIST_ADDR
 	default 0xc000 if SANDBOX
 	help
 	  Sets the address of the bloblist, set up by the first part of U-Boot
-	  which runs. Subsequent U-Boot stages typically use the same address.
+	  which runs. Subsequent U-Boot phases typically use the same address.
 
 	  This is not used if BLOBLIST_ALLOC is selected.
 
-- 
2.34.1.575.g55b058a8bb-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 09/12] bloblist: Refactor Kconfig to support alloc or fixed
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (7 preceding siblings ...)
  2022-01-13  2:26 ` [PATCH v2 08/12] bloblist: Use 'phase' consistently for bloblists Simon Glass
@ 2022-01-13  2:26 ` Simon Glass
  2022-01-13  2:26 ` [PATCH v2 10/12] bloblist: Add functions to obtain base address and size Simon Glass
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13  2:26 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Tom Rini, Simon Glass

At present we do support allocating the bloblist but the Kconfig is a bit
strange, since we still have to specify an address in that case. Partly
this is because it is a pain to have CONFIG options that disappears when
its dependency is enabled. It means that we must have #ifdefs in the code,
either in the C code or header file.

Make use of IF_ENABLED_INT() and its friend to solve that problem, so we
can separate out the location of bloblist into a choice. Put the address
and size into variables so we can log the result.

Add the options for SPL as well, so we can use CONFIG_IS_ENABLED().

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Create an accessor for CONFIG_BLOBLIST_ADDR instead of the Kconfig macro

 common/Kconfig     | 91 +++++++++++++++++++++++++++++++++++++++++-----
 common/bloblist.c  | 39 ++++++++++++--------
 include/bloblist.h | 10 +++++
 3 files changed, 116 insertions(+), 24 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index ca136b1ac7f..82cd864baf9 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -738,15 +738,17 @@ config TPL_BLOBLIST
 
 if BLOBLIST
 
-config BLOBLIST_SIZE
-	hex "Size of bloblist"
-	depends on BLOBLIST
-	default 0x400
+choice
+	prompt "Bloblist location"
 	help
-	  Sets the size of the bloblist in bytes. This must include all
-	  overhead (alignment, bloblist header, record header). The bloblist
-	  is set up in the first part of U-Boot to run (TPL, SPL or U-Boot
-	  proper), and this sane bloblist is used for subsequent phases.
+	  Select the location of the bloblist, via various means.
+
+config BLOBLIST_FIXED
+	bool "Place bloblist at a fixed address in memory"
+	help
+	  Select this to used a fixed memory address for the bloblist. If the
+	  bloblist exists at this address from a previous phase, it used as is.
+	  If not it is created at this address in U-Boot.
 
 config BLOBLIST_ALLOC
 	bool "Allocate bloblist"
@@ -755,18 +757,31 @@ config BLOBLIST_ALLOC
 	  specify a fixed address on systems where this is unknown or can
 	  change at runtime.
 
+endchoice
+
 config BLOBLIST_ADDR
 	hex "Address of bloblist"
 	default 0xc000 if SANDBOX
+	depends on BLOBLIST_FIXED
 	help
 	  Sets the address of the bloblist, set up by the first part of U-Boot
 	  which runs. Subsequent U-Boot phases typically use the same address.
 
 	  This is not used if BLOBLIST_ALLOC is selected.
 
+config BLOBLIST_SIZE
+	hex "Size of bloblist"
+	default 0x400
+	help
+	  Sets the size of the bloblist in bytes. This must include all
+	  overhead (alignment, bloblist header, record header). The bloblist
+	  is set up in the first part of U-Boot to run (TPL, SPL or U-Boot
+	  proper), and this sane bloblist is used for subsequent phases.
+
 config BLOBLIST_SIZE_RELOC
 	hex "Size of bloblist after relocation"
-	default BLOBLIST_SIZE
+	default BLOBLIST_SIZE if BLOBLIST_FIXED || BLOBLIST_ALLOC
+	default 0 if BLOBLIST_PASSAGE
 	help
 	  Sets the size of the bloblist in bytes after relocation. Since U-Boot
 	  has a lot more memory available then, it is possible to use a larger
@@ -775,6 +790,64 @@ config BLOBLIST_SIZE_RELOC
 
 endif # BLOBLIST
 
+if SPL_BLOBLIST
+
+choice
+	prompt "Bloblist location in SPL"
+	help
+	  Select the location of the bloblist, via various means. Typically
+	  you should use the same value for SPL as for U-Boot, since they need
+	  to look in the same place. But if BLOBLIST_ALLOC is used, then a
+	  fresh bloblist will be created each time, since there is no shared
+	  address (between phases) for the bloblist.
+
+config SPL_BLOBLIST_FIXED
+	bool "Place bloblist at a fixed address in memory"
+	help
+	  Select this to used a fixed memory address for the bloblist. If the
+	  bloblist exists at this address from a previous phase, it used as is.
+	  If not it is created at this address in SPL.
+
+config SPL_BLOBLIST_ALLOC
+	bool "Allocate bloblist"
+	help
+	  Allocate the bloblist using malloc(). This avoids the need to
+	  specify a fixed address on systems where this is unknown or can
+	  change at runtime.
+
+endchoice
+
+endif # SPL_BLOBLIST
+
+if TPL_BLOBLIST
+
+choice
+	prompt "Bloblist location in TPL"
+	help
+	  Select the location of the bloblist, via various means. Typically
+	  you should use the same value for SPL as for U-Boot, since they need
+	  to look in the same place. But if BLOBLIST_ALLOC is used, then a
+	  fresh bloblist will be created each time, since there is no shared
+	  address (between phases) for the bloblist.
+
+config TPL_BLOBLIST_FIXED
+	bool "Place bloblist at a fixed address in memory"
+	help
+	  Select this to used a fixed memory address for the bloblist. If the
+	  bloblist exists at this address from a previous phase, it used as is.
+	  If not it is created at this address in TPL.
+
+config TPL_BLOBLIST_ALLOC
+	bool "Allocate bloblist"
+	help
+	  Allocate the bloblist using malloc(). This avoids the need to
+	  specify a fixed address on systems where this is unknown or can
+	  change at runtime.
+
+endchoice
+
+endif # TPL_BLOBLIST
+
 endmenu
 
 source "common/spl/Kconfig"
diff --git a/common/bloblist.c b/common/bloblist.c
index b5fea12b697..0049bb9a395 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -4,6 +4,7 @@
  * Written by Simon Glass <sjg@chromium.org>
  */
 
+#define LOG_DEBUG
 #define LOG_CATEGORY	LOGC_BLOBLIST
 
 #include <common.h>
@@ -360,6 +361,8 @@ int bloblist_finish(void)
 	struct bloblist_hdr *hdr = gd->bloblist;
 
 	hdr->chksum = bloblist_calc_chksum(hdr);
+	log_debug("Finished bloblist size %lx at %lx\n", (ulong)hdr->size,
+		  (ulong)map_to_sysmem(hdr));
 
 	return 0;
 }
@@ -415,8 +418,9 @@ void bloblist_reloc(void *to, uint to_size, void *from, uint from_size)
 
 int bloblist_init(void)
 {
-	bool expected;
 	int ret = -ENOENT;
+	ulong addr, size;
+	bool expected;
 
 	/**
 	 * Wed expect to find an existing bloblist in the first phase of U-Boot
@@ -425,27 +429,32 @@ int bloblist_init(void)
 	expected = !u_boot_first_phase();
 	if (spl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST))
 		expected = false;
-	if (expected)
-		ret = bloblist_check(CONFIG_BLOBLIST_ADDR,
-				     CONFIG_BLOBLIST_SIZE);
+	addr = bloblist_addr();
+	size = CONFIG_BLOBLIST_SIZE;
+	if (expected) {
+		ret = bloblist_check(addr, size);
+		if (ret) {
+			log_warning("Expected bloblist at %lx not found (err=%d)\n",
+				    addr, ret);
+		} else {
+			/* Get the real size, if it is not what we expected */
+			size = gd->bloblist->size;
+		}
+	}
 	if (ret) {
-		ulong addr;
-
-		log(LOGC_BLOBLIST, expected ? LOGL_WARNING : LOGL_DEBUG,
-		    "Existing bloblist not found: creating new bloblist\n");
-		if (IS_ENABLED(CONFIG_BLOBLIST_ALLOC)) {
-			void *ptr = memalign(BLOBLIST_ALIGN,
-					     CONFIG_BLOBLIST_SIZE);
+		if (CONFIG_IS_ENABLED(BLOBLIST_ALLOC)) {
+			void *ptr = memalign(BLOBLIST_ALIGN, size);
 
 			if (!ptr)
 				return log_msg_ret("alloc", -ENOMEM);
 			addr = map_to_sysmem(ptr);
-		} else {
-			addr = CONFIG_BLOBLIST_ADDR;
 		}
-		ret = bloblist_new(addr, CONFIG_BLOBLIST_SIZE, 0);
+		log_debug("Creating new bloblist size %lx at %lx\n", size,
+			  addr);
+		ret = bloblist_new(addr, size, 0);
 	} else {
-		log_debug("Found existing bloblist\n");
+		log_debug("Found existing bloblist size %lx at %lx\n", size,
+			  addr);
 	}
 
 	return ret;
diff --git a/include/bloblist.h b/include/bloblist.h
index 5de4545160e..13f2b3f1009 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -147,6 +147,16 @@ struct bloblist_rec {
 	u32 spare;
 };
 
+/* access CONFIG_BLOBLIST_ADDR, dealing with it possibly not being defined */
+static inline ulong bloblist_addr(void)
+{
+#ifdef CONFIG_BLOBLIST_FIXED
+	return CONFIG_BLOBLIST_ADDR;
+#else
+	return 0;
+#endif
+}
+
 /**
  * bloblist_check_magic() - return a bloblist if the magic matches
  *
-- 
2.34.1.575.g55b058a8bb-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 10/12] bloblist: Add functions to obtain base address and size
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (8 preceding siblings ...)
  2022-01-13  2:26 ` [PATCH v2 09/12] bloblist: Refactor Kconfig to support alloc or fixed Simon Glass
@ 2022-01-13  2:26 ` Simon Glass
  2022-01-13  2:26 ` [PATCH v2 11/12] bloblist: doc: Bring in the API documentation Simon Glass
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13  2:26 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Tom Rini, Simon Glass

Add a few convenience functions to obtain useful information about the
bloblist.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/bloblist.c  | 12 ++++++++++++
 include/bloblist.h | 14 ++++++++++++++
 test/bloblist.c    |  2 ++
 3 files changed, 28 insertions(+)

diff --git a/common/bloblist.c b/common/bloblist.c
index 0049bb9a395..1ed9172d897 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -367,6 +367,18 @@ int bloblist_finish(void)
 	return 0;
 }
 
+ulong bloblist_get_base(void)
+{
+	return map_to_sysmem(gd->bloblist);
+}
+
+ulong bloblist_get_size(void)
+{
+	struct bloblist_hdr *hdr = gd->bloblist;
+
+	return hdr->size;
+}
+
 void bloblist_get_stats(ulong *basep, ulong *sizep, ulong *allocedp)
 {
 	struct bloblist_hdr *hdr = gd->bloblist;
diff --git a/include/bloblist.h b/include/bloblist.h
index 13f2b3f1009..d9e108d8618 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -302,6 +302,20 @@ int bloblist_finish(void);
  */
 void bloblist_get_stats(ulong *basep, ulong *sizep, ulong *allocedp);
 
+/**
+ * bloblist_get_base() - Get the base address of the bloblist
+ *
+ * @returns base address of bloblist
+ */
+ulong bloblist_get_base(void);
+
+/**
+ * bloblist_get_size() - Get the size of the bloblist
+ *
+ * @returns the size in bytes
+ */
+ulong bloblist_get_size(void);
+
 /**
  * bloblist_show_stats() - Show information about the bloblist
  *
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 */
-- 
2.34.1.575.g55b058a8bb-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 11/12] bloblist: doc: Bring in the API documentation
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (9 preceding siblings ...)
  2022-01-13  2:26 ` [PATCH v2 10/12] bloblist: Add functions to obtain base address and size Simon Glass
@ 2022-01-13  2:26 ` Simon Glass
  2022-01-13  2:26 ` [PATCH v2 12/12] bloblist: Relicense to allow BSD-3-Clause Simon Glass
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13  2:26 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Tom Rini, Simon Glass

FIx up various minor errors and add the API documentation to the bloblist
docs, since it is quite useful to see it in the same place.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 doc/develop/bloblist.rst |  8 +++-
 include/bloblist.h       | 79 +++++++++++++++++++++++-----------------
 2 files changed, 52 insertions(+), 35 deletions(-)

diff --git a/doc/develop/bloblist.rst b/doc/develop/bloblist.rst
index 47274cf8e26..572aa65d764 100644
--- a/doc/develop/bloblist.rst
+++ b/doc/develop/bloblist.rst
@@ -31,7 +31,7 @@ Blobs
 While each blob in the bloblist can be of any length, bloblists are designed to
 hold small amounts of data, typically a few KB at most. It is not possible to
 change the length of a blob once it has been written. Each blob is normally
-created from a C structure which can beused to access its fields.
+created from a C structure which can be used to access its fields.
 
 
 Blob tags
@@ -93,6 +93,12 @@ This should move to using bloblist, to avoid having its own mechanism for
 passing information between U-Boot parts.
 
 
+API documentation
+-----------------
+
+.. kernel-doc:: include/bloblist.h
+
+
 Simon Glass
 sjg@chromium.org
 12-Aug-2018
diff --git a/include/bloblist.h b/include/bloblist.h
index d9e108d8618..798babe9235 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -86,8 +86,8 @@ enum bloblist_tag_t {
  * same place in memory as SPL and U-Boot execute, but it can be safely moved
  * around.
  *
- * None of the bloblist structures contain pointers but it is possible to put
- * pointers inside a bloblist record if desired. This is not encouraged,
+ * None of the bloblist headers themselves contain pointers but it is possible
+ * to put pointers inside a bloblist record if desired. This is not encouraged,
  * since it can make part of the bloblist inaccessible if the pointer is
  * no-longer valid. It is better to just store all the data inside a bloblist
  * record.
@@ -99,7 +99,7 @@ enum bloblist_tag_t {
  * @version: BLOBLIST_VERSION
  * @hdr_size: Size of this header, normally sizeof(struct bloblist_hdr). The
  *	first bloblist_rec starts at this offset from the start of the header
- * @flags: Space for BLOBLISTF_... flags (none yet)
+ * @flags: Space for BLOBLISTF... flags (none yet)
  * @size: Total size of the bloblist (non-zero if valid) including this header.
  *	The bloblist extends for this many bytes from the start of this header.
  *	When adding new records, the bloblist can grow up to this size.
@@ -110,8 +110,8 @@ enum bloblist_tag_t {
  * @chksum: CRC32 for the entire bloblist allocated area. Since any of the
  *	blobs can be altered after being created, this checksum is only valid
  *	when the bloblist is finalised before jumping to the next stage of boot.
- *	Note: @chksum is last to make it easier to exclude it from the checksum
- *	calculation.
+ *	Note that chksum is last to make it easier to exclude it from the
+ *	checksum calculation.
  */
 struct bloblist_hdr {
 	u32 magic;
@@ -128,11 +128,11 @@ struct bloblist_hdr {
 /**
  * struct bloblist_rec - record for the bloblist
  *
- * NOTE: Only exported for testing purposes. Do not use this struct.
- *
  * The bloblist contains a number of records each consisting of this record
  * structure followed by the data contained. Each records is 16-byte aligned.
  *
+ * NOTE: Only exported for testing purposes. Do not use this struct.
+ *
  * @tag: Tag indicating what the record contains
  * @hdr_size: Size of this header, normally sizeof(struct bloblist_rec). The
  *	record's data starts at this offset from the start of the record
@@ -161,7 +161,7 @@ static inline ulong bloblist_addr(void)
  * bloblist_check_magic() - return a bloblist if the magic matches
  *
  * @addr: Address to check
- * @return pointer to bloblist, if the magic matches, else NULL
+ * Return: pointer to bloblist, if the magic matches, else NULL
  */
 static inline void *bloblist_check_magic(ulong addr)
 {
@@ -183,8 +183,8 @@ static inline void *bloblist_check_magic(ulong addr)
  *
  * @tag:	Tag to search for (enum bloblist_tag_t)
  * @size:	Expected size of the blob, or 0 for any size
- * @return pointer to blob if found, or NULL if not found, or a blob was found
- *	but it is the wrong size
+ * Return: pointer to blob if found, or NULL if not found, or a blob was found
+ * but it is the wrong size
  */
 void *bloblist_find(uint tag, int size);
 
@@ -200,8 +200,8 @@ void *bloblist_find(uint tag, int size);
  * @tag:	Tag to add (enum bloblist_tag_t)
  * @size:	Size of the blob
  * @align:	Alignment of the blob (in bytes), 0 for default
- * @return pointer to the newly added block, or NULL if there is not enough
- *	space for the blob
+ * Return: pointer to the newly added block, or NULL if there is not enough
+ * space for the blob
  */
 void *bloblist_add(uint tag, int size, int align);
 
@@ -214,8 +214,8 @@ void *bloblist_add(uint tag, int size, int align);
  * @size:	Size of the blob
  * @blobp:	Returns a pointer to blob on success
  * @align:	Alignment of the blob (in bytes), 0 for default
- * @return 0 if OK, -ENOSPC if it is missing and could not be added due to lack
- *	of space, or -ESPIPE it exists but has the wrong size
+ * Return: 0 if OK, -ENOSPC if it is missing and could not be added due to lack
+ * of space, or -ESPIPE it exists but has the wrong size
  */
 int bloblist_ensure_size(uint tag, int size, int align, void **blobp);
 
@@ -226,8 +226,8 @@ int bloblist_ensure_size(uint tag, int size, int align, void **blobp);
  *
  * @tag:	Tag to add (enum bloblist_tag_t)
  * @size:	Size of the blob
- * @return pointer to blob, or NULL if it is missing and could not be added due
- *	to lack of space, or it exists but has the wrong size
+ * Return: pointer to blob, or NULL if it is missing and could not be added due
+ * to lack of space, or it exists but has the wrong size
  */
 void *bloblist_ensure(uint tag, int size);
 
@@ -239,8 +239,8 @@ void *bloblist_ensure(uint tag, int size);
  * @tag:	Tag to add (enum bloblist_tag_t)
  * @sizep:	Size of the blob to create; returns size of actual blob
  * @blobp:	Returns a pointer to blob on success
- * @return 0 if OK, -ENOSPC if it is missing and could not be added due to lack
- *	of space
+ * Return: 0 if OK, -ENOSPC if it is missing and could not be added due to lack
+ * of space
  */
 int bloblist_ensure_size_ret(uint tag, int *sizep, void **blobp);
 
@@ -252,8 +252,8 @@ int bloblist_ensure_size_ret(uint tag, int *sizep, void **blobp);
  *
  * @tag:	Tag to add (enum bloblist_tag_t)
  * @new_size:	New size of the blob (>0 to expand, <0 to contract)
- * @return 0 if OK, -ENOSPC if the bloblist does not have enough space, -ENOENT
- *	if the tag is not found
+ * Return: 0 if OK, -ENOSPC if the bloblist does not have enough space, -ENOENT
+ * if the tag is not found
  */
 int bloblist_resize(uint tag, int new_size);
 
@@ -263,8 +263,8 @@ int bloblist_resize(uint tag, int new_size);
  * @addr: Address of bloblist
  * @size: Initial size for bloblist
  * @flags: Flags to use for bloblist
- * @return 0 if OK, -EFAULT if addr is not aligned correctly, -ENOSPC is the
- *	area is not large enough
+ * Return: 0 if OK, -EFAULT if addr is not aligned correctly, -ENOSPC is the
+ * area is not large enough
  */
 int bloblist_new(ulong addr, uint size, uint flags);
 
@@ -273,11 +273,11 @@ int bloblist_new(ulong addr, uint size, uint flags);
  *
  * @addr: Address of bloblist
  * @size: Expected size of blobsize, or 0 to detect the size
- * @return 0 if OK, -ENOENT if the magic number doesn't match (indicating that
- *	there problem is no bloblist at the given address), -EPROTONOSUPPORT
- *	if the version does not match, -EIO if the checksum does not match,
- *	-EFBIG if the expected size does not match the detected size, -ENOSPC
- *	if the size is not large enough to hold the headers
+ * Return: 0 if OK, -ENOENT if the magic number doesn't match (indicating that
+ * there problem is no bloblist at the given address), -EPROTONOSUPPORT
+ * if the version does not match, -EIO if the checksum does not match,
+ * -EFBIG if the expected size does not match the detected size, -ENOSPC
+ * if the size is not large enough to hold the headers
  */
 int bloblist_check(ulong addr, uint size);
 
@@ -287,7 +287,7 @@ int bloblist_check(ulong addr, uint size);
  * This sets the correct checksum for the bloblist. This ensures that the
  * bloblist will be detected correctly by the next phase of U-Boot.
  *
- * @return 0
+ * Return: 0
  */
 int bloblist_finish(void);
 
@@ -305,14 +305,14 @@ void bloblist_get_stats(ulong *basep, ulong *sizep, ulong *allocedp);
 /**
  * bloblist_get_base() - Get the base address of the bloblist
  *
- * @returns base address of bloblist
+ * Return: base address of bloblist
  */
 ulong bloblist_get_base(void);
 
 /**
  * bloblist_get_size() - Get the size of the bloblist
  *
- * @returns the size in bytes
+ * Return: the size in bytes
  */
 ulong bloblist_get_size(void);
 
@@ -334,7 +334,7 @@ void bloblist_show_list(void);
  * bloblist_tag_name() - Get the name for a tag
  *
  * @tag: Tag to check
- * @return name of tag, or "invalid" if an invalid tag is provided
+ * Return: name of tag, or "invalid" if an invalid tag is provided
  */
 const char *bloblist_tag_name(enum bloblist_tag_t tag);
 
@@ -342,7 +342,7 @@ const char *bloblist_tag_name(enum bloblist_tag_t tag);
  * bloblist_reloc() - Relocate the bloblist and optionally resize it
  *
  * @to: Pointer to new bloblist location (must not overlap old location)
- * @to:size: New size for bloblist (must be larger than from_size)
+ * @to_size: New size for bloblist (must be larger than from_size)
  * @from: Pointer to bloblist to relocate
  * @from_size: Size of bloblist to relocate
  */
@@ -351,8 +351,19 @@ void bloblist_reloc(void *to, uint to_size, void *from, uint from_size);
 /**
  * bloblist_init() - Init the bloblist system with a single bloblist
  *
- * This uses CONFIG_BLOBLIST_ADDR and CONFIG_BLOBLIST_SIZE to set up a bloblist
- * for use by U-Boot.
+ * This locates and sets up the blocklist for use.
+ *
+ * If CONFIG_BLOBLIST_FIXED is selected, it uses CONFIG_BLOBLIST_ADDR and
+ * CONFIG_BLOBLIST_SIZE to set up a bloblist for use by U-Boot.
+ *
+ * If CONFIG_BLOBLIST_ALLOC is selected, it allocates memory for a bloblist of
+ * size CONFIG_BLOBLIST_SIZE.
+ *
+ * If CONFIG_BLOBLIST_PASSAGE is selected, it uses the bloblist in the incoming
+ * standard passage. The size is detected automatically so CONFIG_BLOBLIST_SIZE
+ * can be 0.
+ *
+ * Return: 0 if OK, -ve on error
  */
 int bloblist_init(void);
 
-- 
2.34.1.575.g55b058a8bb-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 12/12] bloblist: Relicense to allow BSD-3-Clause
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (10 preceding siblings ...)
  2022-01-13  2:26 ` [PATCH v2 11/12] bloblist: doc: Bring in the API documentation Simon Glass
@ 2022-01-13  2:26 ` Simon Glass
  2022-01-13 18:00 ` Simon Glass
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13  2:26 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Tom Rini, Simon Glass

This implementation is intended to be copied to other projects and
modified, to as to foster a standard means of communcating runtime
information between firmware projects.

The GPL-2 license is too restrictive for some projects, e.g. those
intended as reference implementations rather than designed for
collaborative open-source development.

Update the license to make this easier to share.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/bloblist.c  | 2 +-
 include/bloblist.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/bloblist.c b/common/bloblist.c
index 1ed9172d897..056b50c2cb6 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+// SPDX-License-Identifier: GPL-2.0+ BSD-3-Clause
 /*
  * Copyright 2018 Google, Inc
  * Written by Simon Glass <sjg@chromium.org>
diff --git a/include/bloblist.h b/include/bloblist.h
index 798babe9235..173129b0273 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
+/* SPDX-License-Identifier: GPL-2.0+ BSD-3-Clause */
 /*
  * This provides a standard way of passing information between boot phases
  * (TPL -> SPL -> U-Boot proper.)
-- 
2.34.1.575.g55b058a8bb-goog


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 12/12] bloblist: Relicense to allow BSD-3-Clause
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (11 preceding siblings ...)
  2022-01-13  2:26 ` [PATCH v2 12/12] bloblist: Relicense to allow BSD-3-Clause Simon Glass
@ 2022-01-13 18:00 ` Simon Glass
  2022-01-13 18:00 ` [PATCH v2 11/12] bloblist: doc: Bring in the API documentation Simon Glass
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13 18:00 UTC (permalink / raw)
  To: Simon Glass; +Cc: Tom Rini, U-Boot Mailing List

This implementation is intended to be copied to other projects and
modified, to as to foster a standard means of communcating runtime
information between firmware projects.

The GPL-2 license is too restrictive for some projects, e.g. those
intended as reference implementations rather than designed for
collaborative open-source development.

Update the license to make this easier to share.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/bloblist.c  | 2 +-
 include/bloblist.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 11/12] bloblist: doc: Bring in the API documentation
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (12 preceding siblings ...)
  2022-01-13 18:00 ` Simon Glass
@ 2022-01-13 18:00 ` Simon Glass
  2022-01-13 18:00 ` [PATCH v2 10/12] bloblist: Add functions to obtain base address and size Simon Glass
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13 18:00 UTC (permalink / raw)
  To: Simon Glass; +Cc: Tom Rini, U-Boot Mailing List

FIx up various minor errors and add the API documentation to the bloblist
docs, since it is quite useful to see it in the same place.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 doc/develop/bloblist.rst |  8 +++-
 include/bloblist.h       | 79 +++++++++++++++++++++++-----------------
 2 files changed, 52 insertions(+), 35 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 10/12] bloblist: Add functions to obtain base address and size
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (13 preceding siblings ...)
  2022-01-13 18:00 ` [PATCH v2 11/12] bloblist: doc: Bring in the API documentation Simon Glass
@ 2022-01-13 18:00 ` Simon Glass
  2022-01-13 18:00 ` [PATCH v2 08/12] bloblist: Use 'phase' consistently for bloblists Simon Glass
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13 18:00 UTC (permalink / raw)
  To: Simon Glass; +Cc: Tom Rini, U-Boot Mailing List

Add a few convenience functions to obtain useful information about the
bloblist.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/bloblist.c  | 12 ++++++++++++
 include/bloblist.h | 14 ++++++++++++++
 test/bloblist.c    |  2 ++
 3 files changed, 28 insertions(+)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 08/12] bloblist: Use 'phase' consistently for bloblists
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (14 preceding siblings ...)
  2022-01-13 18:00 ` [PATCH v2 10/12] bloblist: Add functions to obtain base address and size Simon Glass
@ 2022-01-13 18:00 ` Simon Glass
  2022-01-13 18:00 ` [PATCH v2 09/12] bloblist: Refactor Kconfig to support alloc or fixed Simon Glass
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13 18:00 UTC (permalink / raw)
  To: Simon Glass; +Cc: Tom Rini, U-Boot Mailing List

We typically refer to the different U-Boot builds that a board runs
through as phases. This avoids confusion with the word 'stage' which is
used with bootstage, for example. Fix up some bloblist Kconfig help
which uses the wrong term.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/Kconfig | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 09/12] bloblist: Refactor Kconfig to support alloc or fixed
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (15 preceding siblings ...)
  2022-01-13 18:00 ` [PATCH v2 08/12] bloblist: Use 'phase' consistently for bloblists Simon Glass
@ 2022-01-13 18:00 ` Simon Glass
  2022-01-13 18:00 ` [PATCH v2 06/12] bloblist: Use explicit numbering for the tags Simon Glass
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13 18:00 UTC (permalink / raw)
  To: Simon Glass; +Cc: Tom Rini, U-Boot Mailing List

At present we do support allocating the bloblist but the Kconfig is a bit
strange, since we still have to specify an address in that case. Partly
this is because it is a pain to have CONFIG options that disappears when
its dependency is enabled. It means that we must have #ifdefs in the code,
either in the C code or header file.

Make use of IF_ENABLED_INT() and its friend to solve that problem, so we
can separate out the location of bloblist into a choice. Put the address
and size into variables so we can log the result.

Add the options for SPL as well, so we can use CONFIG_IS_ENABLED().

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Create an accessor for CONFIG_BLOBLIST_ADDR instead of the Kconfig macro

 common/Kconfig     | 91 +++++++++++++++++++++++++++++++++++++++++-----
 common/bloblist.c  | 39 ++++++++++++--------
 include/bloblist.h | 10 +++++
 3 files changed, 116 insertions(+), 24 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 07/12] bloblist: Use LOG_CATEGORY to simply logging
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (17 preceding siblings ...)
  2022-01-13 18:00 ` [PATCH v2 06/12] bloblist: Use explicit numbering for the tags Simon Glass
@ 2022-01-13 18:00 ` Simon Glass
  2022-01-13 18:00 ` [PATCH v2 05/12] bloblist: Drop unused tags Simon Glass
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13 18:00 UTC (permalink / raw)
  To: Simon Glass; +Cc: Tom Rini, U-Boot Mailing List

Use the convenience functions to improve readability.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/bloblist.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 06/12] bloblist: Use explicit numbering for the tags
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (16 preceding siblings ...)
  2022-01-13 18:00 ` [PATCH v2 09/12] bloblist: Refactor Kconfig to support alloc or fixed Simon Glass
@ 2022-01-13 18:00 ` Simon Glass
  2022-01-13 18:00 ` [PATCH v2 07/12] bloblist: Use LOG_CATEGORY to simply logging Simon Glass
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13 18:00 UTC (permalink / raw)
  To: Simon Glass; +Cc: Tom Rini, U-Boot Mailing List

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 <sjg@chromium.org>
---

(no changes since v1)

 common/bloblist.c  | 45 +++++++++++++++++++++++------------
 include/bloblist.h | 58 +++++++++++++++++++++++++++++++++++++---------
 test/bloblist.c    | 12 +++++-----
 3 files changed, 83 insertions(+), 32 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 05/12] bloblist: Drop unused tags
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (18 preceding siblings ...)
  2022-01-13 18:00 ` [PATCH v2 07/12] bloblist: Use LOG_CATEGORY to simply logging Simon Glass
@ 2022-01-13 18:00 ` Simon Glass
  2022-01-13 18:00 ` [PATCH v2 04/12] bloblist: Rename the SPL tag Simon Glass
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13 18:00 UTC (permalink / raw)
  To: Simon Glass; +Cc: Tom Rini, U-Boot Mailing List

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 <sjg@chromium.org>
---

(no changes since v1)

 common/bloblist.c  | 4 +---
 include/bloblist.h | 2 --
 test/bloblist.c    | 4 ++--
 3 files changed, 3 insertions(+), 7 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 04/12] bloblist: Rename the SPL tag
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (19 preceding siblings ...)
  2022-01-13 18:00 ` [PATCH v2 05/12] bloblist: Drop unused tags Simon Glass
@ 2022-01-13 18:00 ` Simon Glass
  2022-01-13 18:00 ` [PATCH v2 03/12] bloblist: Put the magic number first Simon Glass
  2022-01-13 18:00 ` [PATCH v2 02/12] fdt: Drop SPL_BUILD macro Simon Glass
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13 18:00 UTC (permalink / raw)
  To: Simon Glass; +Cc: Tom Rini, U-Boot Mailing List

Add a U_BOOT prefix to this tag since it is specific to the U-Boot
project.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/x86/cpu/broadwell/cpu_from_spl.c | 4 ++--
 common/bloblist.c                     | 2 +-
 common/board_f.c                      | 2 +-
 common/spl/spl.c                      | 4 ++--
 include/bloblist.h                    | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 03/12] bloblist: Put the magic number first
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (20 preceding siblings ...)
  2022-01-13 18:00 ` [PATCH v2 04/12] bloblist: Rename the SPL tag Simon Glass
@ 2022-01-13 18:00 ` Simon Glass
  2022-01-13 18:00 ` [PATCH v2 02/12] fdt: Drop SPL_BUILD macro Simon Glass
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13 18:00 UTC (permalink / raw)
  To: Simon Glass; +Cc: Tom Rini, U-Boot Mailing List

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 <sjg@chromium.org>
---

(no changes since v1)

 include/bloblist.h | 25 +++++++++++++++++++++++--
 test/bloblist.c    |  7 +++++++
 2 files changed, 30 insertions(+), 2 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 02/12] fdt: Drop SPL_BUILD macro
  2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
                   ` (21 preceding siblings ...)
  2022-01-13 18:00 ` [PATCH v2 03/12] bloblist: Put the magic number first Simon Glass
@ 2022-01-13 18:00 ` Simon Glass
  22 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2022-01-13 18:00 UTC (permalink / raw)
  To: Simon Glass; +Cc: Tom Rini, Jerry Van Baren, U-Boot Mailing List

This old macro is not needed anymore since we can use IS_ENABLED() now.
Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 drivers/serial/serial-uclass.c | 3 ++-
 include/fdtdec.h               | 6 ------
 2 files changed, 2 insertions(+), 7 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2022-01-13 18:03 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-13  2:26 [PATCH v2 00/12] bloblist: Enhancements for standard passage Simon Glass
2022-01-13  2:26 ` [PATCH v2 01/12] stddef: Avoid warning with clang with offsetof() Simon Glass
2022-01-13  2:26 ` [PATCH v2 02/12] fdt: Drop SPL_BUILD macro Simon Glass
2022-01-13  2:26 ` [PATCH v2 03/12] bloblist: Put the magic number first Simon Glass
2022-01-13  2:26 ` [PATCH v2 04/12] bloblist: Rename the SPL tag Simon Glass
2022-01-13  2:26 ` [PATCH v2 05/12] bloblist: Drop unused tags Simon Glass
2022-01-13  2:26 ` [PATCH v2 06/12] bloblist: Use explicit numbering for the tags Simon Glass
2022-01-13  2:26 ` [PATCH v2 07/12] bloblist: Use LOG_CATEGORY to simply logging Simon Glass
2022-01-13  2:26 ` [PATCH v2 08/12] bloblist: Use 'phase' consistently for bloblists Simon Glass
2022-01-13  2:26 ` [PATCH v2 09/12] bloblist: Refactor Kconfig to support alloc or fixed Simon Glass
2022-01-13  2:26 ` [PATCH v2 10/12] bloblist: Add functions to obtain base address and size Simon Glass
2022-01-13  2:26 ` [PATCH v2 11/12] bloblist: doc: Bring in the API documentation Simon Glass
2022-01-13  2:26 ` [PATCH v2 12/12] bloblist: Relicense to allow BSD-3-Clause Simon Glass
2022-01-13 18:00 ` Simon Glass
2022-01-13 18:00 ` [PATCH v2 11/12] bloblist: doc: Bring in the API documentation Simon Glass
2022-01-13 18:00 ` [PATCH v2 10/12] bloblist: Add functions to obtain base address and size Simon Glass
2022-01-13 18:00 ` [PATCH v2 08/12] bloblist: Use 'phase' consistently for bloblists Simon Glass
2022-01-13 18:00 ` [PATCH v2 09/12] bloblist: Refactor Kconfig to support alloc or fixed Simon Glass
2022-01-13 18:00 ` [PATCH v2 06/12] bloblist: Use explicit numbering for the tags Simon Glass
2022-01-13 18:00 ` [PATCH v2 07/12] bloblist: Use LOG_CATEGORY to simply logging Simon Glass
2022-01-13 18:00 ` [PATCH v2 05/12] bloblist: Drop unused tags Simon Glass
2022-01-13 18:00 ` [PATCH v2 04/12] bloblist: Rename the SPL tag Simon Glass
2022-01-13 18:00 ` [PATCH v2 03/12] bloblist: Put the magic number first Simon Glass
2022-01-13 18:00 ` [PATCH v2 02/12] fdt: Drop SPL_BUILD macro Simon Glass

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.