For instance, in case of CpuHotPlug boot path the platform has already been
initialized. The CPU core should not execute any of the platform initialization
in this case.
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13492
6f19259b-4bc3-4df7-8a09-
765794883524
#ifndef _ARMPLATFORMSECLIB_H_
#define _ARMPLATFORMSECLIB_H_
#ifndef _ARMPLATFORMSECLIB_H_
#define _ARMPLATFORMSECLIB_H_
+#define ARM_SEC_BOOT_MASK ~0
+#define ARM_SEC_COLD_BOOT (1 << 0)
+#define ARM_SEC_SECONDARY_COLD_BOOT (1 << 1)
+
/**
Initialize the memory where the initial stacks will reside
/**
Initialize the memory where the initial stacks will reside
\r
# r0: Monitor World EntryPoint\r
# r1: MpId\r
\r
# r0: Monitor World EntryPoint\r
# r1: MpId\r
-# r2: Secure Monitor mode stack\r
+# r2: SecBootMode\r
+# r3: Secure Monitor mode stack\r
ASM_PFX(enter_monitor_mode):\r
ASM_PFX(enter_monitor_mode):\r
- cmp r2, #0 @ If a Secure Monitor stack base has not been defined then use the Secure stack\r
- moveq r2, sp\r
+ cmp r3, #0 @ If a Secure Monitor stack base has not been defined then use the Secure stack\r
+ moveq r3, sp\r
\r
mrs r4, cpsr @ Save current mode (SVC) in r4\r
\r
mrs r4, cpsr @ Save current mode (SVC) in r4\r
- bic r3, r4, #0x1f @ Clear all mode bits\r
- orr r3, r3, #0x16 @ Set bits for Monitor mode\r
- msr cpsr_cxsf, r3 @ We are now in Monitor Mode\r
+ bic r5, r4, #0x1f @ Clear all mode bits\r
+ orr r5, r5, #0x16 @ Set bits for Monitor mode\r
+ msr cpsr_cxsf, r5 @ We are now in Monitor Mode\r
- mov sp, r2 @ Set the stack of the Monitor Mode\r
+ mov sp, r3 @ Set the stack of the Monitor Mode\r
\r
mov lr, r0 @ Use the pass entrypoint as lr\r
\r
\r
mov lr, r0 @ Use the pass entrypoint as lr\r
\r
\r
mov r4, r0 @ Swap EntryPoint and MpId registers\r
mov r0, r1\r
\r
mov r4, r0 @ Swap EntryPoint and MpId registers\r
mov r0, r1\r
+ mov r1, r2\r
+ mov r2, r3\r
\r
// r0: Monitor World EntryPoint\r
// r1: MpId\r
\r
// r0: Monitor World EntryPoint\r
// r1: MpId\r
-// r2: Secure Monitor mode stack\r
-enter_monitor_mode\r
- cmp r2, #0 // If a Secure Monitor stack base has not been defined then use the Secure stack\r
- moveq r2, sp\r
+// r2: SecBootMode\r
+// r3: Secure Monitor mode stack\r
+enter_monitor_mode FUNCTION\r
+ cmp r3, #0 // If a Secure Monitor stack base has not been defined then use the Secure stack\r
+ moveq r3, sp\r
\r
mrs r4, cpsr // Save current mode (SVC) in r4\r
\r
mrs r4, cpsr // Save current mode (SVC) in r4\r
- bic r3, r4, #0x1f // Clear all mode bits\r
- orr r3, r3, #0x16 // Set bits for Monitor mode\r
- msr cpsr_cxsf, r3 // We are now in Monitor Mode\r
+ bic r5, r4, #0x1f // Clear all mode bits\r
+ orr r5, r5, #0x16 // Set bits for Monitor mode\r
+ msr cpsr_cxsf, r5 // We are now in Monitor Mode\r
- mov sp, r2 // Set the stack of the Monitor Mode\r
+ mov sp, r3 // Set the stack of the Monitor Mode\r
\r
mov lr, r0 // Use the pass entrypoint as lr\r
\r
\r
mov lr, r0 // Use the pass entrypoint as lr\r
\r
\r
mov r4, r0 // Swap EntryPoint and MpId registers\r
mov r0, r1\r
\r
mov r4, r0 // Swap EntryPoint and MpId registers\r
mov r0, r1\r
+ mov r1, r2\r
+ mov r2, r3\r
\r
// We cannot use the instruction 'movs pc, lr' because the caller can be written either in ARM or Thumb2 assembler.\r
// When we will jump into this function, we will set the CPSR flag to ARM assembler. By copying directly 'lr' into\r
\r
// We cannot use the instruction 'movs pc, lr' because the caller can be written either in ARM or Thumb2 assembler.\r
// When we will jump into this function, we will set the CPSR flag to ARM assembler. By copying directly 'lr' into\r
+ IN UINTN MpId,
+ IN UINTN SecBootMode
((PcdGet32(PcdCPUCoresSecMonStackBase) != 0) && (PcdGet32(PcdCPUCoreSecMonStackSize) != 0)));
// Enter Monitor Mode
((PcdGet32(PcdCPUCoresSecMonStackBase) != 0) && (PcdGet32(PcdCPUCoreSecMonStackSize) != 0)));
// Enter Monitor Mode
- enter_monitor_mode ((UINTN)TrustedWorldInitialization, MpId, (VOID*)(PcdGet32(PcdCPUCoresSecMonStackBase) + (PcdGet32(PcdCPUCoreSecMonStackSize) * (GET_CORE_POS(MpId) + 1))));
+ enter_monitor_mode ((UINTN)TrustedWorldInitialization, MpId, SecBootMode, (VOID*)(PcdGet32(PcdCPUCoresSecMonStackBase) + (PcdGet32(PcdCPUCoreSecMonStackSize) * (GET_CORE_POS(MpId) + 1))));
} else {
if (IS_PRIMARY_CORE(MpId)) {
SerialPrint ("Trust Zone Configuration is disabled\n\r");
} else {
if (IS_PRIMARY_CORE(MpId)) {
SerialPrint ("Trust Zone Configuration is disabled\n\r");
VOID
TrustedWorldInitialization (
VOID
TrustedWorldInitialization (
+ IN UINTN MpId,
+ IN UINTN SecBootMode
// Signal the secondary core the Security settings is done (event: EVENT_SECURE_INIT)
ArmCallSEV ();
}
// Signal the secondary core the Security settings is done (event: EVENT_SECURE_INIT)
ArmCallSEV ();
}
+ } else if ((SecBootMode & ARM_SEC_BOOT_MASK) == ARM_SEC_COLD_BOOT) {
// The secondary cores need to wait until the Trustzone chipsets configuration is done
// before switching to Non Secure World
// The secondary cores need to wait until the Trustzone chipsets configuration is done
// before switching to Non Secure World
// Ensure that the MMU and caches are off\r
bl ASM_PFX(ArmDisableCachesAndMmu)\r
\r
// Ensure that the MMU and caches are off\r
bl ASM_PFX(ArmDisableCachesAndMmu)\r
\r
+ // By default, we are doing a cold boot\r
+ mov r10, #ARM_SEC_COLD_BOOT\r
+\r
// Jump to Platform Specific Boot Action function\r
blx ASM_PFX(ArmPlatformSecBootAction)\r
\r
// Jump to Platform Specific Boot Action function\r
blx ASM_PFX(ArmPlatformSecBootAction)\r
\r
beq _InitMem\r
\r
_WaitInitMem:\r
beq _InitMem\r
\r
_WaitInitMem:\r
+ // If we are not doing a cold boot in this case we should assume the Initial Memory to be already initialized\r
+ // Otherwise we have to wait the Primary Core to finish the initialization\r
+ cmp r10, #ARM_SEC_COLD_BOOT\r
+ bne _SetupSecondaryCoreStack\r
+\r
// Wait for the primary core to initialize the initial memory (event: BOOT_MEM_INIT)\r
bl ASM_PFX(ArmCallWFE)\r
// Now the Init Mem is initialized, we setup the secondary core stacks\r
// Wait for the primary core to initialize the initial memory (event: BOOT_MEM_INIT)\r
bl ASM_PFX(ArmCallWFE)\r
// Now the Init Mem is initialized, we setup the secondary core stacks\r
\r
// Jump to SEC C code\r
// r0 = mp_id\r
\r
// Jump to SEC C code\r
// r0 = mp_id\r
blx r3\r
\r
_NeverReturn:\r
blx r3\r
\r
_NeverReturn:\r
\r
StartupAddr DCD CEntryPoint\r
\r
\r
StartupAddr DCD CEntryPoint\r
\r
+_ModuleEntryPoint FUNCTION\r
// First ensure all interrupts are disabled\r
blx ArmDisableInterrupts\r
\r
// Ensure that the MMU and caches are off\r
blx ArmDisableCachesAndMmu\r
\r
// First ensure all interrupts are disabled\r
blx ArmDisableInterrupts\r
\r
// Ensure that the MMU and caches are off\r
blx ArmDisableCachesAndMmu\r
\r
+ // By default, we are doing a cold boot\r
+ mov r10, #ARM_SEC_COLD_BOOT\r
+\r
// Jump to Platform Specific Boot Action function\r
blx ArmPlatformSecBootAction\r
\r
// Jump to Platform Specific Boot Action function\r
blx ArmPlatformSecBootAction\r
\r
beq _InitMem\r
\r
_WaitInitMem\r
beq _InitMem\r
\r
_WaitInitMem\r
+ // If we are not doing a cold boot in this case we should assume the Initial Memory to be already initialized\r
+ // Otherwise we have to wait the Primary Core to finish the initialization\r
+ cmp r10, #ARM_SEC_COLD_BOOT\r
+ bne _SetupSecondaryCoreStack\r
+\r
// Wait for the primary core to initialize the initial memory (event: BOOT_MEM_INIT)\r
bl ArmCallWFE\r
// Now the Init Mem is initialized, we setup the secondary core stacks\r
// Wait for the primary core to initialize the initial memory (event: BOOT_MEM_INIT)\r
bl ArmCallWFE\r
// Now the Init Mem is initialized, we setup the secondary core stacks\r
\r
// Jump to SEC C code\r
// r0 = mp_id\r
\r
// Jump to SEC C code\r
// r0 = mp_id\r
\r
_NeverReturn\r
b _NeverReturn\r
\r
_NeverReturn\r
b _NeverReturn\r
\r
VOID\r
TrustedWorldInitialization (\r
\r
VOID\r
TrustedWorldInitialization (\r
+ IN UINTN MpId,\r
+ IN UINTN SecBootMode\r
enter_monitor_mode (\r
IN UINTN MonitorEntryPoint,\r
IN UINTN MpId,\r
enter_monitor_mode (\r
IN UINTN MonitorEntryPoint,\r
IN UINTN MpId,\r
+ IN UINTN SecBootMode,\r
+ IN VOID* MonitorStackBase\r