52 IN OUT VOID *CommBuffer,
57 UINTN TempCommBufferSize;
60 DEBUG ((DEBUG_VERBOSE,
"%a()\n", __func__));
65 if ((CommBuffer ==
NULL) || (CommBufferSize ==
NULL)) {
69 TempCommBufferSize = *CommBufferSize;
72 DEBUG ((DEBUG_ERROR,
"[%a] MM Communication buffer size is invalid for this handler!\n", __func__));
73 return EFI_ACCESS_DENIED;
82 DEBUG ((DEBUG_ERROR,
"[%a] - MM Communication buffer in invalid location!\n", __func__));
83 return EFI_ACCESS_DENIED;
90 DEBUG ((DEBUG_ERROR,
"[%a] - MM NonPrimary buffer pointed from Communication buffer in invalid location!\n", __func__));
91 return EFI_ACCESS_DENIED;
98 switch (CommParams->Function) {
99 case TpmNvsMmExchangeInfo:
100 DEBUG ((DEBUG_VERBOSE,
"[%a] - Function requested: MM_EXCHANGE_NVS_INFO\n", __func__));
101 CommParams->RegisteredPpSwiValue = mPpSoftwareSmi;
102 CommParams->RegisteredMcSwiValue = mMcSoftwareSmi;
107 DEBUG ((DEBUG_INFO,
"[%a] - Unknown function %d!\n", __func__, CommParams->Function));
108 Status = EFI_UNSUPPORTED;
112 CommParams->ReturnStatus = (UINT64)Status;
138 IN OUT VOID *CommBuffer,
142 UINT32 MostRecentRequest;
144 UINT32 OperationRequest;
145 UINT32 RequestParameter;
147 if (mTcgNvs->PhysicalPresence.Parameter == TCG_ACPI_FUNCTION_RETURN_REQUEST_RESPONSE_TO_OS) {
152 mTcgNvs->PhysicalPresence.LastRequest = MostRecentRequest;
153 mTcgNvs->PhysicalPresence.Response = Response;
155 }
else if ( (mTcgNvs->PhysicalPresence.Parameter == TCG_ACPI_FUNCTION_SUBMIT_REQUEST_TO_BIOS)
156 || (mTcgNvs->PhysicalPresence.Parameter == TCG_ACPI_FUNCTION_SUBMIT_REQUEST_TO_BIOS_2))
158 OperationRequest = mTcgNvs->PhysicalPresence.Request;
159 RequestParameter = mTcgNvs->PhysicalPresence.RequestParameter;
164 mTcgNvs->PhysicalPresence.Request = OperationRequest;
165 mTcgNvs->PhysicalPresence.RequestParameter = RequestParameter;
166 }
else if (mTcgNvs->PhysicalPresence.Parameter == TCG_ACPI_FUNCTION_GET_USER_CONFIRMATION_STATUS_FOR_REQUEST) {
195 if (mReadyToLockHandle !=
NULL) {
196 Status = gMmst->MmiHandlerUnRegister (mReadyToLockHandle);
197 mReadyToLockHandle =
NULL;
226 DEBUG ((DEBUG_ERROR,
"No TPM2 DTPM instance required!\n"));
227 return EFI_UNSUPPORTED;
231 mReadyToLockHandle =
NULL;
238 Status = gMmst->MmiHandlerRegister (
TpmNvsCommunciate, &gTpmNvsMmGuid, &mReadyToLockHandle);
240 if (EFI_ERROR (Status)) {
241 DEBUG ((DEBUG_ERROR,
"[%a] Failed to register NVS communicate as root MM handler - %r!\n", __func__, Status));
248 Status = gMmst->MmLocateProtocol (&gEfiSmmSwDispatch2ProtocolGuid,
NULL, (VOID **)&SwDispatch);
250 if (EFI_ERROR (Status)) {
251 DEBUG ((DEBUG_ERROR,
"[%a] Failed to locate Sw dispatch protocol - %r!\n", __func__, Status));
255 SwContext.SwSmiInputValue = (
UINTN)-1;
258 if (EFI_ERROR (Status)) {
259 DEBUG ((DEBUG_ERROR,
"[%a] Failed to register PP callback as SW MM handler - %r!\n", __func__, Status));
263 mPpSoftwareSmi = SwContext.SwSmiInputValue;
268 Status = gMmst->MmLocateProtocol (&gEfiSmmVariableProtocolGuid,
NULL, (VOID **)&mSmmVariable);
270 if (EFI_ERROR (Status)) {
272 DEBUG ((DEBUG_ERROR,
"[%a] Failed to locate SMM variable protocol - %r!\n", __func__, Status));
277 Status = gMmst->MmRegisterProtocolNotify (&gEfiMmReadyToLockProtocolGuid,
TcgMmReadyToLock, &NotifyHandle);
279 if (EFI_ERROR (Status)) {
280 DEBUG ((DEBUG_ERROR,
"[%a] Failed to register ready to lock notification - %r!\n", __func__, Status));
287 if (EFI_ERROR (Status)) {
289 if (NotifyHandle !=
NULL) {
290 gMmst->MmRegisterProtocolNotify (&gEfiMmReadyToLockProtocolGuid,
NULL, &NotifyHandle);
293 if ((McSwHandle !=
NULL) && (SwDispatch !=
NULL)) {
294 SwDispatch->UnRegister (SwDispatch, McSwHandle);
297 if ((PpSwHandle !=
NULL) && (SwDispatch !=
NULL)) {
298 SwDispatch->UnRegister (SwDispatch, PpSwHandle);
301 if (mReadyToLockHandle !=
NULL) {
302 gMmst->MmiHandlerUnRegister (mReadyToLockHandle);
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
UINT32 EFIAPI Tcg2PhysicalPresenceLibReturnOperationResponseToOsFunction(OUT UINT32 *MostRecentRequest, OUT UINT32 *Response)
UINT32 EFIAPI Tcg2PhysicalPresenceLibGetUserConfirmationStatusFunction(IN UINT32 OperationRequest)
UINT32 Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunctionEx(IN OUT UINT32 *OperationRequest, IN OUT UINT32 *RequestParameter)
EFI_STATUS EFIAPI TcgMmReadyToLock(IN CONST EFI_GUID *Protocol, IN VOID *Interface, IN EFI_HANDLE Handle)
EFI_STATUS EFIAPI TpmNvsCommunciate(IN EFI_HANDLE DispatchHandle, IN CONST VOID *RegisterContext, IN OUT VOID *CommBuffer, IN OUT UINTN *CommBufferSize)
EFI_STATUS InitializeTcgCommon(VOID)
EFI_STATUS EFIAPI PhysicalPresenceCallback(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context, IN OUT VOID *CommBuffer, IN OUT UINTN *CommBufferSize)
BOOLEAN IsTpm20Dtpm(VOID)
BOOLEAN Tcg2IsNonPrimaryBufferValid(IN EFI_PHYSICAL_ADDRESS Buffer, IN UINT64 Length)
VOID Tcg2NotifyMmReady(VOID)
BOOLEAN Tcg2IsPrimaryBufferValid(IN EFI_PHYSICAL_ADDRESS Buffer, IN UINT64 Length)
#define EFI_PAGES_TO_SIZE(Pages)
#define EFI_SIZE_TO_PAGES(Size)