#include <PiPei.h>\r
\r
#include <Guid/TpmInstance.h>\r
-#include <Library/BaseLib.h>\r
#include <Library/DebugLib.h>\r
#include <Library/PeiServicesLib.h>\r
#include <Library/Tpm2DeviceLib.h>\r
-#include <Library/Tpm12DeviceLib.h>\r
#include <Ppi/TpmInitialized.h>\r
\r
+#include "Tpm12Support.h"\r
+\r
STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpmSelectedPpi = {\r
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
&gEfiTpmDeviceSelectedGuid,\r
NULL\r
};\r
\r
-#pragma pack (1)\r
-\r
-typedef struct {\r
- TPM_RSP_COMMAND_HDR Hdr;\r
- TPM_CURRENT_TICKS CurrentTicks;\r
-} TPM_RSP_GET_TICKS;\r
-\r
-#pragma pack ()\r
-\r
-/**\r
- Probe for the TPM for 1.2 version, by sending TPM1.2 GetTicks\r
-\r
- Sending a TPM1.2 command to a TPM2 should return a TPM1.2\r
- header (tag = 0xc4) and error code (TPM_BADTAG = 0x1e)\r
-**/\r
-static\r
-EFI_STATUS\r
-TestTpm12 (\r
- )\r
-{\r
- EFI_STATUS Status;\r
- TPM_RQU_COMMAND_HDR Command;\r
- TPM_RSP_GET_TICKS Response;\r
- UINT32 Length;\r
-\r
- Command.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);\r
- Command.paramSize = SwapBytes32 (sizeof (Command));\r
- Command.ordinal = SwapBytes32 (TPM_ORD_GetTicks);\r
-\r
- Length = sizeof (Response);\r
- Status = Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command, &Length, (UINT8 *)&Response);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
/**\r
The entry point for Tcg2 configuration driver.\r
\r
\r
DEBUG ((DEBUG_INFO, "%a\n", __FUNCTION__));\r
\r
- Status = Tpm12RequestUseTpm ();\r
- if (!EFI_ERROR (Status) && !EFI_ERROR (TestTpm12 ())) {\r
+ Status = InternalTpm12Detect ();\r
+ if (!EFI_ERROR (Status)) {\r
DEBUG ((DEBUG_INFO, "%a: TPM1.2 detected\n", __FUNCTION__));\r
Size = sizeof (gEfiTpmDeviceInstanceTpm12Guid);\r
Status = PcdSetPtrS (\r