From: Andreas Dannenberg <dannenberg@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 02/12] spl: Allow performing BSS init early before board_init_f()
Date: Tue, 4 Jun 2019 17:55:45 -0500 [thread overview]
Message-ID: <20190604225555.12186-3-dannenberg@ti.com> (raw)
In-Reply-To: <20190604225555.12186-1-dannenberg@ti.com>
On some platform we have sufficient memory available early on to allow
setting up and using a basic BSS prior to entering board_init_f(). Doing
so can for example be used to carry state over to board_init_r() without
having to resort to extending U-Boot's global data structure.
To support such scenarios add a Kconfig option called CONFIG_SPL_EARLY_BSS
to allow moving the initialization of BSS prior to entering board_init_f(),
if enabled. Note that using this option usually should go along with using
CONFIG_SPL_SEPARATE_BSS and configuring BSS to be located in memory
actually available prior to board_init_f().
Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
---
arch/arm/lib/crt0.S | 53 ++++++++++++++++++++++++++++++---------------
common/spl/Kconfig | 10 +++++++++
2 files changed, 46 insertions(+), 17 deletions(-)
diff --git a/arch/arm/lib/crt0.S b/arch/arm/lib/crt0.S
index 30fba20e1b..c74641dcd9 100644
--- a/arch/arm/lib/crt0.S
+++ b/arch/arm/lib/crt0.S
@@ -57,6 +57,33 @@
* For more information see 'Board Initialisation Flow in README.
*/
+/*
+ * Macro for clearing BSS during SPL execution. Usually called during the
+ * relocation process for most boards before entering board_init_r(), but
+ * can also be done early before entering board_init_f() on plaforms that
+ * can afford it due to sufficient memory being available early.
+ */
+
+.macro SPL_CLEAR_BSS
+ ldr r0, =__bss_start /* this is auto-relocated! */
+
+#ifdef CONFIG_USE_ARCH_MEMSET
+ ldr r3, =__bss_end /* this is auto-relocated! */
+ mov r1, #0x00000000 /* prepare zero to clear BSS */
+
+ subs r2, r3, r0 /* r2 = memset len */
+ bl memset
+#else
+ ldr r1, =__bss_end /* this is auto-relocated! */
+ mov r2, #0x00000000 /* prepare zero to clear BSS */
+
+clbss_l:cmp r0, r1 /* while not at end of BSS */
+ strlo r2, [r0] /* clear 32-bit BSS word */
+ addlo r0, r0, #4 /* move to next */
+ blo clbss_l
+#endif
+.endm
+
/*
* entry point of crt0 sequence
*/
@@ -82,6 +109,10 @@ ENTRY(_main)
mov r9, r0
bl board_init_f_init_reserve
+#if defined(CONFIG_SPL_EARLY_BSS)
+ SPL_CLEAR_BSS
+#endif
+
mov r0, #0
bl board_init_f
@@ -119,6 +150,11 @@ here:
bl c_runtime_cpu_setup /* we still call old routine here */
#endif
#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_FRAMEWORK)
+
+#if !defined(CONFIG_SPL_EARLY_BSS)
+ SPL_CLEAR_BSS
+#endif
+
# ifdef CONFIG_SPL_BUILD
/* Use a DRAM stack for the rest of SPL, if requested */
bl spl_relocate_stack_gd
@@ -126,23 +162,6 @@ here:
movne sp, r0
movne r9, r0
# endif
- ldr r0, =__bss_start /* this is auto-relocated! */
-
-#ifdef CONFIG_USE_ARCH_MEMSET
- ldr r3, =__bss_end /* this is auto-relocated! */
- mov r1, #0x00000000 /* prepare zero to clear BSS */
-
- subs r2, r3, r0 /* r2 = memset len */
- bl memset
-#else
- ldr r1, =__bss_end /* this is auto-relocated! */
- mov r2, #0x00000000 /* prepare zero to clear BSS */
-
-clbss_l:cmp r0, r1 /* while not at end of BSS */
- strlo r2, [r0] /* clear 32-bit BSS word */
- addlo r0, r0, #4 /* move to next */
- blo clbss_l
-#endif
#if ! defined(CONFIG_SPL_BUILD)
bl coloured_LED_init
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index c7cd34449a..b0460e1d17 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -188,6 +188,16 @@ config TPL_BANNER_PRINT
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_EARLY_BSS
+ depends on ARM && !ARM64
+ bool "Allows initializing BSS early before entering board_init_f"
+ help
+ On some platform we have sufficient memory available early on to
+ allow setting up and using a basic BSS prior to entering
+ board_init_f. Activating this option will also de-activate the
+ clearing of BSS during the SPL relocation process, thus allowing
+ to carry state from board_init_f to board_init_r by way of BSS.
+
config SPL_DISPLAY_PRINT
bool "Display a board-specific message in SPL"
help
--
2.17.1
next prev parent reply other threads:[~2019-06-04 22:55 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-04 22:55 [U-Boot] [PATCH v2 00/12] System Firmware Loader for TI K3 family SoCs Andreas Dannenberg
2019-06-04 22:55 ` [U-Boot] [PATCH v2 01/12] mmc: am654_sdhci: Allow driver to probe without PDs specified Andreas Dannenberg
2019-07-19 0:00 ` Tom Rini
2019-06-04 22:55 ` Andreas Dannenberg [this message]
2019-07-19 0:00 ` [U-Boot] [PATCH v2 02/12] spl: Allow performing BSS init early before board_init_f() Tom Rini
2019-06-04 22:55 ` [U-Boot] [PATCH v2 03/12] spl: Make image loader infrastructure more universal Andreas Dannenberg
2019-07-19 0:00 ` Tom Rini
2019-06-04 22:55 ` [U-Boot] [PATCH v2 04/12] arm: K3: Introduce System Firmware loader framework Andreas Dannenberg
2019-07-19 0:00 ` Tom Rini
2019-06-04 22:55 ` [U-Boot] [PATCH v2 05/12] armV7R: K3: am654: Allow using SPL BSS pre-relocation Andreas Dannenberg
2019-07-19 0:00 ` Tom Rini
2019-07-19 5:29 ` Simon Goldschmidt
2019-07-20 15:51 ` Tom Rini
2019-07-25 4:35 ` Lokesh Vutla
2019-07-25 7:01 ` Simon Goldschmidt
2019-07-25 8:22 ` Lokesh Vutla
2019-07-25 9:52 ` Simon Goldschmidt
2019-08-07 21:23 ` Andreas Dannenberg
2019-08-08 7:29 ` Simon Goldschmidt
2019-08-08 18:29 ` Andreas Dannenberg
2019-08-08 19:01 ` Simon Goldschmidt
2019-08-08 19:43 ` Andreas Dannenberg
2019-08-08 20:01 ` Simon Goldschmidt
2019-08-13 20:38 ` Simon Goldschmidt
2019-08-13 21:06 ` Andreas Dannenberg
2019-06-04 22:55 ` [U-Boot] [PATCH v2 06/12] armv7R: K3: am654: Use full malloc implementation in SPL Andreas Dannenberg
2019-07-19 0:00 ` Tom Rini
2019-06-04 22:55 ` [U-Boot] [PATCH v2 07/12] armV7R: K3: am654: Load SYSFW binary and config from boot media Andreas Dannenberg
2019-07-19 0:00 ` Tom Rini
2019-06-04 22:55 ` [U-Boot] [PATCH v2 08/12] configs: am65x_evm_r5: All sysfw to be loaded via MMC Andreas Dannenberg
2019-07-19 0:01 ` Tom Rini
2019-06-04 22:55 ` [U-Boot] [PATCH v2 09/12] configs: am65x_hs_evm_r5: " Andreas Dannenberg
2019-07-19 0:01 ` Tom Rini
2019-06-04 22:55 ` [U-Boot] [PATCH v2 10/12] configs: am65x_evm: Add Support for eMMC boot Andreas Dannenberg
2019-07-19 0:01 ` Tom Rini
2019-06-04 22:55 ` [U-Boot] [PATCH v2 11/12] configs: am65x_hs_evm: " Andreas Dannenberg
2019-07-19 0:01 ` Tom Rini
2019-06-04 22:55 ` [U-Boot] [PATCH v2 12/12] am65x: README: Add eMMC layout and flash instructions Andreas Dannenberg
2019-07-19 0:01 ` Tom Rini
2019-06-05 6:22 ` [U-Boot] [PATCH v2 00/12] System Firmware Loader for TI K3 family SoCs Lokesh Vutla
2019-06-05 15:15 ` Andreas Dannenberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190604225555.12186-3-dannenberg@ti.com \
--to=dannenberg@ti.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox