Skip to contentSkip to conversation

spl: Add features for passing info from SPL to U-Boot proper

PATCH New Simon Glass 2 participants 44 messages Nov 16, 2018 – Nov 27, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover spl: Add features for passing info from SPL to U-Boot proper

At present we have no standard way of passing information from SPL to U-Boot. Such information may be the size of DRAM banks or some information about the reset state of the machine,for example.

This series first adds a bloblist, which allows a list of 'blobs' to be created, each with a tag so that subsystems can store data and retrieve it later. Then it adds the SPL 'handoff' information, which uses bloblist.

Various minor sandbox enhancements are provided to make this easier, or to support testing.

Changes in v3:
- Add comments to the log_ret() functions to indicate usage
- Update log_msg_ret() to make use of the message and avoid a warning
- Correct CONFIG_BLOBLIST_ADDR to have a default only for sandbox
- Drop patch 'spl: Print a message if we are unable to load an image'

Changes in v2:
- Fix several typos
- Add back a blank line, and put one in the new function too
- Drop the wildcard in the .lds file as it is not needed

Simon Glass (21):
spl: Add support for logging in SPL and TPL
Add core support for a bloblist to convey data from SPL
spl: Set up the bloblist in SPL
bloblist: Locate bloblist in U-Boot
test: Add a simple test for bloblist
Add bloblist documentation
spl: Support hash, input, pch, pci, rtc, tpm in SPL
spl: Add a define for SPL_TPL_PROMPT
spl: Make SPL_DISABLE_BANNER_PRINT a positive option
spl: Add a comment to spl_set_bd()
sandbox: Add a memory map to the sandbox README test/py: Add a way to pass flags to sandbox
sandbox: Add an option to display of-platdata in SPL
sandbox: Drop the deprecated 'sb' command
sandbox: Add a new 'sb' command
sandbox: Allow puts() output before global_data is set up
sandbox: Refactor code to create os_jump_to_file()
sandbox: Use malloc() and free() from os layer
sandbox: Filter arguments when starting U-Boot
sandbox: Boot in U-Boot through the standard call
spl: Add support for passing handoff info to U-Boot proper

 arch/Kconfig                       |   1 +
 arch/powerpc/include/asm/spl.h     |   3 -
 arch/sandbox/cpu/eth-raw-os.c      |   9 +-
 arch/sandbox/cpu/os.c              | 115 +++++++++-----
 arch/sandbox/cpu/spl.c             |  31 +++-
 arch/sandbox/cpu/start.c           |  19 +++
 arch/sandbox/cpu/u-boot-spl.lds    |   2 +-
 arch/sandbox/include/asm/handoff.h |  18 +++
 arch/sandbox/include/asm/state.h   |   8 +
 board/sandbox/README.sandbox       |  14 +-
 cmd/Makefile                       |   1 +
 cmd/host.c                         |   5 -
 cmd/sb.c                           |  65 ++++++++
 common/Kconfig                     |  84 +++++++++-
 common/Makefile                    |   5 +-
 common/bloblist.c                  | 239 +++++++++++++++++++++++++++++
 common/board_f.c                   |  49 ++++++
 common/console.c                   |   7 +
 common/init/Makefile               |   1 +
 common/init/handoff.c              |  47 ++++++
 common/spl/Kconfig                 |  95 +++++++++++-
 common/spl/spl.c                   | 135 ++++++++++++----
 configs/sandbox_spl_defconfig      |   1 +
 doc/README.bloblist                |  82 ++++++++++
 doc/README.trace                   |   2 +-
 drivers/Makefile                   |  11 +-
 include/asm-generic/global_data.h  |   7 +
 include/bloblist.h                 | 195 +++++++++++++++++++++++
 include/handoff.h                  |  36 +++++
 include/log.h                      |  20 ++-
 include/spl.h                      |  41 +++++
 include/test/suites.h              |   1 +
 test/Makefile                      |   1 +
 test/bloblist.c                    | 187 ++++++++++++++++++++++
 test/cmd_ut.c                      |   3 +
 test/dm/sf.c                       |   2 +-
 test/py/tests/test_fit.py          |  12 +-
 test/py/tests/test_handoff.py      |  14 ++
 test/py/tests/test_ofplatdata.py   |  31 +++-
 test/py/tests/test_vboot.py        |   2 +-
 test/py/u_boot_console_base.py     |   2 +-
 test/py/u_boot_console_sandbox.py  |  18 +++
 test/run                           |   2 +-
 43 files changed, 1516 insertions(+), 107 deletions(-)
 create mode 100644 arch/sandbox/include/asm/handoff.h
 create mode 100644 cmd/sb.c
 create mode 100644 common/bloblist.c
 create mode 100644 common/init/handoff.c
 create mode 100644 doc/README.bloblist
 create mode 100644 include/bloblist.h
 create mode 100644 include/handoff.h
 create mode 100644 test/bloblist.c
 create mode 100644 test/py/tests/test_handoff.py
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#1 lore raw

PATCH v3 1/21 spl: Add support for logging in SPL and TPL

It is sometimes useful to log information in SPL and TPL. Add support for this.

---

Changes in v3:
- Add comments to the log_ret() functions to indicate usage
- Update log_msg_ret() to make use of the message and avoid a warning

Changes in v2: None

 common/Kconfig   | 36 ++++++++++++++++++++++++++++++++++--
 common/Makefile  |  4 ++--
 common/spl/spl.c |  7 +++++++
 include/log.h    | 19 +++++++++++++++++--
 4 files changed, 60 insertions(+), 6 deletions(-)
common/Kconfig +34 -2
index d7300c212f5..9bc329a0e61 100644
@@ -290,6 +290,10 @@ config SPL_LOGLEVEL
 	int
 	default LOGLEVEL
 
+config TPL_LOGLEVEL
+	int
+	default LOGLEVEL
+
 config SILENT_CONSOLE
 	bool "Support a silent console"
 	help
@@ -486,6 +490,24 @@ config SPL_LOG_MAX_LEVEL
 	    6 - detail
 	    7 - debug
 
+config TPL_LOG_MAX_LEVEL
+	int "Maximum log level to record in TPL"
+	depends on TPL_LOG
+	default 3
+	help
+	  This selects the maximum log level that will be recorded. Any value
+	  higher than this will be ignored. If possible log statements below
+	  this level will be discarded at build time. Levels:
+
+	    0 - panic
+	    1 - critical
+	    2 - error
+	    3 - warning
+	    4 - note
+	    5 - info
+	    6 - detail
+	    7 - debug
+
 config LOG_CONSOLE
 	bool "Allow log output to the console"
 	depends on LOG
@@ -496,9 +518,19 @@ config LOG_CONSOLE
 	  log message is shown - other details like level, category, file and
 	  line number are omitted.
 
-config LOG_SPL_CONSOLE
+config SPL_LOG_CONSOLE
+	bool "Allow log output to the console in SPL"
+	depends on SPL_LOG
+	default y
+	help
+	  Enables a log driver which writes log records to the console.
+	  Generally the console is the serial port or LCD display. Only the
+	  log message is shown - other details like level, category, file and
+	  line number are omitted.
+
+config TPL_LOG_CONSOLE
 	bool "Allow log output to the console in SPL"
-	depends on LOG_SPL
+	depends on TPL_LOG
 	default y
 	help
 	  Enables a log driver which writes log records to the console.
common/Makefile +2 -2
index a2388364d9f..d18897b973b 100644
@@ -118,8 +118,8 @@ obj-y += cli.o
 obj-$(CONFIG_FSL_DDR_INTERACTIVE) += cli_simple.o cli_readline.o
 obj-$(CONFIG_DFU_OVER_USB) += dfu.o
 obj-y += command.o
-obj-$(CONFIG_$(SPL_)LOG) += log.o
-obj-$(CONFIG_$(SPL_)LOG_CONSOLE) += log_console.o
+obj-$(CONFIG_$(SPL_TPL_)LOG) += log.o
+obj-$(CONFIG_$(SPL_TPL_)LOG_CONSOLE) += log_console.o
 obj-y += s_record.o
 obj-$(CONFIG_CMD_LOADB) += xyzModem.o
 obj-$(CONFIG_$(SPL_TPL_)YMODEM_SUPPORT) += xyzModem.o
common/spl/spl.c +7 -0
index 12f9359c0ac..740182a8be6 100644
@@ -336,6 +336,13 @@ static int spl_common_init(bool setup_malloc)
 		return ret;
 	}
 	bootstage_mark_name(BOOTSTAGE_ID_START_SPL, "spl");
+#if CONFIG_IS_ENABLED(LOG)
+	ret = log_init();
+	if (ret) {
+		debug("%s: Failed to set up logging\n", __func__);
+		return ret;
+	}
+#endif
 	if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
 		ret = fdtdec_setup();
 		if (ret) {
include/log.h +17 -2
index a872fc6ef5f..ad6870bfed8 100644
@@ -107,6 +107,8 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file,
 #define log_io(_fmt...)
 #endif
 
+#if CONFIG_IS_ENABLED(LOG)
+
 /* Emit a log record if the level is less that the maximum */
 #define log(_cat, _level, _fmt, _args...) ({ \
 	int _l = _level; \
@@ -115,6 +117,9 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file,
 		      __func__, \
 		      pr_fmt(_fmt), ##_args); \
 	})
+#else
+#define log(_cat, _level, _fmt, _args...)
+#endif
 
 #ifdef DEBUG
 #define _DEBUG	1
@@ -174,7 +179,16 @@ void __assert_fail(const char *assertion, const char *file, unsigned int line,
 	({ if (!(x) && _DEBUG) \
 		__assert_fail(#x, __FILE__, __LINE__, __func__); })
 
-#ifdef CONFIG_LOG_ERROR_RETURN
+#if CONFIG_IS_ENABLED(LOG) && defined(CONFIG_LOG_ERROR_RETURN)
+/*
+ * Log an error return value, possibly with a message. Usage:
+ *
+ *	return log_ret(fred_call());
+ *
+ * or:
+ *
+ *	return log_msg_ret("fred failed", fred_call());
+ */
 #define log_ret(_ret) ({ \
 	int __ret = (_ret); \
 	if (__ret < 0) \
@@ -189,8 +203,9 @@ void __assert_fail(const char *assertion, const char *file, unsigned int line,
 	__ret; \
 	})
 #else
+/* Non-logging versions of the above which just return the error code */
 #define log_ret(_ret) (_ret)
-#define log_msg_ret(_msg, _ret) (_ret)
+#define log_msg_ret(_msg, _ret) ((void)(_msg), _ret)
 #endif
 
 /**
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#2 lore raw

PATCH v3 1/21 spl: Add support for logging in SPL and TPL

Quoted 5 lines · Simon Glass

It is sometimes useful to log information in SPL and TPL. Add support for this.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/5b762d8a/attachment.sig>
#3 lore raw

PATCH v3 2/21 Add core support for a bloblist to convey data from SPL

In reply to Simon Glass

At present there is no standard way in U-Boot to pass information from SPL to U-Boot proper. But sometimes SPL wants to convey information to U-Boot that U-Boot cannot easily figure out. For example, if SPL sets up SDRAM then it might want to pass the size of SDRAM, or the location of each bank, to U-Boot proper.

Add a new 'bloblist' feature which provides this. A bloblist is set up in the first phase of U-Boot that runs (i.e. TPL or SPL). The location of this info may be in SRAM or CAR (x86 cache-as-RAM) or somewhere else.

Information placed in this region is preserved (with a checksum) through TPL and SPL and ends up in U-Boot. At this point it is copied into SDRAM so it can be used after relocation.

---

Changes in v3:
- Correct CONFIG_BLOBLIST_ADDR to have a default only for sandbox

Changes in v2:
- Fix several typos

 common/Kconfig     |  48 +++++++++
 common/Makefile    |   1 +
 common/bloblist.c  | 239 +++++++++++++++++++++++++++++++++++++++++++++
 include/bloblist.h | 195 ++++++++++++++++++++++++++++++++++++
 include/log.h      |   1 +
 5 files changed, 484 insertions(+)
 create mode 100644 common/bloblist.c
 create mode 100644 include/bloblist.h
common/Kconfig +48 -0
index 9bc329a0e61..a44bfdef9f2 100644
@@ -715,4 +715,52 @@ config UPDATE_TFTP_MSEC_MAX
 
 endmenu
 
+menu "Blob list"
+
+config BLOBLIST
+	bool "Support for a bloblist"
+	help
+	  This enables support for a bloblist in U-Boot, which can be passed
+	  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.
+
+config SPL_BLOBLIST
+	bool "Support for a bloblist in SPL"
+	depends on BLOBLIST
+	default y if SPL
+	help
+	  This enables a bloblist in SPL. If this is the first part of U-Boot
+	  to run, then the bloblist is set up in SPL and passed to U-Boot
+	  proper. If TPL also has a bloblist, then SPL uses the one from there.
+
+config TPL_BLOBLIST
+	bool "Support for a bloblist in TPL"
+	depends on BLOBLIST
+	default y if TPL
+	help
+	  This enables a bloblist in TPL. The bloblist is set up in TPL and
+	  passed to SPL and U-Boot proper.
+
+config BLOBLIST_SIZE
+	hex "Size of bloblist"
+	depends on 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 stages.
+
+config BLOBLIST_ADDR
+	hex "Address of bloblist"
+	depends on BLOBLIST
+	default 0xe000 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.
+
+endmenu
+
 source "common/spl/Kconfig"
common/Makefile +1 -0
index d18897b973b..3d97a0dceae 100644
@@ -61,6 +61,7 @@ obj-$(CONFIG_CMDLINE) += cli_readline.o cli_simple.o
 endif # !CONFIG_SPL_BUILD
 
 obj-$(CONFIG_$(SPL_TPL_)BOOTSTAGE) += bootstage.o
+obj-$(CONFIG_$(SPL_TPL_)BLOBLIST) += bloblist.o
 
 ifdef CONFIG_SPL_BUILD
 ifdef CONFIG_SPL_DFU_SUPPORT
common/bloblist.c new file +239 -0

239 lines not on this page · raw message

include/bloblist.h new file +195 -0

195 lines not on this page · raw message

include/log.h +1 -0
index ad6870bfed8..61de319da65 100644
@@ -47,6 +47,7 @@ enum log_category_t {
 	LOGC_DT,	/* Device-tree */
 	LOGC_EFI,	/* EFI implementation */
 	LOGC_ALLOC,	/* Memory allocation */
+	LOGC_BLOBLIST,	/* Bloblist */
 
 	LOGC_COUNT,	/* Number of log categories */
 	LOGC_END,	/* Sentinel value for a list of log categories */
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#4 lore raw

PATCH v3 2/21 Add core support for a bloblist to convey data from SPL

Quoted 10 lines · Simon Glass

At present there is no standard way in U-Boot to pass information from SPL to U-Boot proper. But sometimes SPL wants to convey information to U-Boot that U-Boot cannot easily figure out. For example, if SPL sets up SDRAM then it might want to pass the size of SDRAM, or the location of each bank, to U-Boot proper.

Add a new 'bloblist' feature which provides this. A bloblist is set up in the first phase of U-Boot that runs (i.e. TPL or SPL). The location of this info may be in SRAM or CAR (x86 cache-as-RAM) or somewhere else.

Quoted 7 lines

Information placed in this region is preserved (with a checksum) through TPL and SPL and ends up in U-Boot. At this point it is copied into SDRAM so it can be used after relocation.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/cd4c97e9/attachment.sig>
#5 lore raw

PATCH v3 3/21 spl: Set up the bloblist in SPL

In reply to Simon Glass

The bloblist is normally set up in SPL ready for use by U-Boot. Add a simple implementation of this to the common SPL code.

---

Changes in v3: None
Changes in v2: None

 common/spl/spl.c | 18 ++++++++++++++++--
 include/spl.h    | 27 +++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 2 deletions(-)
common/spl/spl.c +16 -2
index 740182a8be6..eea92ec1f8c 100644
@@ -7,6 +7,7 @@
  */
 
 #include <common.h>
+#include <bloblist.h>
 #include <binman_sym.h>
 #include <dm.h>
 #include <spl.h>
@@ -343,6 +344,14 @@ static int spl_common_init(bool setup_malloc)
 		return ret;
 	}
 #endif
+	if (CONFIG_IS_ENABLED(BLOBLIST)) {
+		ret = bloblist_init();
+		if (ret) {
+			debug("%s: Failed to set up bloblist: ret=%d\n",
+			      __func__, ret);
+			return ret;
+		}
+	}
 	if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
 		ret = fdtdec_setup();
 		if (ret) {
@@ -481,6 +490,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 		BOOT_DEVICE_NONE,
 	};
 	struct spl_image_info spl_image;
+	int ret;
 
 	debug(">>spl:board_init_r()\n");
 
@@ -527,6 +537,12 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	}
 
 	spl_perform_fixups(&spl_image);
+	if (CONFIG_IS_ENABLED(BLOBLIST)) {
+		ret = bloblist_finish();
+		if (ret)
+			printf("Warning: Failed to finish bloblist (ret=%d)\n",
+			       ret);
+	}
 
 #ifdef CONFIG_CPU_V7M
 	spl_image.entry_point |= 0x1;
@@ -563,8 +579,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	      gd->malloc_ptr / 1024);
 #endif
 #ifdef CONFIG_BOOTSTAGE_STASH
-	int ret;
-
 	bootstage_mark_name(BOOTSTAGE_ID_END_SPL, "end_spl");
 	ret = bootstage_stash((void *)CONFIG_BOOTSTAGE_STASH_ADDR,
 			      CONFIG_BOOTSTAGE_STASH_SIZE);
include/spl.h +27 -0
index 9a439f468b9..a56032ae3eb 100644
@@ -21,6 +21,33 @@
 #define MMCSD_MODE_FS		2
 #define MMCSD_MODE_EMMCBOOT	3
 
+/*
+ * u_boot_first_phase() - check if this is the first U-Boot phase
+ *
+ * U-Boot has up to three phases: TPL, SPL and U-Boot proper. Depending on the
+ * build flags we can determine whether the current build is for the first
+ * phase of U-Boot or not. If there is no SPL, then this is U-Boot proper. If
+ * there is SPL but no TPL, the the first phase is SPL. If there is TPL, then
+ * it is the first phase.
+ *
+ * @returns true if this is the first phase of U-Boot
+ *
+ */
+static inline bool u_boot_first_phase(void)
+{
+	if (IS_ENABLED(CONFIG_TPL)) {
+		if (IS_ENABLED(CONFIG_TPL_BUILD))
+			return true;
+	} else if (IS_ENABLED(CONFIG_SPL)) {
+		if (IS_ENABLED(CONFIG_SPL_BUILD))
+			return true;
+	} else {
+		return true;
+	}
+
+	return false;
+}
+
 struct spl_image_info {
 	const char *name;
 	u8 os;
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#6 lore raw

PATCH v3 3/21 spl: Set up the bloblist in SPL

Quoted 4 lines · Simon Glass

The bloblist is normally set up in SPL ready for use by U-Boot. Add a simple implementation of this to the common SPL code.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/7e56fae8/attachment.sig>
#7 lore raw

PATCH v3 4/21 bloblist: Locate bloblist in U-Boot

In reply to Simon Glass

Add support for locating a bloblist in U-Boot that has been set up by SPL. It is copied into RAM during relocation.

---

Changes in v3: None
Changes in v2: None

 common/board_f.c                  | 34 +++++++++++++++++++++++++++++++
 include/asm-generic/global_data.h |  4 ++++
 2 files changed, 38 insertions(+)
common/board_f.c +34 -0
index 96503ff8d3c..42378537c8d 100644
@@ -10,6 +10,7 @@
  */
 
 #include <common.h>
+#include <bloblist.h>
 #include <console.h>
 #include <cpu.h>
 #include <dm.h>
@@ -560,6 +561,16 @@ static int reserve_stacks(void)
 	return arch_reserve_stacks();
 }
 
+static int reserve_bloblist(void)
+{
+#ifdef CONFIG_BLOBLIST
+	gd->start_addr_sp -= CONFIG_BLOBLIST_SIZE;
+	gd->new_bloblist = map_sysmem(gd->start_addr_sp, CONFIG_BLOBLIST_SIZE);
+#endif
+
+	return 0;
+}
+
 static int display_new_sp(void)
 {
 	debug("New Stack Pointer is: %08lx\n", gd->start_addr_sp);
@@ -666,6 +677,24 @@ static int reloc_bootstage(void)
 	return 0;
 }
 
+static int reloc_bloblist(void)
+{
+#ifdef CONFIG_BLOBLIST
+	if (gd->flags & GD_FLG_SKIP_RELOC)
+		return 0;
+	if (gd->new_bloblist) {
+		int size = CONFIG_BLOBLIST_SIZE;
+
+		debug("Copying bloblist from %p to %p, size %x\n",
+		      gd->bloblist, gd->new_bloblist, size);
+		memcpy(gd->new_bloblist, gd->bloblist, size);
+		gd->bloblist = gd->new_bloblist;
+	}
+#endif
+
+	return 0;
+}
+
 static int setup_reloc(void)
 {
 	if (gd->flags & GD_FLG_SKIP_RELOC) {
@@ -813,6 +842,9 @@ static const init_fnc_t init_sequence_f[] = {
 	initf_malloc,
 	log_init,
 	initf_bootstage,	/* uses its own timer, so does not need DM */
+#ifdef CONFIG_BLOBLIST
+	bloblist_init,
+#endif
 	initf_console_record,
 #if defined(CONFIG_HAVE_FSP)
 	arch_fsp_init,
@@ -913,6 +945,7 @@ static const init_fnc_t init_sequence_f[] = {
 	reserve_global_data,
 	reserve_fdt,
 	reserve_bootstage,
+	reserve_bloblist,
 	reserve_arch,
 	reserve_stacks,
 	dram_init_banksize,
@@ -932,6 +965,7 @@ static const init_fnc_t init_sequence_f[] = {
 	INIT_FUNC_WATCHDOG_RESET
 	reloc_fdt,
 	reloc_bootstage,
+	reloc_bloblist,
 	setup_reloc,
 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
 	copy_uboot_to_ram,
include/asm-generic/global_data.h +4 -0
index c83fc01b764..ccf361ed88a 100644
@@ -122,6 +122,10 @@ typedef struct global_data {
 	struct list_head log_head;	/* List of struct log_device */
 	int log_fmt;			/* Mask containing log format info */
 #endif
+#if CONFIG_IS_ENABLED(BLOBLIST)
+	struct bloblist_hdr *bloblist;	/* Bloblist information */
+	struct bloblist_hdr *new_bloblist;	/* Relocated blolist info */
+#endif
 } gd_t;
 #endif
 
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#8 lore raw

PATCH v3 4/21 bloblist: Locate bloblist in U-Boot

Quoted 5 lines · Simon Glass

Add support for locating a bloblist in U-Boot that has been set up by SPL. It is copied into RAM during relocation.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/988c4d1e/attachment.sig>
#9 lore raw

PATCH v3 5/21 test: Add a simple test for bloblist

In reply to Simon Glass

Add a unit test for the bloblist functionality and enable bloblist for sandbox.

---

Changes in v3: None
Changes in v2: None

 arch/Kconfig          |   1 +
 include/test/suites.h |   1 +
 test/Makefile         |   1 +
 test/bloblist.c       | 187 ++++++++++++++++++++++++++++++++++++++++++
 test/cmd_ut.c         |   3 +
 5 files changed, 193 insertions(+)
 create mode 100644 test/bloblist.c
arch/Kconfig +1 -0
index 9fdd2f7e66a..947070fdd35 100644
@@ -91,6 +91,7 @@ config SANDBOX
 	select SPI
 	select SUPPORT_OF_CONTROL
 	imply BITREVERSE
+	select BLOBLIST
 	imply CMD_DM
 	imply CMD_GETTIME
 	imply CMD_HASH
include/test/suites.h +1 -0
index abb3a4b8169..77d863b4a6a 100644
@@ -23,6 +23,7 @@ struct unit_test;
 int cmd_ut_category(const char *name, struct unit_test *tests, int n_ents,
 		    int argc, char * const argv[]);
 
+int do_ut_bloblist(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_compression(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 int do_ut_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
test/Makefile +1 -0
index 1e434730b68..2fe41f489c3 100644
@@ -2,6 +2,7 @@
 #
 # (C) Copyright 2012 The Chromium Authors
 
+obj-$(CONFIG_SANDBOX) += bloblist.o
 obj-$(CONFIG_UNIT_TEST) += cmd_ut.o
 obj-$(CONFIG_UNIT_TEST) += ut.o
 obj-$(CONFIG_SANDBOX) += command_ut.o
test/bloblist.c new file +187 -0

187 lines not on this page · raw message

test/cmd_ut.c +3 -0
index b7e01a4847e..56924a52726 100644
@@ -55,6 +55,8 @@ static cmd_tbl_t cmd_ut_sub[] = {
 #ifdef CONFIG_SANDBOX
 	U_BOOT_CMD_MKENT(compression, CONFIG_SYS_MAXARGS, 1, do_ut_compression,
 			 "", ""),
+	U_BOOT_CMD_MKENT(bloblist, CONFIG_SYS_MAXARGS, 1, do_ut_bloblist,
+			 "", ""),
 #endif
 };
 
@@ -97,6 +99,7 @@ static int do_ut(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 static char ut_help_text[] =
 	"all - execute all enabled tests\n"
 #ifdef CONFIG_SANDBOX
+	"ut bloblist - Test bloblist implementation\n"
 	"ut compression - Test compressors and bootm decompression\n"
 #endif
 #ifdef CONFIG_UT_DM
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#10 lore raw

PATCH v3 5/21 test: Add a simple test for bloblist

Quoted 4 lines · Simon Glass

Add a unit test for the bloblist functionality and enable bloblist for sandbox.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/edee3e30/attachment.sig>
#11 lore raw

PATCH v3 6/21 Add bloblist documentation

In reply to Simon Glass

Add a description of the purpose of bloblist and how to use it.

---

Changes in v3: None
Changes in v2: None

 doc/README.bloblist | 82 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 82 insertions(+)
 create mode 100644 doc/README.bloblist
doc/README.bloblist new file +82 -0
new file mode 100644
index 00000000000..b0e787b97db
@@ -0,0 +1,82 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+Blob Lists - bloblist
+=====================
+
+Introduction
+------------
+
+A bloblist provides a way to store collections of binary information (blobs) in
+a central structure. Each record of information is assigned a tag so that its
+owner can find it and update it. Each record is generally described by a C
+structure defined by the code that owns it.
+
+
+Passing state through the boot process
+--------------------------------------
+
+The bloblist is created when the first U-Boot component runs (often SPL,
+sometimes TPL). It is passed through to each successive part of the boot and
+can be accessed as needed. This provides a way to transfer state from one part
+to the next. For example, TPL may determine that a watchdog reset occurred by
+reading an SoC register. Reading the register may reset the value, so that it
+cannot be read a second time. So TPL can store that in a bloblist record which
+can be passed through to SPL and U-Boot proper, which can print a message
+indicating that something went wrong and the watchdog fired.
+
+
+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.
+
+
+Blob tags
+---------
+
+Each blob has a tag which is a 32-bit number. This uniquely identifies the
+owner of the blob. Blob tags are listed in enum blob_tag_t and are named
+with a BLOBT_ prefix.
+
+
+Single structure
+----------------
+
+There is normally only one bloblist in U-Boot. Since a bloblist can store
+multiple blobs it does not seem useful to allow multiple bloblists. Of course
+there could be reasons for this, such as needing to spread the blobs around in
+different memory areas due to fragmented memory, but it is simpler to just have
+a single bloblist.
+
+
+API
+---
+
+Bloblist provides a fairly simple API which allows blobs to be created  and
+found. All access is via the blob's tag.
+
+
+Finishing the bloblist
+----------------------
+
+When a part of U-Boot is about to jump to the next part, it can 'finish' the
+bloblist in preparation for the next stage. This involves adding a checksum so
+that the next stage can make sure that the data arrived safely. While the
+bloblist is in use, changes can be made which will affect the checksum, so it
+is easier to calculate the checksum at the end after all changes are made.
+
+
+Future work
+-----------
+
+Bootstage has a mechanism to 'stash' its records for passing to the next part.
+This should move to using bloblist, to avoid having its own mechanism for
+passing information between U-Boot parts.
+
+
+Simon Glass
+sjg at chromium.org
+12-Aug-2018
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#12 lore raw

PATCH v3 6/21 Add bloblist documentation

Quoted 3 lines · Simon Glass

Add a description of the purpose of bloblist and how to use it.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/439b0380/attachment.sig>
#13 lore raw

PATCH v3 7/21 spl: Support hash, input, pch, pci, rtc, tpm in SPL

In reply to Simon Glass

At present these subsystems are only supported in U-Boot proper but it is sometimes necessary to support them in SPL, or even TPL. Update the Kconfig and Makefile to support this. Also adjust GPIO so that it can be used in TPL if required.

---

Changes in v3: None
Changes in v2: None

 common/spl/Kconfig | 48 +++++++++++++++++++++++++++++++++++++++++++++-
 drivers/Makefile   | 11 ++++++-----
 2 files changed, 53 insertions(+), 6 deletions(-)
common/spl/Kconfig +47 -1
index d0564621d4d..365e692d8b5 100644
@@ -295,6 +295,16 @@ config SPL_HASH_SUPPORT
 	  this option to build system-specific drivers for hash acceleration
 	  as part of an SPL build.
 
+config TPL_HASH_SUPPORT
+	bool "Support hashing drivers in TPL"
+	select SHA1
+	select SHA256
+	help
+	  Enable hashing drivers in SPL. These drivers can be used to
+	  accelerate secure boot processing in secure applications. Enable
+	  this option to build system-specific drivers for hash acceleration
+	  as part of an SPL build.
+
 config SPL_DMA_SUPPORT
 	bool "Support DMA drivers"
 	help
@@ -376,7 +386,7 @@ config SPL_FPGA_SUPPORT
 	  within SPL.
 
 config SPL_GPIO_SUPPORT
-	bool "Support GPIO"
+	bool "Support GPIO in SPL"
 	help
 	  Enable support for GPIOs (General-purpose Input/Output) in SPL.
 	  GPIOs allow U-Boot to read the state of an input line (high or
@@ -928,6 +938,17 @@ config TPL_ENV_SUPPORT
 	help
 	  Enable environment support in TPL. See SPL_ENV_SUPPORT for details.
 
+config TPL_GPIO_SUPPORT
+	bool "Support GPIO in TPL"
+	help
+	  Enable support for GPIOs (General-purpose Input/Output) in TPL.
+	  GPIOs allow U-Boot to read the state of an input line (high or
+	  low) and set the state of an output line. This can be used to
+	  drive LEDs, control power to various system parts and read user
+	  input. GPIOs can be useful in TPL to enable a 'sign-of-life' LED,
+	  for example. Enable this option to build the drivers in
+	  drivers/gpio as part of an TPL build.
+
 config TPL_I2C_SUPPORT
 	bool "Support I2C"
 	help
@@ -963,6 +984,22 @@ config TPL_NAND_SUPPORT
 	help
 	  Enable support for NAND in TPL. See SPL_NAND_SUPPORT for details.
 
+config TPL_PCI_SUPPORT
+	bool "Support PCI drivers"
+	help
+	  Enable support for PCI in TPL. For platforms that need PCI to boot,
+	  or must perform some init using PCI in SPL, this provides the
+	  necessary driver support. This enables the drivers in drivers/pci
+	  as part of a TPL build.
+
+config TPL_PCH_SUPPORT
+	bool "Support PCH drivers"
+	help
+	  Enable support for PCH (Platform Controller Hub) devices in TPL.
+	  These are used to set up GPIOs and the SPI peripheral early in
+	  boot. This enables the drivers in drivers/pch as part of a TPL
+	  build.
+
 config TPL_RAM_SUPPORT
 	bool "Support booting from RAM"
 	help
@@ -977,6 +1014,15 @@ config TPL_RAM_DEVICE
 	  be already in memory when TPL takes over, e.g. loaded by the boot
 	  ROM.
 
+config TPL_RTC_SUPPORT
+	bool "Support RTC drivers"
+	help
+	  Enable RTC (Real-time Clock) support in TPL. This includes support
+	  for reading and setting the time. Some RTC devices also have some
+	  non-volatile (battery-backed) memory which is accessible if
+	  needed. This enables the drivers in drivers/rtc as part of an TPL
+	  build.
+
 config TPL_SERIAL_SUPPORT
 	bool "Support serial"
 	select TPL_PRINTF
drivers/Makefile +6 -5
index 4453c62ad33..55de10926ef 100644
@@ -2,14 +2,19 @@
 
 obj-$(CONFIG_$(SPL_TPL_)CLK) += clk/
 obj-$(CONFIG_$(SPL_TPL_)DM) += core/
+obj-$(CONFIG_$(SPL_TPL_)GPIO_SUPPORT) += gpio/
 obj-$(CONFIG_$(SPL_TPL_)DRIVERS_MISC_SUPPORT) += misc/ sysreset/ firmware/
 obj-$(CONFIG_$(SPL_TPL_)I2C_SUPPORT) += i2c/
+obj-$(CONFIG_$(SPL_TPL_)INPUT) += input/
 obj-$(CONFIG_$(SPL_TPL_)LED) += led/
 obj-$(CONFIG_$(SPL_TPL_)MMC_SUPPORT) += mmc/
 obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += mtd/nand/raw/
+obj-$(CONFIG_$(SPL_TPL_)PCH_SUPPORT) += pch/
+obj-$(CONFIG_$(SPL_TPL_)PCI_SUPPORT) += pci/
 obj-$(CONFIG_$(SPL_TPL_)PHY) += phy/
 obj-$(CONFIG_$(SPL_TPL_)PINCTRL) += pinctrl/
 obj-$(CONFIG_$(SPL_TPL_)RAM) += ram/
+obj-$(CONFIG_$(SPL_TPL_)RTC_SUPPORT) += rtc/
 obj-$(CONFIG_$(SPL_TPL_)SERIAL_SUPPORT) += serial/
 obj-$(CONFIG_$(SPL_TPL_)SPI_FLASH_SUPPORT) += mtd/spi/
 obj-$(CONFIG_$(SPL_TPL_)SPI_SUPPORT) += spi/
@@ -17,6 +22,7 @@ obj-$(CONFIG_$(SPL_TPL_)TIMER) += timer/
 obj-$(CONFIG_$(SPL_TPL_)VIRTIO) += virtio/
 obj-$(CONFIG_$(SPL_)DM_MAILBOX) += mailbox/
 obj-$(CONFIG_$(SPL_)REMOTEPROC) += remoteproc/
+obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm/
 
 ifndef CONFIG_TPL_BUILD
 ifdef CONFIG_SPL_BUILD
@@ -24,7 +30,6 @@ ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_BOOTCOUNT_LIMIT) += bootcount/
 obj-$(CONFIG_SPL_CPU_SUPPORT) += cpu/
 obj-$(CONFIG_SPL_CRYPTO_SUPPORT) += crypto/
-obj-$(CONFIG_SPL_GPIO_SUPPORT) += gpio/
 obj-$(CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT) += ddr/fsl/
 obj-$(CONFIG_ARMADA_38X) += ddr/marvell/a38x/
 obj-$(CONFIG_ARMADA_XP) += ddr/marvell/axp/
@@ -40,9 +45,6 @@ obj-$(CONFIG_SPL_DMA_SUPPORT) += dma/
 obj-$(CONFIG_SPL_ETH_SUPPORT) += net/
 obj-$(CONFIG_SPL_ETH_SUPPORT) += net/phy/
 obj-$(CONFIG_SPL_USB_ETHER) += net/phy/
-obj-$(CONFIG_SPL_PCI_SUPPORT) += pci/
-obj-$(CONFIG_SPL_PCH_SUPPORT) += pch/
-obj-$(CONFIG_SPL_RTC_SUPPORT) += rtc/
 obj-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += usb/musb-new/
 obj-$(CONFIG_SPL_USB_GADGET_SUPPORT) += usb/gadget/
 obj-$(CONFIG_SPL_USB_GADGET_SUPPORT) += usb/gadget/udc/
@@ -92,7 +94,6 @@ obj-y += scsi/
 obj-y += sound/
 obj-y += spmi/
 obj-y += sysreset/
-obj-y += tpm/
 obj-y += video/
 obj-y += watchdog/
 obj-$(CONFIG_QE) += qe/
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#14 lore raw

PATCH v3 7/21 spl: Support hash, input, pch, pci, rtc, tpm in SPL

Quoted 7 lines · Simon Glass

At present these subsystems are only supported in U-Boot proper but it is sometimes necessary to support them in SPL, or even TPL. Update the Kconfig and Makefile to support this. Also adjust GPIO so that it can be used in TPL if required.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/2b84a34b/attachment.sig>
#15 lore raw

PATCH v3 8/21 spl: Add a define for SPL_TPL_PROMPT

In reply to Simon Glass

We should use a macro rather than hard-coding the SPL prompt to 'spl' since the code can be used by TPL too. Add a macro that works for both and use it in various places.

This allows TPL to use the same code without printing confusing messages.

Note that the string is lower case ('spl', 'tpl') which is a change from previously.

---

Changes in v3: None
Changes in v2: None

 common/spl/spl.c               | 27 +++++++++++++++------------
 include/spl.h                  | 13 +++++++++++++
 test/py/u_boot_console_base.py |  2 +-
 3 files changed, 29 insertions(+), 13 deletions(-)
common/spl/spl.c +15 -12
index eea92ec1f8c..23be33c5c10 100644
@@ -58,8 +58,9 @@ __weak void show_boot_progress(int val) {}
 #ifdef CONFIG_SPL_OS_BOOT
 __weak int spl_start_uboot(void)
 {
-	puts("SPL: Please implement spl_start_uboot() for your board\n");
-	puts("SPL: Direct Linux boot not active!\n");
+	puts(SPL_TPL_PROMPT
+	     "Please implement spl_start_uboot() for your board\n");
+	puts(SPL_TPL_PROMPT "Direct Linux boot not active!\n");
 	return 1;
 }
 
@@ -101,13 +102,13 @@ void spl_fixup_fdt(void)
 	/* fixup the memory dt node */
 	err = fdt_shrink_to_minimum(fdt_blob, 0);
 	if (err == 0) {
-		printf("spl: fdt_shrink_to_minimum err - %d\n", err);
+		printf(SPL_TPL_PROMPT "fdt_shrink_to_minimum err - %d\n", err);
 		return;
 	}
 
 	err = arch_fixup_fdt(fdt_blob);
 	if (err) {
-		printf("spl: arch_fixup_fdt err - %d\n", err);
+		printf(SPL_TPL_PROMPT "arch_fixup_fdt err - %d\n", err);
 		return;
 	}
 #endif
@@ -186,7 +187,7 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
 	spl_image->os = IH_OS_U_BOOT;
 	spl_image->name = "U-Boot";
 
-	debug("spl: payload image: %32s load addr: 0x%lx size: %d\n",
+	debug(SPL_TPL_PROMPT "payload image: %32s load addr: 0x%lx size: %d\n",
 	      spl_image->name, spl_image->load_addr, spl_image->size);
 
 #ifdef CONFIG_SPL_FIT_SIGNATURE
@@ -256,7 +257,8 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
 		}
 		spl_image->os = image_get_os(header);
 		spl_image->name = image_get_name(header);
-		debug("spl: payload image: %32s load addr: 0x%lx size: %d\n",
+		debug(SPL_TPL_PROMPT
+		      "payload image: %32s load addr: 0x%lx size: %d\n",
 		      spl_image->name, spl_image->load_addr, spl_image->size);
 #else
 		/* LEGACY image not supported */
@@ -285,7 +287,8 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
 			spl_image->load_addr = CONFIG_SYS_LOAD_ADDR;
 			spl_image->entry_point = CONFIG_SYS_LOAD_ADDR;
 			spl_image->size = end - start;
-			debug("spl: payload zImage, load addr: 0x%lx size: %d\n",
+			debug(SPL_TPL_PROMPT
+			      "payload zImage, load addr: 0x%lx size: %d\n",
 			      spl_image->load_addr, spl_image->size);
 			return 0;
 		}
@@ -469,7 +472,7 @@ static int boot_from_devices(struct spl_image_info *spl_image,
 		if (loader)
 			printf("Trying to boot from %s\n", loader->name);
 		else
-			puts("SPL: Unsupported Boot Device!\n");
+			puts(SPL_TPL_PROMPT "Unsupported Boot Device!\n");
 #endif
 		if (loader && !spl_load_image(spl_image, loader)) {
 			spl_image->boot_device = spl_boot_list[i];
@@ -492,7 +495,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	struct spl_image_info spl_image;
 	int ret;
 
-	debug(">>spl:board_init_r()\n");
+	debug(">>" SPL_TPL_PROMPT "board_init_r()\n");
 
 	spl_set_bd();
 
@@ -532,7 +535,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 
 	if (boot_from_devices(&spl_image, spl_boot_list,
 			      ARRAY_SIZE(spl_boot_list))) {
-		puts("SPL: failed to boot from all boot devices\n");
+		puts(SPL_TPL_PROMPT "failed to boot from all boot devices\n");
 		hang();
 	}
 
@@ -605,8 +608,8 @@ void preloader_console_init(void)
 	gd->have_console = 1;
 
 #ifndef CONFIG_SPL_DISABLE_BANNER_PRINT
-	puts("\nU-Boot SPL " PLAIN_VERSION " (" U_BOOT_DATE " - " \
-			U_BOOT_TIME " " U_BOOT_TZ ")\n");
+	puts("\nU-Boot " SPL_TPL_NAME " " PLAIN_VERSION " (" U_BOOT_DATE " - "
+	     U_BOOT_TIME " " U_BOOT_TZ ")\n");
 #endif
 #ifdef CONFIG_SPL_DISPLAY_PRINT
 	spl_display_print();
include/spl.h +13 -0
index a56032ae3eb..205aaff4b9d 100644
@@ -48,6 +48,19 @@ static inline bool u_boot_first_phase(void)
 	return false;
 }
 
+/* A string name for SPL or TPL */
+#ifdef CONFIG_SPL_BUILD
+# ifdef CONFIG_TPL_BUILD
+#  define SPL_TPL_NAME	"tpl"
+# else
+#  define SPL_TPL_NAME	"spl"
+# endif
+# define SPL_TPL_PROMPT	SPL_TPL_NAME ": "
+#else
+# define SPL_TPL_NAME	""
+# define SPL_TPL_PROMPT	""
+#endif
+
 struct spl_image_info {
 	const char *name;
 	u8 os;
test/py/u_boot_console_base.py +1 -1
index 326b2ac51fb..e044eb3ea1d 100644
@@ -16,7 +16,7 @@ import sys
 import u_boot_spawn
 
 # Regexes for text we expect U-Boot to send to the console.
-pattern_u_boot_spl_signon = re.compile('(U-Boot SPL \\d{4}\\.\\d{2}[^\r\n]*\\))')
+pattern_u_boot_spl_signon = re.compile('(U-Boot spl \\d{4}\\.\\d{2}[^\r\n]*\\))')
 pattern_u_boot_main_signon = re.compile('(U-Boot \\d{4}\\.\\d{2}[^\r\n]*\\))')
 pattern_stop_autoboot_prompt = re.compile('Hit any key to stop autoboot: ')
 pattern_unknown_command = re.compile('Unknown command \'.*\' - try \'help\'')
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#16 lore raw

PATCH v3 8/21 spl: Add a define for SPL_TPL_PROMPT

Quoted 11 lines · Simon Glass

We should use a macro rather than hard-coding the SPL prompt to 'spl' since the code can be used by TPL too. Add a macro that works for both and use it in various places.

This allows TPL to use the same code without printing confusing messages.

Note that the string is lower case ('spl', 'tpl') which is a change from previously.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/58c5840c/attachment.sig>
#17 lore raw

PATCH v3 9/21 spl: Make SPL_DISABLE_BANNER_PRINT a positive option

In reply to Simon Glass

Rather than having a negative option, make this a positive option and enable it by default. This makes it easier to understand.

---

Changes in v3: None
Changes in v2: None

 common/spl/Kconfig | 17 +++++++++++++----
 common/spl/spl.c   |  2 +-
 2 files changed, 14 insertions(+), 5 deletions(-)
common/spl/Kconfig +13 -4
index 365e692d8b5..32fa5758bf6 100644
@@ -135,12 +135,21 @@ config SPL_SEPARATE_BSS
 	  location is used. Normally we put the device tree at the end of BSS
 	  but with this option enabled, it goes at _image_binary_end.
 
-config SPL_DISABLE_BANNER_PRINT
-	bool "Disable output of the SPL banner 'U-Boot SPL ...'"
+config SPL_BANNER_PRINT
+	bool "Enable output of the SPL banner 'U-Boot SPL ...'"
+	default y
+	help
+	  If this option is enabled, SPL will print the banner with version
+	  info. Disabling this option could be useful to reduce TPL boot time
+	  (e.g. approx. 6 ms faster, when output on i.MX6 with 115200 baud).
+
+config TPL_BANNER_PRINT
+	bool "Enable output of the TPL banner 'U-Boot TPL ...'"
+	default y
 	help
 	  If this option is enabled, SPL will not print the banner with version
-	  info. Selecting this option could be useful to reduce SPL boot time
-	  (e.g. approx. 6 ms slower, when output on i.MX6 with 115200 baud).
+	  info. Disabling this option could be useful to reduce SPL boot time
+	  (e.g. approx. 6 ms faster, when output on i.MX6 with 115200 baud).
 
 config SPL_DISPLAY_PRINT
 	bool "Display a board-specific message in SPL"
common/spl/spl.c +1 -1
index 23be33c5c10..5a026b844e9 100644
@@ -607,7 +607,7 @@ void preloader_console_init(void)
 
 	gd->have_console = 1;
 
-#ifndef CONFIG_SPL_DISABLE_BANNER_PRINT
+#if CONFIG_IS_ENABLED(BANNER_PRINT)
 	puts("\nU-Boot " SPL_TPL_NAME " " PLAIN_VERSION " (" U_BOOT_DATE " - "
 	     U_BOOT_TIME " " U_BOOT_TZ ")\n");
 #endif
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#18 lore raw

PATCH v3 9/21 spl: Make SPL_DISABLE_BANNER_PRINT a positive option

Quoted 5 lines · Simon Glass

Rather than having a negative option, make this a positive option and enable it by default. This makes it easier to understand.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/66c64730/attachment.sig>
#19 lore raw

PATCH v3 10/21 spl: Add a comment to spl_set_bd()

In reply to Simon Glass

There is a strange feature to set global_data to a data-section variable early in SPL. This only works if SPL actually has access to SRAM which is not the case on x86, for eaxmple. Add a comment to this effect.

---

Changes in v3: None
Changes in v2: None

 common/spl/spl.c | 4 ++++
 1 file changed, 4 insertions(+)
common/spl/spl.c +4 -0
index 5a026b844e9..43137105bab 100644
@@ -378,6 +378,10 @@ static int spl_common_init(bool setup_malloc)
 
 void spl_set_bd(void)
 {
+	/*
+	 * NOTE: On some platforms (e.g. x86) bdata may be in flash and not
+	 * writeable.
+	 */
 	if (!gd->bd)
 		gd->bd = &bdata;
 }
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#20 lore raw

PATCH v3 10/21 spl: Add a comment to spl_set_bd()

Quoted 6 lines · Simon Glass

There is a strange feature to set global_data to a data-section variable early in SPL. This only works if SPL actually has access to SRAM which is not the case on x86, for eaxmple. Add a comment to this effect.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/fa12609e/attachment.sig>
#21 lore raw

PATCH v3 11/21 sandbox: Add a memory map to the sandbox README

In reply to Simon Glass

We have a few things in the memory map now, so add documentation for this to avoid confusion. Also note that it is possible to run all tests now.

---

Changes in v3: None
Changes in v2: None

 board/sandbox/README.sandbox | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
board/sandbox/README.sandbox +13 -1
index a28fc9f36c1..6d85901b38d 100644
@@ -418,7 +418,19 @@ coverage in U-Boot is limited, as we need to work to improve it.
 Note that many of these tests are implemented as commands which you can
 run natively on your board if desired (and enabled).
 
-It would be useful to have a central script to run all of these.
+To run all tests use "make check".
+
+
+Memory Map
+----------
+
+Sandbox has its own emulated memory starting at 0. Here are some of the things
+that are mapped into that memory:
+
+      0   CONFIG_SYS_FDT_LOAD_ADDR   Device tree
+   e000   CONFIG_BLOBLIST_ADDR       Blob list
+  10000   CONFIG_MALLOC_F_ADDR       Early memory allocation
+
 
 --
 Simon Glass <[email protected]>
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#22 lore raw

PATCH v3 11/21 sandbox: Add a memory map to the sandbox README

Quoted 4 lines · Simon Glass

We have a few things in the memory map now, so add documentation for this to avoid confusion. Also note that it is possible to run all tests now.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/ce22a45b/attachment.sig>
#23 lore raw

PATCH v3 12/21 test/py: Add a way to pass flags to sandbox

In reply to Simon Glass

It is sometimes useful to restart sandbox with some particular flags to test certain functionality. Add a new method to ConsoleSandbox to handle this, without changing the existing APIs.

---

Changes in v3: None
Changes in v2:
- Add back a blank line, and put one in the new function too

 test/py/u_boot_console_sandbox.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
test/py/u_boot_console_sandbox.py +18 -0
index 778f6d0983d..836f5a9e2b8 100644
@@ -24,6 +24,7 @@ class ConsoleSandbox(ConsoleBase):
         """
 
         super(ConsoleSandbox, self).__init__(log, config, max_fifo_fill=1024)
+        self.sandbox_flags = []
 
     def get_spawn(self):
         """Connect to a fresh U-Boot instance.
@@ -51,8 +52,25 @@ class ConsoleSandbox(ConsoleBase):
             '-d',
             self.config.dtb
         ]
+        cmd += self.sandbox_flags
         return Spawn(cmd, cwd=self.config.source_dir)
 
+    def restart_uboot_with_flags(self, flags):
+        """Run U-Boot with the given command-line flags
+
+        Args:
+            flags: List of flags to pass, each a string
+
+        Returns:
+            A u_boot_spawn.Spawn object that is attached to U-Boot.
+        """
+
+        try:
+            self.sandbox_flags = flags
+            return self.restart_uboot()
+        finally:
+            self.sandbox_flags = []
+
     def kill(self, sig):
         """Send a specific Unix signal to the sandbox process.
 
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#24 lore raw

PATCH v3 12/21 test/py: Add a way to pass flags to sandbox

Quoted 6 lines · Simon Glass

It is sometimes useful to restart sandbox with some particular flags to test certain functionality. Add a new method to ConsoleSandbox to handle this, without changing the existing APIs.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/e589f57f/attachment.sig>
#25 lore raw

PATCH v3 13/21 sandbox: Add an option to display of-platdata in SPL

In reply to Simon Glass

At present we don't have a test that of-platdata can be accessed in SPL. Add this in as a command-line option to SPL.

---

Changes in v3: None
Changes in v2:
- Drop the wildcard in the .lds file as it is not needed

 arch/sandbox/cpu/spl.c           | 14 ++++++++++++++
 arch/sandbox/cpu/start.c         |  9 +++++++++
 arch/sandbox/cpu/u-boot-spl.lds  |  2 +-
 arch/sandbox/include/asm/state.h |  1 +
 test/py/tests/test_ofplatdata.py | 31 ++++++++++++++++++++++++++++++-
 5 files changed, 55 insertions(+), 2 deletions(-)
arch/sandbox/cpu/spl.c +14 -0
index 42c149a4981..49f98644c02 100644
@@ -44,5 +44,19 @@ SPL_LOAD_IMAGE_METHOD("sandbox", 0, BOOT_DEVICE_BOARD, spl_board_load_image);
 
 void spl_board_init(void)
 {
+	struct sandbox_state *state = state_get_current();
+	struct udevice *dev;
+
 	preloader_console_init();
+	if (state->show_of_platdata) {
+		/*
+		 * Scan all the devices so that we can output their platform
+		 * data. See sandbox_spl_probe().
+		 */
+		printf("Scanning misc devices\n");
+		for (uclass_first_device(UCLASS_MISC, &dev);
+		     dev;
+		     uclass_next_device(&dev))
+			;
+	}
 }
arch/sandbox/cpu/start.c +9 -0
index 2ee3b485657..28ca35392c9 100644
@@ -283,6 +283,15 @@ static int sandbox_cmdline_cb_log_level(struct sandbox_state *state,
 SANDBOX_CMDLINE_OPT_SHORT(log_level, 'L', 1,
 			  "Set log level (0=panic, 7=debug)");
 
+static int sandbox_cmdline_cb_show_of_platdata(struct sandbox_state *state,
+					       const char *arg)
+{
+	state->show_of_platdata = true;
+
+	return 0;
+}
+SANDBOX_CMDLINE_OPT(show_of_platdata, 0, "Show of-platdata in SPL");
+
 int board_run_command(const char *cmdline)
 {
 	printf("## Commands are disabled. Please enable CONFIG_CMDLINE.\n");
arch/sandbox/cpu/u-boot-spl.lds +1 -1
index f97abdfa050..de65b01b33c 100644
@@ -14,7 +14,7 @@ SECTIONS
 	}
 
 	__u_boot_sandbox_option_start = .;
-	_u_boot_sandbox_getopt : { *(.u_boot_sandbox_getopt) }
+	_u_boot_sandbox_getopt : { KEEP(*(.u_boot_sandbox_getopt)) }
 	__u_boot_sandbox_option_end = .;
 
 	__bss_start = .;
arch/sandbox/include/asm/state.h +1 -0
index dcb6d5f5683..0a2e3c41ae3 100644
@@ -89,6 +89,7 @@ struct sandbox_state {
 	bool skip_delays;		/* Ignore any time delays (for test) */
 	bool show_test_output;		/* Don't suppress stdout in tests */
 	int default_log_level;		/* Default log level for sandbox */
+	bool show_of_platdata;		/* Show of-platdata in SPL */
 
 	/* Pointer to information for each SPI bus/cs */
 	struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS]
test/py/tests/test_ofplatdata.py +30 -1
index dd8a09f0324..98103ee71a9 100644
@@ -3,11 +3,40 @@
 
 import pytest
 
-OF_PLATDATA_OUTPUT = ''
+OF_PLATDATA_OUTPUT = '''
+of-platdata probe:
+bool 1
+byte 05
+bytearray 06 00 00
+int 1
+intarray 2 3 4 0
+longbytearray 09 0a 0b 0c 0d 0e 0f 10 11
+string message
+stringarray "multi-word" "message" ""
+of-platdata probe:
+bool 0
+byte 08
+bytearray 01 23 34
+int 3
+intarray 5 0 0 0
+longbytearray 09 00 00 00 00 00 00 00 00
+string message2
+stringarray "another" "multi-word" "message"
+of-platdata probe:
+bool 0
+byte 00
+bytearray 00 00 00
+int 0
+intarray 0 0 0 0
+longbytearray 00 00 00 00 00 00 00 00 00
+string <NULL>
+stringarray "one" "" ""
+'''
 
 @pytest.mark.buildconfigspec('spl_of_platdata')
 def test_ofplatdata(u_boot_console):
     """Test that of-platdata can be generated and used in sandbox"""
     cons = u_boot_console
+    cons.restart_uboot_with_flags(['--show_of_platdata'])
     output = cons.get_spawn_output().replace('\r', '')
     assert OF_PLATDATA_OUTPUT in output
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#26 lore raw

PATCH v3 13/21 sandbox: Add an option to display of-platdata in SPL

Quoted 4 lines · Simon Glass

At present we don't have a test that of-platdata can be accessed in SPL. Add this in as a command-line option to SPL.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/af34fe9d/attachment.sig>
#27 lore raw

PATCH v3 14/21 sandbox: Drop the deprecated 'sb' command

In reply to Simon Glass

The old 'sb' command was deprecated in 2015 and replaced with 'host'. Remove the remaining users and the command, so that the name is available for other purposes.

---

Changes in v3: None
Changes in v2: None

 cmd/host.c                  |  5 -----
 doc/README.trace            |  2 +-
 test/dm/sf.c                |  2 +-
 test/py/tests/test_fit.py   | 12 ++++++------
 test/py/tests/test_vboot.py |  2 +-
 5 files changed, 9 insertions(+), 14 deletions(-)
cmd/host.c +0 -5
index 645dba4de83..f7d3eae5b1a 100644
@@ -167,11 +167,6 @@ static int do_host(cmd_tbl_t *cmdtp, int flag, int argc,
 		return CMD_RET_USAGE;
 }
 
-U_BOOT_CMD(
-	sb,	8,	1,	do_host,
-	"Deprecated: use 'host' command instead.", ""
-);
-
 U_BOOT_CMD(
 	host, 8, 1, do_host,
 	"Miscellaneous host commands",
doc/README.trace +1 -1
index 74ba26a5a48..2e7ca3319a9 100644
@@ -88,7 +88,7 @@ stdin=serial
 stdout=serial
 
 Environment size: 117/8188 bytes
-=>sb save host 0 trace 0 ${profoffset}
+=>host save host 0 trace 0 ${profoffset}
 11405888 bytes written in 10 ms (1.1 GiB/s)
 =>reset
 
test/dm/sf.c +1 -1
index 35241b9f574..af49d7a2129 100644
@@ -28,7 +28,7 @@ static int dm_test_spi_flash(struct unit_test_state *uts)
 	 * benefit is worth the extra complexity.
 	 */
 	ut_asserteq(0, run_command_list(
-		"sb save hostfs - 0 spi.bin 200000;"
+		"host save hostfs - 0 spi.bin 200000;"
 		"sf probe;"
 		"sf test 0 10000", -1,  0));
 	/*
test/py/tests/test_fit.py +6 -6
index 34696e97679..49d6fea5716 100755
@@ -99,15 +99,15 @@ base_fdt = '''
 # then run the 'bootm' command, then save out memory from the places where
 # we expect 'bootm' to write things. Then quit.
 base_script = '''
-sb load hostfs 0 %(fit_addr)x %(fit)s
+host load hostfs 0 %(fit_addr)x %(fit)s
 fdt addr %(fit_addr)x
 bootm start %(fit_addr)x
 bootm loados
-sb save hostfs 0 %(kernel_addr)x %(kernel_out)s %(kernel_size)x
-sb save hostfs 0 %(fdt_addr)x %(fdt_out)s %(fdt_size)x
-sb save hostfs 0 %(ramdisk_addr)x %(ramdisk_out)s %(ramdisk_size)x
-sb save hostfs 0 %(loadables1_addr)x %(loadables1_out)s %(loadables1_size)x
-sb save hostfs 0 %(loadables2_addr)x %(loadables2_out)s %(loadables2_size)x
+host save hostfs 0 %(kernel_addr)x %(kernel_out)s %(kernel_size)x
+host save hostfs 0 %(fdt_addr)x %(fdt_out)s %(fdt_size)x
+host save hostfs 0 %(ramdisk_addr)x %(ramdisk_out)s %(ramdisk_size)x
+host save hostfs 0 %(loadables1_addr)x %(loadables1_out)s %(loadables1_size)x
+host save hostfs 0 %(loadables2_addr)x %(loadables2_out)s %(loadables2_size)x
 '''
 
 @pytest.mark.boardspec('sandbox')
test/py/tests/test_vboot.py +1 -1
index e9cbd57fbab..92144d4c1e3 100644
@@ -74,7 +74,7 @@ def test_vboot(u_boot_console):
         cons.restart_uboot()
         with cons.log.section('Verified boot %s %s' % (sha_algo, test_type)):
             output = cons.run_command_list(
-                ['sb load hostfs - 100 %stest.fit' % tmpdir,
+                ['host load hostfs - 100 %stest.fit' % tmpdir,
                 'fdt addr 100',
                 'bootm 100'])
         assert(expect_string in ''.join(output))
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#28 lore raw

PATCH v3 14/21 sandbox: Drop the deprecated 'sb' command

Quoted 5 lines · Simon Glass

The old 'sb' command was deprecated in 2015 and replaced with 'host'. Remove the remaining users and the command, so that the name is available for other purposes.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/cad2b356/attachment.sig>
#29 lore raw

PATCH v3 15/21 sandbox: Add a new 'sb' command

In reply to Simon Glass

The old 'sb' command was deprecated in 2015 and replaced with 'host'. It is useful to be able to access some internal sandbox state, particularly for testing.

Resurrect the old command and provide a way to print some basic state information (currently just the arguments to sandbox).

---

Changes in v3: None
Changes in v2: None

 arch/sandbox/cpu/start.c         | 10 +++++++
 arch/sandbox/include/asm/state.h |  7 +++++
 cmd/Makefile                     |  1 +
 cmd/sb.c                         | 46 ++++++++++++++++++++++++++++++++
 4 files changed, 64 insertions(+)
 create mode 100644 cmd/sb.c
arch/sandbox/cpu/start.c +10 -0
index 28ca35392c9..b1566a81435 100644
@@ -305,6 +305,16 @@ static void setup_ram_buf(struct sandbox_state *state)
 	gd->ram_size = state->ram_size;
 }
 
+void state_show(struct sandbox_state *state)
+{
+	char **p;
+
+	printf("Arguments:\n");
+	for (p = state->argv; *p; p++)
+		printf("%s ", *p);
+	printf("\n");
+}
+
 int main(int argc, char *argv[])
 {
 	struct sandbox_state *state;
arch/sandbox/include/asm/state.h +7 -0
index 0a2e3c41ae3..8fabe70a86d 100644
@@ -242,6 +242,13 @@ bool state_get_skip_delays(void);
  */
 void state_reset_for_test(struct sandbox_state *state);
 
+/**
+ * state_show() - Show information about the sandbox state
+ *
+ * @param state		Sandbox state to show
+ */
+void state_show(struct sandbox_state *state);
+
 /**
  * Initialize the test system state
  */
cmd/Makefile +1 -0
index 12a1330b062..68f22f1af91 100644
@@ -114,6 +114,7 @@ obj-$(CONFIG_CMD_ROCKUSB) += rockusb.o
 obj-$(CONFIG_SANDBOX) += host.o
 obj-$(CONFIG_CMD_SATA) += sata.o
 obj-$(CONFIG_CMD_NVME) += nvme.o
+obj-$(CONFIG_SANDBOX) += sb.o
 obj-$(CONFIG_CMD_SF) += sf.o
 obj-$(CONFIG_CMD_SCSI) += scsi.o disk.o
 obj-$(CONFIG_CMD_SHA1SUM) += sha1sum.o
cmd/sb.c new file +46 -0

46 lines not on this page · raw message

Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#30 lore raw

PATCH v3 15/21 sandbox: Add a new 'sb' command

Quoted 8 lines · Simon Glass

The old 'sb' command was deprecated in 2015 and replaced with 'host'. It is useful to be able to access some internal sandbox state, particularly for testing.

Resurrect the old command and provide a way to print some basic state information (currently just the arguments to sandbox).

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/278a363f/attachment.sig>
#31 lore raw

PATCH v3 16/21 sandbox: Allow puts() output before global_data is set up

In reply to Simon Glass

We support putc() in this case but not puts(), but this is more useful since it is what printf() uses.

This particularly affects debugging early in SPL, where currently printf() statements result in no output. Fix this by adding a special case into puts() for sandbox, just like putc().

---

Changes in v3: None
Changes in v2: None

 common/console.c | 7 +++++++
 1 file changed, 7 insertions(+)
common/console.c +7 -0
index 9a94f321922..0b0dd76256c 100644
@@ -535,6 +535,13 @@ void putc(const char c)
 
 void puts(const char *s)
 {
+#ifdef CONFIG_SANDBOX
+	/* sandbox can send characters to stdout before it has a console */
+	if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
+		os_puts(s);
+		return;
+	}
+#endif
 #ifdef CONFIG_DEBUG_UART
 	if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
 		while (*s) {
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#32 lore raw

PATCH v3 16/21 sandbox: Allow puts() output before global_data is set up

Quoted 9 lines · Simon Glass

We support putc() in this case but not puts(), but this is more useful since it is what printf() uses.

This particularly affects debugging early in SPL, where currently printf() statements result in no output. Fix this by adding a special case into puts() for sandbox, just like putc().

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/471ba4e9/attachment.sig>
#33 lore raw

PATCH v3 17/21 sandbox: Refactor code to create os_jump_to_file()

In reply to Simon Glass

At present os_jump_to_image() jumps to a given image, and this is written to a file. But it is useful to be able to jump to a file also.

To avoid duplicating code, split out the implementation of os_jump_to_image() into a new function that jumps to a file.

---

Changes in v3: None
Changes in v2: None

 arch/sandbox/cpu/os.c | 48 ++++++++++++++++++++++++++++++++++---------
 1 file changed, 38 insertions(+), 10 deletions(-)
arch/sandbox/cpu/os.c +38 -10
index 325ded51d8a..b4d7a252b54 100644
@@ -525,7 +525,18 @@ static int make_exec(char *fname, const void *data, int size)
 	return 0;
 }
 
-static int add_args(char ***argvp, const char *add_args[], int count)
+/**
+ * add_args() - Allocate a new argv with the given args
+ *
+ * This is used to create a new argv array with all the old arguments and some
+ * new ones that are passed in
+ *
+ * @argvp:  Returns newly allocated args list
+ * @add_args: Arguments to add, each a string
+ * @count: Number of arguments in @add_args
+ * @return 0 if OK, -ENOMEM if out of memory
+ */
+static int add_args(char ***argvp, char *add_args[], int count)
 {
 	char **argv;
 	int argc;
@@ -546,21 +557,26 @@ static int add_args(char ***argvp, const char *add_args[], int count)
 	return 0;
 }
 
-int os_jump_to_image(const void *dest, int size)
+/**
+ * os_jump_to_file() - Jump to a new program
+ *
+ * This saves the memory buffer, sets up arguments to the new process, then
+ * execs it.
+ *
+ * @fname: Filename to exec
+ * @return does not return on success, any return value is an error
+ */
+static int os_jump_to_file(const char *fname)
 {
 	struct sandbox_state *state = state_get_current();
-	char fname[30], mem_fname[30];
+	char mem_fname[30];
 	int fd, err;
-	const char *extra_args[5];
+	char *extra_args[5];
 	char **argv = state->argv;
 #ifdef DEBUG
-	int argc, i;
+	int i;
 #endif
 
-	err = make_exec(fname, dest, size);
-	if (err)
-		return err;
-
 	strcpy(mem_fname, "/tmp/u-boot.mem.XXXXXX");
 	fd = mkstemp(mem_fname);
 	if (fd < 0)
@@ -573,7 +589,7 @@ int os_jump_to_image(const void *dest, int size)
 	os_fd_restore();
 
 	extra_args[0] = "-j";
-	extra_args[1] = fname;
+	extra_args[1] = (char *)fname;
 	extra_args[2] = "-m";
 	extra_args[3] = mem_fname;
 	extra_args[4] = "--rm_memory";
@@ -598,6 +614,18 @@ int os_jump_to_image(const void *dest, int size)
 	return unlink(fname);
 }
 
+int os_jump_to_image(const void *dest, int size)
+{
+	char fname[30];
+	int err;
+
+	err = make_exec(fname, dest, size);
+	if (err)
+		return err;
+
+	return os_jump_to_file(fname);
+}
+
 int os_find_u_boot(char *fname, int maxlen)
 {
 	struct sandbox_state *state = state_get_current();
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#34 lore raw

PATCH v3 17/21 sandbox: Refactor code to create os_jump_to_file()

Quoted 7 lines · Simon Glass

At present os_jump_to_image() jumps to a given image, and this is written to a file. But it is useful to be able to jump to a file also.

To avoid duplicating code, split out the implementation of os_jump_to_image() into a new function that jumps to a file.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/f73e83b8/attachment.sig>
#35 lore raw

PATCH v3 18/21 sandbox: Use malloc() and free() from os layer

In reply to Simon Glass

At present sandbox calls malloc() from various places in the OS layer and this results in calls to U-Boot's malloc() implementation. It is better to use the on in the OS layer, since it does not mix allocations with the main U-Boot code.

Fix this by replacing calls with malloc() to os_malloc(), etc.

---

Changes in v3: None
Changes in v2: None

 arch/sandbox/cpu/eth-raw-os.c |  9 ++++++---
 arch/sandbox/cpu/os.c         | 18 +++++++++---------
 2 files changed, 15 insertions(+), 12 deletions(-)
arch/sandbox/cpu/eth-raw-os.c +6 -3
index 75bfaa4c90a..8d05bc2eda0 100644
@@ -11,6 +11,7 @@
 #include <netinet/in.h>
 #include <netinet/ip.h>
 #include <netinet/udp.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -23,6 +24,8 @@
 #include <linux/if_ether.h>
 #include <linux/if_packet.h>
 
+#include <os.h>
+
 struct sandbox_eth_raw_if_nameindex *sandbox_eth_raw_if_nameindex(void)
 {
 	return (struct sandbox_eth_raw_if_nameindex *)if_nameindex();
@@ -71,7 +74,7 @@ static int _raw_packet_start(struct eth_sandbox_raw_priv *priv,
 
 	/* Prepare device struct */
 	priv->local_bind_sd = -1;
-	priv->device = malloc(sizeof(struct sockaddr_ll));
+	priv->device = os_malloc(sizeof(struct sockaddr_ll));
 	if (priv->device == NULL)
 		return -ENOMEM;
 	device = priv->device;
@@ -144,7 +147,7 @@ static int _local_inet_start(struct eth_sandbox_raw_priv *priv)
 	/* Prepare device struct */
 	priv->local_bind_sd = -1;
 	priv->local_bind_udp_port = 0;
-	priv->device = malloc(sizeof(struct sockaddr_in));
+	priv->device = os_malloc(sizeof(struct sockaddr_in));
 	if (priv->device == NULL)
 		return -ENOMEM;
 	device = priv->device;
@@ -279,7 +282,7 @@ int sandbox_eth_raw_os_recv(void *packet, int *length,
 
 void sandbox_eth_raw_os_stop(struct eth_sandbox_raw_priv *priv)
 {
-	free(priv->device);
+	os_free(priv->device);
 	priv->device = NULL;
 	close(priv->sd);
 	priv->sd = -1;
arch/sandbox/cpu/os.c +9 -9
index b4d7a252b54..d3dc74db4b1 100644
@@ -343,7 +343,7 @@ void os_dirent_free(struct os_dirent_node *node)
 
 	while (node) {
 		next = node->next;
-		free(node);
+		os_free(node);
 		node = next;
 	}
 }
@@ -368,7 +368,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp)
 	/* Create a buffer upfront, with typically sufficient size */
 	dirlen = strlen(dirname) + 2;
 	len = dirlen + 256;
-	fname = malloc(len);
+	fname = os_malloc(len);
 	if (!fname) {
 		ret = -ENOMEM;
 		goto done;
@@ -381,7 +381,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp)
 			ret = errno;
 			break;
 		}
-		next = malloc(sizeof(*node) + strlen(entry->d_name) + 1);
+		next = os_malloc(sizeof(*node) + strlen(entry->d_name) + 1);
 		if (!next) {
 			os_dirent_free(head);
 			ret = -ENOMEM;
@@ -390,10 +390,10 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp)
 		if (dirlen + strlen(entry->d_name) > len) {
 			len = dirlen + strlen(entry->d_name);
 			old_fname = fname;
-			fname = realloc(fname, len);
+			fname = os_realloc(fname, len);
 			if (!fname) {
-				free(old_fname);
-				free(next);
+				os_free(old_fname);
+				os_free(next);
 				os_dirent_free(head);
 				ret = -ENOMEM;
 				goto done;
@@ -427,7 +427,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp)
 
 done:
 	closedir(dir);
-	free(fname);
+	os_free(fname);
 	return ret;
 }
 
@@ -544,7 +544,7 @@ static int add_args(char ***argvp, char *add_args[], int count)
 	for (argv = *argvp, argc = 0; (*argvp)[argc]; argc++)
 		;
 
-	argv = malloc((argc + count + 1) * sizeof(char *));
+	argv = os_malloc((argc + count + 1) * sizeof(char *));
 	if (!argv) {
 		printf("Out of memory for %d argv\n", count);
 		return -ENOMEM;
@@ -607,7 +607,7 @@ static int os_jump_to_file(const char *fname)
 		os_exit(2);
 
 	err = execv(fname, argv);
-	free(argv);
+	os_free(argv);
 	if (err)
 		return err;
 
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#36 lore raw

PATCH v3 18/21 sandbox: Use malloc() and free() from os layer

Quoted 9 lines · Simon Glass

At present sandbox calls malloc() from various places in the OS layer and this results in calls to U-Boot's malloc() implementation. It is better to use the on in the OS layer, since it does not mix allocations with the main U-Boot code.

Fix this by replacing calls with malloc() to os_malloc(), etc.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/689f6518/attachment.sig>
#37 lore raw

PATCH v3 19/21 sandbox: Filter arguments when starting U-Boot

In reply to Simon Glass

The current method of starting U-Boot from U-Boot adds arguments to pass the memory file through, so that memory is preserved. This is fine for a single call, but if we call from TPL -> SPL -> U-Boot the arguments build up and we have several memory files in the argument list.

Adjust the implementation to filter out arguments that we want to replace with new ones. Also print a useful error if the exec() call fails.

---

Changes in v3: None
Changes in v2: None

 arch/sandbox/cpu/os.c | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)
arch/sandbox/cpu/os.c +26 -6
index d3dc74db4b1..5e55d31be9d 100644
@@ -538,10 +538,10 @@ static int make_exec(char *fname, const void *data, int size)
  */
 static int add_args(char ***argvp, char *add_args[], int count)
 {
-	char **argv;
+	char **argv, **ap;
 	int argc;
 
-	for (argv = *argvp, argc = 0; (*argvp)[argc]; argc++)
+	for (argc = 0; (*argvp)[argc]; argc++)
 		;
 
 	argv = os_malloc((argc + count + 1) * sizeof(char *));
@@ -549,7 +549,24 @@ static int add_args(char ***argvp, char *add_args[], int count)
 		printf("Out of memory for %d argv\n", count);
 		return -ENOMEM;
 	}
-	memcpy(argv, *argvp, argc * sizeof(char *));
+	for (ap = *argvp, argc = 0; *ap; ap++) {
+		char *arg = *ap;
+
+		/* Drop args that we don't want to propagate */
+		if (*arg == '-' && strlen(arg) == 2) {
+			switch (arg[1]) {
+			case 'j':
+			case 'm':
+				ap++;
+				continue;
+			}
+		} else if (!strcmp(arg, "--rm_memory")) {
+			ap++;
+			continue;
+		}
+		argv[argc++] = arg;
+	}
+
 	memcpy(argv + argc, add_args, count * sizeof(char *));
 	argv[argc + count] = NULL;
 
@@ -573,6 +590,7 @@ static int os_jump_to_file(const char *fname)
 	int fd, err;
 	char *extra_args[5];
 	char **argv = state->argv;
+	int argc;
 #ifdef DEBUG
 	int i;
 #endif
@@ -592,11 +610,13 @@ static int os_jump_to_file(const char *fname)
 	extra_args[1] = (char *)fname;
 	extra_args[2] = "-m";
 	extra_args[3] = mem_fname;
-	extra_args[4] = "--rm_memory";
-	err = add_args(&argv, extra_args,
-		       sizeof(extra_args) / sizeof(extra_args[0]));
+	argc = 4;
+	if (state->ram_buf_rm)
+		extra_args[argc++] = "--rm_memory";
+	err = add_args(&argv, extra_args, argc);
 	if (err)
 		return err;
+	argv[0] = (char *)fname;
 
 #ifdef DEBUG
 	for (i = 0; argv[i]; i++)
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#38 lore raw

PATCH v3 19/21 sandbox: Filter arguments when starting U-Boot

Quoted 9 lines · Simon Glass

The current method of starting U-Boot from U-Boot adds arguments to pass the memory file through, so that memory is preserved. This is fine for a single call, but if we call from TPL -> SPL -> U-Boot the arguments build up and we have several memory files in the argument list.

Adjust the implementation to filter out arguments that we want to replace with new ones. Also print a useful error if the exec() call fails.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/6262026b/attachment.sig>
#39 lore raw

PATCH v3 20/21 sandbox: Boot in U-Boot through the standard call

In reply to Simon Glass

Most architectures use jump_to_image_no_args() to jump from SPL to U-Boot. At present sandbox is special in that it jumps in its spl_board_load_image() call. This is not strictly correct, and means that sandbox misses out some parts of board_init_r(), just as calling bloblist_finish(), for example.

Change spl_board_load_image() to just identify the filename to boot, and implement jump_to_image_no_args() to actually jump to it.

---

Changes in v3: None
Changes in v2: None

 arch/sandbox/cpu/os.c  | 17 +++++------------
 arch/sandbox/cpu/spl.c | 17 +++++++++++++++--
 2 files changed, 20 insertions(+), 14 deletions(-)
arch/sandbox/cpu/os.c +5 -12
index 5e55d31be9d..eef4390b294 100644
@@ -628,8 +628,11 @@ static int os_jump_to_file(const char *fname)
 
 	err = execv(fname, argv);
 	os_free(argv);
-	if (err)
+	if (err) {
+		perror("Unable to run image");
+		printf("Image filename '%s'\n", mem_fname);
 		return err;
+	}
 
 	return unlink(fname);
 }
@@ -709,17 +712,7 @@ int os_find_u_boot(char *fname, int maxlen)
 
 int os_spl_to_uboot(const char *fname)
 {
-	struct sandbox_state *state = state_get_current();
-	char *argv[state->argc + 1];
-	int ret;
-
-	memcpy(argv, state->argv, sizeof(char *) * (state->argc + 1));
-	argv[0] = (char *)fname;
-	ret = execv(fname, argv);
-	if (ret)
-		return ret;
-
-	return unlink(fname);
+	return os_jump_to_file(fname);
 }
 
 void os_localtime(struct rtc_time *rt)
arch/sandbox/cpu/spl.c +15 -2
index 49f98644c02..5005ed2f54a 100644
@@ -37,8 +37,12 @@ static int spl_board_load_image(struct spl_image_info *spl_image,
 		return ret;
 	}
 
-	/* Hopefully this will not return */
-	return os_spl_to_uboot(fname);
+	/* Set up spl_image to boot from jump_to_image_no_args() */
+	spl_image->arg = strdup(fname);
+	if (!spl_image->arg)
+		return log_msg_ret("Setup exec filename", -ENOMEM);
+
+	return 0;
 }
 SPL_LOAD_IMAGE_METHOD("sandbox", 0, BOOT_DEVICE_BOARD, spl_board_load_image);
 
@@ -60,3 +64,12 @@ void spl_board_init(void)
 			;
 	}
 }
+
+void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
+{
+	const char *fname = spl_image->arg;
+
+	os_fd_restore();
+	os_spl_to_uboot(fname);
+	hang();
+}
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#40 lore raw

PATCH v3 20/21 sandbox: Boot in U-Boot through the standard call

Quoted 10 lines · Simon Glass

Most architectures use jump_to_image_no_args() to jump from SPL to U-Boot. At present sandbox is special in that it jumps in its spl_board_load_image() call. This is not strictly correct, and means that sandbox misses out some parts of board_init_r(), just as calling bloblist_finish(), for example.

Change spl_board_load_image() to just identify the filename to boot, and implement jump_to_image_no_args() to actually jump to it.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/e5ea4107/attachment.sig>
#41 lore raw

PATCH v3 21/21 spl: Add support for passing handoff info to U-Boot proper

In reply to Simon Glass

There is some basic informaton that SPL normally wants to pass through to U-Boot, such as the SDRAM size and bank information.

Mkae use of the new bloblist structure for this. Add a new 'handoff' blob which is set up in SPL and passed to U-Boot proper. Also adda test for sandbox_spl that checks that this works correctly and a new 'sb' command to show the information passed from SPL.

---

Changes in v3:
- Drop patch 'spl: Print a message if we are unable to load an image'

Changes in v2: None

 arch/powerpc/include/asm/spl.h     |  3 --
 arch/sandbox/include/asm/handoff.h | 18 +++++++
 cmd/sb.c                           | 21 +++++++-
 common/board_f.c                   | 15 ++++++
 common/init/Makefile               |  1 +
 common/init/handoff.c              | 47 ++++++++++++++++++
 common/spl/Kconfig                 | 30 ++++++++++++
 common/spl/spl.c                   | 77 +++++++++++++++++++++++++-----
 configs/sandbox_spl_defconfig      |  1 +
 include/asm-generic/global_data.h  |  3 ++
 include/handoff.h                  | 36 ++++++++++++++
 include/spl.h                      |  1 +
 test/py/tests/test_handoff.py      | 14 ++++++
 test/run                           |  2 +-
 14 files changed, 252 insertions(+), 17 deletions(-)
 create mode 100644 arch/sandbox/include/asm/handoff.h
 create mode 100644 common/init/handoff.c
 create mode 100644 include/handoff.h
 create mode 100644 test/py/tests/test_handoff.py
arch/powerpc/include/asm/spl.h +0 -3
index cd6d31c71a7..60a7d37d30b 100644
@@ -8,7 +8,4 @@
 
 #define BOOT_DEVICE_NOR		1
 
-/* Linker symbols */
-extern char __bss_start[], __bss_end[];
-
 #endif
arch/sandbox/include/asm/handoff.h new file +18 -0
new file mode 100644
index 00000000000..be4e7b0fae2
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Architecture-specific SPL handoff information for sandbox
+ *
+ * Copyright 2018 Google, Inc
+ * Written by Simon Glass <[email protected]>
+ */
+
+#ifndef __handoff_h
+#define __handoff_h
+
+#define TEST_HANDOFF_MAGIC	0x14f93c7b
+
+struct arch_spl_handoff {
+	ulong	magic;		/* Used for testing */
+};
+
+#endif
cmd/sb.c +20 -1
index 6ca3361d7e3..5701e03797c 100644
@@ -9,6 +9,23 @@
 #include <spl.h>
 #include <asm/state.h>
 
+static int do_sb_handoff(cmd_tbl_t *cmdtp, int flag, int argc,
+			 char *const argv[])
+{
+#if CONFIG_IS_ENABLED(HANDOFF)
+	if (gd->spl_handoff)
+		printf("SPL handoff magic %lx\n", gd->spl_handoff->arch.magic);
+	else
+		printf("SPL handoff info not received\n");
+
+	return 0;
+#else
+	printf("Command not supported\n");
+
+	return CMD_RET_USAGE;
+#endif
+}
+
 static int do_sb_state(cmd_tbl_t *cmdtp, int flag, int argc,
 		       char * const argv[])
 {
@@ -21,6 +38,7 @@ static int do_sb_state(cmd_tbl_t *cmdtp, int flag, int argc,
 }
 
 static cmd_tbl_t cmd_sb_sub[] = {
+	U_BOOT_CMD_MKENT(handoff, 1, 0, do_sb_handoff, "", ""),
 	U_BOOT_CMD_MKENT(state, 1, 0, do_sb_state, "", ""),
 };
 
@@ -42,5 +60,6 @@ static int do_sb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 U_BOOT_CMD(
 	sb,	8,	1,	do_sb,
 	"Sandbox status commands",
-	"state       - Show sandbox state"
+	"handoff     - Show handoff data received from SPL\n"
+	"sb state       - Show sandbox state"
 );
common/board_f.c +15 -0
index 42378537c8d..6516620de6f 100644
@@ -25,6 +25,9 @@
 #include <post.h>
 #include <relocate.h>
 #include <spi.h>
+#ifdef CONFIG_SPL
+#include <spl.h>
+#endif
 #include <status_led.h>
 #include <sysreset.h>
 #include <timer.h>
@@ -286,6 +289,17 @@ static int setup_mon_len(void)
 	return 0;
 }
 
+static int setup_spl_handoff(void)
+{
+#if CONFIG_IS_ENABLED(HANDOFF)
+	gd->spl_handoff = bloblist_find(BLOBLISTT_SPL_HANDOFF,
+					sizeof(struct spl_handoff));
+	debug("Found SPL hand-off info %p\n", gd->spl_handoff);
+#endif
+
+	return 0;
+}
+
 __weak int arch_cpu_init(void)
 {
 	return 0;
@@ -845,6 +859,7 @@ static const init_fnc_t init_sequence_f[] = {
 #ifdef CONFIG_BLOBLIST
 	bloblist_init,
 #endif
+	setup_spl_handoff,
 	initf_console_record,
 #if defined(CONFIG_HAVE_FSP)
 	arch_fsp_init,
common/init/Makefile +1 -0
index 4902635f535..853b56d1e57 100644
@@ -5,3 +5,4 @@
 #
 
 obj-y += board_init.o
+obj-$(CONFIG_$(SPL_TPL_)HANDOFF) += handoff.o
common/init/handoff.c new file +47 -0

47 lines not on this page · raw message

common/spl/Kconfig +30 -0
index 32fa5758bf6..0ddbffc7d1c 100644
@@ -25,8 +25,28 @@ config SPL_FRAMEWORK
 	  supports MMC, NAND and YMODEM and other methods loading of U-Boot
 	  and the Linux Kernel.  If unsure, say Y.
 
+config HANDOFF
+	bool "Pass hand-off information from SPL to U-Boot proper"
+	depends on BLOBLIST
+	help
+	  It is useful to be able to pass information from SPL to U-Boot
+	  proper to preserve state that is known in SPL and is needed in U-Boot.
+	  Enable this to locate the handoff information in U-Boot proper, early
+	  in boot. It is available in gd->handoff. The state state is set up
+	  in SPL (or TPL if that is being used).
+
 if SPL
 
+config SPL_HANDOFF
+	bool "Pass hand-off information from SPL to U-Boot proper"
+	depends on HANDOFF
+	default y
+	help
+	  This option enables SPL to write handoff information. This can be
+	  used to pass information like the size of SDRAM from SPL to U-Boot
+	  proper. Also SPL can receive information from TPL in the same place
+	  if that is enabled.
+
 config SPL_LDSCRIPT
 	string "Linker script for the SPL stage"
 	default "arch/$(ARCH)/cpu/u-boot-spl.lds"
@@ -867,6 +887,16 @@ config TPL
 
 if TPL
 
+config TPL_HANDOFF
+	bool "Pass hand-off information from TPL to SPL and U-Boot proper"
+	depends on HANDOFF
+	default y
+	help
+	  This option enables TPL to write handoff information. This can be
+	  used to pass information like the size of SDRAM from TPL to U-Boot
+	  proper. The information is also available to SPL if it is useful
+	  there.
+
 config TPL_BOARD_INIT
 	bool "Call board-specific initialization in TPL"
 	help
common/spl/spl.c +65 -12

125 lines not on this page · raw message

configs/sandbox_spl_defconfig +1 -0
index f44e80e8c33..452a2ef4a50 100644
@@ -22,6 +22,7 @@ CONFIG_CONSOLE_RECORD=y
 CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
 CONFIG_SILENT_CONSOLE=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_HANDOFF=y
 CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_CMD_CPU=y
include/asm-generic/global_data.h +3 -0
index ccf361ed88a..dffd6b26026 100644
@@ -125,6 +125,9 @@ typedef struct global_data {
 #if CONFIG_IS_ENABLED(BLOBLIST)
 	struct bloblist_hdr *bloblist;	/* Bloblist information */
 	struct bloblist_hdr *new_bloblist;	/* Relocated blolist info */
+# ifdef CONFIG_SPL
+	struct spl_handoff *spl_handoff;
+# endif
 #endif
 } gd_t;
 #endif
include/handoff.h new file +36 -0
new file mode 100644
index 00000000000..aacb0f5ebf2
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Passing basic information from SPL to U-Boot proper
+ *
+ * Copyright 2018 Google, Inc
+ */
+
+#ifndef __HANDOFF_H
+#define __HANDOFF_H
+
+#if CONFIG_IS_ENABLED(HANDOFF)
+
+#include <asm/handoff.h>
+
+/**
+ * struct spl_handoff - information passed from SPL to U-Boot proper
+ *
+ * @ram_size: Value to use for gd->ram_size
+ */
+struct spl_handoff {
+	struct arch_spl_handoff arch;
+	u64 ram_size;
+#ifdef CONFIG_NR_DRAM_BANKS
+	struct {
+		u64 start;
+		u64 size;
+	} ram_bank[CONFIG_NR_DRAM_BANKS];
+#endif
+};
+
+void handoff_save_dram(struct spl_handoff *ho);
+void handoff_load_dram_size(struct spl_handoff *ho);
+void handoff_load_dram_banks(struct spl_handoff *ho);
+#endif
+
+#endif
include/spl.h +1 -0
index 205aaff4b9d..ee92832f0ae 100644
@@ -11,6 +11,7 @@
 /* Platform-specific defines */
 #include <linux/compiler.h>
 #include <asm/spl.h>
+#include <handoff.h>
 
 /* Value in r0 indicates we booted from U-Boot */
 #define UBOOT_NOT_LOADED_FROM_SPL	0x13578642
test/py/tests/test_handoff.py new file +14 -0
new file mode 100644
index 00000000000..4540441fae7
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2016 Google, Inc
+
+import pytest
+
+# Magic number to check that SPL handoff is working
+TEST_HANDOFF_MAGIC = 0x14f93c7b
+
+ at pytest.mark.buildconfigspec('spl')
+def test_handoff(u_boot_console):
+    """Test that of-platdata can be generated and used in sandbox"""
+    cons = u_boot_console
+    response = cons.run_command('sb handoff')
+    assert ('SPL handoff magic %x' % TEST_HANDOFF_MAGIC) in response
test/run +1 -1
index fb8ff5da0cb..cd323b0a85e 100755
@@ -19,7 +19,7 @@ run_test "sandbox" ./test/py/test.py --bd sandbox --build
 
 # Run tests which require sandbox_spl
 run_test "sandbox_spl" ./test/py/test.py --bd sandbox_spl --build \
-	-k test_ofplatdata.py
+	-k 'test_ofplatdata or test_handoff'
 
 # Run tests for the flat-device-tree version of sandbox. This is a special
 # build which does not enable CONFIG_OF_LIVE for the live device tree, so we can
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
#42 lore raw

PATCH v3 21/21 spl: Add support for passing handoff info to U-Boot proper

Quoted 10 lines · Simon Glass

There is some basic informaton that SPL normally wants to pass through to U-Boot, such as the SDRAM size and bank information.

Mkae use of the new bloblist structure for this. Add a new 'handoff' blob which is set up in SPL and passed to U-Boot proper. Also adda test for sandbox_spl that checks that this works correctly and a new 'sb' command to show the information passed from SPL.

After tweaking the test to only run on sandbox as well, applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181126/7dfcb68e/attachment.sig>
#43 lore raw

PATCH v3 21/21 spl: Add support for passing handoff info to U-Boot proper

Hi Tom,

Quoted 11 lines · Tom Rini
Quoted 8 lines · Simon Glass

There is some basic informaton that SPL normally wants to pass through to U-Boot, such as the SDRAM size and bank information.

Mkae use of the new bloblist structure for this. Add a new 'handoff' blob which is set up in SPL and passed to U-Boot proper. Also adda test for sandbox_spl that checks that this works correctly and a new 'sb' command to show the information passed from SPL.

Quoted 5 lines
Quoted 2 lines

After tweaking the test to only run on sandbox as well, applied to u-boot/master, thanks!

Thanks for that. I was going to ask about what to do here as I have a similar problem with some other code on the qemu tests. I'll use that approach in future.

Regards,
Simon