[U-Boot] [PATCH v2 2/6] spl: arm: implement SPL_CLEAR_BSS_F
Simon Goldschmidt
simon.k.r.goldschmidt at gmail.com
Fri Mar 15 20:13:43 UTC 2019
This implements the new option to clear BSS early in SPL for standard arm
and arm64 crt0.
BSS is cleared before calling board_init_f() and thus not cleared before
calling board_init_r() as it is not relocated in SPL.
Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt at gmail.com>
---
Changes in v2:
- add CONFIG_SPL_CLEAR_BSS_F implementation for arm64 also
arch/arm/lib/crt0.S | 22 ++++++++++++++++++++++
arch/arm/lib/crt0_64.S | 14 ++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/arch/arm/lib/crt0.S b/arch/arm/lib/crt0.S
index fe312db690..b06e54e144 100644
--- a/arch/arm/lib/crt0.S
+++ b/arch/arm/lib/crt0.S
@@ -80,6 +80,26 @@ ENTRY(_main)
mov r9, r0
bl board_init_f_init_reserve
+#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_CLEAR_BSS_F)
+ ldr r0, =__bss_start
+
+#ifdef CONFIG_USE_ARCH_MEMSET
+ ldr r3, =__bss_end
+ mov r1, #0x00000000 /* prepare zero to clear BSS */
+
+ subs r2, r3, r0 /* r2 = memset len */
+ bl memset
+#else
+ ldr r1, =__bss_end
+ 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
+#endif
+
mov r0, #0
bl board_init_f
@@ -124,6 +144,7 @@ here:
movne sp, r0
movne r9, r0
# endif
+#if !defined(CONFIG_SPL_BUILD) || !defined(CONFIG_SPL_CLEAR_BSS_F)
ldr r0, =__bss_start /* this is auto-relocated! */
#ifdef CONFIG_USE_ARCH_MEMSET
@@ -141,6 +162,7 @@ clbss_l:cmp r0, r1 /* while not at end of BSS */
addlo r0, r0, #4 /* move to next */
blo clbss_l
#endif
+#endif
#if ! defined(CONFIG_SPL_BUILD)
bl coloured_LED_init
diff --git a/arch/arm/lib/crt0_64.S b/arch/arm/lib/crt0_64.S
index d6b632aa87..82f643f737 100644
--- a/arch/arm/lib/crt0_64.S
+++ b/arch/arm/lib/crt0_64.S
@@ -86,6 +86,18 @@ ENTRY(_main)
mov x18, x0
bl board_init_f_init_reserve
+#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_CLEAR_BSS_F)
+/*
+ * Clear BSS section
+ */
+ ldr x0, =__bss_start
+ ldr x1, =__bss_end
+clear_loop:
+ str xzr, [x0], #8
+ cmp x0, x1
+ b.lo clear_loop
+#endif
+
mov x0, #0
bl board_init_f
@@ -136,6 +148,7 @@ relocation_return:
mov sp, x0
#endif
+#if !defined(CONFIG_SPL_BUILD) || !defined(CONFIG_SPL_CLEAR_BSS_F)
/*
* Clear BSS section
*/
@@ -145,6 +158,7 @@ clear_loop:
str xzr, [x0], #8
cmp x0, x1
b.lo clear_loop
+#endif
/* call board_init_r(gd_t *id, ulong dest_addr) */
mov x0, x18 /* gd_t */
--
2.17.1
More information about the U-Boot
mailing list