]>
Commit | Line | Data |
---|---|---|
c1d93242 JY |
1 | /** @file\r |
2 | Ihis library is TPM2 DTPM instance.\r | |
3 | It can be registered to Tpm2 Device router, to be active TPM2 engine,\r | |
4 | based on platform setting.\r | |
5 | \r | |
6 | Copyright (c) 2013, Intel Corporation. All rights reserved. <BR>\r | |
7 | This program and the accompanying materials\r | |
8 | are licensed and made available under the terms and conditions of the BSD License\r | |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #include <Library/BaseLib.h>\r | |
18 | #include <Library/BaseMemoryLib.h>\r | |
19 | #include <Library/DebugLib.h>\r | |
20 | #include <Library/Tpm2DeviceLib.h>\r | |
21 | \r | |
22 | #include <Guid/TpmInstance.h>\r | |
23 | \r | |
24 | /**\r | |
25 | This service enables the sending of commands to the TPM2.\r | |
26 | \r | |
27 | @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.\r | |
28 | @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.\r | |
29 | @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.\r | |
30 | @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.\r | |
31 | \r | |
32 | @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.\r | |
33 | @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.\r | |
34 | @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small. \r | |
35 | **/\r | |
36 | EFI_STATUS\r | |
37 | EFIAPI\r | |
38 | DTpm2SubmitCommand (\r | |
39 | IN UINT32 InputParameterBlockSize,\r | |
40 | IN UINT8 *InputParameterBlock,\r | |
41 | IN OUT UINT32 *OutputParameterBlockSize,\r | |
42 | IN UINT8 *OutputParameterBlock\r | |
43 | );\r | |
44 | \r | |
45 | /**\r | |
46 | This service requests use TPM2.\r | |
47 | \r | |
48 | @retval EFI_SUCCESS Get the control of TPM2 chip.\r | |
49 | @retval EFI_NOT_FOUND TPM2 not found.\r | |
50 | @retval EFI_DEVICE_ERROR Unexpected device behavior.\r | |
51 | **/\r | |
52 | EFI_STATUS\r | |
53 | EFIAPI\r | |
54 | DTpm2RequestUseTpm (\r | |
55 | VOID\r | |
56 | );\r | |
57 | \r | |
58 | TPM2_DEVICE_INTERFACE mDTpm2InternalTpm2Device = {\r | |
59 | TPM_DEVICE_INTERFACE_TPM20_DTPM,\r | |
60 | DTpm2SubmitCommand,\r | |
61 | DTpm2RequestUseTpm,\r | |
62 | };\r | |
63 | \r | |
64 | /**\r | |
65 | The function register DTPM2.0 instance.\r | |
66 | \r | |
67 | @retval EFI_SUCCESS DTPM2.0 instance is registered, or system dose not surpport registr DTPM2.0 instance\r | |
68 | **/\r | |
69 | EFI_STATUS\r | |
70 | EFIAPI\r | |
71 | Tpm2InstanceLibDTpmConstructor (\r | |
72 | VOID\r | |
73 | )\r | |
74 | {\r | |
75 | EFI_STATUS Status;\r | |
76 | \r | |
77 | Status = Tpm2RegisterTpm2DeviceLib (&mDTpm2InternalTpm2Device);\r | |
78 | if ((Status == EFI_SUCCESS) || (Status == EFI_UNSUPPORTED)) {\r | |
79 | //\r | |
80 | // Unsupported means platform policy does not need this instance enabled.\r | |
81 | //\r | |
82 | return EFI_SUCCESS;\r | |
83 | }\r | |
84 | return Status;\r | |
85 | }\r |