]>
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 | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include <IndustryStandard/UefiTcgPlatform.h>\r | |
16 | #include <Library/Tpm2CommandLib.h>\r | |
17 | #include <Library/Tpm2DeviceLib.h>\r | |
18 | #include <Library/BaseMemoryLib.h>\r | |
19 | #include <Library/BaseLib.h>\r | |
20 | #include <Library/DebugLib.h>\r | |
21 | \r | |
22 | #pragma pack(1)\r | |
23 | \r | |
24 | typedef struct {\r | |
25 | TPM2_COMMAND_HEADER Header;\r | |
26 | TPMI_YES_NO FullTest;\r | |
27 | } TPM2_SELF_TEST_COMMAND;\r | |
28 | \r | |
29 | typedef struct {\r | |
30 | TPM2_RESPONSE_HEADER Header;\r | |
31 | } TPM2_SELF_TEST_RESPONSE;\r | |
32 | \r | |
33 | #pragma pack()\r | |
34 | \r | |
35 | /**\r | |
36 | This command causes the TPM to perform a test of its capabilities.\r | |
37 | If the fullTest is YES, the TPM will test all functions.\r | |
38 | If fullTest = NO, the TPM will only test those functions that have not previously been tested.\r | |
39 | \r | |
40 | @param[in] FullTest YES if full test to be performed\r | |
41 | NO if only test of untested functions required\r | |
42 | \r | |
43 | @retval EFI_SUCCESS Operation completed successfully.\r | |
44 | @retval EFI_DEVICE_ERROR Unexpected device behavior.\r | |
45 | **/\r | |
46 | EFI_STATUS\r | |
47 | EFIAPI\r | |
48 | Tpm2SelfTest (\r | |
49 | IN TPMI_YES_NO FullTest\r | |
50 | )\r | |
51 | {\r | |
52 | EFI_STATUS Status;\r | |
53 | TPM2_SELF_TEST_COMMAND Cmd;\r | |
54 | TPM2_SELF_TEST_RESPONSE Res;\r | |
55 | UINT32 ResultBufSize;\r | |
56 | \r | |
57 | Cmd.Header.tag = SwapBytes16(TPM_ST_NO_SESSIONS);\r | |
58 | Cmd.Header.paramSize = SwapBytes32(sizeof(Cmd));\r | |
59 | Cmd.Header.commandCode = SwapBytes32(TPM_CC_SelfTest);\r | |
60 | Cmd.FullTest = FullTest;\r | |
61 | \r | |
62 | ResultBufSize = sizeof(Res);\r | |
63 | Status = Tpm2SubmitCommand (sizeof(Cmd), (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);\r | |
64 | \r | |
65 | return Status;\r | |
66 | }\r |