]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/MmTcg2PhysicalPresenceLibCommon.c
SecurityPkg: Apply uncrustify changes
[mirror_edk2.git] / SecurityPkg / Library / SmmTcg2PhysicalPresenceLib / MmTcg2PhysicalPresenceLibCommon.c
index 3788537db3180d35835d944c31ae9f47de462334..1fbfc00547cdef32f49024a044839d83e57f6c62 100644 (file)
@@ -27,7 +27,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Library/Tcg2PpVendorLib.h>\r
 #include <Library/MmServicesTableLib.h>\r
 \r
-#define     PP_INF_VERSION_1_2    "1.2"\r
+#define     PP_INF_VERSION_1_2  "1.2"\r
 \r
 EFI_SMM_VARIABLE_PROTOCOL  *mTcg2PpSmmVariable;\r
 BOOLEAN                    mIsTcg2PPVerLowerThan_1_3 = FALSE;\r
@@ -47,13 +47,13 @@ UINT32                     mTcg2PhysicalPresenceFlags;
 UINT32\r
 EFIAPI\r
 Tcg2PhysicalPresenceLibReturnOperationResponseToOsFunction (\r
-  OUT UINT32                *MostRecentRequest,\r
-  OUT UINT32                *Response\r
+  OUT UINT32  *MostRecentRequest,\r
+  OUT UINT32  *Response\r
   )\r
 {\r
-  EFI_STATUS                        Status;\r
-  UINTN                             DataSize;\r
-  EFI_TCG2_PHYSICAL_PRESENCE        PpData;\r
+  EFI_STATUS                  Status;\r
+  UINTN                       DataSize;\r
+  EFI_TCG2_PHYSICAL_PRESENCE  PpData;\r
 \r
   DEBUG ((DEBUG_INFO, "[TPM2] ReturnOperationResponseToOsFunction\n"));\r
 \r
@@ -61,13 +61,13 @@ Tcg2PhysicalPresenceLibReturnOperationResponseToOsFunction (
   // Get the Physical Presence variable\r
   //\r
   DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
-  Status = mTcg2PpSmmVariable->SmmGetVariable (\r
-                                 TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
-                                 &gEfiTcg2PhysicalPresenceGuid,\r
-                                 NULL,\r
-                                 &DataSize,\r
-                                 &PpData\r
-                                 );\r
+  Status   = mTcg2PpSmmVariable->SmmGetVariable (\r
+                                   TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
+                                   &gEfiTcg2PhysicalPresenceGuid,\r
+                                   NULL,\r
+                                   &DataSize,\r
+                                   &PpData\r
+                                   );\r
   if (EFI_ERROR (Status)) {\r
     *MostRecentRequest = 0;\r
     *Response          = 0;\r
@@ -98,8 +98,8 @@ Tcg2PhysicalPresenceLibReturnOperationResponseToOsFunction (
   **/\r
 UINT32\r
 Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunctionEx (\r
-  IN OUT UINT32               *OperationRequest,\r
-  IN OUT UINT32               *RequestParameter\r
+  IN OUT UINT32  *OperationRequest,\r
+  IN OUT UINT32  *RequestParameter\r
   )\r
 {\r
   EFI_STATUS                        Status;\r
@@ -115,13 +115,13 @@ Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunctionEx (
   // Get the Physical Presence variable\r
   //\r
   DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
-  Status = mTcg2PpSmmVariable->SmmGetVariable (\r
-                                 TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
-                                 &gEfiTcg2PhysicalPresenceGuid,\r
-                                 NULL,\r
-                                 &DataSize,\r
-                                 &PpData\r
-                                 );\r
+  Status   = mTcg2PpSmmVariable->SmmGetVariable (\r
+                                   TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
+                                   &gEfiTcg2PhysicalPresenceGuid,\r
+                                   NULL,\r
+                                   &DataSize,\r
+                                   &PpData\r
+                                   );\r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((DEBUG_ERROR, "[TPM2] Get PP variable failure! Status = %r\n", Status));\r
     ReturnCode = TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;\r
@@ -129,23 +129,25 @@ Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunctionEx (
   }\r
 \r
   if ((*OperationRequest > TCG2_PHYSICAL_PRESENCE_NO_ACTION_MAX) &&\r
-      (*OperationRequest < TCG2_PHYSICAL_PRESENCE_STORAGE_MANAGEMENT_BEGIN) ) {\r
+      (*OperationRequest < TCG2_PHYSICAL_PRESENCE_STORAGE_MANAGEMENT_BEGIN))\r
+  {\r
     ReturnCode = TCG_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED;\r
     goto EXIT;\r
   }\r
 \r
   if ((PpData.PPRequest != *OperationRequest) ||\r
-      (PpData.PPRequestParameter != *RequestParameter)) {\r
-    PpData.PPRequest = (UINT8)*OperationRequest;\r
+      (PpData.PPRequestParameter != *RequestParameter))\r
+  {\r
+    PpData.PPRequest          = (UINT8)*OperationRequest;\r
     PpData.PPRequestParameter = *RequestParameter;\r
-    DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
-    Status = mTcg2PpSmmVariable->SmmSetVariable (\r
-                                   TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
-                                   &gEfiTcg2PhysicalPresenceGuid,\r
-                                   EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-                                   DataSize,\r
-                                   &PpData\r
-                                   );\r
+    DataSize                  = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
+    Status                    = mTcg2PpSmmVariable->SmmSetVariable (\r
+                                                      TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
+                                                      &gEfiTcg2PhysicalPresenceGuid,\r
+                                                      EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+                                                      DataSize,\r
+                                                      &PpData\r
+                                                      );\r
     if (EFI_ERROR (Status)) {\r
       DEBUG ((DEBUG_ERROR, "[TPM2] Set PP variable failure! Status = %r\n", Status));\r
       ReturnCode = TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;\r
@@ -155,16 +157,17 @@ Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunctionEx (
 \r
   if (*OperationRequest >= TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {\r
     DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE_FLAGS);\r
-    Status = mTcg2PpSmmVariable->SmmGetVariable (\r
-                                   TCG2_PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
-                                   &gEfiTcg2PhysicalPresenceGuid,\r
-                                   NULL,\r
-                                   &DataSize,\r
-                                   &Flags\r
-                                   );\r
+    Status   = mTcg2PpSmmVariable->SmmGetVariable (\r
+                                     TCG2_PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
+                                     &gEfiTcg2PhysicalPresenceGuid,\r
+                                     NULL,\r
+                                     &DataSize,\r
+                                     &Flags\r
+                                     );\r
     if (EFI_ERROR (Status)) {\r
       Flags.PPFlags = mTcg2PhysicalPresenceFlags;\r
     }\r
+\r
     ReturnCode = Tcg2PpVendorLibSubmitRequestToPreOSFunction (*OperationRequest, Flags.PPFlags, *RequestParameter);\r
   }\r
 \r
@@ -175,7 +178,7 @@ EXIT:
   if (ReturnCode != TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS) {\r
     DEBUG ((DEBUG_ERROR, "[TPM2] Submit PP Request failure! Sync PPRQ/PPRM with PP variable.\n", Status));\r
     DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
-    ZeroMem(&PpData, DataSize);\r
+    ZeroMem (&PpData, DataSize);\r
     Status = mTcg2PpSmmVariable->SmmGetVariable (\r
                                    TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
                                    &gEfiTcg2PhysicalPresenceGuid,\r
@@ -208,17 +211,17 @@ EXIT:
 UINT32\r
 EFIAPI\r
 Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction (\r
-  IN UINT32                 OperationRequest,\r
-  IN UINT32                 RequestParameter\r
+  IN UINT32  OperationRequest,\r
+  IN UINT32  RequestParameter\r
   )\r
 {\r
-  UINT32                 TempOperationRequest;\r
-  UINT32                 TempRequestParameter;\r
+  UINT32  TempOperationRequest;\r
+  UINT32  TempRequestParameter;\r
 \r
   TempOperationRequest = OperationRequest;\r
   TempRequestParameter = RequestParameter;\r
 \r
-  return Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunctionEx(&TempOperationRequest, &TempRequestParameter);\r
+  return Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunctionEx (&TempOperationRequest, &TempRequestParameter);\r
 }\r
 \r
 /**\r
@@ -236,7 +239,7 @@ Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction (
 UINT32\r
 EFIAPI\r
 Tcg2PhysicalPresenceLibGetUserConfirmationStatusFunction (\r
-  IN UINT32                 OperationRequest\r
+  IN UINT32  OperationRequest\r
   )\r
 {\r
   EFI_STATUS                        Status;\r
@@ -251,28 +254,29 @@ Tcg2PhysicalPresenceLibGetUserConfirmationStatusFunction (
   // Get the Physical Presence variable\r
   //\r
   DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
-  Status = mTcg2PpSmmVariable->SmmGetVariable (\r
-                                 TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
-                                 &gEfiTcg2PhysicalPresenceGuid,\r
-                                 NULL,\r
-                                 &DataSize,\r
-                                 &PpData\r
-                                 );\r
+  Status   = mTcg2PpSmmVariable->SmmGetVariable (\r
+                                   TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
+                                   &gEfiTcg2PhysicalPresenceGuid,\r
+                                   NULL,\r
+                                   &DataSize,\r
+                                   &PpData\r
+                                   );\r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((DEBUG_ERROR, "[TPM2] Get PP variable failure! Status = %r\n", Status));\r
     return TCG_PP_GET_USER_CONFIRMATION_BLOCKED_BY_BIOS_CONFIGURATION;\r
   }\r
+\r
   //\r
   // Get the Physical Presence flags\r
   //\r
   DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE_FLAGS);\r
-  Status = mTcg2PpSmmVariable->SmmGetVariable (\r
-                                 TCG2_PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
-                                 &gEfiTcg2PhysicalPresenceGuid,\r
-                                 NULL,\r
-                                 &DataSize,\r
-                                 &Flags\r
-                                 );\r
+  Status   = mTcg2PpSmmVariable->SmmGetVariable (\r
+                                   TCG2_PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
+                                   &gEfiTcg2PhysicalPresenceGuid,\r
+                                   NULL,\r
+                                   &DataSize,\r
+                                   &Flags\r
+                                   );\r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((DEBUG_ERROR, "[TPM2] Get PP flags failure! Status = %r\n", Status));\r
     return TCG_PP_GET_USER_CONFIRMATION_BLOCKED_BY_BIOS_CONFIGURATION;\r
@@ -288,6 +292,7 @@ Tcg2PhysicalPresenceLibGetUserConfirmationStatusFunction (
       if ((Flags.PPFlags & TCG2_BIOS_TPM_MANAGEMENT_FLAG_PP_REQUIRED_FOR_CLEAR) == 0) {\r
         RequestConfirmed = TRUE;\r
       }\r
+\r
       break;\r
 \r
     case TCG2_PHYSICAL_PRESENCE_NO_ACTION:\r
@@ -302,12 +307,14 @@ Tcg2PhysicalPresenceLibGetUserConfirmationStatusFunction (
       if ((Flags.PPFlags & TCG2_BIOS_TPM_MANAGEMENT_FLAG_PP_REQUIRED_FOR_CHANGE_PCRS) == 0) {\r
         RequestConfirmed = TRUE;\r
       }\r
+\r
       break;\r
 \r
     case TCG2_PHYSICAL_PRESENCE_CHANGE_EPS:\r
       if ((Flags.PPFlags & TCG2_BIOS_TPM_MANAGEMENT_FLAG_PP_REQUIRED_FOR_CHANGE_EPS) == 0) {\r
         RequestConfirmed = TRUE;\r
       }\r
+\r
       break;\r
 \r
     case TCG2_PHYSICAL_PRESENCE_LOG_ALL_DIGESTS:\r
@@ -318,12 +325,14 @@ Tcg2PhysicalPresenceLibGetUserConfirmationStatusFunction (
       if ((Flags.PPFlags & TCG2_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_ENABLE_BLOCK_SID) == 0) {\r
         RequestConfirmed = TRUE;\r
       }\r
+\r
       break;\r
 \r
     case TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID:\r
       if ((Flags.PPFlags & TCG2_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_DISABLE_BLOCK_SID) == 0) {\r
         RequestConfirmed = TRUE;\r
       }\r
+\r
       break;\r
 \r
     case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_ENABLE_BLOCK_SID_FUNC_TRUE:\r
@@ -344,15 +353,16 @@ Tcg2PhysicalPresenceLibGetUserConfirmationStatusFunction (
           return TCG_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED;\r
         }\r
       } else {\r
-       //\r
-       // TCG PP lower than 1.3. (1.0, 1.1, 1.2)\r
-       //\r
-       if (OperationRequest <= TCG2_PHYSICAL_PRESENCE_NO_ACTION_MAX) {\r
-         RequestConfirmed = TRUE;\r
-       } else if (OperationRequest < TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {\r
-         return TCG_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED;\r
-       }\r
+        //\r
+        // TCG PP lower than 1.3. (1.0, 1.1, 1.2)\r
+        //\r
+        if (OperationRequest <= TCG2_PHYSICAL_PRESENCE_NO_ACTION_MAX) {\r
+          RequestConfirmed = TRUE;\r
+        } else if (OperationRequest < TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {\r
+          return TCG_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED;\r
+        }\r
       }\r
+\r
       break;\r
   }\r
 \r
@@ -382,17 +392,17 @@ Tcg2PhysicalPresenceLibCommonConstructor (
 {\r
   EFI_STATUS  Status;\r
 \r
-  if (AsciiStrnCmp(PP_INF_VERSION_1_2, (CHAR8 *)PcdGetPtr(PcdTcgPhysicalPresenceInterfaceVer), sizeof(PP_INF_VERSION_1_2) - 1) >= 0) {\r
+  if (AsciiStrnCmp (PP_INF_VERSION_1_2, (CHAR8 *)PcdGetPtr (PcdTcgPhysicalPresenceInterfaceVer), sizeof (PP_INF_VERSION_1_2) - 1) >= 0) {\r
     mIsTcg2PPVerLowerThan_1_3 = TRUE;\r
   }\r
 \r
   //\r
   // Locate SmmVariableProtocol.\r
   //\r
-  Status = gMmst->MmLocateProtocol (&gEfiSmmVariableProtocolGuid, NULL, (VOID**)&mTcg2PpSmmVariable);\r
+  Status = gMmst->MmLocateProtocol (&gEfiSmmVariableProtocolGuid, NULL, (VOID **)&mTcg2PpSmmVariable);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  mTcg2PhysicalPresenceFlags = PcdGet32(PcdTcg2PhysicalPresenceFlags);\r
+  mTcg2PhysicalPresenceFlags = PcdGet32 (PcdTcg2PhysicalPresenceFlags);\r
 \r
   return EFI_SUCCESS;\r
 }\r