ArmPlatformPkg/ArmVExpressPkg: switch to ASM_FUNC() asm macro

Annotate functions with ASM_FUNC() so that they are emitted into
separate sections.

While we're at it, replace some inefficient uses of LoadConstantToReg()

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
This commit is contained in:
Ard Biesheuvel 2016-08-10 16:51:11 +02:00
parent 13dc7fa5a0
commit 04209b5354
5 changed files with 41 additions and 111 deletions

View File

@ -16,22 +16,14 @@
#include <ArmPlatform.h> #include <ArmPlatform.h>
.text ASM_FUNC(ArmPlatformPeiBootAction)
.align 2
GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)
ASM_PFX(ArmPlatformPeiBootAction):
bx lr bx lr
//UINTN //UINTN
//ArmPlatformGetCorePosition ( //ArmPlatformGetCorePosition (
// IN UINTN MpId // IN UINTN MpId
// ); // );
ASM_PFX(ArmPlatformGetCorePosition): ASM_FUNC(ArmPlatformGetCorePosition)
and r1, r0, #ARM_CORE_MASK and r1, r0, #ARM_CORE_MASK
and r0, r0, #ARM_CLUSTER_MASK and r0, r0, #ARM_CLUSTER_MASK
add r0, r1, r0, LSR #7 add r0, r1, r0, LSR #7
@ -41,10 +33,10 @@ ASM_PFX(ArmPlatformGetCorePosition):
//ArmPlatformIsPrimaryCore ( //ArmPlatformIsPrimaryCore (
// IN UINTN MpId // IN UINTN MpId
// ); // );
ASM_PFX(ArmPlatformIsPrimaryCore): ASM_FUNC(ArmPlatformIsPrimaryCore)
// Extract cpu_id and cluster_id from ARM_SCC_CFGREG48 // Extract cpu_id and cluster_id from ARM_SCC_CFGREG48
// with cpu_id[0:3] and cluster_id[4:7] // with cpu_id[0:3] and cluster_id[4:7]
LoadConstantToReg (ARM_CTA15A7_SCC_CFGREG48, r1) MOV32 (r1, ARM_CTA15A7_SCC_CFGREG48)
ldr r1, [r1] ldr r1, [r1]
lsr r1, #24 lsr r1, #24
@ -58,7 +50,7 @@ ASM_PFX(ArmPlatformIsPrimaryCore):
orr r1, r1, r2 orr r1, r1, r2
// Keep the Cluster ID and Core ID from the MPID // Keep the Cluster ID and Core ID from the MPID
LoadConstantToReg (ARM_CLUSTER_MASK | ARM_CORE_MASK, r2) MOV32 (r2, ARM_CLUSTER_MASK | ARM_CORE_MASK)
and r0, r0, r2 and r0, r0, r2
// Compare mpid and boot cpu from ARM_SCC_CFGREG48 // Compare mpid and boot cpu from ARM_SCC_CFGREG48
@ -71,10 +63,10 @@ ASM_PFX(ArmPlatformIsPrimaryCore):
//ArmPlatformGetPrimaryCoreMpId ( //ArmPlatformGetPrimaryCoreMpId (
// VOID // VOID
// ); // );
ASM_PFX(ArmPlatformGetPrimaryCoreMpId): ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
// Extract cpu_id and cluster_id from ARM_SCC_CFGREG48 // Extract cpu_id and cluster_id from ARM_SCC_CFGREG48
// with cpu_id[0:3] and cluster_id[4:7] // with cpu_id[0:3] and cluster_id[4:7]
LoadConstantToReg (ARM_CTA15A7_SCC_CFGREG48, r0) MOV32 (r0, ARM_CTA15A7_SCC_CFGREG48)
ldr r0, [r0] ldr r0, [r0]
lsr r0, #24 lsr r0, #24

View File

@ -14,36 +14,22 @@
#include <AsmMacroIoLib.h> #include <AsmMacroIoLib.h>
#include <Library/ArmLib.h> #include <Library/ArmLib.h>
.text
.align 2
GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)
GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)
GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)
//UINTN //UINTN
//ArmPlatformGetPrimaryCoreMpId ( //ArmPlatformGetPrimaryCoreMpId (
// VOID // VOID
// ); // );
ASM_PFX(ArmPlatformGetPrimaryCoreMpId): ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r0) MOV32 (r0, FixedPcdGet32 (PcdArmPrimaryCore))
ldr r0, [r0]
bx lr bx lr
//UINTN //UINTN
//ArmPlatformIsPrimaryCore ( //ArmPlatformIsPrimaryCore (
// IN UINTN MpId // IN UINTN MpId
// ); // );
ASM_PFX(ArmPlatformIsPrimaryCore): ASM_FUNC(ArmPlatformIsPrimaryCore)
LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1) MOV32 (r1, FixedPcdGet32 (PcdArmPrimaryCoreMask))
ldr r1, [r1]
and r0, r0, r1 and r0, r0, r1
LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1) MOV32 (r1, FixedPcdGet32 (PcdArmPrimaryCore))
ldr r1, [r1]
cmp r0, r1 cmp r0, r1
moveq r0, #1 moveq r0, #1
movne r0, #0 movne r0, #0
@ -53,11 +39,11 @@ ASM_PFX(ArmPlatformIsPrimaryCore):
//ArmPlatformGetCorePosition ( //ArmPlatformGetCorePosition (
// IN UINTN MpId // IN UINTN MpId
// ); // );
ASM_PFX(ArmPlatformGetCorePosition): ASM_FUNC(ArmPlatformGetCorePosition)
and r0, r0, #ARM_CORE_MASK and r0, r0, #ARM_CORE_MASK
bx lr bx lr
ASM_PFX(ArmPlatformPeiBootAction): ASM_FUNC(ArmPlatformPeiBootAction)
bx lr bx lr
ASM_FUNCTION_REMOVE_IF_UNREFERENCED ASM_FUNCTION_REMOVE_IF_UNREFERENCED

View File

@ -12,53 +12,33 @@
# #
#include <AsmMacroIoLibV8.h> #include <AsmMacroIoLibV8.h>
#include <Base.h>
#include <Library/ArmLib.h> #include <Library/ArmLib.h>
#include <Library/PcdLib.h>
#include <AutoGen.h>
.text ASM_FUNC(ArmPlatformPeiBootAction)
.align 2
GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)
GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
GCC_ASM_EXPORT(ArmGetCpuCountPerCluster)
GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)
GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)
GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdCoreCount)
ASM_PFX(ArmPlatformPeiBootAction):
ret ret
//UINTN //UINTN
//ArmPlatformGetPrimaryCoreMpId ( //ArmPlatformGetPrimaryCoreMpId (
// VOID // VOID
// ); // );
ASM_PFX(ArmPlatformGetPrimaryCoreMpId): ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, x0) MOV32 (w0, FixedPcdGet32 (PcdArmPrimaryCore))
ldrh w0, [x0]
ret ret
# IN None # IN None
# OUT x0 = number of cores present in the system # OUT x0 = number of cores present in the system
ASM_PFX(ArmGetCpuCountPerCluster): ASM_FUNC(ArmGetCpuCountPerCluster)
LoadConstantToReg (_gPcd_FixedAtBuild_PcdCoreCount, x0) MOV32 (w0, FixedPcdGet32 (PcdCoreCount))
ldrh w0, [x0]
ret ret
//UINTN //UINTN
//ArmPlatformIsPrimaryCore ( //ArmPlatformIsPrimaryCore (
// IN UINTN MpId // IN UINTN MpId
// ); // );
ASM_PFX(ArmPlatformIsPrimaryCore): ASM_FUNC(ArmPlatformIsPrimaryCore)
LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, x1) MOV32 (w1, FixedPcdGet32 (PcdArmPrimaryCoreMask))
ldrh w1, [x1]
and x0, x0, x1 and x0, x0, x1
LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, x1) MOV32 (w1, FixedPcdGet32 (PcdArmPrimaryCore))
ldrh w1, [x1]
cmp w0, w1 cmp w0, w1
b.ne 1f b.ne 1f
mov x0, #1 mov x0, #1
@ -72,7 +52,7 @@ ASM_PFX(ArmPlatformIsPrimaryCore):
// IN UINTN MpId // IN UINTN MpId
// ); // );
// With this function: CorePos = (ClusterId * 4) + CoreId // With this function: CorePos = (ClusterId * 4) + CoreId
ASM_PFX(ArmPlatformGetCorePosition): ASM_FUNC(ArmPlatformGetCorePosition)
and x1, x0, #ARM_CORE_MASK and x1, x0, #ARM_CORE_MASK
and x0, x0, #ARM_CLUSTER_MASK and x0, x0, #ARM_CLUSTER_MASK
add x0, x1, x0, LSR #6 add x0, x1, x0, LSR #6

View File

@ -12,32 +12,16 @@
# #
#include <AsmMacroIoLib.h> #include <AsmMacroIoLib.h>
#include <Base.h>
#include <Library/ArmLib.h> #include <Library/ArmLib.h>
#include <Library/PcdLib.h>
#include <AutoGen.h>
#include "AsmMacroIoLib.inc"
#include <Chipset/ArmCortexA9.h> #include <Chipset/ArmCortexA9.h>
.text ASM_FUNC(ArmPlatformPeiBootAction)
.align 2
GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
GCC_ASM_EXPORT(ArmGetCpuCountPerCluster)
GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)
GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)
GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)
ASM_PFX(ArmPlatformPeiBootAction):
bx lr bx lr
# IN None # IN None
# OUT r0 = SCU Base Address # OUT r0 = SCU Base Address
ASM_PFX(ArmGetScuBaseAddress): ASM_FUNC(ArmGetScuBaseAddress)
# Read Configuration Base Address Register. ArmCBar cannot be called to get # Read Configuration Base Address Register. ArmCBar cannot be called to get
# the Configuration BAR as a stack is not necessary setup. The SCU is at the # the Configuration BAR as a stack is not necessary setup. The SCU is at the
# offset 0x0000 from the Private Memory Region. # offset 0x0000 from the Private Memory Region.
@ -48,14 +32,13 @@ ASM_PFX(ArmGetScuBaseAddress):
//ArmPlatformGetPrimaryCoreMpId ( //ArmPlatformGetPrimaryCoreMpId (
// VOID // VOID
// ); // );
ASM_PFX(ArmPlatformGetPrimaryCoreMpId): ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r0) MOV32 (r0, FixedPcdGet32 (PcdArmPrimaryCore))
ldr r0, [r0]
bx lr bx lr
# IN None # IN None
# OUT r0 = number of cores present in the system # OUT r0 = number of cores present in the system
ASM_PFX(ArmGetCpuCountPerCluster): ASM_FUNC(ArmGetCpuCountPerCluster)
stmfd SP!, {r1-r2} stmfd SP!, {r1-r2}
# Read CP15 MIDR # Read CP15 MIDR
@ -63,10 +46,10 @@ ASM_PFX(ArmGetCpuCountPerCluster):
# Check if the CPU is A15 # Check if the CPU is A15
mov r1, r1, LSR #4 mov r1, r1, LSR #4
LoadConstantToReg (ARM_CPU_TYPE_MASK, r0) MOV32 (r0, ARM_CPU_TYPE_MASK)
and r1, r1, r0 and r1, r1, r0
LoadConstantToReg (ARM_CPU_TYPE_A15, r0) MOV32 (r0, ARM_CPU_TYPE_A15)
cmp r1, r0 cmp r1, r0
beq _Read_cp15_reg beq _Read_cp15_reg
@ -92,12 +75,10 @@ _Return:
//ArmPlatformIsPrimaryCore ( //ArmPlatformIsPrimaryCore (
// IN UINTN MpId // IN UINTN MpId
// ); // );
ASM_PFX(ArmPlatformIsPrimaryCore): ASM_FUNC(ArmPlatformIsPrimaryCore)
LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1) MOV32 (r1, FixedPcdGet32 (PcdArmPrimaryCoreMask))
ldr r1, [r1]
and r0, r0, r1 and r0, r0, r1
LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1) MOV32 (r1, FixedPcdGet32 (PcdArmPrimaryCore))
ldr r1, [r1]
cmp r0, r1 cmp r0, r1
moveq r0, #1 moveq r0, #1
movne r0, #0 movne r0, #0
@ -107,7 +88,7 @@ ASM_PFX(ArmPlatformIsPrimaryCore):
//ArmPlatformGetCorePosition ( //ArmPlatformGetCorePosition (
// IN UINTN MpId // IN UINTN MpId
// ); // );
ASM_PFX(ArmPlatformGetCorePosition): ASM_FUNC(ArmPlatformGetCorePosition)
and r1, r0, #ARM_CORE_MASK and r1, r0, #ARM_CORE_MASK
and r0, r0, #ARM_CLUSTER_MASK and r0, r0, #ARM_CLUSTER_MASK
add r0, r1, r0, LSR #7 add r0, r1, r0, LSR #7

View File

@ -12,18 +12,9 @@
// //
#include <AsmMacroIoLib.h> #include <AsmMacroIoLib.h>
#include <Base.h>
#include <Library/ArmPlatformLib.h> #include <Library/ArmPlatformLib.h>
#include <Drivers/PL35xSmc.h> #include <Drivers/PL35xSmc.h>
#include <ArmPlatform.h> #include <ArmPlatform.h>
#include <AutoGen.h>
.text
.align 3
GCC_ASM_EXPORT(ArmPlatformSecBootAction)
GCC_ASM_EXPORT(ArmPlatformSecBootMemoryInit)
GCC_ASM_IMPORT(PL35xSmcInitialize)
// //
// For each Chip Select: ChipSelect / SetCycle / SetOpMode // For each Chip Select: ChipSelect / SetCycle / SetOpMode
@ -69,7 +60,7 @@ VersatileExpressSmcConfigurationEnd:
Note: This function must be implemented in assembler as there is no stack set up yet Note: This function must be implemented in assembler as there is no stack set up yet
**/ **/
ASM_PFX(ArmPlatformSecBootAction): ASM_FUNC(ArmPlatformSecBootAction)
bx lr bx lr
/** /**
@ -82,21 +73,21 @@ ASM_PFX(ArmPlatformSecBootAction):
pointer is not used (probably required to use assembly language) pointer is not used (probably required to use assembly language)
**/ **/
ASM_PFX(ArmPlatformSecBootMemoryInit): ASM_FUNC(ArmPlatformSecBootMemoryInit)
mov r5, lr mov r5, lr
// //
// Initialize PL354 SMC // Initialize PL354 SMC
// //
LoadConstantToReg (ARM_VE_SMC_CTRL_BASE, r1) MOV32 (r1, ARM_VE_SMC_CTRL_BASE)
LoadConstantToReg (VersatileExpressSmcConfiguration, r2) MOV32 (r2, VersatileExpressSmcConfiguration)
LoadConstantToReg (VersatileExpressSmcConfigurationEnd, r3) MOV32 (r3, VersatileExpressSmcConfigurationEnd)
blx ASM_PFX(PL35xSmcInitialize) blx ASM_PFX(PL35xSmcInitialize)
// //
// Page mode setup for VRAM // Page mode setup for VRAM
// //
LoadConstantToReg (VRAM_MOTHERBOARD_BASE, r2) MOV32 (r2, VRAM_MOTHERBOARD_BASE)
// Read current state // Read current state
ldr r0, [r2, #0] ldr r0, [r2, #0]
@ -110,7 +101,7 @@ ASM_PFX(ArmPlatformSecBootMemoryInit):
ldr r0, [r2, #0] ldr r0, [r2, #0]
ldr r0, = 0x00000000 ldr r0, = 0x00000000
str r0, [r2, #0] str r0, [r2, #0]
LoadConstantToReg (0x00900090, r0) ldr r0, = 0x00900090
str r0, [r2, #0] str r0, [r2, #0]
// Confirm page mode enabled // Confirm page mode enabled