]> git.proxmox.com Git - mirror_edk2.git/commitdiff
PrmPkg: Remove ALLOCATE_CONTEXT_BUFFER_IN_FW build flag
authorMichael Kubacki <michael.kubacki@microsoft.com>
Mon, 8 Jun 2020 18:06:44 +0000 (11:06 -0700)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 5 Apr 2022 00:42:38 +0000 (00:42 +0000)
The POR is firmly to use an OS allocated context buffer now so the
build flag that allows firmware to allocate the context buffer
is removed along with supporting code.

Cc: Andrew Fish <afish@apple.com>
Cc: Kang Gao <kang.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Michael Kubacki <michael.kubacki@microsoft.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Liu Yun <yun.y.liu@intel.com>
Cc: Ankit Sinha <ankit.sinha@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Michael D Kinney <michael.d.kinney@intel.com>
Acked-by: Liming Gao <gaoliming@byosoft.com.cn>
Acked-by: Leif Lindholm <quic_llindhol@quicinc.com>
Reviewed-by: Ankit Sinha <ankit.sinha@intel.com>
PrmPkg/PrmConfigDxe/PrmConfigDxe.c
PrmPkg/PrmLoaderDxe/PrmAcpiTable.h
PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c
PrmPkg/PrmPkg.dsc
PrmPkg/Readme.md
PrmPkg/Samples/PrmSampleContextBufferModule/Library/DxeContextBufferModuleConfigLib/DxeContextBufferModuleConfigLib.c

index 7215c2e1dc6f11a921065c18770e39640a741ec4..c547db3eca5ec2d672d10d1acfeac88ccf6622b7 100644 (file)
 #define _DBGMSGID_                "[PRMCONFIG]"\r
 \r
 STATIC  UINTN                     mMaxRuntimeMmioRangeCount;\r
-STATIC  UINTN                     mMaxStaticDataBufferCount;\r
 \r
 GLOBAL_REMOVE_IF_UNREFERENCED STATIC  PRM_RUNTIME_MMIO_RANGES   **mRuntimeMmioRanges;\r
-GLOBAL_REMOVE_IF_UNREFERENCED STATIC  PRM_DATA_BUFFER           ***mStaticDataBuffers;\r
 \r
 /**\r
   Converts the runtime memory range physical addresses to virtual addresses.\r
@@ -181,32 +179,12 @@ StoreVirtualMemoryAddressChangePointers (
   UINTN                       HandleCount;\r
   UINTN                       HandleIndex;\r
   UINTN                       RangeIndex;\r
-#ifdef ALLOCATE_CONTEXT_BUFFER_IN_FW\r
-  UINTN                       BufferIndex;\r
-  UINTN                       StaticDataBufferIndex;\r
-  PRM_CONTEXT_BUFFER          *CurrentContextBuffer;\r
-#endif\r
   EFI_HANDLE                  *HandleBuffer;\r
   PRM_CONFIG_PROTOCOL         *PrmConfigProtocol;\r
 \r
   DEBUG ((DEBUG_INFO, "%a %a - Entry.\n", _DBGMSGID_, __FUNCTION__));\r
 \r
   RangeIndex = 0;\r
-#ifdef ALLOCATE_CONTEXT_BUFFER_IN_FW\r
-  StaticDataBufferIndex = 0;\r
-\r
-  mStaticDataBuffers = AllocateRuntimeZeroPool (sizeof (*mStaticDataBuffers) * mMaxStaticDataBufferCount);\r
-  if (mStaticDataBuffers == NULL && mMaxStaticDataBufferCount > 0) {\r
-    DEBUG ((\r
-      DEBUG_ERROR,\r
-      "  %a %a: Memory allocation for PRM static data buffer pointer array failed.\n",\r
-      _DBGMSGID_,\r
-      __FUNCTION__\r
-      ));\r
-    ASSERT (FALSE);\r
-    return;\r
-  }\r
-#endif\r
 \r
   mRuntimeMmioRanges = AllocateRuntimeZeroPool (sizeof (*mRuntimeMmioRanges) * mMaxRuntimeMmioRangeCount);\r
   if (mRuntimeMmioRanges == NULL && mMaxRuntimeMmioRangeCount > 0) {\r
@@ -240,28 +218,6 @@ StoreVirtualMemoryAddressChangePointers (
         continue;\r
       }\r
 \r
-#ifdef ALLOCATE_CONTEXT_BUFFER_IN_FW\r
-      for (BufferIndex = 0; BufferIndex < PrmConfigProtocol->ModuleContextBuffers.BufferCount; BufferIndex++) {\r
-        CurrentContextBuffer = &(PrmConfigProtocol->ModuleContextBuffers.Buffer[BufferIndex]);\r
-\r
-        if (CurrentContextBuffer->StaticDataBuffer != NULL) {\r
-          if (StaticDataBufferIndex >= mMaxStaticDataBufferCount) {\r
-            Status = EFI_BUFFER_TOO_SMALL;\r
-            DEBUG ((\r
-              DEBUG_ERROR,\r
-              "  %a %a: Index out of bounds - Actual count (%d) of PRM data buffers exceeds maximum count (%d).\n",\r
-              _DBGMSGID_,\r
-              __FUNCTION__,\r
-              StaticDataBufferIndex + 1,\r
-              mMaxStaticDataBufferCount\r
-              ));\r
-            ASSERT_EFI_ERROR (Status);\r
-            return;\r
-          }\r
-          mStaticDataBuffers[StaticDataBufferIndex++] = &CurrentContextBuffer->StaticDataBuffer;\r
-        }\r
-      }\r
-#endif\r
       if (PrmConfigProtocol->ModuleContextBuffers.RuntimeMmioRanges != NULL) {\r
         if (RangeIndex >= mMaxRuntimeMmioRangeCount) {\r
           Status = EFI_BUFFER_TOO_SMALL;\r
@@ -286,15 +242,6 @@ StoreVirtualMemoryAddressChangePointers (
       __FUNCTION__,\r
       RangeIndex\r
       ));\r
-#ifdef ALLOCATE_CONTEXT_BUFFER_IN_FW\r
-    DEBUG ((\r
-      DEBUG_INFO,\r
-      "  %a %a: %d static buffers saved for future virtual memory conversion.\n",\r
-      _DBGMSGID_,\r
-      __FUNCTION__,\r
-      StaticDataBufferIndex\r
-      ));\r
-#endif\r
   }\r
 }\r
 \r
@@ -396,15 +343,6 @@ PrmConfigVirtualAddressChangeEvent (
 {\r
   UINTN   Index;\r
 \r
-#ifdef ALLOCATE_CONTEXT_BUFFER_IN_FW\r
-  //\r
-  // Convert static data buffer pointers\r
-  //\r
-  for (Index = 0; Index < mMaxStaticDataBufferCount; Index++) {\r
-    gRT->ConvertPointer (0x0, (VOID **) mStaticDataBuffers[Index]);\r
-  }\r
-#endif\r
-\r
   //\r
   // Convert runtime MMIO ranges\r
   //\r
@@ -485,9 +423,6 @@ PrmConfigEndOfDxeNotification (
             CurrentContextBuffer->HandlerGuid\r
             ));\r
         }\r
-        if (CurrentContextBuffer->StaticDataBuffer != NULL) {\r
-          mMaxStaticDataBufferCount++;\r
-        }\r
       }\r
       DEBUG ((DEBUG_INFO, "      %a %a: Module context buffer validation complete.\n", _DBGMSGID_, __FUNCTION__));\r
 \r
@@ -551,13 +486,6 @@ PrmConfigEntryPoint (
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  DEBUG ((DEBUG_INFO, "  %a %a: Context buffers will be allocated in ", _DBGMSGID_, __FUNCTION__));\r
-#ifdef ALLOCATE_CONTEXT_BUFFER_IN_FW\r
-  DEBUG ((DEBUG_INFO, "firmware.\n"));\r
-#else\r
-  DEBUG ((DEBUG_INFO, "the operating system.\n"));\r
-#endif\r
-\r
   //\r
   // Register a notification function for virtual address change\r
   //\r
index ca09be389235db2647a52e761b1a2b29b5cdd2e2..ec3be529d1199690fd8b5f31d80a3faf65a1e2d4 100644 (file)
@@ -30,10 +30,6 @@ typedef struct {
   UINT16                              StructureLength;            ///< Length in bytes of this structure\r
   GUID                                Identifier;                 ///< GUID of the PRM handler for this structure\r
   UINT64                              PhysicalAddress;            ///< Physical address of this PRM handler\r
-#ifdef ALLOCATE_CONTEXT_BUFFER_IN_FW\r
-  UINT64                              PrmContextBuffer;           ///< Physical address of the context buffer for this\r
-                                                                  ///< PRM handler (PRM_CONTEXT_BUFFER *)\r
-#else\r
   UINT64                              StaticDataBuffer;           ///< Physical address of the static data buffer for\r
                                                                   ///< this PRM handler (PRM_DATA_BUFFER *)\r
   UINT64                              AcpiParameterBuffer;        ///< Physical address of the parameter buffer\r
@@ -41,8 +37,6 @@ typedef struct {
                                                                   ///< that is only used in the case of _DSM invocation.\r
                                                                   ///< If _DSM invocation is not used, this value is\r
                                                                   ///< ignored.\r
-#endif\r
-\r
 } PRM_HANDLER_INFORMATION_STRUCT;\r
 \r
 typedef struct {\r
index e2a838ea29bd117d57c04ebc24f26b85362a370f..433d81cf8009a7100edde185ff261d1eb0f349d5 100644 (file)
@@ -738,11 +738,7 @@ ProcessPrmModules (
                   &CurrentContextBuffer\r
                   );\r
       if (!EFI_ERROR (Status)) {\r
-#ifdef ALLOCATE_CONTEXT_BUFFER_IN_FW\r
-        CurrentHandlerInfoStruct->PrmContextBuffer = (UINT64) (UINTN) CurrentContextBuffer;\r
-#else\r
         CurrentHandlerInfoStruct->StaticDataBuffer = (UINT64) (UINTN) CurrentContextBuffer->StaticDataBuffer;\r
-#endif\r
       }\r
 \r
       Status =  GetExportEntryAddress (\r
index d3aeffa152e0ccb4ec8edc68f6350a1f8b9ec157..6d352dfadb2669cc608d235ca434c1d9fb3385e3 100644 (file)
 [BuildOptions]\r
 # Force deprecated interfaces off\r
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES\r
-\r
-# Append package-specific build settings\r
-!ifdef $(ALLOCATE_CONTEXT_BUFFER_IN_FW)\r
-  *_*_*_CC_FLAGS = -D ALLOCATE_CONTEXT_BUFFER_IN_FW\r
-!endif\r
index f430006905c5e244735b0cc441c6f36e0a569bd3..52b44a95ddbceeb9ccdb7094738c2debea8fcfe0 100644 (file)
@@ -68,17 +68,11 @@ record (POR) configuration.
 The following list are the currently defined build flags (if any) that may be passed to the `build` command\r
 (e.g. -D FLAG=VALUE).\r
 \r
-* `ALLOCATE_CONTEXT_BUFFER_IN_FW` - Allocates the context buffer for each PRM handler in the firmware instead of\r
-   the operating system (OS).\r
+* NONE - No build flags are currently used.\r
 \r
    Additional detail: The context buffer structure is defined in [PrmContextBuffer.h](PrmPkg/Include/PrmContextBuffer.h).\r
-   This structure can be instantiated by either firmware with a physical pointer to the buffer placed in the\r
-   `PRM_HANDLER_INFORMATION_STRUCT` for each handler wherein the OS would convert that physical pointer and pass it\r
-   as a virtual address pointer to each PRM handler. Alternatively, the context buffer can be allocated and populated\r
-   by the OS where it would get all the information to populate the context buffer from other structures.\r
-\r
-   The default is for the OS to allocate and populate the buffer. The alternative option of the firmware doing this\r
-   work is kept in the source code until broader OS testing is completed.\r
+   This structure is passed as the context buffer to PRM handlers. The structure actually passed to PRM handlers is\r
+   allocated and populated by the OS where it gets all the information to populate the context buffer from other structures.\r
 \r
 ## Overview\r
 At a high-level, PRM can be viewed from three levels of granularity:\r
index b0b12c012a41ca45b1627508b7e3efed66be580b..c222c961f23bd3d1e5ec7c98967883d754057f79 100644 (file)
@@ -151,16 +151,7 @@ ContextBufferModuleConfigLibConstructor (
   //\r
   // Allocate and populate the context buffer\r
   //\r
-#ifdef ALLOCATE_CONTEXT_BUFFER_IN_FW\r
-  //\r
-  // The context buffer allocated in FW will continue being used at OS runtime so it must\r
-  // be a runtime services data buffer.\r
-  //\r
-  // This sample module uses a single context buffer for all the handlers\r
-  // Todo: This can be done more elegantly in the future. Likely though a library service.\r
-  //\r
-  PrmContextBuffer = AllocateRuntimeZeroPool (sizeof (*PrmContextBuffer));\r
-#else\r
+\r
   //\r
   // This context buffer is not actually used by PRM handler at OS runtime. The OS will allocate\r
   // the actual context buffer passed to the PRM handler.\r
@@ -170,7 +161,6 @@ ContextBufferModuleConfigLibConstructor (
   // PRM_HANDLER_INFORMATION_STRUCT and PRM_MODULE_INFORMATION_STRUCT respectively for the PRM handler.\r
   //\r
   PrmContextBuffer = AllocateZeroPool (sizeof (*PrmContextBuffer));\r
-#endif\r
   ASSERT (PrmContextBuffer != NULL);\r
   if (PrmContextBuffer == NULL) {\r
     Status = EFI_OUT_OF_RESOURCES;\r