All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/6] spl: arm: implement SPL_CLEAR_BSS_F
Date: Mon, 11 Mar 2019 22:35:20 +0100	[thread overview]
Message-ID: <20190311213524.15893-3-simon.k.r.goldschmidt@gmail.com> (raw)
In-Reply-To: <20190311213524.15893-1-simon.k.r.goldschmidt@gmail.com>

This implements the new option to clear BSS early in SPL for standard arm
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@gmail.com>
---

 arch/arm/lib/crt0.S | 22 ++++++++++++++++++++++
 1 file changed, 22 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
-- 
2.17.1

  parent reply	other threads:[~2019-03-11 21:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-11 21:35 [U-Boot] [PATCH 0/6] spl: full-featured heap cleanups Simon Goldschmidt
2019-03-11 21:35 ` [U-Boot] [PATCH 1/6] spl: add Kconfig option to clear bss early Simon Goldschmidt
2019-03-12  6:02   ` Stefan Roese
2019-03-12 20:52     ` Simon Goldschmidt
2019-03-11 21:35 ` Simon Goldschmidt [this message]
2019-03-11 21:35 ` [U-Boot] [PATCH 3/6] dlmalloc: fix malloc range at end of ram Simon Goldschmidt
2019-03-11 21:35 ` [U-Boot] [PATCH 4/6] dlmalloc: be compatible to tiny printf Simon Goldschmidt
2019-03-11 21:35 ` [U-Boot] [PATCH 5/6] spl: support using full malloc with SYS_MALLOC_F_LEN Simon Goldschmidt
2019-03-19  1:24   ` Simon Glass
2019-03-19 18:52     ` Simon Goldschmidt
2019-03-11 21:35 ` [U-Boot] [PATCH 6/6] arm: socfpga: a10: move SPL stack size to Kconfig Simon Goldschmidt
2019-03-18  7:45   ` Chee, Tien Fong

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=20190311213524.15893-3-simon.k.r.goldschmidt@gmail.com \
    --to=simon.k.r.goldschmidt@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.