]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c
579fed722bc54057348eec9509238d8e70ca5fd9
[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 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #include <PiPei.h>
17 #include <Library/Tpm12CommandLib.h>
18 #include <Library/BaseLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/Tpm12DeviceLib.h>
21
22 /**
23 Send TPM_ContinueSelfTest command to TPM.
24
25 @retval EFI_SUCCESS Operation completed successfully.
26 @retval EFI_TIMEOUT The register can't run into the expected status in time.
27 @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
28 @retval EFI_DEVICE_ERROR Unexpected device behavior.
29
30 **/
31 EFI_STATUS
32 EFIAPI
33 Tpm12ContinueSelfTest (
34 VOID
35 )
36 {
37 EFI_STATUS Status;
38 TPM_RQU_COMMAND_HDR Command;
39 TPM_RSP_COMMAND_HDR Response;
40 UINT32 Length;
41
42 //
43 // send Tpm command TPM_ORD_ContinueSelfTest
44 //
45 Command.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);
46 Command.paramSize = SwapBytes32 (sizeof (Command));
47 Command.ordinal = SwapBytes32 (TPM_ORD_ContinueSelfTest);
48 Length = sizeof (Response);
49 Status = Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command, &Length, (UINT8 *)&Response);
50 if (EFI_ERROR (Status)) {
51 return Status;
52 }
53
54 if (SwapBytes32 (Response.returnCode) != TPM_SUCCESS) {
55 DEBUG ((DEBUG_ERROR, "Tpm12ContinueSelfTest: Response Code error! 0x%08x\r\n", SwapBytes32 (Response.returnCode)));
56 return EFI_DEVICE_ERROR;
57 }
58
59 return Status;
60 }