]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Correct more comments for PeiCore.
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 11 Aug 2008 09:28:27 +0000 (09:28 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 11 Aug 2008 09:28:27 +0000 (09:28 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5627 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
MdeModulePkg/Core/Pei/Memory/MemoryServices.c
MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
MdeModulePkg/Core/Pei/Security/Security.c

index 9e0160cc866ca440278ca50c96b6bfffda0a0b25..1ea443f6ef8b25c229edbf1126299f341d677023 100644 (file)
@@ -100,7 +100,7 @@ DiscoverPeimsAndOrderWithApriori (
       Private->AprioriCount -= sizeof (EFI_FFS_FILE_HEADER) - sizeof (EFI_COMMON_SECTION_HEADER);\r
       Private->AprioriCount /= sizeof (EFI_GUID);\r
 \r
-      SetMem (FileGuid, sizeof (FileGuid), 0);\r
+      ZeroMem (FileGuid, sizeof (FileGuid));\r
       for (Index = 0; Index < PeimCount; Index++) {\r
         //\r
         // Make an array of file name guids that matches the FileHandle array so we can convert\r
@@ -178,6 +178,7 @@ DiscoverPeimsAndOrderWithApriori (
   @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param PrivateInMem    PeiCore's private data structure\r
 \r
+  @return PeiCore function address after shadowing.\r
 **/\r
 VOID*\r
 ShadowPeiCore(\r
@@ -215,6 +216,10 @@ ShadowPeiCore(
               );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  //\r
+  // Compute the PeiCore's function address after shaowed PeiCore.\r
+  // _ModuleEntryPoint is PeiCore main function entry\r
+  //\r
   return (VOID*) ((UINTN) EntryPoint + (UINTN) PeiCore - (UINTN) _ModuleEntryPoint);\r
 }\r
 \r
@@ -791,9 +796,11 @@ PeiRegisterForShadow (
   @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
-\r
+  @retval EFI_NOT_FOUND         FV image can't be found.\r
+  @retval EFI_SUCCESS           Successfully to process it.\r
+  @retval EFI_OUT_OF_RESOURCES  Can not allocate page when aligning FV image\r
+  @retval Others                Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section\r
+  \r
 **/\r
 EFI_STATUS\r
 ProcessFvFile (\r
@@ -840,11 +847,13 @@ ProcessFvFile (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
+  \r
   //\r
   // Collect FvImage Info.\r
   //\r
   Status = PeiFfsGetVolumeInfo (FvImageHandle, &FvImageInfo);\r
   ASSERT_EFI_ERROR (Status);\r
+  \r
   //\r
   // FvAlignment must be more than 8 bytes required by FvHeader structure.\r
   //\r
@@ -852,6 +861,7 @@ ProcessFvFile (
   if (FvAlignment < 8) {\r
     FvAlignment = 8;\r
   }\r
+  \r
   //\r
   // Check FvImage\r
   //\r
index d24897d7767b505022f074df42f25342b67881b3..7e841c3c461a7ef35888a6a518ca4b943ba9476e 100644 (file)
@@ -18,8 +18,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
   Initialize the memory services.\r
 \r
-\r
-  @param PrivateData     Add parameter description\r
+  @param PrivateData     Points to PeiCore's private instance data.\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
@@ -76,9 +75,13 @@ InitializeMemoryServices (
 \r
 /**\r
 \r
-  Install the permanent memory is now available.\r
-  Creates HOB (PHIT and Stack).\r
+  This function registers the found memory configuration with the PEI Foundation.\r
 \r
+  The usage model is that the PEIM that discovers the permanent memory shall invoke this service.\r
+  This routine will hold discoveried memory information into PeiCore's private data,\r
+  and set SwitchStackSignal flag. After PEIM who discovery memory is dispatched,\r
+  PeiDispatcher will migrate temporary memory to permenement memory.\r
+  \r
   @param PeiServices        An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param MemoryBegin        Start of memory address.\r
   @param MemoryLength       Length of memory.\r
@@ -120,7 +123,6 @@ PeiInstallPeiMemory (
   @param Memory          Pointer of memory allocated.\r
 \r
   @retval EFI_SUCCESS              The allocation was successful\r
-  @retval EFI_INVALID_PARAMETER    Only AllocateAnyAddress is supported.\r
   @retval EFI_NOT_AVAILABLE_YET    Called with permanent memory not available\r
   @retval EFI_OUT_OF_RESOURCES     There is not enough HOB heap to satisfy the requirement\r
                                    to allocate the number of pages.\r
@@ -129,15 +131,14 @@ PeiInstallPeiMemory (
 EFI_STATUS\r
 EFIAPI\r
 PeiAllocatePages (\r
-  IN CONST EFI_PEI_SERVICES           **PeiServices,\r
-  IN EFI_MEMORY_TYPE            MemoryType,\r
-  IN UINTN                      Pages,\r
-  OUT EFI_PHYSICAL_ADDRESS      *Memory\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices,\r
+  IN       EFI_MEMORY_TYPE      MemoryType,\r
+  IN       UINTN                Pages,\r
+  OUT      EFI_PHYSICAL_ADDRESS *Memory\r
   )\r
 {\r
   PEI_CORE_INSTANCE                       *PrivateData;\r
   EFI_PEI_HOB_POINTERS                    Hob;\r
-  EFI_PHYSICAL_ADDRESS                    Offset;\r
   EFI_PHYSICAL_ADDRESS                    *FreeMemoryTop;\r
   EFI_PHYSICAL_ADDRESS                    *FreeMemoryBottom;\r
 \r
@@ -150,7 +151,7 @@ PeiAllocatePages (
   if (!PrivateData->PeiMemoryInstalled) {\r
     //\r
     // When PeiInstallMemory is called but CAR has *not* been moved to temporary memory,\r
-    // the AllocatePage will dependent the field of PEI_CORE_INSTANCE structure.\r
+    // the AllocatePage will dependent on the field of PEI_CORE_INSTANCE structure.\r
     //\r
     if (!PrivateData->SwitchStackSignal) {\r
       return EFI_NOT_AVAILABLE_YET;\r
@@ -164,16 +165,9 @@ PeiAllocatePages (
   }\r
 \r
   //\r
-  // Check to see if on 4k boundary\r
+  // Check to see if on 4k boundary, If not aligned, make the allocation aligned.\r
   //\r
-  Offset = *(FreeMemoryTop) & 0xFFF;\r
-  \r
-  //\r
-  // If not aligned, make the allocation aligned.\r
-  //\r
-  if (Offset != 0) {\r
-    *(FreeMemoryTop) -= Offset;\r
-  }\r
+  *(FreeMemoryTop) -= *(FreeMemoryTop) & 0xFFF;\r
   \r
   //\r
   // Verify that there is sufficient memory to satisfy the allocation\r
@@ -210,12 +204,14 @@ PeiAllocatePages (
 \r
 /**\r
 \r
-  Memory allocation service on the CAR.\r
-\r
+  Pool allocation service. Before permenent memory is discoveried, the pool will \r
+  be allocated the heap in the CAR. Genenrally, the size of heap in temporary \r
+  memory does not exceed to 64K, so the biggest pool size could be allocated is \r
+  64K.\r
 \r
-  @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
-  @param Size            Amount of memory required\r
-  @param Buffer          Address of pointer to the buffer\r
+  @param PeiServices               An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param Size                      Amount of memory required\r
+  @param Buffer                    Address of pointer to the buffer\r
 \r
   @retval EFI_SUCCESS              The allocation was successful\r
   @retval EFI_OUT_OF_RESOURCES     There is not enough heap to satisfy the requirement\r
@@ -225,26 +221,30 @@ PeiAllocatePages (
 EFI_STATUS\r
 EFIAPI\r
 PeiAllocatePool (\r
-  IN CONST EFI_PEI_SERVICES           **PeiServices,\r
-  IN UINTN                      Size,\r
-  OUT VOID                      **Buffer\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices,\r
+  IN       UINTN                Size,\r
+  OUT      VOID                 **Buffer\r
   )\r
 {\r
   EFI_STATUS               Status;\r
   EFI_HOB_MEMORY_POOL      *Hob;\r
 \r
- //\r
- // If some "post-memory" PEIM wishes to allocate larger pool,\r
- // it should use AllocatePages service instead.\r
- //\r
- ASSERT (Size < 0x10000 - sizeof (EFI_HOB_MEMORY_POOL));\r
- Status = PeiServicesCreateHob (\r
+  //\r
+  // If some "post-memory" PEIM wishes to allocate larger pool,\r
+  // it should use AllocatePages service instead.\r
+  //\r
+  \r
+  //\r
+  // Generally, the size of heap in temporary memory does not exceed to 64K,\r
+  // so the maxmium size of pool is 0x10000 - sizeof (EFI_HOB_MEMORY_POOL)\r
+  //\r
+  ASSERT (Size < 0x10000 - sizeof (EFI_HOB_MEMORY_POOL));\r
+  Status = PeiServicesCreateHob (\r
              EFI_HOB_TYPE_MEMORY_POOL,\r
              (UINT16)(sizeof (EFI_HOB_MEMORY_POOL) + Size),\r
              (VOID **)&Hob\r
              );\r
   *Buffer = Hob+1;  \r
 \r
-\r
   return Status;\r
 }\r
index d257eaee432db9bd8d41151dd50a58b9f2d63fe0..6e032783d0bdd88142cd5d52be38993a54b47647 100644 (file)
@@ -21,8 +21,7 @@ STATIC EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = {
 };\r
 \r
 ///\r
-/// Pei Core Module Variables\r
-///\r
+/// Pei service instance\r
 ///\r
 STATIC EFI_PEI_SERVICES  gPs = {\r
   {\r
@@ -67,11 +66,10 @@ STATIC EFI_PEI_SERVICES  gPs = {
 \r
 /**\r
 \r
-  The entry routine to Pei Core, invoked by PeiMain during transition\r
+  This routine is invoked by main entry of PeiMain module during transition\r
   from SEC to PEI. After switching stack in the PEI core, it will restart\r
   with the old core data.\r
 \r
-\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
@@ -83,6 +81,7 @@ STATIC EFI_PEI_SERVICES  gPs = {
                          calls and/or code in these early PPIs\r
   @param Data            Pointer to old core data that is used to initialize the\r
                          core's data areas.\r
+                         If NULL, it is first PeiCore entering.\r
 \r
   @retval EFI_NOT_FOUND  Never reach\r
 \r
@@ -98,13 +97,13 @@ PeiCore (
   PEI_CORE_INSTANCE                                     PrivateData;\r
   EFI_STATUS                                            Status;\r
   PEI_CORE_TEMP_POINTERS                                TempPtr;\r
-  UINT64                                                mTick;\r
+  UINT64                                                Tick;\r
   PEI_CORE_INSTANCE                                     *OldCoreData;\r
   EFI_PEI_CPU_IO_PPI                                    *CpuIo;\r
   EFI_PEI_PCI_CFG2_PPI                                  *PciCfg;\r
   PEICORE_FUNCTION_POINTER                              ShadowedPeiCore;\r
 \r
-  mTick = 0;\r
+  Tick = 0;\r
   OldCoreData = (PEI_CORE_INSTANCE *) Data;\r
 \r
   //\r
@@ -113,16 +112,17 @@ PeiCore (
   // \r
   if (PerformanceMeasurementEnabled()) {\r
     if (OldCoreData == NULL) {\r
-      mTick = GetPerformanceCounter ();\r
+      Tick = GetPerformanceCounter ();\r
     }\r
   }\r
 \r
-  //\r
-  // PeiCore has been shadowed to memory for first entering, so\r
-  // just jump to PeiCore in memory here.\r
-  //\r
   if (OldCoreData != NULL) {\r
     ShadowedPeiCore = (PEICORE_FUNCTION_POINTER) (UINTN) OldCoreData->ShadowedPeiCore;\r
+    \r
+    //\r
+    // PeiCore has been shadowed to memory for first entering, so\r
+    // just jump to PeiCore in memory here.\r
+    //\r
     if (ShadowedPeiCore != NULL) {\r
       OldCoreData->ShadowedPeiCore = NULL;\r
       ShadowedPeiCore (\r
@@ -142,6 +142,10 @@ PeiCore (
     PrivateData.ServiceTableShadow.CpuIo  = CpuIo;\r
     PrivateData.ServiceTableShadow.PciCfg = PciCfg;\r
   } else {\r
+    //\r
+    // If OldCoreData is NULL, means current is first Peicore's entering.\r
+    //\r
+    \r
     ZeroMem (&PrivateData, sizeof (PEI_CORE_INSTANCE));\r
     PrivateData.Signature = PEI_CORE_HANDLE_SIGNATURE;\r
     CopyMem (&PrivateData.ServiceTableShadow, &gPs, sizeof (gPs));\r
@@ -186,11 +190,11 @@ PeiCore (
       FixedPcdGet32 (PcdStatusCodeValuePeiCoreEntry)\r
       );\r
 \r
-    PERF_START (NULL,"PEI", NULL, mTick);\r
+    PERF_START (NULL,"PEI", NULL, Tick);\r
     //\r
     // If first pass, start performance measurement.\r
     //\r
-    PERF_START (NULL,"PreMem", NULL, mTick);\r
+    PERF_START (NULL,"PreMem", NULL, Tick);\r
 \r
     //\r
     // If SEC provided any PPI services to PEI, install them.\r
index 7460707a274f164589a5befc2b744856f6703984..469686ff23ed5ed7f404bf34bb17a7c34bf8b323 100644 (file)
@@ -62,7 +62,8 @@ InitializeSecurityServices (
 /**\r
 \r
   Provide a callback for when the security PPI is installed.\r
-\r
+  This routine will cache installed security PPI into PeiCore's private data.\r
+  \r
   @param PeiServices        An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param NotifyDescriptor   The descriptor for the notification event.\r
   @param Ppi                Pointer to the PPI in question.\r
@@ -105,7 +106,7 @@ SecurityPpiNotifyCallback (
 \r
   @retval EFI_SUCCESS              Image is OK\r
   @retval EFI_SECURITY_VIOLATION   Image is illegal\r
-\r
+  @retval EFI_NOT_FOUND            If security PPI is not installed.\r
 **/\r
 EFI_STATUS\r
 VerifyPeim (\r
@@ -148,10 +149,9 @@ VerifyPeim (
 /**\r
   Verify a Firmware volume.\r
 \r
-  @param CurrentFvAddress - Pointer to the current Firmware Volume under consideration\r
+  @param CurrentFvAddress   Pointer to the current Firmware Volume under consideration\r
 \r
-  @retval EFI_SUCCESS              Firmware Volume is legal\r
-  @retval EFI_SECURITY_VIOLATION   Firmware Volume fails integrity test\r
+  @retval EFI_SUCCESS       Firmware Volume is legal\r
 \r
 **/\r
 EFI_STATUS\r