]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
SecurityPkg: Clean up source files
[mirror_edk2.git] / SecurityPkg / Tcg / Tcg2Dxe / Tcg2Dxe.c
index e2f346217aab9e276a5c06d6e9a618ec0fe5cfa6..aa463b287e79819d1f20cdc9f0d27795b8cbd3c8 100644 (file)
@@ -1,14 +1,14 @@
 /** @file\r
   This module implements Tcg2 Protocol.\r
-  \r
-Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
+\r
+Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<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
+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
+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
 **/\r
@@ -372,11 +372,11 @@ GetProcessorsCpuLocation (
 \r
   @retval EFI_SUCCESS            Operation completed successfully.\r
   @retval EFI_DEVICE_ERROR       The command was unsuccessful.\r
-                                 The ProtocolCapability variable will not be populated. \r
+                                 The ProtocolCapability variable will not be populated.\r
   @retval EFI_INVALID_PARAMETER  One or more of the parameters are incorrect.\r
                                  The ProtocolCapability variable will not be populated.\r
   @retval EFI_BUFFER_TOO_SMALL   The ProtocolCapability variable is too small to hold the full response.\r
-                                 It will be partially populated (required Size field will be set). \r
+                                 It will be partially populated (required Size field will be set).\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -390,7 +390,7 @@ Tcg2GetCapability (
   if ((This == NULL) || (ProtocolCapability == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-  \r
+\r
   DEBUG ((DEBUG_VERBOSE, "Size - 0x%x\n", ProtocolCapability->Size));\r
   DEBUG ((DEBUG_VERBOSE, " 1.1 - 0x%x, 1.0 - 0x%x\n", sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY), sizeof(TREE_BOOT_SERVICE_CAPABILITY_1_0)));\r
 \r
@@ -398,7 +398,7 @@ Tcg2GetCapability (
     //\r
     // Handle the case that firmware support 1.1 but OS only support 1.0.\r
     //\r
-    if ((mTcgDxeData.BsCap.ProtocolVersion.Major > 0x01) || \r
+    if ((mTcgDxeData.BsCap.ProtocolVersion.Major > 0x01) ||\r
         ((mTcgDxeData.BsCap.ProtocolVersion.Major == 0x01) && ((mTcgDxeData.BsCap.ProtocolVersion.Minor > 0x00)))) {\r
       if (ProtocolCapability->Size >= sizeof(TREE_BOOT_SERVICE_CAPABILITY_1_0)) {\r
         CopyMem (ProtocolCapability, &mTcgDxeData.BsCap, sizeof(TREE_BOOT_SERVICE_CAPABILITY_1_0));\r
@@ -563,7 +563,7 @@ DumpEvent2 (
 \r
 /**\r
   This function returns size of TCG PCR event 2.\r
-  \r
+\r
   @param[in]  TcgPcrEvent2     TCG PCR event 2 structure.\r
 \r
   @return size of TCG PCR event 2.\r
@@ -623,7 +623,7 @@ DumpEventLog (
   UINTN                     NumberOfEvents;\r
 \r
   DEBUG ((EFI_D_INFO, "EventLogFormat: (0x%x)\n", EventLogFormat));\r
-  \r
+\r
   switch (EventLogFormat) {\r
   case EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2:\r
     EventHdr = (TCG_PCR_EVENT_HDR *)(UINTN)EventLogLocation;\r
@@ -647,7 +647,7 @@ DumpEventLog (
     break;\r
   case EFI_TCG2_EVENT_LOG_FORMAT_TCG_2:\r
     //\r
-    // Dump first event        \r
+    // Dump first event\r
     //\r
     EventHdr = (TCG_PCR_EVENT_HDR *)(UINTN)EventLogLocation;\r
     DumpEvent (EventHdr);\r
@@ -682,7 +682,7 @@ DumpEventLog (
 \r
 /**\r
   The EFI_TCG2_PROTOCOL Get Event Log function call allows a caller to\r
-  retrieve the address of a given event log and its last entry. \r
+  retrieve the address of a given event log and its last entry.\r
 \r
   @param[in]  This               Indicates the calling context\r
   @param[in]  EventLogFormat     The type of the event log for which the information is requested.\r
@@ -780,14 +780,14 @@ Tcg2GetEventLog (
 /**\r
   Add a new entry to the Event Log.\r
 \r
-  @param[in, out] EventLogPtr     Pointer to the Event Log data.  \r
-  @param[in, out] LogSize         Size of the Event Log.  \r
+  @param[in, out] EventLogPtr     Pointer to the Event Log data.\r
+  @param[in, out] LogSize         Size of the Event Log.\r
   @param[in]      MaxSize         Maximum size of the Event Log.\r
-  @param[in]      NewEventHdr     Pointer to a TCG_PCR_EVENT_HDR/TCG_PCR_EVENT_EX data structure.  \r
+  @param[in]      NewEventHdr     Pointer to a TCG_PCR_EVENT_HDR/TCG_PCR_EVENT_EX data structure.\r
   @param[in]      NewEventHdrSize New event header size.\r
-  @param[in]      NewEventData    Pointer to the new event data.  \r
+  @param[in]      NewEventData    Pointer to the new event data.\r
   @param[in]      NewEventSize    New event data size.\r
-  \r
+\r
   @retval EFI_SUCCESS           The new event log entry was added.\r
   @retval EFI_OUT_OF_RESOURCES  No enough memory to log the new event.\r
 \r
@@ -838,9 +838,9 @@ TcgCommLogEvent (
   Add a new entry to the Event Log.\r
 \r
   @param[in] EventLogFormat  The type of the event log for which the information is requested.\r
-  @param[in] NewEventHdr     Pointer to a TCG_PCR_EVENT_HDR/TCG_PCR_EVENT_EX data structure.  \r
+  @param[in] NewEventHdr     Pointer to a TCG_PCR_EVENT_HDR/TCG_PCR_EVENT_EX data structure.\r
   @param[in] NewEventHdrSize New event header size.\r
-  @param[in] NewEventData    Pointer to the new event data.  \r
+  @param[in] NewEventData    Pointer to the new event data.\r
   @param[in] NewEventSize    New event data size.\r
 \r
   @retval EFI_SUCCESS           The new event log entry was added.\r
@@ -859,7 +859,7 @@ TcgDxeLogEvent (
   EFI_STATUS                Status;\r
   UINTN                     Index;\r
   TCG_EVENT_LOG_AREA_STRUCT *EventLogAreaStruct;\r
-  \r
+\r
   for (Index = 0; Index < sizeof(mTcg2EventInfo)/sizeof(mTcg2EventInfo[0]); Index++) {\r
     if (EventLogFormat == mTcg2EventInfo[Index].LogFormat) {\r
       break;\r
@@ -889,7 +889,7 @@ TcgDxeLogEvent (
              NewEventData,\r
              NewEventSize\r
              );\r
-  \r
+\r
   if (Status == EFI_OUT_OF_RESOURCES) {\r
     EventLogAreaStruct->EventLogTruncated = TRUE;\r
     return EFI_VOLUME_FULL;\r
@@ -1122,11 +1122,11 @@ TcgDxeLogHashEvent (
   and add an entry to the Event Log.\r
 \r
   @param[in]      Flags         Bitmap providing additional information.\r
-  @param[in]      HashData      Physical address of the start of the data buffer \r
+  @param[in]      HashData      Physical address of the start of the data buffer\r
                                 to be hashed, extended, and logged.\r
   @param[in]      HashDataLen   The length, in bytes, of the buffer referenced by HashData\r
-  @param[in, out] NewEventHdr   Pointer to a TCG_PCR_EVENT_HDR data structure.  \r
-  @param[in]      NewEventData  Pointer to the new event data.  \r
+  @param[in, out] NewEventHdr   Pointer to a TCG_PCR_EVENT_HDR data structure.\r
+  @param[in]      NewEventData  Pointer to the new event data.\r
 \r
   @retval EFI_SUCCESS           Operation completed successfully.\r
   @retval EFI_OUT_OF_RESOURCES  No enough memory to log the new event.\r
@@ -1176,13 +1176,13 @@ TcgDxeHashLogExtendEvent (
 /**\r
   The EFI_TCG2_PROTOCOL HashLogExtendEvent function call provides callers with\r
   an opportunity to extend and optionally log events without requiring\r
-  knowledge of actual TPM commands. \r
+  knowledge of actual TPM commands.\r
   The extend operation will occur even if this function cannot create an event\r
-  log entry (e.g. due to the event log being full). \r
+  log entry (e.g. due to the event log being full).\r
 \r
   @param[in]  This               Indicates the calling context\r
   @param[in]  Flags              Bitmap providing additional information.\r
-  @param[in]  DataToHash         Physical address of the start of the data buffer to be hashed. \r
+  @param[in]  DataToHash         Physical address of the start of the data buffer to be hashed.\r
   @param[in]  DataToHashLen      The length in bytes of the buffer referenced by DataToHash.\r
   @param[in]  Event              Pointer to data buffer containing information about the event.\r
 \r
@@ -1272,7 +1272,7 @@ Tcg2HashLogExtendEvent (
   @retval EFI_SUCCESS            The command byte stream was successfully sent to the device and a response was successfully received.\r
   @retval EFI_DEVICE_ERROR       The command was not successfully sent to the device or a response was not successfully received from the device.\r
   @retval EFI_INVALID_PARAMETER  One or more of the parameters are incorrect.\r
-  @retval EFI_BUFFER_TOO_SMALL   The output parameter block is too small. \r
+  @retval EFI_BUFFER_TOO_SMALL   The output parameter block is too small.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -1322,7 +1322,7 @@ Tcg2SubmitCommand (
   @param[out] ActivePcrBanks  Pointer to the variable receiving the bitmap of currently active PCR banks.\r
 \r
   @retval EFI_SUCCESS           The bitmap of active PCR banks was stored in the ActivePcrBanks parameter.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect. \r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -1412,7 +1412,7 @@ Tcg2GetResultOfSetActivePcrBanks (
   if ((OperationPresent == NULL) || (Response == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-  \r
+\r
   ReturnCode = Tcg2PhysicalPresenceLibReturnOperationResponseToOsFunction (OperationPresent, Response);\r
   if (ReturnCode == TCG_PP_RETURN_TPM_OPERATION_RESPONSE_SUCCESS) {\r
     return EFI_SUCCESS;\r
@@ -1485,7 +1485,7 @@ SetupEventLog (
       mTcgDxeData.EventLogAreaStruct[Index].Lasa = Lasa;\r
       mTcgDxeData.EventLogAreaStruct[Index].Laml = PcdGet32 (PcdTcgLogAreaMinLen);\r
       //\r
-      // To initialize them as 0xFF is recommended \r
+      // To initialize them as 0xFF is recommended\r
       // because the OS can know the last entry for that.\r
       //\r
       SetMem ((VOID *)(UINTN)Lasa, PcdGet32 (PcdTcgLogAreaMinLen), 0xFF);\r
@@ -1631,7 +1631,7 @@ SetupEventLog (
         mTcgDxeData.FinalEventLogAreaStruct[Index].EventLogTruncated = FALSE;\r
 \r
         //\r
-        // Install to configuration table for EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 \r
+        // Install to configuration table for EFI_TCG2_EVENT_LOG_FORMAT_TCG_2\r
         //\r
         Status = gBS->InstallConfigurationTable (&gEfiTcg2FinalEventsTableGuid, (VOID *)mTcgDxeData.FinalEventsTable[Index]);\r
         if (EFI_ERROR (Status)) {\r
@@ -1652,7 +1652,7 @@ SetupEventLog (
       }\r
     }\r
   }\r
-  \r
+\r
   //\r
   // 3. Sync data from PEI to DXE\r
   //\r
@@ -1661,7 +1661,7 @@ SetupEventLog (
     if ((mTcgDxeData.BsCap.SupportedEventLogs & mTcg2EventInfo[Index].LogFormat) != 0) {\r
       GuidHob.Raw = GetHobList ();\r
       Status = EFI_SUCCESS;\r
-      while (!EFI_ERROR (Status) && \r
+      while (!EFI_ERROR (Status) &&\r
              (GuidHob.Raw = GetNextGuidHob (mTcg2EventInfo[Index].EventGuid, GuidHob.Raw)) != NULL) {\r
         TcgEvent    = AllocateCopyPool (GET_GUID_HOB_DATA_SIZE (GuidHob.Guid), GET_GUID_HOB_DATA (GuidHob.Guid));\r
         ASSERT (TcgEvent != NULL);\r
@@ -1729,8 +1729,8 @@ SetupEventLog (
   Measure and log an action string, and extend the measurement result into PCR[PCRIndex].\r
 \r
   @param[in] PCRIndex         PCRIndex to extend\r
-  @param[in] String           A specific string that indicates an Action event.  \r
-  \r
+  @param[in] String           A specific string that indicates an Action event.\r
+\r
   @retval EFI_SUCCESS         Operation completed successfully.\r
   @retval EFI_DEVICE_ERROR    The operation was unsuccessful.\r
 \r
@@ -1778,7 +1778,7 @@ MeasureHandoffTables (
 \r
   if (PcdGet8 (PcdTpmPlatformClass) == TCG_PLATFORM_TYPE_SERVER) {\r
     //\r
-    // Tcg Server spec. \r
+    // Tcg Server spec.\r
     // Measure each processor EFI_CPU_PHYSICAL_LOCATION with EV_TABLE_OF_DEVICES to PCR[1]\r
     //\r
     Status = GetProcessorsCpuLocation(&ProcessorLocBuf, &ProcessorNum);\r
@@ -1810,7 +1810,7 @@ MeasureHandoffTables (
 /**\r
   Measure and log Separator event, and extend the measurement result into a specific PCR.\r
 \r
-  @param[in] PCRIndex         PCR index.  \r
+  @param[in] PCRIndex         PCR index.\r
 \r
   @retval EFI_SUCCESS         Operation completed successfully.\r
   @retval EFI_DEVICE_ERROR    The operation was unsuccessful.\r
@@ -1842,13 +1842,13 @@ MeasureSeparatorEvent (
 /**\r
   Measure and log an EFI variable, and extend the measurement result into a specific PCR.\r
 \r
-  @param[in]  PCRIndex          PCR Index.  \r
-  @param[in]  EventType         Event type.  \r
+  @param[in]  PCRIndex          PCR Index.\r
+  @param[in]  EventType         Event type.\r
   @param[in]  VarName           A Null-terminated string that is the name of the vendor's variable.\r
   @param[in]  VendorGuid        A unique identifier for the vendor.\r
-  @param[in]  VarData           The content of the variable data.  \r
-  @param[in]  VarSize           The size of the variable data.  \r
\r
+  @param[in]  VarData           The content of the variable data.\r
+  @param[in]  VarSize           The size of the variable data.\r
+\r
   @retval EFI_SUCCESS           Operation completed successfully.\r
   @retval EFI_OUT_OF_RESOURCES  Out of memory.\r
   @retval EFI_DEVICE_ERROR      The operation was unsuccessful.\r
@@ -1928,13 +1928,13 @@ MeasureVariable (
 /**\r
   Read then Measure and log an EFI variable, and extend the measurement result into a specific PCR.\r
 \r
-  @param[in]  PCRIndex          PCR Index.  \r
-  @param[in]  EventType         Event type.  \r
+  @param[in]  PCRIndex          PCR Index.\r
+  @param[in]  EventType         Event type.\r
   @param[in]   VarName          A Null-terminated string that is the name of the vendor's variable.\r
   @param[in]   VendorGuid       A unique identifier for the vendor.\r
-  @param[out]  VarSize          The size of the variable data.  \r
-  @param[out]  VarData          Pointer to the content of the variable.  \r
\r
+  @param[out]  VarSize          The size of the variable data.\r
+  @param[out]  VarData          Pointer to the content of the variable.\r
+\r
   @retval EFI_SUCCESS           Operation completed successfully.\r
   @retval EFI_OUT_OF_RESOURCES  Out of memory.\r
   @retval EFI_DEVICE_ERROR      The operation was unsuccessful.\r
@@ -1987,9 +1987,9 @@ according to TCG PC Client PFP spec 0021 Section 2.4.4.2
 \r
   @param[in]   VarName          A Null-terminated string that is the name of the vendor's variable.\r
   @param[in]   VendorGuid       A unique identifier for the vendor.\r
-  @param[out]  VarSize          The size of the variable data.  \r
-  @param[out]  VarData          Pointer to the content of the variable.  \r
\r
+  @param[out]  VarSize          The size of the variable data.\r
+  @param[out]  VarData          Pointer to the content of the variable.\r
+\r
   @retval EFI_SUCCESS           Operation completed successfully.\r
   @retval EFI_OUT_OF_RESOURCES  Out of memory.\r
   @retval EFI_DEVICE_ERROR      The operation was unsuccessful.\r
@@ -2018,9 +2018,9 @@ ReadAndMeasureBootVariable (
 \r
   @param[in]   VarName          A Null-terminated string that is the name of the vendor's variable.\r
   @param[in]   VendorGuid       A unique identifier for the vendor.\r
-  @param[out]  VarSize          The size of the variable data.  \r
-  @param[out]  VarData          Pointer to the content of the variable.  \r
\r
+  @param[out]  VarSize          The size of the variable data.\r
+  @param[out]  VarData          Pointer to the content of the variable.\r
+\r
   @retval EFI_SUCCESS           Operation completed successfully.\r
   @retval EFI_OUT_OF_RESOURCES  Out of memory.\r
   @retval EFI_DEVICE_ERROR      The operation was unsuccessful.\r
@@ -2477,7 +2477,7 @@ OnResetNotificationInstall (
 \r
 /**\r
   The function install Tcg2 protocol.\r
-  \r
+\r
   @retval EFI_SUCCESS     Tcg2 protocol is installed.\r
   @retval other           Some error occurs.\r
 **/\r
@@ -2502,9 +2502,9 @@ InstallTcg2 (
 /**\r
   The driver's entry point. It publishes EFI Tcg2 Protocol.\r
 \r
-  @param[in] ImageHandle  The firmware allocated handle for the EFI image.  \r
+  @param[in] ImageHandle  The firmware allocated handle for the EFI image.\r
   @param[in] SystemTable  A pointer to the EFI System Table.\r
-  \r
+\r
   @retval EFI_SUCCESS     The entry point is executed successfully.\r
   @retval other           Some error occurs when executing this entry point.\r
 **/\r
@@ -2537,18 +2537,18 @@ DriverEntry (
     DEBUG ((EFI_D_ERROR, "TPM2 error!\n"));\r
     return EFI_DEVICE_ERROR;\r
   }\r
-  \r
+\r
   Status = Tpm2RequestUseTpm ();\r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((EFI_D_ERROR, "TPM2 not detected!\n"));\r
     return Status;\r
   }\r
-  \r
+\r
   //\r
   // Fill information\r
   //\r
   ASSERT (TCG_EVENT_LOG_AREA_COUNT_MAX == sizeof(mTcg2EventInfo)/sizeof(mTcg2EventInfo[0]));\r
-  \r
+\r
   mTcgDxeData.BsCap.Size = sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY);\r
   mTcgDxeData.BsCap.ProtocolVersion.Major = 1;\r
   mTcgDxeData.BsCap.ProtocolVersion.Minor = 1;\r
@@ -2655,7 +2655,7 @@ DriverEntry (
                     );\r
 \r
     //\r
-    // Measure Exit Boot Service failed \r
+    // Measure Exit Boot Service failed\r
     //\r
     Status = gBS->CreateEventEx (\r
                     EVT_NOTIFY_SIGNAL,\r