]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/Security/Security.c
Patch to remove STATIC modifier. This is on longer recommended by EFI Framework codin...
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Security / Security.c
index e7c2fbde956dde14b545ebb15609515856f2e002..5b37bf021dcaf3fcb757f535956745eee2627d0a 100644 (file)
@@ -1,5 +1,6 @@
-/*++\r
-\r
+/** @file\r
+  EFI PEI Core Security 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,24 +10,21 @@ 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
-  Security.c\r
+**/\r
 \r
-Abstract:\r
+#include <PeiMain.h>\r
 \r
-  EFI PEI Core Security services\r
+/**\r
 \r
---*/\r
+  Provide a callback for when the security PPI is installed.\r
 \r
-//\r
-// Include common header file for this module.\r
-//\r
-#include "CommonHeader.h"\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
 \r
-#include <PeiMain.h>\r
+  @return Always success\r
 \r
-STATIC\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 SecurityPpiNotifyCallback (\r
@@ -35,33 +33,25 @@ SecurityPpiNotifyCallback (
   IN VOID                       *Ppi\r
   );\r
 \r
-static EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList = {\r
+EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList = {\r
    EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
-   &gEfiPeiSecurityPpiGuid,\r
+   &gEfiPeiSecurity2PpiGuid,\r
    SecurityPpiNotifyCallback\r
 };\r
 \r
+/**\r
+  Initialize the security services.\r
+\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
+\r
+**/\r
 VOID\r
 InitializeSecurityServices (\r
   IN EFI_PEI_SERVICES  **PeiServices,\r
   IN PEI_CORE_INSTANCE *OldCoreData\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Initialize the security services.\r
-\r
-Arguments:\r
-\r
-  PeiServices - The PEI core services table.\r
-  OldCoreData - Pointer to the old core data.\r
-                NULL if being run in non-permament memory mode.\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
 {\r
   if (OldCoreData == NULL) {\r
     PeiServicesNotifyPpi (&mNotifyList);\r
@@ -69,7 +59,18 @@ Returns:
   return;\r
 }\r
 \r
-STATIC\r
+/**\r
+\r
+  Provide a callback for when the security PPI is installed.\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
+\r
+  @return Always success\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 SecurityPpiNotifyCallback (\r
@@ -77,23 +78,6 @@ SecurityPpiNotifyCallback (
   IN EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyDescriptor,\r
   IN VOID                       *Ppi\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Provide a callback for when the security PPI is installed.\r
-\r
-Arguments:\r
-\r
-  PeiServices       - The PEI core services table.\r
-  NotifyDescriptor  - The descriptor for the notification event.\r
-  Ppi               - Pointer to the PPI in question.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS - The function is successfully processed.\r
-\r
---*/\r
 {\r
   PEI_CORE_INSTANCE                       *PrivateData;\r
 \r
@@ -106,49 +90,40 @@ Returns:
   // If there isn't a security PPI installed, use the one from notification\r
   //\r
   if (PrivateData->PrivateSecurityPpi == NULL) {\r
-    PrivateData->PrivateSecurityPpi = (EFI_PEI_SECURITY_PPI *)Ppi;\r
+    PrivateData->PrivateSecurityPpi = (EFI_PEI_SECURITY2_PPI *)Ppi;\r
   }\r
   return EFI_SUCCESS;\r
 }\r
 \r
-EFI_STATUS\r
-VerifyPeim (\r
-  IN EFI_PEI_SERVICES     **PeiServices,\r
-  IN EFI_FFS_FILE_HEADER  *CurrentPeimAddress\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Provide a callout to the security verification service.\r
 \r
-Arguments:\r
-\r
-  PeiServices          - The PEI core services table.\r
-  CurrentPeimAddress   - Pointer to the Firmware File under investigation.\r
 \r
-Returns:\r
+  @param PrivateData     PeiCore's private data structure\r
+  @param VolumeHandle    Handle of FV\r
+  @param FileHandle      Handle of PEIM's ffs\r
 \r
-  EFI_SUCCESS             - Image is OK\r
-  EFI_SECURITY_VIOLATION  - Image is illegal\r
-\r
---*/\r
+  @retval EFI_SUCCESS              Image is OK\r
+  @retval EFI_SECURITY_VIOLATION   Image is illegal\r
+  @retval EFI_NOT_FOUND            If security PPI is not installed.\r
+**/\r
+EFI_STATUS\r
+VerifyPeim (\r
+  IN PEI_CORE_INSTANCE      *PrivateData,\r
+  IN EFI_PEI_FV_HANDLE      VolumeHandle,\r
+  IN EFI_PEI_FILE_HANDLE    FileHandle\r
+  )\r
 {\r
-  PEI_CORE_INSTANCE               *PrivateData;\r
   EFI_STATUS                      Status;\r
   UINT32                          AuthenticationStatus;\r
-  BOOLEAN                         StartCrisisRecovery;\r
+  BOOLEAN                         DeferExection;\r
 \r
   //\r
   // Set a default authentication state\r
   //\r
   AuthenticationStatus = 0;\r
 \r
-  //\r
-  // get security PPI instance from PEI private data\r
-  //\r
-  PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
-\r
   if (PrivateData->PrivateSecurityPpi == NULL) {\r
     Status = EFI_NOT_FOUND;\r
   } else {\r
@@ -156,13 +131,14 @@ Returns:
     // Check to see if the image is OK\r
     //\r
     Status = PrivateData->PrivateSecurityPpi->AuthenticationState (\r
-                                                PeiServices,\r
+                                                (CONST EFI_PEI_SERVICES **) &PrivateData->PS,\r
                                                 PrivateData->PrivateSecurityPpi,\r
                                                 AuthenticationStatus,\r
-                                                CurrentPeimAddress,\r
-                                                &StartCrisisRecovery\r
+                                                VolumeHandle,\r
+                                                FileHandle,\r
+                                                &DeferExection\r
                                                 );\r
-    if (StartCrisisRecovery) {\r
+    if (DeferExection) {\r
       Status = EFI_SECURITY_VIOLATION;\r
     }\r
   }\r
@@ -170,26 +146,18 @@ Returns:
 }\r
 \r
 \r
+/**\r
+  Verify a Firmware volume.\r
+\r
+  @param CurrentFvAddress   Pointer to the current Firmware Volume under consideration\r
+\r
+  @retval EFI_SUCCESS       Firmware Volume is legal\r
+\r
+**/\r
 EFI_STATUS\r
 VerifyFv (\r
   IN EFI_FIRMWARE_VOLUME_HEADER  *CurrentFvAddress\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Verify a Firmware volume\r
-\r
-Arguments:\r
-\r
-  CurrentFvAddress - Pointer to the current Firmware Volume under consideration\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             - Firmware Volume is legal\r
-  EFI_SECURITY_VIOLATION  - Firmware Volume fails integrity test\r
-\r
---*/\r
 {\r
   //\r
   // Right now just pass the test.  Future can authenticate and/or check the\r