]>
Commit | Line | Data |
---|---|---|
c1d93242 JY |
1 | /** @file\r |
2 | Implement TPM2 Test related command.\r | |
3 | \r | |
4 | Copyright (c) 2013, Intel Corporation. All rights reserved. <BR>\r | |
289b714b | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
c1d93242 JY |
6 | \r |
7 | **/\r | |
8 | \r | |
9 | #include <IndustryStandard/UefiTcgPlatform.h>\r | |
10 | #include <Library/Tpm2CommandLib.h>\r | |
11 | #include <Library/Tpm2DeviceLib.h>\r | |
12 | #include <Library/BaseMemoryLib.h>\r | |
13 | #include <Library/BaseLib.h>\r | |
14 | #include <Library/DebugLib.h>\r | |
15 | \r | |
16 | #pragma pack(1)\r | |
17 | \r | |
18 | typedef struct {\r | |
c411b485 MK |
19 | TPM2_COMMAND_HEADER Header;\r |
20 | TPMI_YES_NO FullTest;\r | |
c1d93242 JY |
21 | } TPM2_SELF_TEST_COMMAND;\r |
22 | \r | |
23 | typedef struct {\r | |
c411b485 | 24 | TPM2_RESPONSE_HEADER Header;\r |
c1d93242 JY |
25 | } TPM2_SELF_TEST_RESPONSE;\r |
26 | \r | |
27 | #pragma pack()\r | |
28 | \r | |
29 | /**\r | |
30 | This command causes the TPM to perform a test of its capabilities.\r | |
31 | If the fullTest is YES, the TPM will test all functions.\r | |
32 | If fullTest = NO, the TPM will only test those functions that have not previously been tested.\r | |
33 | \r | |
34 | @param[in] FullTest YES if full test to be performed\r | |
35 | NO if only test of untested functions required\r | |
36 | \r | |
37 | @retval EFI_SUCCESS Operation completed successfully.\r | |
38 | @retval EFI_DEVICE_ERROR Unexpected device behavior.\r | |
39 | **/\r | |
40 | EFI_STATUS\r | |
41 | EFIAPI\r | |
42 | Tpm2SelfTest (\r | |
c411b485 | 43 | IN TPMI_YES_NO FullTest\r |
c1d93242 JY |
44 | )\r |
45 | {\r | |
c411b485 MK |
46 | EFI_STATUS Status;\r |
47 | TPM2_SELF_TEST_COMMAND Cmd;\r | |
48 | TPM2_SELF_TEST_RESPONSE Res;\r | |
49 | UINT32 ResultBufSize;\r | |
50 | \r | |
51 | Cmd.Header.tag = SwapBytes16 (TPM_ST_NO_SESSIONS);\r | |
52 | Cmd.Header.paramSize = SwapBytes32 (sizeof (Cmd));\r | |
53 | Cmd.Header.commandCode = SwapBytes32 (TPM_CC_SelfTest);\r | |
c1d93242 JY |
54 | Cmd.FullTest = FullTest;\r |
55 | \r | |
c411b485 MK |
56 | ResultBufSize = sizeof (Res);\r |
57 | Status = Tpm2SubmitCommand (sizeof (Cmd), (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);\r | |
c1d93242 JY |
58 | \r |
59 | return Status;\r | |
60 | }\r |