diff mbox

[U-Boot,1/4] arm: make sure board_init_r() is being called using the right mode (ARM / THUMB)

Message ID 1455032911-29001-2-git-send-email-d.mueller@elsoft.ch
State Accepted
Commit 03a3a8aec85780f034c9c8fca4a12abfeb9b4da7
Delegated to: Tom Rini
Headers show

Commit Message

David Müller (ELSOFT AG) Feb. 9, 2016, 3:48 p.m. UTC
Signed-off-by: David Müller <d.mueller@elsoft.ch>
---
 arch/arm/lib/crt0.S | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Tom Rini Feb. 9, 2016, 5:03 p.m. UTC | #1
On Tue, Feb 09, 2016 at 04:48:28PM +0100, David Müller wrote:

> Signed-off-by: David Müller <d.mueller@elsoft.ch>
> ---
>  arch/arm/lib/crt0.S | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/lib/crt0.S b/arch/arm/lib/crt0.S
> index 2f4c14e..8415f77 100644
> --- a/arch/arm/lib/crt0.S
> +++ b/arch/arm/lib/crt0.S
> @@ -167,8 +167,12 @@ clbss_l:cmp	r0, r1			/* while not at end of BSS */
>  	mov     r0, r9                  /* gd_t */
>  	ldr	r1, [r9, #GD_RELOCADDR]	/* dest_addr */
>  	/* call board_init_r */
> +#if defined(CONFIG_SYS_THUMB_BUILD)
> +	ldr	lr, =board_init_r	/* this is auto-relocated! */
> +	bx	lr
> +#else
>  	ldr	pc, =board_init_r	/* this is auto-relocated! */
> -
> +#endif
>  	/* we should not return here. */
>  #endif

In general, my preference is always to use the thumb compatible way, can
you rework like that and explain in the commit message?  Thanks!
David Müller (ELSOFT AG) Feb. 10, 2016, 7:57 a.m. UTC | #2
Hello

Tom Rini wrote:
> On Tue, Feb 09, 2016 at 04:48:28PM +0100, David Müller wrote:
>>  	/* call board_init_r */
>> +#if defined(CONFIG_SYS_THUMB_BUILD)
>> +	ldr	lr, =board_init_r	/* this is auto-relocated! */
>> +	bx	lr
>> +#else
>>  	ldr	pc, =board_init_r	/* this is auto-relocated! */
>> -
>> +#endif
>>  	/* we should not return here. */
>>  #endif
> 
> In general, my preference is always to use the thumb compatible way, can
> you rework like that and explain in the commit message?  Thanks!

AFAIK, the "bx" instruction is undefined on non-THUMB capable
architectures. I therefore don't see a way to avoid some kind of
#if/#else/#endif construct.

Dave
Tom Rini Feb. 10, 2016, 10:12 p.m. UTC | #3
On Wed, Feb 10, 2016 at 08:57:38AM +0100, David Müller (ELSOFT AG) wrote:
> Hello
> 
> Tom Rini wrote:
> > On Tue, Feb 09, 2016 at 04:48:28PM +0100, David Müller wrote:
> >>  	/* call board_init_r */
> >> +#if defined(CONFIG_SYS_THUMB_BUILD)
> >> +	ldr	lr, =board_init_r	/* this is auto-relocated! */
> >> +	bx	lr
> >> +#else
> >>  	ldr	pc, =board_init_r	/* this is auto-relocated! */
> >> -
> >> +#endif
> >>  	/* we should not return here. */
> >>  #endif
> > 
> > In general, my preference is always to use the thumb compatible way, can
> > you rework like that and explain in the commit message?  Thanks!
> 
> AFAIK, the "bx" instruction is undefined on non-THUMB capable
> architectures. I therefore don't see a way to avoid some kind of
> #if/#else/#endif construct.

Ah, OK, nevermind then, thanks.
Tom Rini Feb. 15, 2016, 10:35 p.m. UTC | #4
On Tue, Feb 09, 2016 at 04:48:28PM +0100, David Müller (ELSOFT AG) wrote:

> Signed-off-by: David Müller <d.mueller@elsoft.ch>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/arch/arm/lib/crt0.S b/arch/arm/lib/crt0.S
index 2f4c14e..8415f77 100644
--- a/arch/arm/lib/crt0.S
+++ b/arch/arm/lib/crt0.S
@@ -167,8 +167,12 @@  clbss_l:cmp	r0, r1			/* while not at end of BSS */
 	mov     r0, r9                  /* gd_t */
 	ldr	r1, [r9, #GD_RELOCADDR]	/* dest_addr */
 	/* call board_init_r */
+#if defined(CONFIG_SYS_THUMB_BUILD)
+	ldr	lr, =board_init_r	/* this is auto-relocated! */
+	bx	lr
+#else
 	ldr	pc, =board_init_r	/* this is auto-relocated! */
-
+#endif
 	/* we should not return here. */
 #endif