File ovmf-SecurityPkg-Tpm2DeviceLibDTpm-Add-header-file-for-Tp.patch of Package ovmf-edk2-stable202502

From edf5e365c104fb86623b6359ac53d79777d521bf Mon Sep 17 00:00:00 2001
From: Oliver Steffen <osteffen@redhat.com>
Date: Mon, 16 Dec 2024 17:25:36 +0100
Subject: [PATCH] SecurityPkg/Tpm2DeviceLibDTpm: Add header file for Tpm2Ptp.c

A some of functions implemented in Tpm2Ptp.c are forward declared in a
couple of places. To clean this up, introduce a header that contains
these declarations in a central place and use it instead.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
---
 .../Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c     | 35 +-----------
 .../Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c   | 45 +---------------
 .../Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c       |  2 +
 .../Library/Tpm2DeviceLibDTpm/Tpm2Ptp.h       | 53 +++++++++++++++++++
 4 files changed, 57 insertions(+), 78 deletions(-)
 create mode 100644 SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.h

diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c
index e0897417ba..828fb856ad 100644
--- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c
+++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c
@@ -13,42 +13,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Library/Tpm2DeviceLib.h>
 #include <Library/PcdLib.h>
 
+#include "Tpm2Ptp.h"
 #include "Tpm2DeviceLibDTpm.h"
 
-/**
-  This service enables the sending of commands to the TPM2.
-
-  @param[in]      InputParameterBlockSize  Size of the TPM2 input parameter block.
-  @param[in]      InputParameterBlock      Pointer to the TPM2 input parameter block.
-  @param[in,out]  OutputParameterBlockSize Size of the TPM2 output parameter block.
-  @param[in]      OutputParameterBlock     Pointer to the TPM2 output parameter block.
-
-  @retval EFI_SUCCESS            The command byte stream was successfully sent to the device and a response was successfully received.
-  @retval EFI_DEVICE_ERROR       The command was not successfully sent to the device or a response was not successfully received from the device.
-  @retval EFI_BUFFER_TOO_SMALL   The output parameter block is too small.
-**/
-EFI_STATUS
-EFIAPI
-DTpm2SubmitCommand (
-  IN UINT32      InputParameterBlockSize,
-  IN UINT8       *InputParameterBlock,
-  IN OUT UINT32  *OutputParameterBlockSize,
-  IN UINT8       *OutputParameterBlock
-  );
-
-/**
-  This service requests use TPM2.
-
-  @retval EFI_SUCCESS      Get the control of TPM2 chip.
-  @retval EFI_NOT_FOUND    TPM2 not found.
-  @retval EFI_DEVICE_ERROR Unexpected device behavior.
-**/
-EFI_STATUS
-EFIAPI
-DTpm2RequestUseTpm (
-  VOID
-  );
-
 /**
   This service enables the sending of commands to the TPM2.
 
diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c
index 11796d5b97..2762626575 100644
--- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c
+++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c
@@ -16,52 +16,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 #include <Guid/TpmInstance.h>
 
+#include "Tpm2Ptp.h"
 #include "Tpm2DeviceLibDTpm.h"
 
-/**
-  Dump PTP register information.
-
-  @param[in] Register                Pointer to PTP register.
-**/
-VOID
-DumpPtpInfo (
-  IN VOID  *Register
-  );
-
-/**
-  This service enables the sending of commands to the TPM2.
-
-  @param[in]      InputParameterBlockSize  Size of the TPM2 input parameter block.
-  @param[in]      InputParameterBlock      Pointer to the TPM2 input parameter block.
-  @param[in,out]  OutputParameterBlockSize Size of the TPM2 output parameter block.
-  @param[in]      OutputParameterBlock     Pointer to the TPM2 output parameter block.
-
-  @retval EFI_SUCCESS            The command byte stream was successfully sent to the device and a response was successfully received.
-  @retval EFI_DEVICE_ERROR       The command was not successfully sent to the device or a response was not successfully received from the device.
-  @retval EFI_BUFFER_TOO_SMALL   The output parameter block is too small.
-**/
-EFI_STATUS
-EFIAPI
-DTpm2SubmitCommand (
-  IN UINT32      InputParameterBlockSize,
-  IN UINT8       *InputParameterBlock,
-  IN OUT UINT32  *OutputParameterBlockSize,
-  IN UINT8       *OutputParameterBlock
-  );
-
-/**
-  This service requests use TPM2.
-
-  @retval EFI_SUCCESS      Get the control of TPM2 chip.
-  @retval EFI_NOT_FOUND    TPM2 not found.
-  @retval EFI_DEVICE_ERROR Unexpected device behavior.
-**/
-EFI_STATUS
-EFIAPI
-DTpm2RequestUseTpm (
-  VOID
-  );
-
 TPM2_DEVICE_INTERFACE  mDTpm2InternalTpm2Device = {
   TPM_DEVICE_INTERFACE_TPM20_DTPM,
   DTpm2SubmitCommand,
diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
index dee01d9707..d1565c72d7 100644
--- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
+++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
@@ -22,6 +22,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 #include "Tpm2DeviceLibDTpm.h"
 
+#include "Tpm2Ptp.h"
+
 //
 // Execution of the command may take from several seconds to minutes for certain
 // commands, such as key generation.
diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.h b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.h
new file mode 100644
index 0000000000..238d6e8dba
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.h
@@ -0,0 +1,53 @@
+/** @file
+  PTP (Platform TPM Profile) CRB (Command Response Buffer) interface used by dTPM2.0 library.
+
+Copyright (c) 2024 Red Hat
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+
+/**
+  Dump PTP register information.
+
+  @param[in] Register                Pointer to PTP register.
+**/
+VOID
+DumpPtpInfo (
+  IN VOID  *Register
+  );
+
+/**
+  This service enables the sending of commands to the TPM2.
+
+  @param[in]      InputParameterBlockSize  Size of the TPM2 input parameter block.
+  @param[in]      InputParameterBlock      Pointer to the TPM2 input parameter block.
+  @param[in,out]  OutputParameterBlockSize Size of the TPM2 output parameter block.
+  @param[in]      OutputParameterBlock     Pointer to the TPM2 output parameter block.
+
+  @retval EFI_SUCCESS            The command byte stream was successfully sent to the device and a response was successfully received.
+  @retval EFI_DEVICE_ERROR       The command was not successfully sent to the device or a response was not successfully received from the device.
+  @retval EFI_BUFFER_TOO_SMALL   The output parameter block is too small.
+**/
+EFI_STATUS
+EFIAPI
+DTpm2SubmitCommand (
+  IN UINT32      InputParameterBlockSize,
+  IN UINT8       *InputParameterBlock,
+  IN OUT UINT32  *OutputParameterBlockSize,
+  IN UINT8       *OutputParameterBlock
+  );
+
+/**
+  This service requests use TPM2.
+
+  @retval EFI_SUCCESS      Get the control of TPM2 chip.
+  @retval EFI_NOT_FOUND    TPM2 not found.
+  @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+DTpm2RequestUseTpm (
+  VOID
+  );
-- 
2.43.0

openSUSE Build Service is sponsored by