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