xen/arm32: head: Add a macro to move an immediate constant into a 32-bit register
authorJulien Grall <julien.grall@arm.com>
Mon, 15 Apr 2019 20:58:51 +0000 (21:58 +0100)
committerJulien Grall <julien.grall@arm.com>
Sat, 7 Sep 2019 11:09:58 +0000 (12:09 +0100)
The current boot code is using the pattern ldr rX, =... to move an
immediate constant into a 32-bit register.

This pattern implies to load the immediate constant from a literal pool,
meaning a memory access will be performed.

The memory access can be avoided by using movw/movt instructions.

A new macro is introduced to move an immediate constant into a 32-bit
register without a memory load. Follow-up patches will make use of it.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/arm32/head.S

index 18ded49a04d793d333ba25bb3fa01ffc7649da16..99f4af18d8544559b5b61d3ad8ba727cad96decb 100644 (file)
 #include EARLY_PRINTK_INC
 #endif
 
+/*
+ * Move an immediate constant into a 32-bit register using movw/movt
+ * instructions.
+ */
+.macro mov_w reg, word
+        movw  \reg, #:lower16:\word
+        movt  \reg, #:upper16:\word
+.endm
+
 /*
  * Common register usage in this file:
  *   r0  -