]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
Fix function comment to follows doxygen format.
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Dispatcher / Dispatcher.c
index 099e38ef43e5924616cda9717060e4225ec83891..481cf5d02e5c99da47fb0b26a5a2103bcb14523a 100644 (file)
@@ -1,5 +1,6 @@
-/*++\r
-\r
+/** @file\r
+  EFI PEI Core dispatch services\r
+  \r
 Copyright (c) 2006, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -9,20 +10,13 @@ http://opensource.org/licenses/bsd-license.php
 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
-Module Name:\r
-\r
-  Dispatcher.c\r
-\r
-Abstract:\r
-\r
-  EFI PEI Core dispatch services\r
-\r
-Revision History\r
-\r
---*/\r
+**/\r
 \r
 #include <PeiMain.h>\r
 \r
+///\r
+/// CAR is filled with this initial value during SEC phase\r
+///\r
 #define INIT_CAR_VALUE 0x5AA55AA5\r
 \r
 typedef struct {\r
@@ -30,27 +24,21 @@ typedef struct {
   EFI_HANDLE            Handle;\r
 } PEIM_FILE_HANDLE_EXTENDED_DATA;\r
 \r
-VOID\r
-DiscoverPeimsAndOrderWithApriori (\r
-  IN  PEI_CORE_INSTANCE    *Private,\r
-  IN  EFI_PEI_FV_HANDLE    VolumeHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Discover all Peims and optional Apriori file in one FV. There is at most one\r
   Apriori file in one FV.\r
 \r
-Arguments:\r
-\r
-  Private          - Pointer to the private data passed in from caller\r
-  VolumeHandle     - Fv handle.\r
-Returns:\r
 \r
-  NONE\r
+  @param Private         - Pointer to the private data passed in from caller\r
+  @param VolumeHandle    - Fv handle.\r
 \r
---*/\r
+**/\r
+VOID\r
+DiscoverPeimsAndOrderWithApriori (\r
+  IN  PEI_CORE_INSTANCE    *Private,\r
+  IN  EFI_PEI_FV_HANDLE    VolumeHandle\r
+  )\r
 {\r
   EFI_STATUS                          Status;\r
   EFI_PEI_FV_HANDLE                   FileHandle;\r
@@ -184,6 +172,13 @@ Returns:
 \r
 }\r
 \r
+/**\r
+  Shadow PeiCore module from flash to installed memory.\r
+  \r
+  @param PeiServices     Pointer to PeiService table\r
+  @param PrivateInMem    PeiCore's private data structure\r
+\r
+**/\r
 VOID*\r
 ShadowPeiCore(\r
   EFI_PEI_SERVICES     **PeiServices,\r
@@ -223,32 +218,23 @@ ShadowPeiCore(
   return (VOID*) ((UINTN) EntryPoint + (UINTN) PeiCore - (UINTN) _ModuleEntryPoint);\r
 }\r
 \r
-VOID\r
-PeiDispatcher (\r
-  IN CONST EFI_SEC_PEI_HAND_OFF  *SecCoreData,\r
-  IN PEI_CORE_INSTANCE           *Private\r
-  )\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Conduct PEIM dispatch.\r
 \r
-Arguments:\r
-\r
-  SecCoreData          - Points to a data structure containing information about the PEI core's operating\r
+  @param SecCoreData     Points to a data structure containing information about the PEI core's operating\r
                          environment, such as the size and location of temporary RAM, the stack location and\r
                          the BFV location.\r
-  PrivateData          - Pointer to the private data passed in from caller\r
-  DispatchData         - Pointer to PEI_CORE_DISPATCH_DATA data.\r
-\r
-Returns:\r
+  @param Private         Pointer to the private data passed in from caller\r
 \r
-  EFI_SUCCESS   - Successfully dispatched PEIM.\r
-  EFI_NOT_FOUND - The dispatch failed.\r
+  @retval EFI_SUCCESS   - Successfully dispatched PEIM.\r
+  @retval EFI_NOT_FOUND - The dispatch failed.\r
 \r
---*/\r
+**/\r
+VOID\r
+PeiDispatcher (\r
+  IN CONST EFI_SEC_PEI_HAND_OFF  *SecCoreData,\r
+  IN PEI_CORE_INSTANCE           *Private\r
+  )\r
 {\r
   EFI_STATUS                          Status;\r
   UINT32                              Index1;\r
@@ -271,7 +257,8 @@ Returns:
   TEMPORARY_RAM_SUPPORT_PPI           *TemporaryRamSupportPpi;\r
   EFI_HOB_HANDOFF_INFO_TABLE          *OldHandOffTable;\r
   EFI_HOB_HANDOFF_INFO_TABLE          *NewHandOffTable;\r
-  INTN                                Offset;\r
+  INTN                                StackOffset;\r
+  INTN                                HeapOffset;\r
   PEI_CORE_INSTANCE                   *PrivateInMem;\r
   UINT64                              NewPeiStackSize;\r
   UINT64                              OldPeiStackSize;\r
@@ -443,10 +430,10 @@ Returns:
               // usage in temporary memory for debuging.\r
               //\r
               DEBUG_CODE_BEGIN ();\r
-                UINTN  *StackPointer;\r
+                UINT32  *StackPointer;\r
                 \r
-                for (StackPointer = (UINTN*)SecCoreData->StackBase;\r
-                     (StackPointer < (UINTN*)((UINTN)SecCoreData->StackBase + SecCoreData->StackSize)) \\r
+                for (StackPointer = (UINT32*)SecCoreData->StackBase;\r
+                     (StackPointer < (UINT32*)((UINTN)SecCoreData->StackBase + SecCoreData->StackSize)) \\r
                      && (*StackPointer == INIT_CAR_VALUE);\r
                      StackPointer ++);\r
                      \r
@@ -494,9 +481,13 @@ Returns:
               // CAUTION: The new base is computed accounding to gap of new stack.\r
               //\r
               NewPermenentMemoryBase = Private->PhysicalMemoryBegin + StackGap;\r
-              Offset                 = (UINTN) NewPermenentMemoryBase - (UINTN) SecCoreData->TemporaryRamBase;\r
-              NewHandOffTable        = (EFI_HOB_HANDOFF_INFO_TABLE *)((UINTN)OldHandOffTable + Offset);\r
-              PrivateInMem           = (PEI_CORE_INSTANCE *)((UINTN) (VOID*) Private + Offset);\r
+              StackOffset            = (UINTN) NewPermenentMemoryBase - (UINTN) SecCoreData->StackBase;\r
+              HeapOffset             = (INTN) ((UINTN) Private->PhysicalMemoryBegin + Private->StackSize - \\r
+                                               (UINTN) SecCoreData->PeiTemporaryRamBase);\r
+              DEBUG ((EFI_D_INFO, "Heap Offset = 0x%X Stack Offset = 0x%X\n", HeapOffset, StackOffset));\r
+              \r
+              NewHandOffTable        = (EFI_HOB_HANDOFF_INFO_TABLE *)((UINTN)OldHandOffTable + HeapOffset);\r
+              PrivateInMem           = (PEI_CORE_INSTANCE *)((UINTN) (VOID*) Private + StackOffset);\r
 \r
               //\r
               // TemporaryRamSupportPpi is produced by platform's SEC\r
@@ -519,11 +510,11 @@ Returns:
                                           );\r
 \r
               } else {\r
-                CopyMem (\r
-                  (VOID*)(UINTN) NewPermenentMemoryBase,\r
-                  SecCoreData->TemporaryRamBase,\r
-                  SecCoreData->TemporaryRamSize\r
-                  );\r
+                //\r
+                // In IA32/x64/Itanium architecture, we need platform provide\r
+                // TEMPORAY_RAM_MIGRATION_PPI.\r
+                //\r
+                ASSERT (FALSE);\r
               }\r
 \r
 \r
@@ -533,7 +524,7 @@ Returns:
               //\r
               PrivateInMem->PS          = &PrivateInMem->ServiceTableShadow;\r
               PrivateInMem->CpuIo       = &PrivateInMem->ServiceTableShadow.CpuIo;\r
-              PrivateInMem->HobList.Raw = (VOID*) ((UINTN) PrivateInMem->HobList.Raw + Offset);\r
+              PrivateInMem->HobList.Raw = (VOID*) ((UINTN) PrivateInMem->HobList.Raw + HeapOffset);\r
               PrivateInMem->StackBase   = (EFI_PHYSICAL_ADDRESS)(((UINTN)PrivateInMem->PhysicalMemoryBegin + EFI_PAGE_MASK) & ~EFI_PAGE_MASK);\r
 \r
               PeiServices = &PrivateInMem->PS;\r
@@ -547,7 +538,7 @@ Returns:
               // Update HandOffHob for new installed permenent memory\r
               //\r
               NewHandOffTable->EfiEndOfHobList =\r
-                (EFI_PHYSICAL_ADDRESS)(VOID*)((UINTN) NewHandOffTable->EfiEndOfHobList + Offset);\r
+                (EFI_PHYSICAL_ADDRESS)((UINTN) NewHandOffTable->EfiEndOfHobList + HeapOffset);\r
               NewHandOffTable->EfiMemoryTop        = PrivateInMem->PhysicalMemoryBegin +\r
                                                      PrivateInMem->PhysicalMemoryLength;\r
               NewHandOffTable->EfiMemoryBottom     = PrivateInMem->PhysicalMemoryBegin;\r
@@ -575,9 +566,9 @@ Returns:
               PrivateInMem->PeiMemoryInstalled     = TRUE;\r
 \r
               //\r
-              // Make sure we don't retry the same PEIM that added memory\r
+              // Restart scan of all PEIMs on next pass\r
               //\r
-              PrivateInMem->CurrentPeimCount++;\r
+              PrivateInMem->CurrentPeimCount = 0;\r
 \r
               //\r
               // Shadow PEI Core. When permanent memory is avaiable, shadow\r
@@ -666,32 +657,25 @@ Returns:
 \r
 }\r
 \r
-VOID\r
-InitializeDispatcherData (\r
-  IN PEI_CORE_INSTANCE            *PrivateData,\r
-  IN PEI_CORE_INSTANCE            *OldCoreData,\r
-  IN CONST EFI_SEC_PEI_HAND_OFF   *SecCoreData\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Initialize the Dispatcher's data members\r
 \r
-Arguments:\r
-\r
-  PeiServices          - The PEI core services table.\r
-  OldCoreData          - Pointer to old core data (before switching stack).\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
-  SecCoreData          - Points to a data structure containing information about the PEI core's operating\r
+  @param SecCoreData     Points to a data structure containing information about the PEI core's operating\r
                          environment, such as the size and location of temporary RAM, the stack location and\r
                          the BFV location.\r
 \r
-Returns:\r
-\r
-  None.\r
+  @return None.\r
 \r
---*/\r
+**/\r
+VOID\r
+InitializeDispatcherData (\r
+  IN PEI_CORE_INSTANCE            *PrivateData,\r
+  IN PEI_CORE_INSTANCE            *OldCoreData,\r
+  IN CONST EFI_SEC_PEI_HAND_OFF   *SecCoreData\r
+  )\r
 {\r
   if (OldCoreData == NULL) {\r
     PeiInitializeFv (PrivateData, SecCoreData);\r
@@ -700,29 +684,25 @@ Returns:
   return;\r
 }\r
 \r
+/**\r
+  This routine parses the Dependency Expression, if available, and\r
+  decides if the module can be executed.\r
+\r
+\r
+  @param Private         PeiCore's private data structure\r
+  @param FileHandle      PEIM's file handle\r
+  @param PeimCount       Peim count in all dispatched PEIMs.\r
+\r
+  @retval TRUE   Can be dispatched\r
+  @retval FALSE  Cannot be dispatched\r
 \r
+**/\r
 BOOLEAN\r
 DepexSatisfied (\r
   IN PEI_CORE_INSTANCE          *Private,\r
   IN EFI_PEI_FILE_HANDLE        FileHandle,\r
   IN UINTN                      PeimCount\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This routine parses the Dependency Expression, if available, and\r
-  decides if the module can be executed.\r
-\r
-Arguments:\r
-  PeiServices - The PEI Service Table\r
-  CurrentPeimAddress - Address of the PEIM Firmware File under investigation\r
-\r
-Returns:\r
-  TRUE  - Can be dispatched\r
-  FALSE - Cannot be dispatched\r
-\r
---*/\r
 {\r
   EFI_STATUS           Status;\r
   VOID                 *DepexData;\r
@@ -760,11 +740,11 @@ Returns:
   This routine enable a PEIM to register itself to shadow when PEI Foundation\r
   discovery permanent memory.\r
 \r
-       @param FileHandle       File handle of a PEIM.\r
+  @param FileHandle             File handle of a PEIM.\r
 \r
-  @retval EFI_NOT_FOUND                                The file handle doesn't point to PEIM itself.\r
-  @retval EFI_ALREADY_STARTED          Indicate that the PEIM has been registered itself.\r
-  @retval EFI_SUCCESS                                          Successfully to register itself.\r
+  @retval EFI_NOT_FOUND         The file handle doesn't point to PEIM itself.\r
+  @retval EFI_ALREADY_STARTED   Indicate that the PEIM has been registered itself.\r
+  @retval EFI_SUCCESS           Successfully to register itself.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -795,18 +775,16 @@ PeiRegisterForShadow (
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
-\r
 /**\r
   Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r
 \r
-       @param PeiServices          Pointer to the PEI Core Services Table.\r
-       @param FileHandle               File handle of a Fv type file.\r
+  @param PeiServices          Pointer to the PEI Core Services Table.\r
+  @param FvFileHandle         File handle of a Fv type file.\r
   @param AuthenticationState  Pointer to attestation authentication state of image.\r
 \r
 \r
-  @retval EFI_NOT_FOUND                                FV image can't be found.\r
-  @retval EFI_SUCCESS                                          Successfully to process it.\r
+  @retval EFI_NOT_FOUND       FV image can't be found.\r
+  @retval EFI_SUCCESS         Successfully to process it.\r
 \r
 **/\r
 EFI_STATUS\r