]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c
SecurityPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / SecurityPkg / Library / Tpm12CommandLib / Tpm12SelfTest.c
1 /** @file
2 Implement TPM1.2 NV Self Test related commands.
3
4 Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved. <BR>
5 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #include <PiPei.h>
11 #include <Library/Tpm12CommandLib.h>
12 #include <Library/BaseLib.h>
13 #include <Library/DebugLib.h>
14 #include <Library/Tpm12DeviceLib.h>
15
16 /**
17 Send TPM_ContinueSelfTest command to TPM.
18
19 @retval EFI_SUCCESS Operation completed successfully.
20 @retval EFI_TIMEOUT The register can't run into the expected status in time.
21 @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
22 @retval EFI_DEVICE_ERROR Unexpected device behavior.
23
24 **/
25 EFI_STATUS
26 EFIAPI
27 Tpm12ContinueSelfTest (
28 VOID
29 )
30 {
31 EFI_STATUS Status;
32 TPM_RQU_COMMAND_HDR Command;
33 TPM_RSP_COMMAND_HDR Response;
34 UINT32 Length;
35
36 //
37 // send Tpm command TPM_ORD_ContinueSelfTest
38 //
39 Command.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);
40 Command.paramSize = SwapBytes32 (sizeof (Command));
41 Command.ordinal = SwapBytes32 (TPM_ORD_ContinueSelfTest);
42 Length = sizeof (Response);
43 Status = Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command, &Length, (UINT8 *)&Response);
44 if (EFI_ERROR (Status)) {
45 return Status;
46 }
47
48 if (SwapBytes32 (Response.returnCode) != TPM_SUCCESS) {
49 DEBUG ((DEBUG_ERROR, "Tpm12ContinueSelfTest: Response Code error! 0x%08x\r\n", SwapBytes32 (Response.returnCode)));
50 return EFI_DEVICE_ERROR;
51 }
52
53 return Status;
54 }