diff options
author | Kevin Hao <haokexin@gmail.com> | 2013-12-24 02:12:05 -0500 |
---|---|---|
committer | Scott Wood <scottwood@freescale.com> | 2014-01-09 18:52:15 -0500 |
commit | 1c49abec677c7ff495837dbaafad8e12f09c29fc (patch) | |
tree | 9a1bef7d4684457e5ff5ba6869e17264a2cf0bc3 | |
parent | 99739611e816716d912ae89a4354237fc39745a6 (diff) |
powerpc: introduce macro LOAD_REG_ADDR_PIC
This is used to get the address of a variable when the kernel is not
running at the linked or relocated address.
Signed-off-by: Kevin Hao <haokexin@gmail.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
-rw-r--r-- | arch/powerpc/include/asm/ppc_asm.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h index f595b98079ee..1279c59624ed 100644 --- a/arch/powerpc/include/asm/ppc_asm.h +++ b/arch/powerpc/include/asm/ppc_asm.h | |||
@@ -295,6 +295,11 @@ n: | |||
295 | * you want to access various offsets within it). On ppc32 this is | 295 | * you want to access various offsets within it). On ppc32 this is |
296 | * identical to LOAD_REG_IMMEDIATE. | 296 | * identical to LOAD_REG_IMMEDIATE. |
297 | * | 297 | * |
298 | * LOAD_REG_ADDR_PIC(rn, name) | ||
299 | * Loads the address of label 'name' into register 'run'. Use this when | ||
300 | * the kernel doesn't run at the linked or relocated address. Please | ||
301 | * note that this macro will clobber the lr register. | ||
302 | * | ||
298 | * LOAD_REG_ADDRBASE(rn, name) | 303 | * LOAD_REG_ADDRBASE(rn, name) |
299 | * ADDROFF(name) | 304 | * ADDROFF(name) |
300 | * LOAD_REG_ADDRBASE loads part of the address of label 'name' into | 305 | * LOAD_REG_ADDRBASE loads part of the address of label 'name' into |
@@ -305,6 +310,14 @@ n: | |||
305 | * LOAD_REG_ADDRBASE(rX, name) | 310 | * LOAD_REG_ADDRBASE(rX, name) |
306 | * ld rY,ADDROFF(name)(rX) | 311 | * ld rY,ADDROFF(name)(rX) |
307 | */ | 312 | */ |
313 | |||
314 | /* Be careful, this will clobber the lr register. */ | ||
315 | #define LOAD_REG_ADDR_PIC(reg, name) \ | ||
316 | bl 0f; \ | ||
317 | 0: mflr reg; \ | ||
318 | addis reg,reg,(name - 0b)@ha; \ | ||
319 | addi reg,reg,(name - 0b)@l; | ||
320 | |||
308 | #ifdef __powerpc64__ | 321 | #ifdef __powerpc64__ |
309 | #define LOAD_REG_IMMEDIATE(reg,expr) \ | 322 | #define LOAD_REG_IMMEDIATE(reg,expr) \ |
310 | lis reg,(expr)@highest; \ | 323 | lis reg,(expr)@highest; \ |