ARM中r9寄存器的使用
Usage of r9 register in ARM
我正在尝试了解U-boot源码(2014.07)。我可以在 arch/arm/cpu/armv7/lowlevel_init.S 文件中看到以下代码。
#ifdef CONFIG_SPL_BUILD
ldr r9, =gdata
#else
sub sp, sp, #GD_SIZE
bic sp, sp, #7
mov r9, sp
#endif
push {ip, lr}
bl s_init
pop {ip, pc}
你能告诉我为什么 sp 被移动到 r9 寄存器 - "mov r9, sp"(对于 SPL 构建,gdata 被加载到 r9 寄存器 - "ldr r9, =gdata")。
r9寄存器有没有什么具体用途,所以我们把sp的值存到r9。
ARM在Procedure Call Standard中列出的通用ABI将r9指定为"Platform Register":
A virtual platform may assign any role to this register and must document this usage. For example, it may designate it as the static base (SB) in a position-independent data model, or it may designate it as the thread register (TR) in an environment with thread-local storage. The usage of this register may require that the value held is persistent across all calls. A virtual platform that has no need for such a special register may designate r9 as an additional callee-saved variable register, v6.
在这种情况下,U-Boot ABI 似乎将其用于全局数据指针(另请参阅 arch/arm/lib/crt0.S 和 arch/arm/include/asm/global_data.h), 但可能在 "must document this usage" 点上不足...
我正在尝试了解U-boot源码(2014.07)。我可以在 arch/arm/cpu/armv7/lowlevel_init.S 文件中看到以下代码。
#ifdef CONFIG_SPL_BUILD
ldr r9, =gdata
#else
sub sp, sp, #GD_SIZE
bic sp, sp, #7
mov r9, sp
#endif
push {ip, lr}
bl s_init
pop {ip, pc}
你能告诉我为什么 sp 被移动到 r9 寄存器 - "mov r9, sp"(对于 SPL 构建,gdata 被加载到 r9 寄存器 - "ldr r9, =gdata")。 r9寄存器有没有什么具体用途,所以我们把sp的值存到r9。
ARM在Procedure Call Standard中列出的通用ABI将r9指定为"Platform Register":
A virtual platform may assign any role to this register and must document this usage. For example, it may designate it as the static base (SB) in a position-independent data model, or it may designate it as the thread register (TR) in an environment with thread-local storage. The usage of this register may require that the value held is persistent across all calls. A virtual platform that has no need for such a special register may designate r9 as an additional callee-saved variable register, v6.
在这种情况下,U-Boot ABI 似乎将其用于全局数据指针(另请参阅 arch/arm/lib/crt0.S 和 arch/arm/include/asm/global_data.h), 但可能在 "must document this usage" 点上不足...