diff mbox series

[4/5] Nokia RX-51: Simplify calculation of attached kernel image address

Message ID 20220811202725.24752-4-pali@kernel.org
State Accepted
Commit 0ba6ce4b7889dc74a646cf54ea97a9d48428bcfe
Delegated to: Tom Rini
Headers show
Series [1/5] Nokia RX-51: Fix invalidating zImage kernel format | expand

Commit Message

Pali Rohár Aug. 11, 2022, 8:27 p.m. UTC
Now when board starup code does not copy image to CONFIG_SYS_TEXT_BASE
address there is no need to calculate all addresses from base address at
runtime. The only address which needs to be calculated is attached kernel
image address which can be simplified at compile time without need to know
CONFIG_SYS_TEXT_BASE address or relocation address at the runtime.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 board/nokia/rx51/lowlevel_init.S | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

Comments

Tom Rini Aug. 20, 2022, 11:01 p.m. UTC | #1
On Thu, Aug 11, 2022 at 10:27:24PM +0200, Pali Rohár wrote:

> Now when board starup code does not copy image to CONFIG_SYS_TEXT_BASE
> address there is no need to calculate all addresses from base address at
> runtime. The only address which needs to be calculated is attached kernel
> image address which can be simplified at compile time without need to know
> CONFIG_SYS_TEXT_BASE address or relocation address at the runtime.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>

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

Patch

diff --git a/board/nokia/rx51/lowlevel_init.S b/board/nokia/rx51/lowlevel_init.S
index 4f76e80b20f1..c1785bc3f72f 100644
--- a/board/nokia/rx51/lowlevel_init.S
+++ b/board/nokia/rx51/lowlevel_init.S
@@ -6,11 +6,8 @@ 
 
 #include <config.h>
 
-relocaddr:		/* address of this relocaddr section after coping */
-	.word .		/* address of section (calculated at compile time) */
-
-startaddr:		/* address of u-boot after copying */
-	.word CONFIG_SYS_TEXT_BASE
+kernoffs:		/* offset of kernel image from this address */
+	.word KERNEL_OFFSET - (. - CONFIG_SYS_TEXT_BASE)
 
 kernaddr:		/* address of kernel after copying */
 	.word KERNEL_ADDRESS
@@ -18,9 +15,6 @@  kernaddr:		/* address of kernel after copying */
 kernsize:		/* maximal size of kernel image */
 	.word KERNEL_MAXSIZE
 
-kernoffs:		/* offset of kernel image in loaded u-boot */
-	.word KERNEL_OFFSET
-
 imagesize:		/* maximal size of image */
 	.word IMAGE_MAXSIZE
 
@@ -53,16 +47,9 @@  save_boot_params:
  */
 
 copy_kernel_start:
-	adr	r0, relocaddr	/* r0 - address of section relocaddr */
-	ldr	r1, relocaddr	/* r1 - address of relocaddr after relocation */
-
-	/* r4 - calculated offset */
-	sub	r4, r0, r1
-
 	/* r0 - start of kernel before */
-	ldr	r0, startaddr
-	add	r0, r0, r4
-	ldr	r1, kernoffs
+	adr	r0, kernoffs	/* r0 - current address of kernoffs section */
+	ldr	r1, kernoffs	/* r1 - offset of kernel image from kernoffs section */
 	add	r0, r0, r1
 
 	/* r3 - start of kernel after */