1 /** @file
2   Ihis library is to support TCG Physical Presence Interface (PPI) specification
3   >= 128 Vendor Specific PPI Operation.
4 
5   The Vendor Specific PPI operation may change TPM state, BIOS TPM management
6   flags, and may need additional boot cycle.
7 
8   Caution: This function may receive untrusted input.
9 
10 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
11 This program and the accompanying materials
12 are licensed and made available under the terms and conditions of the BSD License
13 which accompanies this distribution.  The full text of the license may be found at
14 http://opensource.org/licenses/bsd-license.php
15 
16 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
17 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 
19 **/
20 
21 #ifndef _TCG_PP_VENDOR_LIB_H_
22 #define _TCG_PP_VENDOR_LIB_H_
23 
24 //
25 // The definition of physical presence operation actions
26 //
27 #define TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION                         128
28 
29 //
30 // The definition bit of the BIOS TPM Management Flags
31 //
32 #define TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION                    BIT0
33 #define TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR                        BIT1
34 #define TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_MAINTENANCE                  BIT2
35 #define TCG_VENDOR_LIB_FLAG_RESET_TRACK                                  BIT3
36 
37 //
38 // The definition for TPM Operation Response to OS Environment
39 //
40 #define TCG_PP_OPERATION_RESPONSE_SUCCESS              0x0
41 #define TCG_PP_OPERATION_RESPONSE_USER_ABORT           0xFFFFFFF0
42 #define TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE         0xFFFFFFF1
43 
44 //
45 // The return code for Sumbit TPM Request to Pre-OS Environment
46 // and Sumbit TPM Request to Pre-OS Environment 2
47 //
48 #define TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS                                  0
49 #define TCG_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED                          1
50 #define TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE                          2
51 #define TCG_PP_SUBMIT_REQUEST_TO_PREOS_BLOCKED_BY_BIOS_SETTINGS                 3
52 
53 //
54 // The return code for Get User Confirmation Status for Operation
55 //
56 #define TCG_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED                                 0
57 #define TCG_PP_GET_USER_CONFIRMATION_BIOS_ONLY                                       1
58 #define TCG_PP_GET_USER_CONFIRMATION_BLOCKED_BY_BIOS_CONFIGURATION                   2
59 #define TCG_PP_GET_USER_CONFIRMATION_ALLOWED_AND_PPUSER_REQUIRED                     3
60 #define TCG_PP_GET_USER_CONFIRMATION_ALLOWED_AND_PPUSER_NOT_REQUIRED                 4
61 
62 /**
63   Check and execute the requested physical presence command.
64 
65   This API should be invoked in BIOS boot phase to process pending request.
66 
67   Caution: This function may receive untrusted input.
68 
69   If OperationRequest < 128, then ASSERT().
70 
71   @param[in]      OperationRequest TPM physical presence operation request.
72   @param[in, out] ManagementFlags  BIOS TPM Management Flags.
73   @param[out]     ResetRequired    If reset is required to vendor settings in effect.
74                                    True, it indicates the reset is required.
75                                    False, it indicates the reset is not required.
76 
77   @return TPM Operation Response to OS Environment.
78 **/
79 UINT32
80 EFIAPI
81 TcgPpVendorLibExecutePendingRequest (
82   IN UINT32                 OperationRequest,
83   IN OUT UINT32             *ManagementFlags,
84   OUT BOOLEAN               *ResetRequired
85   );
86 
87 /**
88   Check if there is a valid physical presence command request.
89 
90   This API should be invoked in BIOS boot phase to process pending request.
91 
92   Caution: This function may receive untrusted input.
93 
94   If OperationRequest < 128, then ASSERT().
95 
96   @param[in]      OperationRequest TPM physical presence operation request.
97   @param[in]      ManagementFlags  BIOS TPM Management Flags.
98   @param[out]     RequestConfirmed If the physical presence operation command required user confirm from UI.
99                                    True, it indicates the command doesn't require user confirm.
100                                    False, it indicates the command need user confirm from UI.
101 
102   @retval  TRUE        Physical Presence operation command is valid.
103   @retval  FALSE       Physical Presence operation command is invalid.
104 **/
105 BOOLEAN
106 EFIAPI
107 TcgPpVendorLibHasValidRequest (
108   IN UINT32                 OperationRequest,
109   IN UINT32                 ManagementFlags,
110   OUT BOOLEAN               *RequestConfirmed
111   );
112 
113 /**
114   The callback for TPM vendor specific physical presence which is called for
115   Submit TPM Operation Request to Pre-OS Environment and
116   Submit TPM Operation Request to Pre-OS Environment 2.
117 
118   This API should be invoked in OS runtime phase to interface with ACPI method.
119 
120   Caution: This function may receive untrusted input.
121 
122   If OperationRequest < 128, then ASSERT().
123 
124   @param[in]      OperationRequest TPM physical presence operation request.
125   @param[in]      ManagementFlags  BIOS TPM Management Flags.
126 
127   @return Return Code for Submit TPM Operation Request to Pre-OS Environment and
128           Submit TPM Operation Request to Pre-OS Environment 2.
129 **/
130 UINT32
131 EFIAPI
132 TcgPpVendorLibSubmitRequestToPreOSFunction (
133   IN UINT32                 OperationRequest,
134   IN UINT32                 ManagementFlags
135   );
136 
137 /**
138   The callback for TPM vendor specific physical presence which is called for
139   Get User Confirmation Status for Operation.
140 
141   This API should be invoked in OS runtime phase to interface with ACPI method.
142 
143   Caution: This function may receive untrusted input.
144 
145   If OperationRequest < 128, then ASSERT().
146 
147   @param[in]      OperationRequest TPM physical presence operation request.
148   @param[in]      ManagementFlags  BIOS TPM Management Flags.
149 
150   @return Return Code for Get User Confirmation Status for Operation.
151 **/
152 UINT32
153 EFIAPI
154 TcgPpVendorLibGetUserConfirmationStatusFunction (
155   IN UINT32                 OperationRequest,
156   IN UINT32                 ManagementFlags
157   );
158 
159 #endif
160