diff mbox

[U-Boot,v2,03/56] rockchip: back-to-bootrom: add 'back-to-bootrom' support for AArch64

Message ID 1501065662-52029-4-git-send-email-philipp.tomsich@theobroma-systems.com
State Superseded
Delegated to: Philipp Tomsich
Headers show

Commit Message

Philipp Tomsich July 26, 2017, 10:40 a.m. UTC
The back-to-bootrom support for Rockchip is equivalent to an
(assembly) implementation of setjmp/longjmp (i.e. it saves the
stack-pointer, link-register and callee-saved registers). Up until
now, this had only been implemented for AArch32 (i.e. ARMv7 or older),
which puts the new ARMv8 devices (which boot in AArch64 mode) at a
slight disadvantage.

To allow use of the 'back-to-bootrom' feature on new devices (e.g. the
RK3368), this commit adds an implementation for AArch64.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
---

Changes in v2: None

 arch/arm/mach-rockchip/save_boot_param.S | 37 ++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

Comments

Simon Glass July 28, 2017, 3:37 a.m. UTC | #1
Hi Philipp,

On 26 July 2017 at 04:40, Philipp Tomsich
<philipp.tomsich@theobroma-systems.com> wrote:
> The back-to-bootrom support for Rockchip is equivalent to an
> (assembly) implementation of setjmp/longjmp (i.e. it saves the
> stack-pointer, link-register and callee-saved registers). Up until
> now, this had only been implemented for AArch32 (i.e. ARMv7 or older),
> which puts the new ARMv8 devices (which boot in AArch64 mode) at a
> slight disadvantage.
>
> To allow use of the 'back-to-bootrom' feature on new devices (e.g. the
> RK3368), this commit adds an implementation for AArch64.
>
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> ---
>
> Changes in v2: None
>
>  arch/arm/mach-rockchip/save_boot_param.S | 37 ++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

>
> diff --git a/arch/arm/mach-rockchip/save_boot_param.S b/arch/arm/mach-rockchip/save_boot_param.S
> index 5e6c8db..945a9dd 100644
> --- a/arch/arm/mach-rockchip/save_boot_param.S
> +++ b/arch/arm/mach-rockchip/save_boot_param.S
> @@ -1,11 +1,47 @@
>  /*
>   * (C) Copyright 2016 Rockchip Electronics Co., Ltd
> + * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
>   *
>   * SPDX-License-Identifier:     GPL-2.0+
>   */
>
>  #include <linux/linkage.h>
>
> +#if defined(CONFIG_ARM64)
> +.globl SAVE_SP_ADDR
> +SAVE_SP_ADDR:
> +       .quad 0
> +
> +ENTRY(save_boot_params)
> +       sub     sp, sp, #0x100

Can you please add a comment as to why this is 0x100?

> +       stp     x29, x30, [sp, #0x50]
> +       stp     x27, x28, [sp, #0x40]
> +       stp     x25, x26, [sp, #0x30]
> +       stp     x23, x24, [sp, #0x20]
> +       stp     x21, x22, [sp, #0x10]
> +       stp     x19, x20, [sp, #0]
> +       ldr     x8, =SAVE_SP_ADDR
> +       mov     x9, sp
> +       str     x9, [x8]
> +       b       save_boot_params_ret  /* back to my caller */
> +ENDPROC(save_boot_params)
> +
> +.globl _back_to_bootrom_s
> +ENTRY(_back_to_bootrom_s)
> +       ldr     x0, =SAVE_SP_ADDR
> +       ldr     x0, [x0]
> +       mov     sp, x0
> +       ldp     x29, x30, [sp, #0x50]
> +       ldp     x27, x28, [sp, #0x40]
> +       ldp     x25, x26, [sp, #0x30]
> +       ldp     x23, x24, [sp, #0x20]
> +       ldp     x21, x22, [sp, #0x10]
> +       ldp     x19, x20, [sp]
> +       add     sp, sp, #0x100
> +       mov     x0, xzr
> +       ret
> +ENDPROC(_back_to_bootrom_s)
> +#else
>  .globl SAVE_SP_ADDR
>  SAVE_SP_ADDR:
>         .word 0
> @@ -30,3 +66,4 @@ ENTRY(_back_to_bootrom_s)
>         mov     r0, #0
>         pop     {r1-r12, pc}
>  ENDPROC(_back_to_bootrom_s)
> +#endif
> --
> 2.1.4
>

Regards,
Simon
diff mbox

Patch

diff --git a/arch/arm/mach-rockchip/save_boot_param.S b/arch/arm/mach-rockchip/save_boot_param.S
index 5e6c8db..945a9dd 100644
--- a/arch/arm/mach-rockchip/save_boot_param.S
+++ b/arch/arm/mach-rockchip/save_boot_param.S
@@ -1,11 +1,47 @@ 
 /*
  * (C) Copyright 2016 Rockchip Electronics Co., Ltd
+ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
  *
  * SPDX-License-Identifier:     GPL-2.0+
  */
 
 #include <linux/linkage.h>
 
+#if defined(CONFIG_ARM64)
+.globl	SAVE_SP_ADDR
+SAVE_SP_ADDR:
+	.quad 0
+
+ENTRY(save_boot_params)
+	sub	sp, sp, #0x100
+	stp	x29, x30, [sp, #0x50]
+	stp	x27, x28, [sp, #0x40]
+	stp	x25, x26, [sp, #0x30]
+	stp	x23, x24, [sp, #0x20]
+	stp	x21, x22, [sp, #0x10]
+	stp	x19, x20, [sp, #0]
+	ldr	x8, =SAVE_SP_ADDR
+	mov	x9, sp
+	str	x9, [x8]
+	b	save_boot_params_ret  /* back to my caller */
+ENDPROC(save_boot_params)
+
+.globl _back_to_bootrom_s
+ENTRY(_back_to_bootrom_s)
+	ldr	x0, =SAVE_SP_ADDR
+	ldr	x0, [x0]
+	mov	sp, x0
+	ldp	x29, x30, [sp, #0x50]
+	ldp	x27, x28, [sp, #0x40]
+	ldp	x25, x26, [sp, #0x30]
+	ldp	x23, x24, [sp, #0x20]
+	ldp	x21, x22, [sp, #0x10]
+	ldp	x19, x20, [sp]
+	add	sp, sp, #0x100
+	mov	x0, xzr
+	ret
+ENDPROC(_back_to_bootrom_s)
+#else
 .globl	SAVE_SP_ADDR
 SAVE_SP_ADDR:
 	.word 0
@@ -30,3 +66,4 @@  ENTRY(_back_to_bootrom_s)
 	mov	r0, #0
 	pop	{r1-r12, pc}
 ENDPROC(_back_to_bootrom_s)
+#endif