]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/PeiMain.h
MdeModulePkg: Make retval in UninstallMultipleProtocol follow Spec
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain.h
index 6469436b8f79319d7df802541b394029fd930201..56b3bd85793d168a40fbc69a4e972c7b785dffa6 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
   Definition of Pei Core Structures and Services\r
 \r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\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
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -31,6 +25,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Ppi/TemporaryRamSupport.h>\r
 #include <Ppi/TemporaryRamDone.h>\r
 #include <Ppi/SecHobData.h>\r
+#include <Ppi/PeiCoreFvLocation.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/PeiCoreEntryPoint.h>\r
 #include <Library/BaseLib.h>\r
@@ -52,7 +47,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 ///\r
 /// It is an FFS type extension used for PeiFindFileEx. It indicates current\r
-/// Ffs searching is for all PEIMs can be dispatched by PeiCore.\r
+/// FFS searching is for all PEIMs can be dispatched by PeiCore.\r
 ///\r
 #define PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE   0xff\r
 \r
@@ -66,39 +61,62 @@ typedef union {
 } PEI_PPI_LIST_POINTERS;\r
 \r
 ///\r
-/// PPI database structure which contains two link: PpiList and NotifyList. PpiList\r
-/// is in head of PpiListPtrs array and notify is in end of PpiListPtrs.\r
+/// Number of PEI_PPI_LIST_POINTERS to grow by each time we run out of room\r
 ///\r
+#define PPI_GROWTH_STEP             64\r
+#define CALLBACK_NOTIFY_GROWTH_STEP 32\r
+#define DISPATCH_NOTIFY_GROWTH_STEP 8\r
+\r
 typedef struct {\r
+  UINTN                 CurrentCount;\r
+  UINTN                 MaxCount;\r
+  UINTN                 LastDispatchedCount;\r
   ///\r
-  /// index of end of PpiList link list.\r
+  /// MaxCount number of entries.\r
   ///\r
-  INTN                    PpiListEnd;\r
+  PEI_PPI_LIST_POINTERS *PpiPtrs;\r
+} PEI_PPI_LIST;\r
+\r
+typedef struct {\r
+  UINTN                 CurrentCount;\r
+  UINTN                 MaxCount;\r
   ///\r
-  /// index of end of notify link list.\r
+  /// MaxCount number of entries.\r
   ///\r
-  INTN                    NotifyListEnd;\r
+  PEI_PPI_LIST_POINTERS *NotifyPtrs;\r
+} PEI_CALLBACK_NOTIFY_LIST;\r
+\r
+typedef struct {\r
+  UINTN                 CurrentCount;\r
+  UINTN                 MaxCount;\r
+  UINTN                 LastDispatchedCount;\r
   ///\r
-  /// index of the dispatched notify list.\r
+  /// MaxCount number of entries.\r
   ///\r
-  INTN                    DispatchListEnd;\r
+  PEI_PPI_LIST_POINTERS *NotifyPtrs;\r
+} PEI_DISPATCH_NOTIFY_LIST;\r
+\r
+///\r
+/// PPI database structure which contains three links:\r
+/// PpiList, CallbackNotifyList and DispatchNotifyList.\r
+///\r
+typedef struct {\r
   ///\r
-  /// index of last installed Ppi description in PpiList link list.\r
+  /// PPI List.\r
   ///\r
-  INTN                    LastDispatchedInstall;\r
+  PEI_PPI_LIST              PpiList;\r
   ///\r
-  /// index of last dispatched notify in Notify link list.\r
+  /// Notify List at dispatch level.\r
   ///\r
-  INTN                    LastDispatchedNotify;\r
+  PEI_CALLBACK_NOTIFY_LIST  CallbackNotifyList;\r
   ///\r
-  /// Ppi database has the PcdPeiCoreMaxPpiSupported number of entries.\r
+  /// Notify List at callback level.\r
   ///\r
-  PEI_PPI_LIST_POINTERS   *PpiListPtrs;\r
+  PEI_DISPATCH_NOTIFY_LIST  DispatchNotifyList;\r
 } PEI_PPI_DATABASE;\r
 \r
-\r
 //\r
-// PEI_CORE_FV_HANDE.PeimState\r
+// PEI_CORE_FV_HANDLE.PeimState\r
 // Do not change these values as there is code doing math to change states.\r
 // Look for Private->Fv[FvCount].PeimState[PeimCount]++;\r
 //\r
@@ -107,16 +125,22 @@ typedef struct {
 #define PEIM_STATE_REGISTER_FOR_SHADOW    0x02\r
 #define PEIM_STATE_DONE                   0x03\r
 \r
+//\r
+// Number of FV instances to grow by each time we run out of room\r
+//\r
+#define FV_GROWTH_STEP 8\r
+\r
 typedef struct {\r
   EFI_FIRMWARE_VOLUME_HEADER          *FvHeader;\r
   EFI_PEI_FIRMWARE_VOLUME_PPI         *FvPpi;\r
   EFI_PEI_FV_HANDLE                   FvHandle;\r
+  UINTN                               PeimCount;\r
   //\r
-  // Ponter to the buffer with the PcdPeiCoreMaxPeimPerFv number of Entries.\r
+  // Pointer to the buffer with the PeimCount number of Entries.\r
   //\r
   UINT8                               *PeimState;\r
   //\r
-  // Ponter to the buffer with the PcdPeiCoreMaxPeimPerFv number of Entries.\r
+  // Pointer to the buffer with the PeimCount number of Entries.\r
   //\r
   EFI_PEI_FILE_HANDLE                 *FvFileHandles;\r
   BOOLEAN                             ScanFv;\r
@@ -176,6 +200,11 @@ EFI_STATUS
   IN PEI_CORE_INSTANCE              *OldCoreData\r
   );\r
 \r
+//\r
+// Number of files to grow by each time we run out of room\r
+//\r
+#define TEMP_FILE_GROWTH_STEP 32\r
+\r
 #define PEI_CORE_HANDLE_SIGNATURE  SIGNATURE_32('P','e','i','C')\r
 \r
 ///\r
@@ -196,20 +225,26 @@ struct _PEI_CORE_INSTANCE {
   UINTN                              FvCount;\r
 \r
   ///\r
-  /// Pointer to the buffer with the PcdPeiCoreMaxFvSupported number of entries.\r
+  /// The max count of FVs which contains FFS and could be dispatched by PeiCore.\r
+  ///\r
+  UINTN                              MaxFvCount;\r
+\r
+  ///\r
+  /// Pointer to the buffer with the MaxFvCount number of entries.\r
   /// Each entry is for one FV which contains FFS and could be dispatched by PeiCore.\r
   ///\r
   PEI_CORE_FV_HANDLE                 *Fv;\r
 \r
   ///\r
-  /// Pointer to the buffer with the PcdPeiCoreMaxFvSupported number of entries.\r
+  /// Pointer to the buffer with the MaxUnknownFvInfoCount number of entries.\r
   /// Each entry is for one FV which could not be dispatched by PeiCore.\r
   ///\r
   PEI_CORE_UNKNOW_FORMAT_FV_INFO     *UnknownFvInfo;\r
+  UINTN                              MaxUnknownFvInfoCount;\r
   UINTN                              UnknownFvInfoCount;\r
 \r
   ///\r
-  /// Pointer to the buffer with the PcdPeiCoreMaxPeimPerFv number of entries.\r
+  /// Pointer to the buffer FvFileHandlers in PEI_CORE_FV_HANDLE specified by CurrentPeimFvCount.\r
   ///\r
   EFI_PEI_FILE_HANDLE                *CurrentFvFileHandles;\r
   UINTN                              AprioriCount;\r
@@ -242,12 +277,12 @@ struct _PEI_CORE_INSTANCE {
   //\r
   // For Loading modules at fixed address feature to cache the top address below which the\r
   // Runtime code, boot time code and PEI memory will be placed. Please note that the offset between this field\r
-  // and  Ps should not be changed since maybe user could get this top address by using the offet to Ps.\r
+  // and Ps should not be changed since maybe user could get this top address by using the offset to Ps.\r
   //\r
   EFI_PHYSICAL_ADDRESS               LoadModuleAtFixAddressTopAddress;\r
   //\r
   // The field is define for Loading modules at fixed address feature to tracker the PEI code\r
-  // memory range usage. It is a bit mapped array in which every bit indicates the correspoding memory page\r
+  // memory range usage. It is a bit mapped array in which every bit indicates the corresponding memory page\r
   // available or not.\r
   //\r
   UINT64                            *PeiCodeMemoryRangeUsageBitMap;\r
@@ -256,14 +291,16 @@ struct _PEI_CORE_INSTANCE {
   //\r
   PE_COFF_LOADER_READ_FILE          ShadowedImageRead;\r
 \r
+  UINTN                             TempPeimCount;\r
+\r
   //\r
-  // Pointer to the temp buffer with the PcdPeiCoreMaxPeimPerFv + 1 number of entries.\r
+  // Pointer to the temp buffer with the TempPeimCount number of entries.\r
   //\r
-  EFI_PEI_FILE_HANDLE               *FileHandles;\r
+  EFI_PEI_FILE_HANDLE               *TempFileHandles;\r
   //\r
-  // Pointer to the temp buffer with the PcdPeiCoreMaxPeimPerFv number of entries.\r
+  // Pointer to the temp buffer with the TempPeimCount number of entries.\r
   //\r
-  EFI_GUID                          *FileGuid;\r
+  EFI_GUID                          *TempFileGuid;\r
 \r
   //\r
   // Temp Memory Range is not covered by PeiTempMem and Stack.\r
@@ -335,7 +372,7 @@ PeiCore (
 \r
   This is the POSTFIX version of the dependency evaluator.  When a\r
   PUSH [PPI GUID] is encountered, a pointer to the GUID is stored on\r
-  the evaluation stack.  When that entry is poped from the evaluation\r
+  the evaluation stack.  When that entry is popped from the evaluation\r
   stack, the PPI is checked if it is installed.  This method allows\r
   some time savings as not all PPIs must be checked for certain\r
   operation types (AND, OR).\r
@@ -375,7 +412,7 @@ PeiDispatcher (
 \r
   @param PrivateData     PeiCore's private data structure\r
   @param OldCoreData     Old data from SecCore\r
-                         NULL if being run in non-permament memory mode.\r
+                         NULL if being run in non-permanent memory mode.\r
   @param SecCoreData     Points to a data structure containing SEC to PEI handoff data, such as the size\r
                          and location of temporary RAM, the stack location and the BFV location.\r
 \r
@@ -416,7 +453,7 @@ DepexSatisfied (
 \r
   @param PrivateData     Pointer to the PEI Core data.\r
   @param OldCoreData     Pointer to old PEI Core data.\r
-                         NULL if being run in non-permament memory mode.\r
+                         NULL if being run in non-permanent memory mode.\r
 \r
 **/\r
 VOID\r
@@ -445,7 +482,7 @@ ConvertPpiPointers (
   Install PPI services. It is implementation of EFI_PEI_SERVICE.InstallPpi.\r
 \r
   @param PeiServices                An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
-  @param PpiList                    Pointer to ppi array that want to be installed.\r
+  @param PpiList                    Pointer to PPI array that want to be installed.\r
 \r
   @retval EFI_SUCCESS               if all PPIs in PpiList are successfully installed.\r
   @retval EFI_INVALID_PARAMETER     if PpiList is NULL pointer\r
@@ -518,7 +555,7 @@ PeiLocatePpi (
 \r
   @retval EFI_SUCCESS           if successful\r
   @retval EFI_OUT_OF_RESOURCES  if no space in the database\r
-  @retval EFI_INVALID_PARAMETER if not a good decriptor\r
+  @retval EFI_INVALID_PARAMETER if not a good descriptor\r
 \r
 **/\r
 EFI_STATUS\r
@@ -536,13 +573,13 @@ PeiNotifyPpi (
 \r
 **/\r
 VOID\r
-ProcessNotifyList (\r
+ProcessDispatchNotifyList (\r
   IN PEI_CORE_INSTANCE  *PrivateData\r
   );\r
 \r
 /**\r
 \r
-  Dispatch notifications.\r
+  Process notifications.\r
 \r
   @param PrivateData        PeiCore's private data structure\r
   @param NotifyType         Type of notify to fire.\r
@@ -553,7 +590,7 @@ ProcessNotifyList (
 \r
 **/\r
 VOID\r
-DispatchNotify (\r
+ProcessNotify (\r
   IN PEI_CORE_INSTANCE  *PrivateData,\r
   IN UINTN               NotifyType,\r
   IN INTN                InstallStartIndex,\r
@@ -622,7 +659,7 @@ PeiSetBootMode (
 \r
   @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param OldCoreData     Pointer to the old core data.\r
-                         NULL if being run in non-permament memory mode.\r
+                         NULL if being run in non-permanent memory mode.\r
 \r
 **/\r
 VOID\r
@@ -650,7 +687,7 @@ VerifyFv (
 \r
   @param PrivateData     PeiCore's private data structure\r
   @param VolumeHandle    Handle of FV\r
-  @param FileHandle      Handle of PEIM's ffs\r
+  @param FileHandle      Handle of PEIM's FFS\r
   @param AuthenticationStatus Authentication status\r
 \r
   @retval EFI_SUCCESS              Image is OK\r
@@ -693,7 +730,7 @@ PeiGetHobList (
   @param Length             Length of the new HOB to allocate.\r
   @param Hob                Pointer to the new HOB.\r
 \r
-  @return  EFI_SUCCESS           Success to create hob.\r
+  @return  EFI_SUCCESS           Success to create HOB.\r
   @retval  EFI_INVALID_PARAMETER if Hob is NULL\r
   @retval  EFI_NOT_AVAILABLE_YET if HobList is still not available.\r
   @retval  EFI_OUT_OF_RESOURCES  if there is no more memory to grow the Hoblist.\r
@@ -850,7 +887,7 @@ PeiFfsFindNextVolume (
   @param SecCoreData     Points to a data structure containing SEC to PEI handoff data, such as the size\r
                          and location of temporary RAM, the stack location and the BFV location.\r
   @param OldCoreData     Pointer to the PEI Core data.\r
-                         NULL if being run in non-permament memory mode.\r
+                         NULL if being run in non-permanent memory mode.\r
 \r
 **/\r
 VOID\r
@@ -1060,9 +1097,7 @@ PeiResetSystem (
                             the data buffer starts with a Null-terminated string, optionally\r
                             followed by additional binary data. The string is a description\r
                             that the caller may use to further indicate the reason for the\r
-                            system reset. ResetData is only valid if ResetStatus is something\r
-                            other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific\r
-                            where a minimum amount of ResetData is always required.\r
+                            system reset.\r
 \r
 **/\r
 VOID\r
@@ -1076,7 +1111,7 @@ PeiResetSystem2 (
 \r
 /**\r
 \r
-  Initialize PeiCore Fv List.\r
+  Initialize PeiCore FV List.\r
 \r
 \r
   @param PrivateData     - Pointer to PEI_CORE_INSTANCE.\r
@@ -1090,7 +1125,7 @@ PeiInitializeFv (
   );\r
 \r
 /**\r
-  Process Firmware Volum Information once FvInfoPPI install.\r
+  Process Firmware Volume Information once FvInfoPPI install.\r
 \r
   @param PeiServices       An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param NotifyDescriptor  Address of the notification descriptor data structure.\r
@@ -1101,7 +1136,7 @@ PeiInitializeFv (
 **/\r
 EFI_STATUS\r
 EFIAPI\r
-FirmwareVolmeInfoPpiNotifyCallback (\r
+FirmwareVolumeInfoPpiNotifyCallback (\r
   IN EFI_PEI_SERVICES              **PeiServices,\r
   IN EFI_PEI_NOTIFY_DESCRIPTOR     *NotifyDescriptor,\r
   IN VOID                          *Ppi\r
@@ -1182,8 +1217,8 @@ PeiFfsGetVolumeInfo (
   );\r
 \r
 /**\r
-  This routine enable a PEIM to register itself to shadow when PEI Foundation\r
-  discovery permanent memory.\r
+  This routine enables a PEIM to register itself for shadow when the PEI Foundation\r
+  discovers permanent memory.\r
 \r
   @param FileHandle             File handle of a PEIM.\r
 \r
@@ -1258,11 +1293,11 @@ SecurityPpiNotifyCallback (
   );\r
 \r
 /**\r
-  Get Fv image(s) from the FV type file, then install FV INFO(2) ppi, Build FV(2, 3) hob.\r
+  Get FV image(s) from the FV type file, then install FV INFO(2) PPI, Build FV(2, 3) HOB.\r
 \r
   @param PrivateData          PeiCore's private data structure\r
-  @param ParentFvCoreHandle   Pointer of EFI_CORE_FV_HANDLE to parent Fv image that contain this Fv image.\r
-  @param ParentFvFileHandle   File handle of a Fv type file that contain this Fv image.\r
+  @param ParentFvCoreHandle   Pointer of EFI_CORE_FV_HANDLE to parent FV image that contain this FV image.\r
+  @param ParentFvFileHandle   File handle of a FV type file that contain this FV image.\r
 \r
   @retval EFI_NOT_FOUND         FV image can't be found.\r
   @retval EFI_SUCCESS           Successfully to process it.\r
@@ -1279,12 +1314,13 @@ ProcessFvFile (
   );\r
 \r
 /**\r
-  Get instance of PEI_CORE_FV_HANDLE for next volume according to given index.\r
+  Gets a PEI_CORE_FV_HANDLE instance for the next volume according to the given index.\r
 \r
-  This routine also will install FvInfo ppi for FV hob in PI ways.\r
+  This routine also will install an instance of the FvInfo PPI for the FV HOB\r
+  as defined in the PI specification.\r
 \r
   @param Private    Pointer of PEI_CORE_INSTANCE\r
-  @param Instance   The index of FV want to be searched.\r
+  @param Instance   Index of the FV to search\r
 \r
   @return Instance of PEI_CORE_FV_HANDLE.\r
 **/\r