]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c
StandaloneMmPkg: build for 32bit arm machines
[mirror_edk2.git] / StandaloneMmPkg / Drivers / StandaloneMmCpu / AArch64 / EventHandle.c
diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c
deleted file mode 100644 (file)
index 63fbe26..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
-/** @file\r
-\r
-  Copyright (c) 2016 HP Development Company, L.P.\r
-  Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.\r
-\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\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/ArmFfaSvc.h>\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
-/**\r
-  The PI Standalone MM entry point for the TF-A CPU driver.\r
-\r
-  @param  [in] EventId            The event Id.\r
-  @param  [in] CpuNumber          The CPU number.\r
-  @param  [in] NsCommBufferAddr   Address of the NS common buffer.\r
-\r
-  @retval   EFI_SUCCESS             Success.\r
-  @retval   EFI_INVALID_PARAMETER   A parameter was invalid.\r
-  @retval   EFI_ACCESS_DENIED       Access not permitted.\r
-  @retval   EFI_OUT_OF_RESOURCES    Out of resources.\r
-  @retval   EFI_UNSUPPORTED         Operation not supported.\r
-**/\r
-EFI_STATUS\r
-PiMmStandaloneArmTfCpuDriverEntry (\r
-  IN UINTN EventId,\r
-  IN UINTN CpuNumber,\r
-  IN UINTN NsCommBufferAddr\r
-  )\r
-{\r
-  EFI_MM_COMMUNICATE_HEADER   *GuidedEventContext;\r
-  EFI_MM_ENTRY_CONTEXT        MmEntryPointContext;\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
-      (ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_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 == (UINTN)NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (NsCommBufferAddr < mNsCommBuffer.PhysicalStart) {\r
-    return EFI_ACCESS_DENIED;\r
-  }\r
-\r
-  if ((NsCommBufferAddr + sizeof (EFI_MM_COMMUNICATE_HEADER)) >=\r
-      (mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\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
-  GuidedEventContext = NULL;\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
-  ZeroMem (&MmEntryPointContext, sizeof (EFI_MM_ENTRY_CONTEXT));\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
-/**\r
-  Registers the MM foundation entry point.\r
-\r
-  @param  [in] This               Pointer to the MM Configuration protocol.\r
-  @param  [in] MmEntryPoint       Function pointer to the MM Entry point.\r
-\r
-  @retval   EFI_SUCCESS             Success.\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\r
-                          MmiHandlerRegister().\r
-  @param  Context         Points to an optional handler context which was\r
-                          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\r
-                          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] == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\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