diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2016-02-16 12:33:56 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2016-02-16 19:28:39 -0500 |
commit | 8ff97fa31333e8d0f4f7029798d9c7d59359b05c (patch) | |
tree | 23903431f74033ab44908b48b16fb2380478aa10 /arch/arm/include/asm/memory.h | |
parent | d78114554939aec0344b494e759d0679224562db (diff) |
ARM: make the physical-relative calculation more obvious
The physical-relative calculation between the XIP text and data sections
introduced by the previous patch was far from obvious. Let's simplify it
by turning it into a macro which takes the two (virtual) addresses.
This allows us to arrange the calculation in a more obvious manner - we
can make it two sub-expressions which calculate the physical address for
each symbol, and then takes the difference of those physical addresses.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/include/asm/memory.h')
-rw-r--r-- | arch/arm/include/asm/memory.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h index ebdaaf7dd19f..51fc9b3b52ea 100644 --- a/arch/arm/include/asm/memory.h +++ b/arch/arm/include/asm/memory.h | |||
@@ -135,11 +135,18 @@ | |||
135 | #define PLAT_PHYS_OFFSET UL(CONFIG_PHYS_OFFSET) | 135 | #define PLAT_PHYS_OFFSET UL(CONFIG_PHYS_OFFSET) |
136 | 136 | ||
137 | #ifdef CONFIG_XIP_KERNEL | 137 | #ifdef CONFIG_XIP_KERNEL |
138 | #define PHYS_OFFSET_FIXUP \ | 138 | /* |
139 | ( XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR) - PAGE_OFFSET + \ | 139 | * When referencing data in RAM from the XIP region in a relative manner |
140 | PLAT_PHYS_OFFSET - CONFIG_XIP_PHYS_ADDR ) | 140 | * with the MMU off, we need the relative offset between the two physical |
141 | * addresses. The macro below achieves this, which is: | ||
142 | * __pa(v_data) - __xip_pa(v_text) | ||
143 | */ | ||
144 | #define PHYS_RELATIVE(v_data, v_text) \ | ||
145 | (((v_data) - PAGE_OFFSET + PLAT_PHYS_OFFSET) - \ | ||
146 | ((v_text) - XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR) + \ | ||
147 | CONFIG_XIP_PHYS_ADDR)) | ||
141 | #else | 148 | #else |
142 | #define PHYS_OFFSET_FIXUP 0 | 149 | #define PHYS_RELATIVE(v_data, v_text) ((v_data) - (v_text)) |
143 | #endif | 150 | #endif |
144 | 151 | ||
145 | #ifndef __ASSEMBLY__ | 152 | #ifndef __ASSEMBLY__ |