diff mbox series

[U-Boot,1/6] spl: add Kconfig option to clear bss early

Message ID 20190311213524.15893-2-simon.k.r.goldschmidt@gmail.com
State Superseded
Delegated to: Tom Rini
Headers show
Series spl: full-featured heap cleanups | expand

Commit Message

Simon Goldschmidt March 11, 2019, 9:35 p.m. UTC
This introduces a new Kconfig option SPL_CLEAR_BSS_F. If enabled, it clears
the bss before calling board_init_f() instead of clearing it before calling
board_init_r().

This also ensures that variables placed in BSS can be shared between
board_init_f() and board_init_r() in SPL.

Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
---

 common/spl/Kconfig | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Stefan Roese March 12, 2019, 6:02 a.m. UTC | #1
Hi Simon,

On 11.03.19 22:35, Simon Goldschmidt wrote:
> This introduces a new Kconfig option SPL_CLEAR_BSS_F. If enabled, it clears
> the bss before calling board_init_f() instead of clearing it before calling
> board_init_r().
> 
> This also ensures that variables placed in BSS can be shared between
> board_init_f() and board_init_r() in SPL.
> 
> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
> ---
> 
>   common/spl/Kconfig | 11 +++++++++++
>   1 file changed, 11 insertions(+)
> 
> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> index 206c24076d..5da8697994 100644
> --- a/common/spl/Kconfig
> +++ b/common/spl/Kconfig
> @@ -156,6 +156,17 @@ config SPL_STACK_R_MALLOC_SIMPLE_LEN
>   	  to give board_init_r() a larger heap then the initial heap in
>   	  SRAM which is limited to SYS_MALLOC_F_LEN bytes.
>   
> +config SPL_CLEAR_BSS_F
> +	bool "Clear BSS section before calling board_init_f"
> +	help
> +	  The BSS section is initialized to zero. In SPL, this is normally done
> +	  before calling board_init_r().
> +	  For platforms using BSS in board_init_f() already, enable this to
> +	  clear the BSS section before calling board_init_f() instead of
> +	  clearing it before calling board_init_r(). This also ensures that
> +	  variables placed in BSS can be shared between board_init_f() and
> +	  board_init_r().
> +

You should probably depend this option on "ARM", as your implementation
is currently only for this arch. Otherwise users might expect this to
work on other platforms as well.

Thanks,
Stefan
Simon Goldschmidt March 12, 2019, 8:52 p.m. UTC | #2
Am 12.03.2019 um 07:02 schrieb Stefan Roese:
> Hi Simon,
> 
> On 11.03.19 22:35, Simon Goldschmidt wrote:
>> This introduces a new Kconfig option SPL_CLEAR_BSS_F. If enabled, it clears
>> the bss before calling board_init_f() instead of clearing it before calling
>> board_init_r().
>>
>> This also ensures that variables placed in BSS can be shared between
>> board_init_f() and board_init_r() in SPL.
>>
>> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
>> ---
>>
>>    common/spl/Kconfig | 11 +++++++++++
>>    1 file changed, 11 insertions(+)
>>
>> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
>> index 206c24076d..5da8697994 100644
>> --- a/common/spl/Kconfig
>> +++ b/common/spl/Kconfig
>> @@ -156,6 +156,17 @@ config SPL_STACK_R_MALLOC_SIMPLE_LEN
>>    	  to give board_init_r() a larger heap then the initial heap in
>>    	  SRAM which is limited to SYS_MALLOC_F_LEN bytes.
>>    
>> +config SPL_CLEAR_BSS_F
>> +	bool "Clear BSS section before calling board_init_f"
>> +	help
>> +	  The BSS section is initialized to zero. In SPL, this is normally done
>> +	  before calling board_init_r().
>> +	  For platforms using BSS in board_init_f() already, enable this to
>> +	  clear the BSS section before calling board_init_f() instead of
>> +	  clearing it before calling board_init_r(). This also ensures that
>> +	  variables placed in BSS can be shared between board_init_f() and
>> +	  board_init_r().
>> +
> 
> You should probably depend this option on "ARM", as your implementation
> is currently only for this arch. Otherwise users might expect this to
> work on other platforms as well.

Hmm, ok. I thought it might be worth leaving this visible for everyone. 
But you're right that people migh rely on this to work where it's not 
implemented...

I'll add that dependency in v2.

Regards,
Simon
diff mbox series

Patch

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 206c24076d..5da8697994 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -156,6 +156,17 @@  config SPL_STACK_R_MALLOC_SIMPLE_LEN
 	  to give board_init_r() a larger heap then the initial heap in
 	  SRAM which is limited to SYS_MALLOC_F_LEN bytes.
 
+config SPL_CLEAR_BSS_F
+	bool "Clear BSS section before calling board_init_f"
+	help
+	  The BSS section is initialized to zero. In SPL, this is normally done
+	  before calling board_init_r().
+	  For platforms using BSS in board_init_f() already, enable this to
+	  clear the BSS section before calling board_init_f() instead of
+	  clearing it before calling board_init_r(). This also ensures that
+	  variables placed in BSS can be shared between board_init_f() and
+	  board_init_r().
+
 config SPL_SEPARATE_BSS
 	bool "BSS section is in a different memory region from text"
 	help