]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Sec/Sec.c
ArmPkg/ArmLib: Added new functions to access ARM coprocessors
[mirror_edk2.git] / ArmPlatformPkg / Sec / Sec.c
index 00d042cf094d6d39b5cd60b3bf47b6f4fbd9d2ff..00293f0d007be2d865a13ee4bfc3c801b4f347bb 100644 (file)
@@ -54,7 +54,8 @@ CEntryPoint (
   // Primary CPU clears out the SCU tag RAMs, secondaries wait
   if (IS_PRIMARY_CORE(MpId)) {
     if (ArmIsMpCore()) {
-      ArmCpuSynchronizeSignal (ARM_CPU_EVENT_BOOT_MEM_INIT);
+      // Signal for the initial memory is configured (event: BOOT_MEM_INIT)
+      ArmCallSEV ();
     }
 
     // SEC phase needs to run library constructors by hand. This assumes we are linked against the SerialLib
@@ -62,7 +63,13 @@ CEntryPoint (
     SerialPortInitialize ();
 
     // Start talking
-    CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"UEFI firmware built at %a on %a\n\r",__TIME__, __DATE__);
+    if (FixedPcdGetBool (PcdTrustzoneSupport)) {
+      CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Secure firmware (version %s built at %a on %a)\n\r",
+          (CHAR16*)PcdGetPtr(PcdFirmwareVersionString), __TIME__, __DATE__);
+    } else {
+      CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Boot firmware (version %s built at %a on %a)\n\r",
+          (CHAR16*)PcdGetPtr(PcdFirmwareVersionString), __TIME__, __DATE__);
+    }
     SerialPortWrite ((UINT8 *) Buffer, CharCount);
 
     // Initialize the Debug Agent for Source Level Debugging
@@ -84,7 +91,7 @@ CEntryPoint (
   }
 
   // Enable Full Access to CoProcessors
-  ArmWriteCPACR (CPACR_CP_FULL_ACCESS);
+  ArmWriteCpacr (CPACR_CP_FULL_ACCESS);
 
   if (IS_PRIMARY_CORE(MpId)) {
     // Initialize peripherals that must be done at the early stage
@@ -106,6 +113,11 @@ CEntryPoint (
       ArmCpuSetupSmpNonSecure (GET_CORE_ID(MpId));
     }
 
+    // Either we use the Secure Stacks for Secure Monitor (in this case (Base == 0) && (Size == 0))
+    // Or we use separate Secure Monitor stacks (but (Base != 0) && (Size != 0))
+    ASSERT (((PcdGet32(PcdCPUCoresSecMonStackBase) == 0) && (PcdGet32(PcdCPUCoreSecMonStackSize) == 0)) ||
+            ((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))));
   } else {
@@ -139,26 +151,27 @@ TrustedWorldInitialization (
   // Set up Monitor World (Vector Table, etc)
   ArmSecureMonitorWorldInitialize ();
 
+  // Transfer the interrupt to Non-secure World
+  ArmGicSetupNonSecure (MpId, PcdGet32(PcdGicDistributorBase), PcdGet32(PcdGicInterruptInterfaceBase));
+
+  // Initialize platform specific security policy
+  ArmPlatformTrustzoneInit (MpId);
+
   // Setup the Trustzone Chipsets
   if (IS_PRIMARY_CORE(MpId)) {
-    ArmPlatformTrustzoneInit ();
-
     if (ArmIsMpCore()) {
-      // Waiting for the Primary Core to have finished to initialize the Secure World
-      ArmCpuSynchronizeSignal (ARM_CPU_EVENT_SECURE_INIT);
+      // Signal the secondary core the Security settings is done (event: EVENT_SECURE_INIT)
+      ArmCallSEV ();
     }
   } else {
     // The secondary cores need to wait until the Trustzone chipsets configuration is done
     // before switching to Non Secure World
 
-    // Waiting for the Primary Core to have finished to initialize the Secure World
-    ArmCpuSynchronizeWait (ARM_CPU_EVENT_SECURE_INIT);
+    // Wait for the Primary Core to finish the initialization of the Secure World (event: EVENT_SECURE_INIT)
+    ArmCallWFE ();
   }
 
-  // Transfer the interrupt to Non-secure World
-  ArmGicSetupNonSecure (PcdGet32(PcdGicDistributorBase), PcdGet32(PcdGicInterruptInterfaceBase));
-
-  // Call the Platform specific fucntion to execute additional actions if required
+  // Call the Platform specific function to execute additional actions if required
   JumpAddress = PcdGet32 (PcdFvBaseAddress);
   ArmPlatformSecExtraAction (MpId, &JumpAddress);