/** This function is the entry point of the Fault Tolerant Write driver. @param[in] ImageHandle A handle for the image that is initializing this driver @param[in] SystemTable A pointer to the EFI system table @retval EFI_SUCCESS The initialization finished successfully. @retval EFI_OUT_OF_RESOURCES Allocate memory error @retval EFI_INVALID_PARAMETER Workspace or Spare block does not exist **/ EFI_STATUS EFIAPI FaultTolerantWriteInitialize ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; EFI_FTW_DEVICE *FtwDevice; FtwDevice = NULL; // // Allocate private data structure for FTW protocol and do some initialization // Status = InitFtwDevice (&FtwDevice); if (EFI_ERROR(Status)) { return Status; } // // Register FvbNotificationEvent () notify function. // EfiCreateProtocolNotifyEvent ( &gEfiFirmwareVolumeBlockProtocolGuid, TPL_CALLBACK, FvbNotificationEvent, (VOID *)FtwDevice, &mFvbRegistration ); return EFI_SUCCESS; }
/** This function is the entry point of the Fault Tolerant Write driver. @param[in] ImageHandle A handle for the image that is initializing this driver @param[in] SystemTable A pointer to the EFI system table @retval EFI_SUCCESS The initialization finished successfully. @retval EFI_OUT_OF_RESOURCES Allocate memory error @retval EFI_INVALID_PARAMETER Workspace or Spare block does not exist **/ EFI_STATUS EFIAPI SmmFaultTolerantWriteInitialize ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; VOID *SmmEndOfDxeRegistration; // // Allocate private data structure for SMM FTW protocol and do some initialization // Status = InitFtwDevice (&mFtwDevice); if (EFI_ERROR(Status)) { return Status; } // // Register EFI_SMM_END_OF_DXE_PROTOCOL_GUID notify function. // Status = gSmst->SmmRegisterProtocolNotify ( &gEfiSmmEndOfDxeProtocolGuid, SmmEndOfDxeCallback, &SmmEndOfDxeRegistration ); ASSERT_EFI_ERROR (Status); // // Register FvbNotificationEvent () notify function. // Status = gSmst->SmmRegisterProtocolNotify ( &gEfiSmmFirmwareVolumeBlockProtocolGuid, FvbNotificationEvent, &mFvbRegistration ); ASSERT_EFI_ERROR (Status); FvbNotificationEvent (NULL, NULL, NULL); return EFI_SUCCESS; }
/** This function is the entry point of the Fault Tolerant Write driver. @param[in] ImageHandle A handle for the image that is initializing this driver @param[in] SystemTable A pointer to the EFI system table @retval EFI_SUCCESS The initialization finished successfully. @retval EFI_OUT_OF_RESOURCES Allocate memory error @retval EFI_INVALID_PARAMETER Workspace or Spare block does not exist **/ EFI_STATUS EFIAPI SmmFaultTolerantWriteInitialize ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; EFI_HANDLE FtwHandle; EFI_SMM_ACCESS2_PROTOCOL *SmmAccess; UINTN Size; // // Allocate private data structure for SMM FTW protocol and do some initialization // Status = InitFtwDevice (&mFtwDevice); if (EFI_ERROR(Status)) { return Status; } // // Get SMRAM information // Status = gBS->LocateProtocol (&gEfiSmmAccess2ProtocolGuid, NULL, (VOID **)&SmmAccess); ASSERT_EFI_ERROR (Status); Size = 0; Status = SmmAccess->GetCapabilities (SmmAccess, &Size, NULL); ASSERT (Status == EFI_BUFFER_TOO_SMALL); Status = gSmst->SmmAllocatePool ( EfiRuntimeServicesData, Size, (VOID **)&mSmramRanges ); ASSERT_EFI_ERROR (Status); Status = SmmAccess->GetCapabilities (SmmAccess, &Size, mSmramRanges); ASSERT_EFI_ERROR (Status); mSmramRangeCount = Size / sizeof (EFI_SMRAM_DESCRIPTOR); // // Register FvbNotificationEvent () notify function. // Status = gSmst->SmmRegisterProtocolNotify ( &gEfiSmmFirmwareVolumeBlockProtocolGuid, FvbNotificationEvent, &mFvbRegistration ); ASSERT_EFI_ERROR (Status); FvbNotificationEvent (NULL, NULL, NULL); /// /// Register SMM FTW SMI handler /// Status = gSmst->SmiHandlerRegister (SmmFaultTolerantWriteHandler, &gEfiSmmFaultTolerantWriteProtocolGuid, &FtwHandle); ASSERT_EFI_ERROR (Status); return EFI_SUCCESS; }