21BOOLEAN mIsTcg2PPVerLowerThan_1_3 =
FALSE;
22UINT32 mTcg2PhysicalPresenceFlags;
38 OUT UINT32 *MostRecentRequest,
46 DEBUG ((DEBUG_INFO,
"[TPM2] ReturnOperationResponseToOsFunction\n"));
52 Status = mTcg2PpSmmVariable->SmmGetVariable (
53 TCG2_PHYSICAL_PRESENCE_VARIABLE,
54 &gEfiTcg2PhysicalPresenceGuid,
59 if (EFI_ERROR (Status)) {
60 *MostRecentRequest = 0;
62 DEBUG ((DEBUG_ERROR,
"[TPM2] Get PP variable failure! Status = %r\n", Status));
63 return TCG_PP_RETURN_TPM_OPERATION_RESPONSE_FAILURE;
66 *MostRecentRequest = PpData.LastPPRequest;
67 *Response = PpData.PPResponse;
69 return TCG_PP_RETURN_TPM_OPERATION_RESPONSE_SUCCESS;
89 IN OUT UINT32 *OperationRequest,
90 IN OUT UINT32 *RequestParameter
99 DEBUG ((DEBUG_INFO,
"[TPM2] SubmitRequestToPreOSFunction, Request = %x, %x\n", *OperationRequest, *RequestParameter));
100 ReturnCode = TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS;
106 Status = mTcg2PpSmmVariable->SmmGetVariable (
107 TCG2_PHYSICAL_PRESENCE_VARIABLE,
108 &gEfiTcg2PhysicalPresenceGuid,
113 if (EFI_ERROR (Status)) {
114 DEBUG ((DEBUG_ERROR,
"[TPM2] Get PP variable failure! Status = %r\n", Status));
115 ReturnCode = TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;
119 if ((*OperationRequest > TCG2_PHYSICAL_PRESENCE_NO_ACTION_MAX) &&
120 (*OperationRequest < TCG2_PHYSICAL_PRESENCE_STORAGE_MANAGEMENT_BEGIN))
122 ReturnCode = TCG_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED;
126 if ((PpData.
PPRequest != *OperationRequest) ||
129 PpData.
PPRequest = (UINT8)*OperationRequest;
132 Status = mTcg2PpSmmVariable->SmmSetVariable (
133 TCG2_PHYSICAL_PRESENCE_VARIABLE,
134 &gEfiTcg2PhysicalPresenceGuid,
139 if (EFI_ERROR (Status)) {
140 DEBUG ((DEBUG_ERROR,
"[TPM2] Set PP variable failure! Status = %r\n", Status));
141 ReturnCode = TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;
146 if (*OperationRequest >= TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {
148 Status = mTcg2PpSmmVariable->SmmGetVariable (
149 TCG2_PHYSICAL_PRESENCE_FLAGS_VARIABLE,
150 &gEfiTcg2PhysicalPresenceGuid,
155 if (EFI_ERROR (Status)) {
156 Flags.PPFlags = mTcg2PhysicalPresenceFlags;
166 if (ReturnCode != TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS) {
167 DEBUG ((DEBUG_ERROR,
"[TPM2] Submit PP Request failure! Sync PPRQ/PPRM with PP variable. Status = %r\n", Status));
170 Status = mTcg2PpSmmVariable->SmmGetVariable (
171 TCG2_PHYSICAL_PRESENCE_VARIABLE,
172 &gEfiTcg2PhysicalPresenceGuid,
177 *OperationRequest = (UINT32)PpData.
PPRequest;
202 IN UINT32 OperationRequest,
203 IN UINT32 RequestParameter
206 UINT32 TempOperationRequest;
207 UINT32 TempRequestParameter;
209 TempOperationRequest = OperationRequest;
210 TempRequestParameter = RequestParameter;
230 IN UINT32 OperationRequest
237 BOOLEAN RequestConfirmed;
239 DEBUG ((DEBUG_INFO,
"[TPM2] GetUserConfirmationStatusFunction, Request = %x\n", OperationRequest));
245 Status = mTcg2PpSmmVariable->SmmGetVariable (
246 TCG2_PHYSICAL_PRESENCE_VARIABLE,
247 &gEfiTcg2PhysicalPresenceGuid,
252 if (EFI_ERROR (Status)) {
253 DEBUG ((DEBUG_ERROR,
"[TPM2] Get PP variable failure! Status = %r\n", Status));
254 return TCG_PP_GET_USER_CONFIRMATION_BLOCKED_BY_BIOS_CONFIGURATION;
261 Status = mTcg2PpSmmVariable->SmmGetVariable (
262 TCG2_PHYSICAL_PRESENCE_FLAGS_VARIABLE,
263 &gEfiTcg2PhysicalPresenceGuid,
268 if (EFI_ERROR (Status)) {
269 DEBUG ((DEBUG_ERROR,
"[TPM2] Get PP flags failure! Status = %r\n", Status));
270 return TCG_PP_GET_USER_CONFIRMATION_BLOCKED_BY_BIOS_CONFIGURATION;
273 RequestConfirmed =
FALSE;
275 switch (OperationRequest) {
276 case TCG2_PHYSICAL_PRESENCE_CLEAR:
277 case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR:
278 case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_2:
279 case TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR_3:
280 if ((Flags.PPFlags & TCG2_BIOS_TPM_MANAGEMENT_FLAG_PP_REQUIRED_FOR_CLEAR) == 0) {
281 RequestConfirmed =
TRUE;
286 case TCG2_PHYSICAL_PRESENCE_NO_ACTION:
287 case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_CLEAR_TRUE:
288 RequestConfirmed =
TRUE;
291 case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_CLEAR_FALSE:
294 case TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS:
295 if ((Flags.PPFlags & TCG2_BIOS_TPM_MANAGEMENT_FLAG_PP_REQUIRED_FOR_CHANGE_PCRS) == 0) {
296 RequestConfirmed =
TRUE;
301 case TCG2_PHYSICAL_PRESENCE_CHANGE_EPS:
302 if ((Flags.PPFlags & TCG2_BIOS_TPM_MANAGEMENT_FLAG_PP_REQUIRED_FOR_CHANGE_EPS) == 0) {
303 RequestConfirmed =
TRUE;
308 case TCG2_PHYSICAL_PRESENCE_LOG_ALL_DIGESTS:
309 RequestConfirmed =
TRUE;
312 case TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID:
313 if ((Flags.PPFlags & TCG2_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_ENABLE_BLOCK_SID) == 0) {
314 RequestConfirmed =
TRUE;
319 case TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID:
320 if ((Flags.PPFlags & TCG2_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_DISABLE_BLOCK_SID) == 0) {
321 RequestConfirmed =
TRUE;
326 case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_ENABLE_BLOCK_SID_FUNC_TRUE:
327 case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_DISABLE_BLOCK_SID_FUNC_TRUE:
328 RequestConfirmed =
TRUE;
331 case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_ENABLE_BLOCK_SID_FUNC_FALSE:
332 case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_DISABLE_BLOCK_SID_FUNC_FALSE:
336 if (!mIsTcg2PPVerLowerThan_1_3) {
337 if (OperationRequest < TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {
341 return TCG_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED;
347 if (OperationRequest <= TCG2_PHYSICAL_PRESENCE_NO_ACTION_MAX) {
348 RequestConfirmed =
TRUE;
349 }
else if (OperationRequest < TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {
350 return TCG_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED;
357 if (OperationRequest >= TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {
361 if (RequestConfirmed) {
362 return TCG_PP_GET_USER_CONFIRMATION_ALLOWED_AND_PPUSER_NOT_REQUIRED;
364 return TCG_PP_GET_USER_CONFIRMATION_ALLOWED_AND_PPUSER_REQUIRED;
388 Status = gMmst->MmLocateProtocol (&gEfiSmmVariableProtocolGuid,
NULL, (VOID **)&mTcg2PpSmmVariable);
391 mTcg2PhysicalPresenceFlags =
PcdGet32 (PcdTcg2PhysicalPresenceFlags);
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
UINT32 EFIAPI Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction(IN UINT32 OperationRequest, IN UINT32 RequestParameter)
UINT32 EFIAPI Tcg2PhysicalPresenceLibReturnOperationResponseToOsFunction(OUT UINT32 *MostRecentRequest, OUT UINT32 *Response)
UINT32 EFIAPI Tcg2PhysicalPresenceLibGetUserConfirmationStatusFunction(IN UINT32 OperationRequest)
EFI_STATUS Tcg2PhysicalPresenceLibCommonConstructor(VOID)
UINT32 Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunctionEx(IN OUT UINT32 *OperationRequest, IN OUT UINT32 *RequestParameter)
BOOLEAN IsTcg2PPVerLowerThan_1_3(VOID)
#define PcdGet32(TokenName)
UINT32 EFIAPI Tcg2PpVendorLibGetUserConfirmationStatusFunction(IN UINT32 OperationRequest, IN UINT32 ManagementFlags)
UINT32 EFIAPI Tcg2PpVendorLibSubmitRequestToPreOSFunction(IN UINT32 OperationRequest, IN UINT32 ManagementFlags, IN UINT32 RequestParameter)
#define EFI_VARIABLE_NON_VOLATILE
UINT32 PPRequestParameter
Physical Presence request Parameter.
UINT8 PPRequest
Physical Presence request command.