]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.c
OvmfPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / Library / Tcg2PhysicalPresenceLibQemu / DxeTcg2PhysicalPresenceLib.c
index 80aad5a3735a998d0ea2aff57132f87cfcaa7b97..403802025156f5d0f6a815f1aa353fb9166f1d82 100644 (file)
@@ -36,14 +36,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 \r
 #include <Library/Tcg2PhysicalPresenceLib.h>\r
 \r
-#define CONFIRM_BUFFER_SIZE         4096\r
+#define CONFIRM_BUFFER_SIZE  4096\r
 \r
-EFI_HII_HANDLE mTcg2PpStringPackHandle;\r
+EFI_HII_HANDLE  mTcg2PpStringPackHandle;\r
 \r
-#define TPM_PPI_FLAGS (QEMU_TPM_PPI_FUNC_ALLOWED_USR_REQ)\r
-\r
-STATIC volatile QEMU_TPM_PPI *mPpi;\r
+#define TPM_PPI_FLAGS  (QEMU_TPM_PPI_FUNC_ALLOWED_USR_REQ)\r
 \r
+STATIC volatile QEMU_TPM_PPI  *mPpi;\r
 \r
 /**\r
   Reads QEMU PPI config from fw_cfg.\r
@@ -56,12 +55,12 @@ STATIC volatile QEMU_TPM_PPI *mPpi;
 STATIC\r
 EFI_STATUS\r
 QemuTpmReadConfig (\r
-  OUT QEMU_FWCFG_TPM_CONFIG *Config\r
+  OUT QEMU_FWCFG_TPM_CONFIG  *Config\r
   )\r
 {\r
-  EFI_STATUS           Status;\r
-  FIRMWARE_CONFIG_ITEM FwCfgItem;\r
-  UINTN                FwCfgSize;\r
+  EFI_STATUS            Status;\r
+  FIRMWARE_CONFIG_ITEM  FwCfgItem;\r
+  UINTN                 FwCfgSize;\r
 \r
   Status = QemuFwCfgFindFile ("etc/tpm/config", &FwCfgItem, &FwCfgSize);\r
   if (EFI_ERROR (Status)) {\r
@@ -77,7 +76,6 @@ QemuTpmReadConfig (
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
 /**\r
   Initializes QEMU PPI memory region.\r
 \r
@@ -90,11 +88,11 @@ QemuTpmInitPPI (
   VOID\r
   )\r
 {\r
-  EFI_STATUS                      Status;\r
-  QEMU_FWCFG_TPM_CONFIG           Config;\r
-  EFI_PHYSICAL_ADDRESS            PpiAddress64;\r
-  EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;\r
-  UINTN                           Idx;\r
+  EFI_STATUS                       Status;\r
+  QEMU_FWCFG_TPM_CONFIG            Config;\r
+  EFI_PHYSICAL_ADDRESS             PpiAddress64;\r
+  EFI_GCD_MEMORY_SPACE_DESCRIPTOR  Descriptor;\r
+  UINTN                            Idx;\r
 \r
   if (mPpi != NULL) {\r
     return EFI_SUCCESS;\r
@@ -114,19 +112,22 @@ QemuTpmInitPPI (
 \r
   PpiAddress64 = (UINTN)mPpi;\r
   if ((PpiAddress64 & ~(UINT64)EFI_PAGE_MASK) !=\r
-      ((PpiAddress64 + sizeof *mPpi - 1) & ~(UINT64)EFI_PAGE_MASK)) {\r
+      ((PpiAddress64 + sizeof *mPpi - 1) & ~(UINT64)EFI_PAGE_MASK))\r
+  {\r
     DEBUG ((DEBUG_ERROR, "[TPM2PP] mPpi crosses a page boundary\n"));\r
     goto InvalidPpiAddress;\r
   }\r
 \r
   Status = gDS->GetMemorySpaceDescriptor (PpiAddress64, &Descriptor);\r
-  if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) {\r
+  if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {\r
     ASSERT_EFI_ERROR (Status);\r
     goto InvalidPpiAddress;\r
   }\r
+\r
   if (!EFI_ERROR (Status) &&\r
-      (Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo &&\r
-       Descriptor.GcdMemoryType != EfiGcdMemoryTypeNonExistent)) {\r
+      ((Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo) &&\r
+       (Descriptor.GcdMemoryType != EfiGcdMemoryTypeNonExistent)))\r
+  {\r
     DEBUG ((DEBUG_ERROR, "[TPM2PP] mPpi has an invalid memory type\n"));\r
     goto InvalidPpiAddress;\r
   }\r
@@ -134,24 +135,25 @@ QemuTpmInitPPI (
   for (Idx = 0; Idx < ARRAY_SIZE (mPpi->Func); Idx++) {\r
     mPpi->Func[Idx] = 0;\r
   }\r
+\r
   if (Config.TpmVersion == QEMU_TPM_VERSION_2) {\r
-    mPpi->Func[TCG2_PHYSICAL_PRESENCE_NO_ACTION] = TPM_PPI_FLAGS;\r
-    mPpi->Func[TCG2_PHYSICAL_PRESENCE_CLEAR] = TPM_PPI_FLAGS;\r
-    mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR] = TPM_PPI_FLAGS;\r
-    mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_2] = TPM_PPI_FLAGS;\r
-    mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_3] = TPM_PPI_FLAGS;\r
-    mPpi->Func[TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS] = TPM_PPI_FLAGS;\r
-    mPpi->Func[TCG2_PHYSICAL_PRESENCE_CHANGE_EPS] = TPM_PPI_FLAGS;\r
-    mPpi->Func[TCG2_PHYSICAL_PRESENCE_LOG_ALL_DIGESTS] = TPM_PPI_FLAGS;\r
-    mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID] = TPM_PPI_FLAGS;\r
+    mPpi->Func[TCG2_PHYSICAL_PRESENCE_NO_ACTION]         = TPM_PPI_FLAGS;\r
+    mPpi->Func[TCG2_PHYSICAL_PRESENCE_CLEAR]             = TPM_PPI_FLAGS;\r
+    mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR]      = TPM_PPI_FLAGS;\r
+    mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_2]    = TPM_PPI_FLAGS;\r
+    mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_3]    = TPM_PPI_FLAGS;\r
+    mPpi->Func[TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS]     = TPM_PPI_FLAGS;\r
+    mPpi->Func[TCG2_PHYSICAL_PRESENCE_CHANGE_EPS]        = TPM_PPI_FLAGS;\r
+    mPpi->Func[TCG2_PHYSICAL_PRESENCE_LOG_ALL_DIGESTS]   = TPM_PPI_FLAGS;\r
+    mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID]  = TPM_PPI_FLAGS;\r
     mPpi->Func[TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID] = TPM_PPI_FLAGS;\r
   }\r
 \r
   if (mPpi->In == 0) {\r
-    mPpi->In = 1;\r
-    mPpi->Request = TCG2_PHYSICAL_PRESENCE_NO_ACTION;\r
+    mPpi->In          = 1;\r
+    mPpi->Request     = TCG2_PHYSICAL_PRESENCE_NO_ACTION;\r
     mPpi->LastRequest = TCG2_PHYSICAL_PRESENCE_NO_ACTION;\r
-    mPpi->NextStep = TCG2_PHYSICAL_PRESENCE_NO_ACTION;\r
+    mPpi->NextStep    = TCG2_PHYSICAL_PRESENCE_NO_ACTION;\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -161,7 +163,6 @@ InvalidPpiAddress:
   return EFI_PROTOCOL_ERROR;\r
 }\r
 \r
-\r
 /**\r
   Get string by string id from HII Interface.\r
 \r
@@ -174,13 +175,12 @@ InvalidPpiAddress:
 STATIC\r
 CHAR16 *\r
 Tcg2PhysicalPresenceGetStringById (\r
-  IN  EFI_STRING_ID   Id\r
+  IN  EFI_STRING_ID  Id\r
   )\r
 {\r
   return HiiGetString (mTcg2PpStringPackHandle, Id, NULL);\r
 }\r
 \r
-\r
 /**\r
   Send ClearControl and Clear command to TPM.\r
 \r
@@ -195,12 +195,12 @@ Tcg2PhysicalPresenceGetStringById (
 EFI_STATUS\r
 EFIAPI\r
 Tpm2CommandClear (\r
-  IN TPM2B_AUTH                *PlatformAuth  OPTIONAL\r
+  IN TPM2B_AUTH  *PlatformAuth  OPTIONAL\r
   )\r
 {\r
-  EFI_STATUS                Status;\r
-  TPMS_AUTH_COMMAND         *AuthSession;\r
-  TPMS_AUTH_COMMAND         LocalAuthSession;\r
+  EFI_STATUS         Status;\r
+  TPMS_AUTH_COMMAND  *AuthSession;\r
+  TPMS_AUTH_COMMAND  LocalAuthSession;\r
 \r
   if (PlatformAuth == NULL) {\r
     AuthSession = NULL;\r
@@ -208,7 +208,7 @@ Tpm2CommandClear (
     AuthSession = &LocalAuthSession;\r
     ZeroMem (&LocalAuthSession, sizeof (LocalAuthSession));\r
     LocalAuthSession.sessionHandle = TPM_RS_PW;\r
-    LocalAuthSession.hmac.size = PlatformAuth->size;\r
+    LocalAuthSession.hmac.size     = PlatformAuth->size;\r
     CopyMem (LocalAuthSession.hmac.buffer, PlatformAuth->buffer, PlatformAuth->size);\r
   }\r
 \r
@@ -218,6 +218,7 @@ Tpm2CommandClear (
   if (EFI_ERROR (Status)) {\r
     goto Done;\r
   }\r
+\r
   DEBUG ((DEBUG_INFO, "Tpm2Clear ... \n"));\r
   Status = Tpm2Clear (TPM_RH_PLATFORM, AuthSession);\r
   DEBUG ((DEBUG_INFO, "Tpm2Clear - %r\n", Status));\r
@@ -227,7 +228,6 @@ Done:
   return Status;\r
 }\r
 \r
-\r
 /**\r
   Change EPS.\r
 \r
@@ -238,12 +238,12 @@ Done:
 STATIC\r
 EFI_STATUS\r
 Tpm2CommandChangeEps (\r
-  IN TPM2B_AUTH                *PlatformAuth  OPTIONAL\r
+  IN TPM2B_AUTH  *PlatformAuth  OPTIONAL\r
   )\r
 {\r
-  EFI_STATUS                Status;\r
-  TPMS_AUTH_COMMAND         *AuthSession;\r
-  TPMS_AUTH_COMMAND         LocalAuthSession;\r
+  EFI_STATUS         Status;\r
+  TPMS_AUTH_COMMAND  *AuthSession;\r
+  TPMS_AUTH_COMMAND  LocalAuthSession;\r
 \r
   if (PlatformAuth == NULL) {\r
     AuthSession = NULL;\r
@@ -251,18 +251,17 @@ Tpm2CommandChangeEps (
     AuthSession = &LocalAuthSession;\r
     ZeroMem (&LocalAuthSession, sizeof (LocalAuthSession));\r
     LocalAuthSession.sessionHandle = TPM_RS_PW;\r
-    LocalAuthSession.hmac.size = PlatformAuth->size;\r
+    LocalAuthSession.hmac.size     = PlatformAuth->size;\r
     CopyMem (LocalAuthSession.hmac.buffer, PlatformAuth->buffer, PlatformAuth->size);\r
   }\r
 \r
   Status = Tpm2ChangeEPS (TPM_RH_PLATFORM, AuthSession);\r
   DEBUG ((DEBUG_INFO, "Tpm2ChangeEPS - %r\n", Status));\r
 \r
-  ZeroMem (&LocalAuthSession.hmac, sizeof(LocalAuthSession.hmac));\r
+  ZeroMem (&LocalAuthSession.hmac, sizeof (LocalAuthSession.hmac));\r
   return Status;\r
 }\r
 \r
-\r
 /**\r
   Execute physical presence operation requested by the OS.\r
 \r
@@ -278,14 +277,14 @@ Tpm2CommandChangeEps (
 STATIC\r
 UINT32\r
 Tcg2ExecutePhysicalPresence (\r
-  IN      TPM2B_AUTH                       *PlatformAuth   OPTIONAL,\r
-  IN      UINT32                           CommandCode,\r
-  IN      UINT32                           CommandParameter\r
+  IN      TPM2B_AUTH  *PlatformAuth   OPTIONAL,\r
+  IN      UINT32      CommandCode,\r
+  IN      UINT32      CommandParameter\r
   )\r
 {\r
-  EFI_STATUS                        Status;\r
-  EFI_TCG2_EVENT_ALGORITHM_BITMAP   TpmHashAlgorithmBitmap;\r
-  UINT32                            ActivePcrBanks;\r
+  EFI_STATUS                       Status;\r
+  EFI_TCG2_EVENT_ALGORITHM_BITMAP  TpmHashAlgorithmBitmap;\r
+  UINT32                           ActivePcrBanks;\r
 \r
   switch (CommandCode) {\r
     case TCG2_PHYSICAL_PRESENCE_CLEAR:\r
@@ -309,8 +308,8 @@ Tcg2ExecutePhysicalPresence (
       //    Firmware has to ensure that at least one PCR banks is active.\r
       // If not, an error is returned and no action is taken.\r
       //\r
-      if (CommandParameter == 0 || (CommandParameter & (~TpmHashAlgorithmBitmap)) != 0) {\r
-        DEBUG((DEBUG_ERROR, "PCR banks %x to allocate are not supported by TPM. Skip operation\n", CommandParameter));\r
+      if ((CommandParameter == 0) || ((CommandParameter & (~TpmHashAlgorithmBitmap)) != 0)) {\r
+        DEBUG ((DEBUG_ERROR, "PCR banks %x to allocate are not supported by TPM. Skip operation\n", CommandParameter));\r
         return TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;\r
       }\r
 \r
@@ -348,7 +347,6 @@ Tcg2ExecutePhysicalPresence (
   }\r
 }\r
 \r
-\r
 /**\r
   Read the specified key for user confirmation.\r
 \r
@@ -361,12 +359,12 @@ Tcg2ExecutePhysicalPresence (
 STATIC\r
 BOOLEAN\r
 Tcg2ReadUserKey (\r
-  IN     BOOLEAN                    CautionKey\r
+  IN     BOOLEAN  CautionKey\r
   )\r
 {\r
-  EFI_STATUS                        Status;\r
-  EFI_INPUT_KEY                     Key;\r
-  UINT16                            InputKey;\r
+  EFI_STATUS     Status;\r
+  EFI_INPUT_KEY  Key;\r
+  UINT16         InputKey;\r
 \r
   InputKey = 0;\r
   do {\r
@@ -376,9 +374,11 @@ Tcg2ReadUserKey (
       if (Key.ScanCode == SCAN_ESC) {\r
         InputKey = Key.ScanCode;\r
       }\r
+\r
       if ((Key.ScanCode == SCAN_F10) && !CautionKey) {\r
         InputKey = Key.ScanCode;\r
       }\r
+\r
       if ((Key.ScanCode == SCAN_F12) && CautionKey) {\r
         InputKey = Key.ScanCode;\r
       }\r
@@ -392,7 +392,6 @@ Tcg2ReadUserKey (
   return FALSE;\r
 }\r
 \r
-\r
 /**\r
   Fill Buffer With BootHashAlg.\r
 \r
@@ -414,35 +413,43 @@ Tcg2FillBufferWithBootHashAlg (
     if (Buffer[0] != 0) {\r
       StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
     }\r
+\r
     StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L"SHA1", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
   }\r
+\r
   if ((BootHashAlg & EFI_TCG2_BOOT_HASH_ALG_SHA256) != 0) {\r
     if (Buffer[0] != 0) {\r
       StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
     }\r
+\r
     StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L"SHA256", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
   }\r
+\r
   if ((BootHashAlg & EFI_TCG2_BOOT_HASH_ALG_SHA384) != 0) {\r
     if (Buffer[0] != 0) {\r
       StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
     }\r
+\r
     StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L"SHA384", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
   }\r
+\r
   if ((BootHashAlg & EFI_TCG2_BOOT_HASH_ALG_SHA512) != 0) {\r
     if (Buffer[0] != 0) {\r
       StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
     }\r
+\r
     StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L"SHA512", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
   }\r
+\r
   if ((BootHashAlg & EFI_TCG2_BOOT_HASH_ALG_SM3_256) != 0) {\r
     if (Buffer[0] != 0) {\r
       StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
     }\r
+\r
     StrnCatS (Buffer, BufferSize / sizeof (CHAR16), L"SM3_256", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
   }\r
 }\r
 \r
-\r
 /**\r
   Display the confirm text and get user confirmation.\r
 \r
@@ -455,8 +462,8 @@ Tcg2FillBufferWithBootHashAlg (
 STATIC\r
 BOOLEAN\r
 Tcg2UserConfirm (\r
-  IN      UINT32                    TpmPpCommand,\r
-  IN      UINT32                    TpmPpCommandParameter\r
+  IN      UINT32  TpmPpCommand,\r
+  IN      UINT32  TpmPpCommandParameter\r
   )\r
 {\r
   CHAR16                            *ConfirmText;\r
@@ -485,13 +492,12 @@ Tcg2UserConfirm (
   ASSERT (mTcg2PpStringPackHandle != NULL);\r
 \r
   switch (TpmPpCommand) {\r
-\r
     case TCG2_PHYSICAL_PRESENCE_CLEAR:\r
     case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR:\r
     case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_2:\r
     case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_3:\r
       CautionKey = TRUE;\r
-      TmpStr2 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CLEAR));\r
+      TmpStr2    = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CLEAR));\r
 \r
       TmpStr1 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_STR));\r
       UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);\r
@@ -505,14 +511,14 @@ Tcg2UserConfirm (
       break;\r
 \r
     case TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS:\r
-      Status = gBS->LocateProtocol (&gEfiTcg2ProtocolGuid, NULL, (VOID **) &Tcg2Protocol);\r
+      Status = gBS->LocateProtocol (&gEfiTcg2ProtocolGuid, NULL, (VOID **)&Tcg2Protocol);\r
       ASSERT_EFI_ERROR (Status);\r
 \r
-      ProtocolCapability.Size = sizeof(ProtocolCapability);\r
-      Status = Tcg2Protocol->GetCapability (\r
-                               Tcg2Protocol,\r
-                               &ProtocolCapability\r
-                               );\r
+      ProtocolCapability.Size = sizeof (ProtocolCapability);\r
+      Status                  = Tcg2Protocol->GetCapability (\r
+                                                Tcg2Protocol,\r
+                                                &ProtocolCapability\r
+                                                );\r
       ASSERT_EFI_ERROR (Status);\r
 \r
       Status = Tcg2Protocol->GetActivePcrBanks (\r
@@ -522,7 +528,7 @@ Tcg2UserConfirm (
       ASSERT_EFI_ERROR (Status);\r
 \r
       CautionKey = TRUE;\r
-      TmpStr2 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_SET_PCR_BANKS));\r
+      TmpStr2    = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_SET_PCR_BANKS));\r
 \r
       TmpStr1 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_STR));\r
       UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);\r
@@ -536,8 +542,8 @@ Tcg2UserConfirm (
       StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen (ConfirmText) - 1);\r
       FreePool (TmpStr1);\r
 \r
-      Tcg2FillBufferWithBootHashAlg (TempBuffer, sizeof(TempBuffer), TpmPpCommandParameter);\r
-      Tcg2FillBufferWithBootHashAlg (TempBuffer2, sizeof(TempBuffer2), CurrentPCRBanks);\r
+      Tcg2FillBufferWithBootHashAlg (TempBuffer, sizeof (TempBuffer), TpmPpCommandParameter);\r
+      Tcg2FillBufferWithBootHashAlg (TempBuffer2, sizeof (TempBuffer2), CurrentPCRBanks);\r
 \r
       TmpStr1 = AllocateZeroPool (BufSize);\r
       ASSERT (TmpStr1 != NULL);\r
@@ -551,7 +557,7 @@ Tcg2UserConfirm (
 \r
     case TCG2_PHYSICAL_PRESENCE_CHANGE_EPS:\r
       CautionKey = TRUE;\r
-      TmpStr2 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CHANGE_EPS));\r
+      TmpStr2    = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CHANGE_EPS));\r
 \r
       TmpStr1 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_STR));\r
       UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);\r
@@ -602,6 +608,7 @@ Tcg2UserConfirm (
     } else {\r
       TmpStr1 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_KEY));\r
     }\r
+\r
     StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen (ConfirmText) - 1);\r
     FreePool (TmpStr1);\r
 \r
@@ -618,6 +625,7 @@ Tcg2UserConfirm (
     } else {\r
       TmpStr1 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TCG_STORAGE_ACCEPT_KEY));\r
     }\r
+\r
     StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen (ConfirmText) - 1);\r
     FreePool (TmpStr1);\r
 \r
@@ -629,6 +637,7 @@ Tcg2UserConfirm (
 \r
     TmpStr1 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TCG_STORAGE_REJECT_KEY));\r
   }\r
+\r
   BufSize -= StrSize (ConfirmText);\r
   UnicodeSPrint (ConfirmText + StrLen (ConfirmText), BufSize, TmpStr1, TmpStr2);\r
 \r
@@ -650,7 +659,6 @@ Tcg2UserConfirm (
   return FALSE;\r
 }\r
 \r
-\r
 /**\r
   Check if there is a valid physical presence command request. Also updates parameter value\r
   to whether the requested physical presence command already confirmed by user\r
@@ -667,11 +675,11 @@ Tcg2UserConfirm (
 STATIC\r
 BOOLEAN\r
 Tcg2HaveValidTpmRequest  (\r
-  OUT     BOOLEAN                          *RequestConfirmed\r
+  OUT     BOOLEAN  *RequestConfirmed\r
   )\r
 {\r
-  EFI_TCG2_PROTOCOL                 *Tcg2Protocol;\r
-  EFI_STATUS                        Status;\r
+  EFI_TCG2_PROTOCOL  *Tcg2Protocol;\r
+  EFI_STATUS         Status;\r
 \r
   *RequestConfirmed = FALSE;\r
 \r
@@ -679,7 +687,7 @@ Tcg2HaveValidTpmRequest  (
     //\r
     // Need TCG2 protocol.\r
     //\r
-    Status = gBS->LocateProtocol (&gEfiTcg2ProtocolGuid, NULL, (VOID **) &Tcg2Protocol);\r
+    Status = gBS->LocateProtocol (&gEfiTcg2ProtocolGuid, NULL, (VOID **)&Tcg2Protocol);\r
     if (EFI_ERROR (Status)) {\r
       return FALSE;\r
     }\r
@@ -714,7 +722,6 @@ Tcg2HaveValidTpmRequest  (
   return TRUE;\r
 }\r
 \r
-\r
 /**\r
   Check and execute the requested physical presence command.\r
 \r
@@ -723,10 +730,10 @@ Tcg2HaveValidTpmRequest  (
 STATIC\r
 VOID\r
 Tcg2ExecutePendingTpmRequest (\r
-  IN      TPM2B_AUTH                       *PlatformAuth OPTIONAL\r
+  IN      TPM2B_AUTH  *PlatformAuth OPTIONAL\r
   )\r
 {\r
-  BOOLEAN                           RequestConfirmed;\r
+  BOOLEAN  RequestConfirmed;\r
 \r
   if (mPpi->Request == TCG2_PHYSICAL_PRESENCE_NO_ACTION) {\r
     //\r
@@ -744,8 +751,9 @@ Tcg2ExecutePendingTpmRequest (
     } else {\r
       mPpi->Response = TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;\r
     }\r
-    mPpi->LastRequest = mPpi->Request;\r
-    mPpi->Request = TCG2_PHYSICAL_PRESENCE_NO_ACTION;\r
+\r
+    mPpi->LastRequest      = mPpi->Request;\r
+    mPpi->Request          = TCG2_PHYSICAL_PRESENCE_NO_ACTION;\r
     mPpi->RequestParameter = 0;\r
     return;\r
   }\r
@@ -763,17 +771,17 @@ Tcg2ExecutePendingTpmRequest (
   mPpi->Response = TCG_PP_OPERATION_RESPONSE_USER_ABORT;\r
   if (RequestConfirmed) {\r
     mPpi->Response = Tcg2ExecutePhysicalPresence (\r
-                                                  PlatformAuth,\r
-                                                  mPpi->Request,\r
-                                                  mPpi->RequestParameter\r
-                                                  );\r
+                       PlatformAuth,\r
+                       mPpi->Request,\r
+                       mPpi->RequestParameter\r
+                       );\r
   }\r
 \r
   //\r
   // Clear request\r
   //\r
-  mPpi->LastRequest = mPpi->Request;\r
-  mPpi->Request = TCG2_PHYSICAL_PRESENCE_NO_ACTION;\r
+  mPpi->LastRequest      = mPpi->Request;\r
+  mPpi->Request          = TCG2_PHYSICAL_PRESENCE_NO_ACTION;\r
   mPpi->RequestParameter = 0;\r
 \r
   if (mPpi->Response == TCG_PP_OPERATION_RESPONSE_USER_ABORT) {\r
@@ -784,24 +792,25 @@ Tcg2ExecutePendingTpmRequest (
   // Reset system to make new TPM settings in effect\r
   //\r
   switch (mPpi->LastRequest) {\r
-  case TCG2_PHYSICAL_PRESENCE_CLEAR:\r
-  case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR:\r
-  case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_2:\r
-  case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_3:\r
-  case TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS:\r
-  case TCG2_PHYSICAL_PRESENCE_CHANGE_EPS:\r
-  case TCG2_PHYSICAL_PRESENCE_LOG_ALL_DIGESTS:\r
-    break;\r
-\r
-  case TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID:\r
-  case TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID:\r
-    break;\r
-\r
-  default:\r
-    if (mPpi->Request != TCG2_PHYSICAL_PRESENCE_NO_ACTION) {\r
+    case TCG2_PHYSICAL_PRESENCE_CLEAR:\r
+    case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR:\r
+    case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_2:\r
+    case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_3:\r
+    case TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS:\r
+    case TCG2_PHYSICAL_PRESENCE_CHANGE_EPS:\r
+    case TCG2_PHYSICAL_PRESENCE_LOG_ALL_DIGESTS:\r
       break;\r
-    }\r
-    return;\r
+\r
+    case TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID:\r
+    case TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID:\r
+      break;\r
+\r
+    default:\r
+      if (mPpi->Request != TCG2_PHYSICAL_PRESENCE_NO_ACTION) {\r
+        break;\r
+      }\r
+\r
+      return;\r
   }\r
 \r
   Print (L"Rebooting system to make TPM2 settings in effect\n");\r
@@ -809,7 +818,6 @@ Tcg2ExecutePendingTpmRequest (
   ASSERT (FALSE);\r
 }\r
 \r
-\r
 /**\r
    Check and execute the pending TPM request.\r
 \r
@@ -826,15 +834,15 @@ Tcg2ExecutePendingTpmRequest (
 VOID\r
 EFIAPI\r
 Tcg2PhysicalPresenceLibProcessRequest (\r
-  IN      TPM2B_AUTH                     *PlatformAuth  OPTIONAL\r
+  IN      TPM2B_AUTH  *PlatformAuth  OPTIONAL\r
   )\r
 {\r
-  EFI_STATUS Status;\r
+  EFI_STATUS  Status;\r
 \r
   Status = QemuTpmInitPPI ();\r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((DEBUG_INFO, "[TPM2PP] no PPI\n"));\r
-    return ;\r
+    return;\r
   }\r
 \r
   //\r
@@ -842,14 +850,13 @@ Tcg2PhysicalPresenceLibProcessRequest (
   //\r
   if (GetBootModeHob () == BOOT_ON_S4_RESUME) {\r
     DEBUG ((DEBUG_INFO, "S4 Resume, Skip TPM PP process!\n"));\r
-    return ;\r
+    return;\r
   }\r
 \r
   DEBUG ((DEBUG_INFO, "[TPM2PP] PPRequest=%x (PPRequestParameter=%x)\n", mPpi->Request, mPpi->RequestParameter));\r
   Tcg2ExecutePendingTpmRequest (PlatformAuth);\r
 }\r
 \r
-\r
 /**\r
   The handler for TPM physical presence function:\r
   Return TPM Operation Response to OS Environment.\r
@@ -862,11 +869,11 @@ Tcg2PhysicalPresenceLibProcessRequest (
 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
+  EFI_STATUS  Status;\r
 \r
   DEBUG ((DEBUG_INFO, "[TPM2PP] ReturnOperationResponseToOsFunction\n"));\r
 \r
@@ -884,7 +891,6 @@ Tcg2PhysicalPresenceLibReturnOperationResponseToOsFunction (
   return TCG_PP_RETURN_TPM_OPERATION_RESPONSE_SUCCESS;\r
 }\r
 \r
-\r
 /**\r
   The handler for TPM physical presence function:\r
   Submit TPM Operation Request to Pre-OS Environment and\r
@@ -901,11 +907,11 @@ Tcg2PhysicalPresenceLibReturnOperationResponseToOsFunction (
 UINT32\r
 EFIAPI\r
 Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction (\r
-  IN UINT32                 OperationRequest,\r
-  IN UINT32                 RequestParameter\r
+  IN UINT32  OperationRequest,\r
+  IN UINT32  RequestParameter\r
   )\r
 {\r
-  EFI_STATUS Status;\r
+  EFI_STATUS  Status;\r
 \r
   DEBUG ((DEBUG_INFO, "[TPM2PP] SubmitRequestToPreOSFunction, Request = %x, %x\n", OperationRequest, RequestParameter));\r
 \r
@@ -915,7 +921,7 @@ Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction (
     return TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;\r
   }\r
 \r
-  mPpi->Request = OperationRequest;\r
+  mPpi->Request          = OperationRequest;\r
   mPpi->RequestParameter = RequestParameter;\r
 \r
   return TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS;\r