]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/Ppi/Ppi.c
Source level security checked
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Ppi / Ppi.c
index fa60d82a5be0857160a9bd4e537c26f74d8486de..6feab63412f44d8d4c932145abe81e65618b0834 100644 (file)
@@ -12,13 +12,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#include <PeiMain.h>\r
+#include "PeiMain.h"\r
 \r
 /**\r
 \r
   Initialize PPI services.\r
 \r
-\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
@@ -41,28 +40,25 @@ InitializePpiServices (
 \r
   Migrate the Hob list from the CAR stack to PEI installed memory.\r
 \r
-  @param PeiServices         The PEI core services table.\r
-  @param OldCheckingBottom   The old checking bottom.\r
-  @param OldCheckingTop      The old checking top.\r
-  @param NewHandOffHob       The new handoff HOB list.\r
+  @param PrivateData         Pointer to PeiCore's private data structure.\r
+  @param OldCheckingBottom   Bottom of temporary memory range. All Ppi in this range\r
+                             will be fixup for PpiData and PpiDescriptor pointer.\r
+  @param OldCheckingTop      Top of temporary memory range. All Ppi in this range\r
+                             will be fixup for PpiData and PpiDescriptor.\r
+  @param Fixup               The address difference between\r
+                             the new Hob list and old Hob list.\r
 \r
 **/\r
 VOID\r
 ConvertPpiPointers (\r
-  IN CONST EFI_PEI_SERVICES                     **PeiServices,\r
-  IN UINTN                         OldCheckingBottom,\r
-  IN UINTN                         OldCheckingTop,\r
-  IN EFI_HOB_HANDOFF_INFO_TABLE    *NewHandOffHob\r
+  IN PEI_CORE_INSTANCE       *PrivateData,\r
+  IN UINTN                   OldCheckingBottom,\r
+  IN UINTN                   OldCheckingTop,\r
+  IN INTN                    Fixup\r
   )\r
 {\r
-  PEI_CORE_INSTANCE     *PrivateData;\r
   UINT8                 Index;\r
   PEI_PPI_LIST_POINTERS *PpiPointer;\r
-  UINTN                 Fixup;\r
-\r
-  PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);\r
-\r
-  Fixup = (UINTN)NewHandOffHob - OldCheckingBottom;\r
 \r
   for (Index = 0; Index < FixedPcdGet32 (PcdPeiCoreMaxPpiSupported); Index++) {\r
     if (Index < PrivateData->PpiData.PpiListEnd ||\r
@@ -111,15 +107,17 @@ ConvertPpiPointers (
 \r
 /**\r
 \r
-  Install PPI services.\r
+  This function installs an interface in the PEI PPI database by GUID. \r
+  The purpose of the service is to publish an interface that other parties\r
+  can use to call additional PEIMs.\r
 \r
-  @param PeiServices     - Pointer to the PEI Service Table\r
-  @param PpiList         - Pointer to a list of PEI PPI Descriptors.\r
+  @param PeiServices                An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param PpiList                    Pointer to a list of PEI PPI Descriptors.\r
 \r
-  @retval EFI_SUCCESS             - if all PPIs in PpiList are successfully installed.\r
-  @retval EFI_INVALID_PARAMETER   - if PpiList is NULL pointer\r
-  @retval EFI_INVALID_PARAMETER   - if any PPI in PpiList is not valid\r
-  @retval EFI_OUT_OF_RESOURCES    - if there is no more memory resource to install PPI\r
+  @retval EFI_SUCCESS              if all PPIs in PpiList are successfully installed.\r
+  @retval EFI_INVALID_PARAMETER    if PpiList is NULL pointer\r
+                                   if any PPI in PpiList is not valid\r
+  @retval EFI_OUT_OF_RESOURCES     if there is no more memory resource to install PPI\r
 \r
 **/\r
 EFI_STATUS\r
@@ -151,7 +149,7 @@ PeiInstallPpi (
 \r
   for (;;) {\r
     //\r
-    // Since PpiData is used for NotifyList and InstallList, max resource\r
+    // Since PpiData is used for NotifyList and PpiList, max resource\r
     // is reached if the Install reaches the NotifyList\r
     //\r
     if (Index == PrivateData->PpiData.NotifyListEnd + 1) {\r
@@ -164,7 +162,7 @@ PeiInstallPpi (
     //\r
     if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) == 0) {\r
       PrivateData->PpiData.PpiListEnd = LastCallbackInstall;\r
-      DEBUG((EFI_D_ERROR, "ERROR -> InstallPpi: %g %x\n", PpiList->Guid, PpiList->Ppi));\r
+      DEBUG((EFI_D_ERROR, "ERROR -> InstallPpi: %g %p\n", PpiList->Guid, PpiList->Ppi));\r
       return  EFI_INVALID_PARAMETER;\r
     }\r
 \r
@@ -201,16 +199,19 @@ PeiInstallPpi (
 \r
 /**\r
 \r
-  Re-Install PPI services.\r
+  This function reinstalls an interface in the PEI PPI database by GUID. \r
+  The purpose of the service is to publish an interface that other parties can \r
+  use to replace an interface of the same name in the protocol database with a \r
+  different interface.\r
 \r
-  @param PeiServices     - Pointer to the PEI Service Table\r
-  @param OldPpi          - Pointer to the old PEI PPI Descriptors.\r
-  @param NewPpi          - Pointer to the new PEI PPI Descriptors.\r
+  @param PeiServices            An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param OldPpi                 Pointer to the old PEI PPI Descriptors.\r
+  @param NewPpi                 Pointer to the new PEI PPI Descriptors.\r
 \r
-  @retval EFI_SUCCESS           if the operation was successful\r
-  @retval EFI_INVALID_PARAMETER if OldPpi or NewPpi is NULL\r
-  @retval EFI_INVALID_PARAMETER if NewPpi is not valid\r
-  @retval EFI_NOT_FOUND         if the PPI was not in the database\r
+  @retval EFI_SUCCESS           if the operation was successful\r
+  @retval EFI_INVALID_PARAMETER if OldPpi or NewPpi is NULL\r
+  @retval EFI_INVALID_PARAMETER if NewPpi is not valid\r
+  @retval EFI_NOT_FOUND         if the PPI was not in the database\r
 \r
 **/\r
 EFI_STATUS\r
@@ -252,6 +253,7 @@ PeiReInstallPpi (
   // Remove the old PPI from the database, add the new one.\r
   //\r
   DEBUG((EFI_D_INFO, "Reinstall PPI: %g\n", NewPpi->Guid));\r
+  ASSERT (Index < FixedPcdGet32 (PcdPeiCoreMaxPpiSupported));\r
   PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) NewPpi;\r
 \r
   //\r
@@ -275,12 +277,12 @@ PeiReInstallPpi (
   Locate a given named PPI.\r
 \r
 \r
-  @param PeiServices     - Pointer to the PEI Service Table\r
-  @param Guid            - Pointer to GUID of the PPI.\r
-  @param Instance        - Instance Number to discover.\r
-  @param PpiDescriptor   - Pointer to reference the found descriptor. If not NULL,\r
-                         returns a pointer to the descriptor (includes flags, etc)\r
-  @param Ppi             - Pointer to reference the found PPI\r
+  @param PeiServices        An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param Guid               Pointer to GUID of the PPI.\r
+  @param Instance           Instance Number to discover.\r
+  @param PpiDescriptor      Pointer to reference the found descriptor. If not NULL,\r
+                            returns a pointer to the descriptor (includes flags, etc)\r
+  @param Ppi                Pointer to reference the found PPI\r
 \r
   @retval EFI_SUCCESS   if the PPI is in the database\r
   @retval EFI_NOT_FOUND if the PPI is not in the database\r
@@ -291,9 +293,9 @@ EFIAPI
 PeiLocatePpi (\r
   IN CONST EFI_PEI_SERVICES        **PeiServices,\r
   IN CONST EFI_GUID                *Guid,\r
-  IN UINTN                   Instance,\r
-  IN OUT EFI_PEI_PPI_DESCRIPTOR  **PpiDescriptor,\r
-  IN OUT VOID                **Ppi\r
+  IN UINTN                         Instance,\r
+  IN OUT EFI_PEI_PPI_DESCRIPTOR    **PpiDescriptor,\r
+  IN OUT VOID                      **Ppi\r
   )\r
 {\r
   PEI_CORE_INSTANCE   *PrivateData;\r
@@ -342,11 +344,12 @@ PeiLocatePpi (
 \r
 /**\r
 \r
-  Install a notification for a given PPI.\r
+  This function installs a notification service to be called back when a given \r
+  interface is installed or reinstalled. The purpose of the service is to publish \r
+  an interface that other parties can use to call additional PPIs that may materialize later.\r
 \r
-\r
-  @param PeiServices     - Pointer to the PEI Service Table\r
-  @param NotifyList      - Pointer to list of Descriptors to notify upon.\r
+  @param PeiServices        An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param NotifyList         Pointer to list of Descriptors to notify upon.\r
 \r
   @retval EFI_SUCCESS           if successful\r
   @retval EFI_OUT_OF_RESOURCES  if no space in the database\r
@@ -399,7 +402,7 @@ PeiNotifyPpi (
     //\r
     if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES) == 0) {\r
         PrivateData->PpiData.NotifyListEnd = LastCallbackNotify;\r
-        DEBUG((EFI_D_ERROR, "ERROR -> InstallNotify: %g %x\n", NotifyList->Guid, NotifyList->Notify));\r
+        DEBUG((EFI_D_ERROR, "ERROR -> InstallNotify: %g %p\n", NotifyList->Guid, NotifyList->Notify));\r
       return  EFI_INVALID_PARAMETER;\r
     }\r
 \r
@@ -453,7 +456,6 @@ PeiNotifyPpi (
     PrivateData->PpiData.NotifyListEnd\r
     );\r
 \r
-\r
   return  EFI_SUCCESS;\r
 }\r
 \r
@@ -568,19 +570,17 @@ DispatchNotify (
           (((INT32 *)SearchGuid)[1] == ((INT32 *)CheckGuid)[1]) &&\r
           (((INT32 *)SearchGuid)[2] == ((INT32 *)CheckGuid)[2]) &&\r
           (((INT32 *)SearchGuid)[3] == ((INT32 *)CheckGuid)[3])) {\r
-        DEBUG ((EFI_D_INFO, "Notify: PPI Guid: %g, Peim notify entry point: %x\n",\r
+        DEBUG ((EFI_D_INFO, "Notify: PPI Guid: %g, Peim notify entry point: %p\n",\r
           SearchGuid,\r
           NotifyDescriptor->Notify\r
           ));\r
         NotifyDescriptor->Notify (\r
-                            GetPeiServicesTablePointer (),\r
+                            (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),\r
                             NotifyDescriptor,\r
                             (PrivateData->PpiData.PpiListPtrs[Index2].Ppi)->Ppi\r
                             );\r
       }\r
     }\r
   }\r
-\r
-  return;\r
 }\r
 \r