]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/PrePi/PrePi.c
ArmPlatformPkg/PrePi: fix IS_XIP
[mirror_edk2.git] / ArmPlatformPkg / PrePi / PrePi.c
old mode 100755 (executable)
new mode 100644 (file)
index 99afe6f..74284f1
@@ -1,14 +1,8 @@
 /** @file\r
 *\r
-*  Copyright (c) 2011-2014, ARM Limited. All rights reserved.\r
+*  Copyright (c) 2011-2017, ARM Limited. All rights reserved.\r
 *\r
-*  This program and the accompanying materials\r
-*  are licensed and made available under the terms and conditions of the BSD License\r
-*  which accompanies this distribution.  The full text of the license may be found at\r
-*  http://opensource.org/licenses/bsd-license.php\r
-*\r
-*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+*  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 *\r
 **/\r
 \r
 #include <Library/DebugAgentLib.h>\r
 #include <Library/PrePiLib.h>\r
 #include <Library/PrintLib.h>\r
-#include <Library/PeCoffGetEntryPointLib.h>\r
 #include <Library/PrePiHobListPointerLib.h>\r
 #include <Library/TimerLib.h>\r
 #include <Library/PerformanceLib.h>\r
 \r
 #include <Ppi/GuidedSectionExtraction.h>\r
 #include <Ppi/ArmMpCoreInfo.h>\r
-#include <Guid/LzmaDecompress.h>\r
-#include <Guid/ArmGlobalVariableHob.h>\r
+#include <Ppi/SecPerformance.h>\r
 \r
 #include "PrePi.h"\r
-#include "LzmaDecompress.h"\r
-\r
-#define IS_XIP() (((UINT32)FixedPcdGet32 (PcdFdBaseAddress) > mSystemMemoryEnd) || \\r
-                  ((FixedPcdGet32 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) < FixedPcdGet64 (PcdSystemMemoryBase)))\r
-\r
-// Not used when PrePi in run in XIP mode\r
-UINTN mGlobalVariableBase = 0;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-ExtractGuidedSectionLibConstructor (\r
-  VOID\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-LzmaDecompressLibConstructor (\r
-  VOID\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-BuildGlobalVariableHob (\r
-  IN EFI_PHYSICAL_ADDRESS         GlobalVariableBase,\r
-  IN UINT32                       GlobalVariableSize\r
-  )\r
-{\r
-  ARM_HOB_GLOBAL_VARIABLE  *Hob;\r
 \r
-  Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, sizeof (ARM_HOB_GLOBAL_VARIABLE));\r
-  ASSERT(Hob != NULL);\r
+#define IS_XIP() (((UINT64)FixedPcdGet64 (PcdFdBaseAddress) > mSystemMemoryEnd) || \\r
+                  ((FixedPcdGet64 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) <= FixedPcdGet64 (PcdSystemMemoryBase)))\r
 \r
-  CopyGuid (&(Hob->Header.Name), &gArmGlobalVariableGuid);\r
-  Hob->GlobalVariableBase = GlobalVariableBase;\r
-  Hob->GlobalVariableSize = GlobalVariableSize;\r
-}\r
+UINT64 mSystemMemoryEnd = FixedPcdGet64(PcdSystemMemoryBase) +\r
+                          FixedPcdGet64(PcdSystemMemorySize) - 1;\r
 \r
 EFI_STATUS\r
 GetPlatformPpi (\r
@@ -93,7 +55,6 @@ VOID
 PrePiMain (\r
   IN  UINTN                     UefiMemoryBase,\r
   IN  UINTN                     StacksBase,\r
-  IN  UINTN                     GlobalVariableBase,\r
   IN  UINT64                    StartTimeStamp\r
   )\r
 {\r
@@ -105,11 +66,12 @@ PrePiMain (
   CHAR8                         Buffer[100];\r
   UINTN                         CharCount;\r
   UINTN                         StacksSize;\r
+  FIRMWARE_SEC_PERFORMANCE      Performance;\r
 \r
   // If ensure the FD is either part of the System Memory or totally outside of the System Memory (XIP)\r
   ASSERT (IS_XIP() ||\r
-          ((FixedPcdGet32 (PcdFdBaseAddress) >= FixedPcdGet64 (PcdSystemMemoryBase)) &&\r
-           ((UINT32)(FixedPcdGet32 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) <= (UINT32)mSystemMemoryEnd)));\r
+          ((FixedPcdGet64 (PcdFdBaseAddress) >= FixedPcdGet64 (PcdSystemMemoryBase)) &&\r
+           ((UINT64)(FixedPcdGet64 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) <= (UINT64)mSystemMemoryEnd)));\r
 \r
   // Initialize the architecture specific bits\r
   ArchInitialize ();\r
@@ -146,11 +108,8 @@ PrePiMain (
   }\r
   BuildStackHob (StacksBase, StacksSize);\r
 \r
-  // Declare the Global Variable HOB\r
-  BuildGlobalVariableHob (GlobalVariableBase, FixedPcdGet32 (PcdPeiGlobalVariableSize));\r
-\r
   //TODO: Call CpuPei as a library\r
-  BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));\r
+  BuildCpuHob (ArmGetPhysicalAddressBits (), PcdGet8 (PcdPrePiCpuIoSize));\r
 \r
   if (ArmIsMpCore ()) {\r
     // Only MP Core platform need to produce gArmMpCoreInfoPpiGuid\r
@@ -168,6 +127,12 @@ PrePiMain (
     }\r
   }\r
 \r
+  // Store timer value logged at the beginning of firmware image execution\r
+  Performance.ResetEnd = GetTimeInNanoSecond (StartTimeStamp);\r
+\r
+  // Build SEC Performance Data Hob\r
+  BuildGuidDataHob (&gEfiFirmwarePerformanceGuid, &Performance, sizeof (Performance));\r
+\r
   // Set the Boot Mode\r
   SetBootMode (ArmPlatformGetBootMode ());\r
 \r
@@ -179,16 +144,7 @@ PrePiMain (
   PERF_START (NULL, "PEI", NULL, StartTimeStamp);\r
 \r
   // SEC phase needs to run library constructors by hand.\r
-  ExtractGuidedSectionLibConstructor ();\r
-  LzmaDecompressLibConstructor ();\r
-\r
-  // Build HOBs to pass up our version of stuff the DXE Core needs to save space\r
-  BuildPeCoffLoaderHob ();\r
-  BuildExtractSectionHob (\r
-    &gLzmaCustomDecompressGuid,\r
-    LzmaGuidedSectionGetInfo,\r
-    LzmaGuidedSectionExtraction\r
-    );\r
+  ProcessLibraryConstructorList ();\r
 \r
   // Assume the FV that contains the SEC (our code) also contains a compressed FV.\r
   Status = DecompressFirstFv ();\r
@@ -203,14 +159,11 @@ VOID
 CEntryPoint (\r
   IN  UINTN                     MpId,\r
   IN  UINTN                     UefiMemoryBase,\r
-  IN  UINTN                     StacksBase,\r
-  IN  UINTN                     GlobalVariableBase\r
+  IN  UINTN                     StacksBase\r
   )\r
 {\r
   UINT64   StartTimeStamp;\r
 \r
-  ASSERT(!ArmIsMpCore() || (PcdGet32 (PcdCoreCount) > 1));\r
-\r
   // Initialize the platform specific controllers\r
   ArmPlatformInitialize (MpId);\r
 \r
@@ -235,13 +188,12 @@ CEntryPoint (
   // Define the Global Variable region when we are not running in XIP\r
   if (!IS_XIP()) {\r
     if (ArmPlatformIsPrimaryCore (MpId)) {\r
-      mGlobalVariableBase = GlobalVariableBase;\r
       if (ArmIsMpCore()) {\r
         // Signal the Global Variable Region is defined (event: ARM_CPU_EVENT_DEFAULT)\r
         ArmCallSEV ();\r
       }\r
     } else {\r
-      // Wait the Primay core has defined the address of the Global Variable region (event: ARM_CPU_EVENT_DEFAULT)\r
+      // Wait the Primary core has defined the address of the Global Variable region (event: ARM_CPU_EVENT_DEFAULT)\r
       ArmCallWFE ();\r
     }\r
   }\r
@@ -249,7 +201,7 @@ CEntryPoint (
   // If not primary Jump to Secondary Main\r
   if (ArmPlatformIsPrimaryCore (MpId)) {\r
     // Goto primary Main.\r
-    PrimaryMain (UefiMemoryBase, StacksBase, GlobalVariableBase, StartTimeStamp);\r
+    PrimaryMain (UefiMemoryBase, StacksBase, StartTimeStamp);\r
   } else {\r
     SecondaryMain (MpId);\r
   }\r