]> git.proxmox.com Git - mirror_edk2.git/commitdiff
StandaloneMmPkg: Add CPU driver suitable for ARM Platforms.
authorSupreeth Venkatesh <supreeth.venkatesh@arm.com>
Fri, 13 Jul 2018 15:05:29 +0000 (23:05 +0800)
committerJiewen Yao <jiewen.yao@intel.com>
Fri, 20 Jul 2018 02:59:53 +0000 (10:59 +0800)
This patch adds a simple CPU driver that exports the
EFI_MM_CONFIGURATION_PROTOCOL to allow registration of the Standalone
MM Foundation entry point. It preserves the existing notification
mechanism for the configuration protocol.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu <sughosh.ganu@arm.com>
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Reviewed-by: Achin Gupta <achin.gupta@arm.com>
StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c [new file with mode: 0644]
StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c [new file with mode: 0644]
StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h [new file with mode: 0644]
StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.inf [new file with mode: 0644]
StandaloneMmPkg/Include/Guid/MpInformation.h [new file with mode: 0644]

diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c
new file mode 100644 (file)
index 0000000..2814577
--- /dev/null
@@ -0,0 +1,220 @@
+/** @file\r
+\r
+  Copyright (c) 2016 HP Development Company, L.P.\r
+  Copyright (c) 2016 - 2018, 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
+\r
+**/\r
+\r
+#include <Base.h>\r
+#include <Pi/PiMmCis.h>\r
+\r
+\r
+#include <Library/ArmSvcLib.h>\r
+#include <Library/ArmLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/HobLib.h>\r
+\r
+#include <Protocol/DebugSupport.h> // for EFI_SYSTEM_CONTEXT\r
+\r
+#include <Guid/ZeroGuid.h>\r
+#include <Guid/MmramMemoryReserve.h>\r
+\r
+#include <IndustryStandard/ArmStdSmc.h>\r
+\r
+#include "StandaloneMmCpu.h"\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+MmFoundationEntryRegister (\r
+  IN CONST EFI_MM_CONFIGURATION_PROTOCOL  *This,\r
+  IN EFI_MM_ENTRY_POINT                    MmEntryPoint\r
+  );\r
+\r
+//\r
+// On ARM platforms every event is expected to have a GUID associated with\r
+// it. It will be used by the MM Entry point to find the handler for the\r
+// event. It will either be populated in a EFI_MM_COMMUNICATE_HEADER by the\r
+// caller of the event (e.g. MM_COMMUNICATE SMC) or by the CPU driver\r
+// (e.g. during an asynchronous event). In either case, this context is\r
+// maintained in an array which has an entry for each CPU. The pointer to this\r
+// array is held in PerCpuGuidedEventContext. Memory is allocated once the\r
+// number of CPUs in the system are made known through the\r
+// MP_INFORMATION_HOB_DATA.\r
+//\r
+EFI_MM_COMMUNICATE_HEADER **PerCpuGuidedEventContext = NULL;\r
+\r
+// Descriptor with whereabouts of memory used for communication with the normal world\r
+EFI_MMRAM_DESCRIPTOR  mNsCommBuffer;\r
+\r
+MP_INFORMATION_HOB_DATA *mMpInformationHobData;\r
+\r
+EFI_MM_CONFIGURATION_PROTOCOL mMmConfig = {\r
+  0,\r
+  MmFoundationEntryRegister\r
+};\r
+\r
+STATIC EFI_MM_ENTRY_POINT     mMmEntryPoint = NULL;\r
+\r
+EFI_STATUS\r
+PiMmStandloneArmTfCpuDriverEntry (\r
+  IN UINTN EventId,\r
+  IN UINTN CpuNumber,\r
+  IN UINTN NsCommBufferAddr\r
+  )\r
+{\r
+  EFI_MM_COMMUNICATE_HEADER *GuidedEventContext = NULL;\r
+  EFI_MM_ENTRY_CONTEXT        MmEntryPointContext = {0};\r
+  EFI_STATUS                  Status;\r
+  UINTN                       NsCommBufferSize;\r
+\r
+  DEBUG ((DEBUG_INFO, "Received event - 0x%x on cpu %d\n", EventId, CpuNumber));\r
+\r
+  Status = EFI_SUCCESS;\r
+  //\r
+  // ARM TF passes SMC FID of the MM_COMMUNICATE interface as the Event ID upon\r
+  // receipt of a synchronous MM request. Use the Event ID to distinguish\r
+  // between synchronous and asynchronous events.\r
+  //\r
+  if (ARM_SMC_ID_MM_COMMUNICATE_AARCH64 != EventId) {\r
+    DEBUG ((DEBUG_INFO, "UnRecognized Event - 0x%x\n", EventId));\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  // Perform parameter validation of NsCommBufferAddr\r
+  if (NsCommBufferAddr && (NsCommBufferAddr < mNsCommBuffer.PhysicalStart))\r
+    return EFI_ACCESS_DENIED;\r
+\r
+  if ((NsCommBufferAddr + sizeof (EFI_MM_COMMUNICATE_HEADER)) >=\r
+      (mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize))\r
+    return EFI_INVALID_PARAMETER;\r
+\r
+  // Find out the size of the buffer passed\r
+  NsCommBufferSize = ((EFI_MM_COMMUNICATE_HEADER *) NsCommBufferAddr)->MessageLength +\r
+    sizeof (EFI_MM_COMMUNICATE_HEADER);\r
+\r
+  // perform bounds check.\r
+  if (NsCommBufferAddr + NsCommBufferSize >=\r
+      mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize)\r
+    return EFI_ACCESS_DENIED;\r
+\r
+\r
+  // Now that the secure world can see the normal world buffer, allocate\r
+  // memory to copy the communication buffer to the secure world.\r
+  Status = mMmst->MmAllocatePool (\r
+                    EfiRuntimeServicesData,\r
+                    NsCommBufferSize,\r
+                    (VOID **) &GuidedEventContext\r
+                    );\r
+\r
+  if (Status != EFI_SUCCESS) {\r
+    DEBUG ((DEBUG_INFO, "Mem alloc failed - 0x%x\n", EventId));\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  // X1 contains the VA of the normal world memory accessible from\r
+  // S-EL0\r
+  CopyMem (GuidedEventContext, (CONST VOID *) NsCommBufferAddr, NsCommBufferSize);\r
+\r
+  // Stash the pointer to the allocated Event Context for this CPU\r
+  PerCpuGuidedEventContext[CpuNumber] = GuidedEventContext;\r
+\r
+  MmEntryPointContext.CurrentlyExecutingCpu = CpuNumber;\r
+  MmEntryPointContext.NumberOfCpus = mMpInformationHobData->NumberOfProcessors;\r
+\r
+  // Populate the MM system table with MP and state information\r
+  mMmst->CurrentlyExecutingCpu = CpuNumber;\r
+  mMmst->NumberOfCpus = mMpInformationHobData->NumberOfProcessors;\r
+  mMmst->CpuSaveStateSize = 0;\r
+  mMmst->CpuSaveState = NULL;\r
+\r
+  if (mMmEntryPoint == NULL) {\r
+    DEBUG ((DEBUG_INFO, "Mm Entry point Not Found\n"));\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  mMmEntryPoint (&MmEntryPointContext);\r
+\r
+  // Free the memory allocation done earlier and reset the per-cpu context\r
+  ASSERT (GuidedEventContext);\r
+  CopyMem ((VOID *)NsCommBufferAddr, (CONST VOID *) GuidedEventContext, NsCommBufferSize);\r
+\r
+  Status = mMmst->MmFreePool ((VOID *) GuidedEventContext);\r
+  if (Status != EFI_SUCCESS) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  PerCpuGuidedEventContext[CpuNumber] = NULL;\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+MmFoundationEntryRegister (\r
+  IN CONST EFI_MM_CONFIGURATION_PROTOCOL  *This,\r
+  IN EFI_MM_ENTRY_POINT                    MmEntryPoint\r
+  )\r
+{\r
+  // store the entry point in a global\r
+  mMmEntryPoint = MmEntryPoint;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  This function is the main entry point for an MM handler dispatch\r
+  or communicate-based callback.\r
+\r
+  @param  DispatchHandle  The unique handle assigned to this handler by MmiHandlerRegister().\r
+  @param  Context         Points to an optional handler context which was specified when the handler was registered.\r
+  @param  CommBuffer      A pointer to a collection of data in memory that will\r
+                          be conveyed from a non-MM environment into an MM environment.\r
+  @param  CommBufferSize  The size of the CommBuffer.\r
+\r
+  @return Status Code\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PiMmCpuTpFwRootMmiHandler (\r
+  IN     EFI_HANDLE               DispatchHandle,\r
+  IN     CONST VOID               *Context,        OPTIONAL\r
+  IN OUT VOID                     *CommBuffer,     OPTIONAL\r
+  IN OUT UINTN                    *CommBufferSize  OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS Status;\r
+  UINTN      CpuNumber;\r
+\r
+  ASSERT (Context == NULL);\r
+  ASSERT (CommBuffer == NULL);\r
+  ASSERT (CommBufferSize == NULL);\r
+\r
+  CpuNumber = mMmst->CurrentlyExecutingCpu;\r
+  if (!PerCpuGuidedEventContext[CpuNumber])\r
+    return EFI_NOT_FOUND;\r
+\r
+  DEBUG ((DEBUG_INFO, "CommBuffer - 0x%x, CommBufferSize - 0x%x\n",\r
+          PerCpuGuidedEventContext[CpuNumber],\r
+          PerCpuGuidedEventContext[CpuNumber]->MessageLength));\r
+\r
+  Status = mMmst->MmiManage (\r
+                    &PerCpuGuidedEventContext[CpuNumber]->HeaderGuid,\r
+                    NULL,\r
+                    PerCpuGuidedEventContext[CpuNumber]->Data,\r
+                    &PerCpuGuidedEventContext[CpuNumber]->MessageLength\r
+                    );\r
+\r
+  if (Status != EFI_SUCCESS) {\r
+    DEBUG ((DEBUG_WARN, "Unable to manage Guided Event - %d\n", Status));\r
+  }\r
+\r
+  return Status;\r
+}\r
diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c
new file mode 100644 (file)
index 0000000..85a9c10
--- /dev/null
@@ -0,0 +1,232 @@
+/** @file\r
+\r
+  Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
+  Copyright (c) 2016 HP Development Company, L.P.\r
+  Copyright (c) 2016 - 2018, 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
+\r
+**/\r
+\r
+#include <Base.h>\r
+#include <Pi/PiMmCis.h>\r
+#include <Library/AArch64/StandaloneMmCoreEntryPoint.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/ArmSvcLib.h>\r
+#include <Library/ArmLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/HobLib.h>\r
+\r
+#include <Protocol/DebugSupport.h> // for EFI_SYSTEM_CONTEXT\r
+\r
+#include <Guid/ZeroGuid.h>\r
+#include <Guid/MmramMemoryReserve.h>\r
+\r
+\r
+#include "StandaloneMmCpu.h"\r
+\r
+// GUID to identify HOB with whereabouts of communication buffer with Normal\r
+// World\r
+extern EFI_GUID gEfiStandaloneMmNonSecureBufferGuid;\r
+\r
+// GUID to identify HOB where the entry point of this CPU driver will be\r
+// populated to allow the entry point driver to invoke it upon receipt of an\r
+// event\r
+extern EFI_GUID gEfiArmTfCpuDriverEpDescriptorGuid;\r
+\r
+//\r
+// Private copy of the MM system table for future use\r
+//\r
+EFI_MM_SYSTEM_TABLE *mMmst = NULL;\r
+\r
+//\r
+// Globals used to initialize the protocol\r
+//\r
+STATIC EFI_HANDLE            mMmCpuHandle = NULL;\r
+\r
+EFI_STATUS\r
+GetGuidedHobData (\r
+  IN  VOID *HobList,\r
+  IN  CONST EFI_GUID *HobGuid,\r
+  OUT VOID **HobData\r
+  )\r
+{\r
+  EFI_HOB_GUID_TYPE *Hob;\r
+\r
+  if (!HobList || !HobGuid || !HobData)\r
+    return EFI_INVALID_PARAMETER;\r
+\r
+  Hob = GetNextGuidHob (HobGuid, HobList);\r
+  if (!Hob)\r
+    return EFI_NOT_FOUND;\r
+\r
+  *HobData = GET_GUID_HOB_DATA (Hob);\r
+  if (!HobData)\r
+    return EFI_NOT_FOUND;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+StandloneMmCpuInitialize (\r
+  IN EFI_HANDLE         ImageHandle,  // not actual imagehandle\r
+  IN EFI_MM_SYSTEM_TABLE   *SystemTable  // not actual systemtable\r
+  )\r
+{\r
+  ARM_TF_CPU_DRIVER_EP_DESCRIPTOR *CpuDriverEntryPointDesc;\r
+  EFI_CONFIGURATION_TABLE         *ConfigurationTable;\r
+  MP_INFORMATION_HOB_DATA         *MpInformationHobData;\r
+  EFI_MMRAM_DESCRIPTOR            *NsCommBufMmramRange;\r
+  EFI_STATUS                       Status;\r
+  EFI_HANDLE                       DispatchHandle;\r
+  UINT32                           MpInfoSize;\r
+  UINTN                            Index;\r
+  UINTN                            ArraySize;\r
+  VOID                            *HobStart;\r
+\r
+  ASSERT (SystemTable != NULL);\r
+  mMmst = SystemTable;\r
+\r
+  // publish the MM config protocol so the MM core can register its entry point\r
+  Status = mMmst->MmInstallProtocolInterface (\r
+                    &mMmCpuHandle,\r
+                    &gEfiMmConfigurationProtocolGuid,\r
+                    EFI_NATIVE_INTERFACE,\r
+                    &mMmConfig\r
+                    );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  // register the root MMI handler\r
+  Status = mMmst->MmiHandlerRegister (\r
+                    PiMmCpuTpFwRootMmiHandler,\r
+                    NULL,\r
+                    &DispatchHandle\r
+                    );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  // Retrieve the Hoblist from the MMST to extract the details of the NS\r
+  // communication buffer that has been reserved by S-EL1/EL3\r
+  ConfigurationTable = mMmst->MmConfigurationTable;\r
+  for (Index = 0; Index < mMmst->NumberOfTableEntries; Index++) {\r
+    if (CompareGuid (&gEfiHobListGuid, &(ConfigurationTable[Index].VendorGuid))) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  // Bail out if the Hoblist could not be found\r
+  if (Index >= mMmst->NumberOfTableEntries) {\r
+    DEBUG ((DEBUG_INFO, "Hoblist not found - 0x%x\n", Index));\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  HobStart = ConfigurationTable[Index].VendorTable;\r
+\r
+  //\r
+  // Locate the HOB with the buffer to populate the entry point of this driver\r
+  //\r
+  Status = GetGuidedHobData (\r
+             HobStart,\r
+             &gEfiArmTfCpuDriverEpDescriptorGuid,\r
+             (VOID **) &CpuDriverEntryPointDesc\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_INFO, "ArmTfCpuDriverEpDesc HOB data extraction failed - 0x%x\n", Status));\r
+    return Status;\r
+  }\r
+\r
+  // Share the entry point of the CPU driver\r
+  DEBUG ((DEBUG_INFO, "Sharing Cpu Driver EP *0x%lx = 0x%lx\n",\r
+          (UINT64) CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr,\r
+          (UINT64) PiMmStandloneArmTfCpuDriverEntry));\r
+  *(CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr) = PiMmStandloneArmTfCpuDriverEntry;\r
+\r
+  // Find the descriptor that contains the whereabouts of the buffer for\r
+  // communication with the Normal world.\r
+  Status = GetGuidedHobData (\r
+             HobStart,\r
+             &gEfiStandaloneMmNonSecureBufferGuid,\r
+             (VOID **) &NsCommBufMmramRange\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_INFO, "NsCommBufMmramRange HOB data extraction failed - 0x%x\n", Status));\r
+    return Status;\r
+  }\r
+\r
+  DEBUG ((DEBUG_INFO, "mNsCommBuffer.PhysicalStart - 0x%lx\n", (UINT64) NsCommBufMmramRange->PhysicalStart));\r
+  DEBUG ((DEBUG_INFO, "mNsCommBuffer.PhysicalSize - 0x%lx\n", (UINT64) NsCommBufMmramRange->PhysicalSize));\r
+\r
+  CopyMem (&mNsCommBuffer, NsCommBufMmramRange, sizeof(EFI_MMRAM_DESCRIPTOR));\r
+  DEBUG ((DEBUG_INFO, "mNsCommBuffer: 0x%016lx - 0x%lx\n", mNsCommBuffer.CpuStart, mNsCommBuffer.PhysicalSize));\r
+\r
+  //\r
+  // Extract the MP information from the Hoblist\r
+  //\r
+  Status = GetGuidedHobData (\r
+             HobStart,\r
+             &gMpInformationHobGuid,\r
+             (VOID **) &MpInformationHobData\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_INFO, "MpInformationHob extraction failed - 0x%x\n", Status));\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Allocate memory for the MP information and copy over the MP information\r
+  // passed by Trusted Firmware. Use the number of processors passed in the HOB\r
+  // to copy the processor information\r
+  //\r
+  MpInfoSize = sizeof (MP_INFORMATION_HOB_DATA) +\r
+               (sizeof (EFI_PROCESSOR_INFORMATION) *\r
+               MpInformationHobData->NumberOfProcessors);\r
+  Status = mMmst->MmAllocatePool (\r
+                    EfiRuntimeServicesData,\r
+                    MpInfoSize,\r
+                    (VOID **) &mMpInformationHobData\r
+                    );\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_INFO, "mMpInformationHobData mem alloc failed - 0x%x\n", Status));\r
+    return Status;\r
+  }\r
+\r
+  CopyMem (mMpInformationHobData, MpInformationHobData, MpInfoSize);\r
+\r
+  // Print MP information\r
+  DEBUG ((DEBUG_INFO, "mMpInformationHobData: 0x%016lx - 0x%lx\n",\r
+          mMpInformationHobData->NumberOfProcessors,\r
+          mMpInformationHobData->NumberOfEnabledProcessors));\r
+  for (Index = 0; Index < mMpInformationHobData->NumberOfProcessors; Index++) {\r
+    DEBUG ((DEBUG_INFO, "mMpInformationHobData[0x%lx]: %d, %d, %d\n",\r
+            mMpInformationHobData->ProcessorInfoBuffer[Index].ProcessorId,\r
+            mMpInformationHobData->ProcessorInfoBuffer[Index].Location.Package,\r
+            mMpInformationHobData->ProcessorInfoBuffer[Index].Location.Core,\r
+            mMpInformationHobData->ProcessorInfoBuffer[Index].Location.Thread));\r
+  }\r
+\r
+  //\r
+  // Allocate memory for a table to hold pointers to a\r
+  // EFI_MM_COMMUNICATE_HEADER for each CPU\r
+  //\r
+  ArraySize = sizeof (EFI_MM_COMMUNICATE_HEADER *) *\r
+              mMpInformationHobData->NumberOfEnabledProcessors;\r
+  Status = mMmst->MmAllocatePool (\r
+                    EfiRuntimeServicesData,\r
+                    ArraySize,\r
+                    (VOID **) &PerCpuGuidedEventContext\r
+                    );\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_INFO, "PerCpuGuidedEventContext mem alloc failed - 0x%x\n", Status));\r
+    return Status;\r
+  }\r
+  return Status;\r
+}\r
diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h
new file mode 100644 (file)
index 0000000..7b38b65
--- /dev/null
@@ -0,0 +1,64 @@
+/** @file\r
+  Private header with declarations and definitions specific to the MM Standalone\r
+  CPU driver\r
+\r
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.\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
+\r
+**/\r
+\r
+#ifndef _ARM_TF_CPU_DRIVER_H_\r
+#define _ARM_TF_CPU_DRIVER_H_\r
+\r
+#include <Protocol/MmCommunication.h>\r
+#include <Protocol/MmConfiguration.h>\r
+#include <Protocol/MmCpu.h>\r
+#include <Guid/MpInformation.h>\r
+\r
+//\r
+// CPU driver initialization specific declarations\r
+//\r
+extern EFI_MM_SYSTEM_TABLE *mMmst;\r
+\r
+//\r
+// CPU State Save protocol specific declarations\r
+//\r
+extern EFI_MM_CPU_PROTOCOL mMmCpuState;\r
+\r
+//\r
+// MM event handling specific declarations\r
+//\r
+extern EFI_MM_COMMUNICATE_HEADER    **PerCpuGuidedEventContext;\r
+extern EFI_MMRAM_DESCRIPTOR          mNsCommBuffer;\r
+extern MP_INFORMATION_HOB_DATA       *mMpInformationHobData;\r
+extern EFI_MM_CONFIGURATION_PROTOCOL mMmConfig;\r
+\r
+EFI_STATUS\r
+PiMmStandloneArmTfCpuDriverEntry (\r
+  IN UINTN EventId,\r
+  IN UINTN CpuNumber,\r
+  IN UINTN NsCommBufferAddr\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PiMmCpuTpFwRootMmiHandler (\r
+  IN     EFI_HANDLE               DispatchHandle,\r
+  IN     CONST VOID               *Context,        OPTIONAL\r
+  IN OUT VOID                     *CommBuffer,     OPTIONAL\r
+  IN OUT UINTN                    *CommBufferSize  OPTIONAL\r
+  );\r
+\r
+EFI_STATUS _PiMmStandloneArmTfCpuDriverEntry (\r
+  IN UINTN EventId,\r
+  IN UINTN CpuNumber,\r
+  IN UINTN NsCommBufferAddr\r
+  );\r
+\r
+#endif\r
diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.inf b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.inf
new file mode 100644 (file)
index 0000000..9e6bbab
--- /dev/null
@@ -0,0 +1,59 @@
+#/** @file\r
+#\r
+#  Standalone MM CPU driver for ARM Standard Platforms\r
+#\r
+#  Copyright (c) 2009, Apple Inc. All rights reserved.<BR>\r
+#  Copyright (c) 2016 HP Development Company, L.P.\r
+#  Copyright (c) 2017 - 2018, 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
+#\r
+#**/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x0001001A\r
+  BASE_NAME                      = StandloneMmCpu\r
+  FILE_GUID                      = 58F7A62B-6280-42A7-BC38-10535A64A92C\r
+  MODULE_TYPE                    = MM_STANDALONE\r
+  VERSION_STRING                 = 1.0\r
+  PI_SPECIFICATION_VERSION       = 0x00010032\r
+  ENTRY_POINT                    = StandloneMmCpuInitialize\r
+\r
+[Sources]\r
+  StandaloneMmCpu.c\r
+  EventHandle.c\r
+\r
+[Packages]\r
+  ArmPkg/ArmPkg.dec\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  StandaloneMmPkg/StandaloneMmPkg.dec\r
+\r
+[LibraryClasses]\r
+  ArmLib\r
+  ArmSvcLib\r
+  BaseMemoryLib\r
+  DebugLib\r
+  HobLib\r
+  StandaloneMmDriverEntryPoint\r
+\r
+[Protocols]\r
+  gEfiMmConfigurationProtocolGuid                        # PROTOCOL ALWAYS_PRODUCED\r
+  gEfiMmCpuProtocolGuid                                  # PROTOCOL ALWAYS_PRODUCED\r
+\r
+[Guids]\r
+  gEfiHobListGuid\r
+  gEfiMmPeiMmramMemoryReserveGuid\r
+  gZeroGuid\r
+  gMpInformationHobGuid\r
+  gEfiStandaloneMmNonSecureBufferGuid\r
+  gEfiArmTfCpuDriverEpDescriptorGuid\r
+\r
+[Depex]\r
+  TRUE\r
diff --git a/StandaloneMmPkg/Include/Guid/MpInformation.h b/StandaloneMmPkg/Include/Guid/MpInformation.h
new file mode 100644 (file)
index 0000000..c88ff4a
--- /dev/null
@@ -0,0 +1,41 @@
+/** @file\r
+  EFI MP information protocol provides a lightweight MP_SERVICES_PROTOCOL.\r
+\r
+  MP information protocol only provides static information of MP processor.\r
+\r
+  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>\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
+\r
+**/\r
+\r
+#ifndef _MP_INFORMATION_H_\r
+#define _MP_INFORMATION_H_\r
+\r
+#include <Protocol/MpService.h>\r
+#include <PiPei.h>\r
+#include <Ppi/SecPlatformInformation.h>\r
+\r
+#define MP_INFORMATION_GUID \\r
+  { \\r
+    0xba33f15d, 0x4000, 0x45c1, {0x8e, 0x88, 0xf9, 0x16, 0x92, 0xd4, 0x57, 0xe3}  \\r
+  }\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+  UINT64                     NumberOfProcessors;\r
+  UINT64                     NumberOfEnabledProcessors;\r
+  EFI_PROCESSOR_INFORMATION  ProcessorInfoBuffer[];\r
+} MP_INFORMATION_HOB_DATA;\r
+#pragma pack()\r
+\r
+extern EFI_GUID gMpInformationHobGuid;\r
+\r
+#endif\r