EFI_STATUS UsbKbLocateAppleKeyMapDb ( IN USB_KB_DEV *UsbKeyboardDevice ) { EFI_STATUS Status; //ASSERT (UsbKeyboardDevice != NULL); if (!UsbKeyboardDevice) { return EFI_UNSUPPORTED; } Status = gBS->LocateProtocol ( &gAppleKeyMapDatabaseProtocolGuid, NULL, (VOID **)&AppleKeyMapDb ); if (!EFI_ERROR (Status)) { UsbKbSetAppleKeyMapDb (UsbKeyboardDevice, AppleKeyMapDb); } else /*if (PcdGetBool (PcdNotifyAppleKeyMapDbInUsbKbDriver))*/ { //true EfiCreateProtocolNotifyEvent ( &gAppleKeyMapDatabaseProtocolGuid, TPL_NOTIFY, UsbKbAppleKeyMapDbInstallNotify, (VOID *)UsbKeyboardDevice, &mAppleKeyMapDbRegistration ); } return Status; //signal that Db is not ready }
/** 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 is the declaration of an EFI image entry point. This entry point is the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including both device drivers and bus drivers. The entry point for IP6 driver which installs the driver binding and component name protocol on its image. @param[in] ImageHandle The firmware allocated handle for the UEFI image. @param[in] SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS The operation completed successfully. @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. **/ EFI_STATUS EFIAPI Ip6DriverEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { VOID *Registration; EfiCreateProtocolNotifyEvent ( &gEfiIpSec2ProtocolGuid, TPL_CALLBACK, IpSec2InstalledCallback, NULL, &Registration ); return EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, &gIp6DriverBinding, ImageHandle, &gIp6ComponentName, &gIp6ComponentName2 ); }
EFI_STATUS EFIAPI VisitingFileSystemInstance ( IN EFI_HANDLE Handle, IN VOID *Instance, IN VOID *Context ) { EFI_STATUS Status; STATIC BOOLEAN ConnectedToFileSystem = FALSE; if (ConnectedToFileSystem) { return EFI_ALREADY_STARTED; } Status = ConnectNvVarsToFileSystem (Handle); if (EFI_ERROR (Status)) { return Status; } ConnectedToFileSystem = TRUE; mEmuVariableEvent = EfiCreateProtocolNotifyEvent ( &gEfiDevicePathProtocolGuid, TPL_CALLBACK, EmuVariablesUpdatedCallback, NULL, &mEmuVariableEventReg ); PcdSet64 (PcdEmuVariableEvent, (UINT64)(UINTN) mEmuVariableEvent); return EFI_SUCCESS; }
/** Register security handler for deferred image load. @param[in] ImageHandle ImageHandle of the loaded driver. @param[in] SystemTable Pointer to the EFI System Table. @retval EFI_SUCCESS The handlers were registered successfully. **/ EFI_STATUS EFIAPI DxeDeferImageLoadLibConstructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { VOID *Registration; // // Register user manager notification function. // EfiCreateProtocolNotifyEvent ( &gEfiUserManagerProtocolGuid, TPL_CALLBACK, FindUserManagerProtocol, NULL, &Registration ); return RegisterSecurity2Handler ( DxeDeferImageLoadHandler, EFI_AUTH_OPERATION_DEFER_IMAGE_LOAD ); }
EFI_STATUS EFIAPI CreateConfigEvents ( VOID ) /*++ Routine Description: Arguments: None Returns: EFI_STATUS --*/ { EFI_EVENT EventSmmCfg; EFI_EVENT EventSpiReady; VOID *RegistrationSmmCfg; VOID *RegistrationSpiReady; // // Schedule callback for when SmmConfigurationProtocol installed. // EventSmmCfg = EfiCreateProtocolNotifyEvent ( &gEfiSmmConfigurationProtocolGuid, TPL_CALLBACK, PlatformConfigOnSmmConfigurationProtocol, NULL, &RegistrationSmmCfg ); ASSERT (EventSmmCfg != NULL); // // Schedule callback to setup SPI Flash Policy when SPI interface ready. // EventSpiReady = EfiCreateProtocolNotifyEvent ( &gEfiSmmSpiReadyProtocolGuid, TPL_CALLBACK, PlatformConfigOnSpiReady, NULL, &RegistrationSpiReady ); ASSERT (EventSpiReady != NULL); return EFI_SUCCESS; }
/** Main entry for PCD DXE driver. This routine initialize the PCD database and install PCD_PROTOCOL. @param ImageHandle Image handle for PCD DXE driver. @param SystemTable Pointer to SystemTable. @return Status of gBS->InstallProtocolInterface() **/ EFI_STATUS EFIAPI PcdDxeInit ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; VOID *Registration; // // Make sure the Pcd Protocol is not already installed in the system // ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gPcdProtocolGuid); BuildPcdDxeDataBase (); // // Install PCD_PROTOCOL to handle dynamic type PCD // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD // Status = gBS->InstallMultipleProtocolInterfaces ( &mPcdHandle, &gPcdProtocolGuid, &mPcdInstance, &gEfiPcdProtocolGuid, &mEfiPcdInstance, NULL ); ASSERT_EFI_ERROR (Status); // // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD // Status = gBS->InstallMultipleProtocolInterfaces ( &mPcdHandle, &gGetPcdInfoProtocolGuid, &mGetPcdInfoInstance, &gEfiGetPcdInfoProtocolGuid, &mEfiGetPcdInfoInstance, NULL ); ASSERT_EFI_ERROR (Status); // // Register callback function upon VariableLockProtocol // to lock the variables referenced by DynamicHii PCDs with RO property set in *.dsc. // EfiCreateProtocolNotifyEvent ( &gEdkiiVariableLockProtocolGuid, TPL_CALLBACK, VariableLockCallBack, NULL, &Registration ); return Status; }
/** Process all the "Key####" variables, associate Hotkeys with corresponding Boot Options. @retval EFI_SUCCESS Hotkey services successfully initialized. **/ EFI_STATUS EFIAPI EfiBootManagerStartHotkeyService ( IN EFI_EVENT *HotkeyTriggered ) { EFI_STATUS Status; EFI_BOOT_MANAGER_KEY_OPTION *KeyOptions; UINTN KeyOptionCount; UINTN Index; EFI_EVENT Event; Status = gBS->CreateEvent ( EVT_NOTIFY_WAIT, TPL_CALLBACK, BdsEmptyFunction, NULL, &mHotkeyTriggered ); ASSERT_EFI_ERROR (Status); if (HotkeyTriggered != NULL) { *HotkeyTriggered = mHotkeyTriggered; } KeyOptions = EfiBootManagerGetKeyOptions (&KeyOptionCount); for (Index = 0; Index < KeyOptionCount; Index ++) { ProcessKeyOption (&KeyOptions[Index]); } EfiBootManagerFreeKeyOptions (KeyOptions, KeyOptionCount); if (mContinueKeyOption != NULL) { ProcessKeyOption (mContinueKeyOption); } EfiCreateProtocolNotifyEvent ( &gEfiSimpleTextInputExProtocolGuid, TPL_CALLBACK, TxtInExCallback, NULL, &mTxtInExRegistration ); Status = EfiCreateEventReadyToBootEx ( TPL_CALLBACK, StopHotkeyService, NULL, &Event ); ASSERT_EFI_ERROR (Status); mHotkeyServiceStarted = TRUE; return Status; }
/** This function is the entry point of the Fault Tolerant Write driver. @param ImageHandle A handle for the image that is initializing this driver @param SystemTable A pointer to the EFI system table @return EFI_SUCCESS FTW has finished the initialization @retval EFI_NOT_FOUND Locate FVB protocol error @retval EFI_OUT_OF_RESOURCES Allocate memory error @retval EFI_VOLUME_CORRUPTED Firmware volume is error @retval EFI_ABORTED FTW initialization error **/ EFI_STATUS EFIAPI InitializeFaultTolerantWrite ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_FTW_DEVICE *FtwDevice; // // Allocate Private data of this driver, // INCLUDING THE FtwWorkSpace[FTW_WORK_SPACE_SIZE]. // FtwDevice = NULL; FtwDevice = AllocateZeroPool (sizeof (EFI_FTW_DEVICE) + PcdGet32 (PcdFlashNvStorageFtwWorkingSize)); if (FtwDevice == NULL) { return EFI_OUT_OF_RESOURCES; } ZeroMem (FtwDevice, sizeof (EFI_FTW_DEVICE)); FtwDevice->Signature = FTW_DEVICE_SIGNATURE; // // Initialize other parameters, and set WorkSpace as FTW_ERASED_BYTE. // FtwDevice->WorkSpaceLength = (UINTN) PcdGet32 (PcdFlashNvStorageFtwWorkingSize); FtwDevice->SpareAreaLength = (UINTN) PcdGet32 (PcdFlashNvStorageFtwSpareSize); if ((FtwDevice->WorkSpaceLength == 0) || (FtwDevice->SpareAreaLength == 0)) { DEBUG ((EFI_D_ERROR, "Ftw: Workspace or Spare block does not exist!\n")); FreePool (FtwDevice); return EFI_OUT_OF_RESOURCES; } FtwDevice->FtwFvBlock = NULL; FtwDevice->FtwBackupFvb = NULL; FtwDevice->FtwWorkSpaceLba = (EFI_LBA) (-1); FtwDevice->FtwSpareLba = (EFI_LBA) (-1); // // Register FvbNotificationEvent () notify function. // EfiCreateProtocolNotifyEvent ( &gEfiFirmwareVolumeBlockProtocolGuid, TPL_CALLBACK, FvbNotificationEvent, (VOID *)FtwDevice, &mFvbRegistration ); return EFI_SUCCESS; }
EFI_STATUS EFIAPI RegisterEmmc ( VOID ) { EFI_STATUS Status; EFI_HANDLE Handle; UINTN Index; if (mHiiSettings->AcpiPref == ACPIPREF_ACPI) { // // Load the SSDT table from a raw section in this FFS file. // for (Index = 0;; Index++) { Status = GetSectionFromFv (&gEfiCallerIdGuid, EFI_SECTION_RAW, Index, (VOID **)&mSsdt, &mSsdtSize); if (EFI_ERROR (Status)) { break; } if (mSsdt->OemTableId != EMMC_TABLE_ID) { continue; } // // Register for the ACPI table protocol // EfiCreateProtocolNotifyEvent (&gEfiAcpiTableProtocolGuid, TPL_CALLBACK, InstallAcpiTable, NULL, &mEventRegistration); break; } } Status = RegisterNonDiscoverableMmioDevice ( NonDiscoverableDeviceTypeSdhci, NonDiscoverableDeviceDmaTypeCoherent, NULL, &mSdMmcControllerHandle, 1, SYNQUACER_EMMC_BASE, SYNQUACER_EMMC_BASE_SZ); ASSERT_EFI_ERROR (Status); Handle = NULL; Status = gBS->InstallProtocolInterface (&Handle, &gEdkiiSdMmcOverrideProtocolGuid, EFI_NATIVE_INTERFACE, (VOID **)&mSdMmcOverride); ASSERT_EFI_ERROR (Status); return EFI_SUCCESS; }
VOID InstallDevicePathCallback ( VOID ) { DEBUG ((EFI_D_INFO, "Registered NotifyDevPath Event\n")); mEfiDevPathEvent = EfiCreateProtocolNotifyEvent ( &gEfiDevicePathProtocolGuid, TPL_CALLBACK, NotifyDevPath, NULL, &mEfiDevPathNotifyReg ); }
/** Main entry for the FSP DXE module. This routine registers two callbacks to call fsp's notifies. @param[in] ImageHandle The firmware allocated handle for the EFI image. @param[in] SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS The entry point is executed successfully. @retval other Some error occurs when executing this entry point. **/ EFI_STATUS EFIAPI FspDxeEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; EFI_EVENT ReadyToBootEvent; VOID *Registration; EFI_EVENT ProtocolNotifyEvent; // // Load this driver's image to memory // Status = RelocateImageUnder4GIfNeeded (ImageHandle, SystemTable); if (EFI_ERROR (Status)) { return EFI_SUCCESS; } if (PcdGet32 (PcdFlashFvSecondFspBase) == 0) { mFspHeader = FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase)); } else { mFspHeader = FspFindFspHeader (PcdGet32 (PcdFlashFvSecondFspBase)); } DEBUG ((DEBUG_INFO, "FspHeader - 0x%x\n", mFspHeader)); if (mFspHeader == NULL) { return EFI_DEVICE_ERROR; } ProtocolNotifyEvent = EfiCreateProtocolNotifyEvent ( &gEfiPciEnumerationCompleteProtocolGuid, TPL_CALLBACK, OnPciEnumerationComplete, NULL, &Registration ); ASSERT (ProtocolNotifyEvent != NULL); Status = EfiCreateEventReadyToBootEx ( TPL_CALLBACK, OnReadyToBoot, NULL, &ReadyToBootEvent ); ASSERT_EFI_ERROR (Status); return EFI_SUCCESS; }
/** The user Entry Point for DXE driver. The user code starts with this function as the real entry point for the image goes into a library that calls this function. @param[in] ImageHandle The firmware allocated handle for the EFI image. @param[in] SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS The entry point is executed successfully. @retval other Some error occurs when executing this entry point. **/ EFI_STATUS EFIAPI InitializeFirmwareVolume2 ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EfiCreateProtocolNotifyEvent ( &gEfiFirmwareVolume2ProtocolGuid, TPL_CALLBACK, FvNotificationEvent, NULL, &mFvRegistration ); return EFI_SUCCESS; }
/** This routine is the driver initialization entry point. It registers a notification function. This notification function are responsible for building the FV stack dynamically. @param ImageHandle The image handle. @param SystemTable The system table. @retval EFI_SUCCESS Function successfully returned. **/ EFI_STATUS EFIAPI FwVolDriverInit ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { gEfiFwVolBlockEvent = EfiCreateProtocolNotifyEvent ( &gEfiFirmwareVolumeBlockProtocolGuid, TPL_CALLBACK, NotifyFwVolBlock, NULL, &gEfiFwVolBlockNotifyReg ); return EFI_SUCCESS; }
/** The user Entry Point for DXE driver. The user code starts with this function as the real entry point for the image goes into a library that calls this function. @param[in] ImageHandle The firmware allocated handle for the EFI image. @param[in] SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS The entry point is executed successfully. @retval other Some error occurs when executing this entry point. **/ EFI_STATUS EFIAPI InitializeUC ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EfiCreateProtocolNotifyEvent ( &gEfiUnicodeCollation2ProtocolGuid, TPL_CALLBACK, Uc2NotificationEvent, NULL, &mUcRegistration ); return EFI_SUCCESS; }
/** CPU Features driver entry point function. If PcdCpuFeaturesInitAfterSmmRelocation is TRUE, it will register one SMM Configuration Protocol notify function to perform CPU features initialization. Otherwise, it will perform CPU features initialization directly. @param ImageHandle Image handle this driver. @param SystemTable Pointer to the System Table. @retval EFI_SUCCESS CPU Features is initialized successfully. **/ EFI_STATUS EFIAPI CpuFeaturesDxeInitialize ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { VOID *Registration; EFI_STATUS Status; EFI_HANDLE Handle; if (GetFirstGuidHob (&gEdkiiCpuFeaturesInitDoneGuid) != NULL) { // // Try to find HOB first. This HOB exist means CPU features have // been initialized by CpuFeaturesPei driver, just install // gEdkiiCpuFeaturesInitDoneGuid. // Handle = NULL; Status = gBS->InstallProtocolInterface ( &Handle, &gEdkiiCpuFeaturesInitDoneGuid, EFI_NATIVE_INTERFACE, NULL ); ASSERT_EFI_ERROR (Status); return Status; } if (PcdGetBool (PcdCpuFeaturesInitAfterSmmRelocation)) { // // Install notification callback on SMM Configuration Protocol // EfiCreateProtocolNotifyEvent ( &gEfiSmmConfigurationProtocolGuid, TPL_CALLBACK, SmmConfigurationEventNotify, NULL, &Registration ); } else { CpuFeaturesInitializeWorker (); } return EFI_SUCCESS; }
/** Create the variable to save the base address of page table and stack for transferring into long mode in IA32 capsule PEI. **/ VOID SaveLongModeContext ( VOID ) { VOID *Registration; if ((FeaturePcdGet(PcdSupportUpdateCapsuleReset)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode))) { // // Register event to get ACPI NVS pages reserved from lock box, these pages will be used by // Capsule IA32 PEI to transfer to long mode to access capsule above 4GB. // EfiCreateProtocolNotifyEvent ( &gEfiDxeSmmReadyToLockProtocolGuid, TPL_CALLBACK, DxeSmmReadyToLockNotification, NULL, &Registration ); } }
/** Initialize the state information for the CPU Architectural Protocol @param ImageHandle of the loaded driver @param SystemTable Pointer to the System Table @retval EFI_SUCCESS Protocol registered @retval EFI_OUT_OF_RESOURCES Cannot allocate protocol data structure @retval EFI_DEVICE_ERROR Hardware problems **/ EFI_STATUS InterruptDxeInitialize ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; EFI_EVENT CpuArchEvent; // Make sure the Interrupt Controller Protocol is not already installed in the system. ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gHardwareInterruptProtocolGuid); Status = gBS->InstallMultipleProtocolInterfaces ( &ImageHandle, &gHardwareInterruptProtocolGuid, &gHardwareInterruptProtocol, NULL ); ASSERT_EFI_ERROR (Status); // // Install the interrupt handler as soon as the CPU arch protocol appears. // CpuArchEvent = EfiCreateProtocolNotifyEvent ( &gEfiCpuArchProtocolGuid, TPL_CALLBACK, CpuArchEventProtocolNotify, NULL, &mCpuArchProtocolNotifyEventRegistration ); ASSERT (CpuArchEvent != NULL); // Register for an ExitBootServicesEvent Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_NOTIFY, ExitBootServicesEvent, NULL, &mExitBootServicesEvent); ASSERT_EFI_ERROR (Status); return Status; }
/** The driver entry point for Fault Tolerant Write driver. The function does the necessary initialization work. @param[in] ImageHandle The firmware allocated handle for the UEFI image. @param[in] SystemTable A pointer to the EFI system table. @retval EFI_SUCCESS This funtion always return EFI_SUCCESS. **/ EFI_STATUS EFIAPI FaultTolerantWriteSmmInitialize ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { VOID *SmmFtwRegistration; // // Smm FTW driver is ready // EfiCreateProtocolNotifyEvent ( &gEfiSmmFaultTolerantWriteProtocolGuid, TPL_CALLBACK, SmmFtwReady, NULL, &SmmFtwRegistration ); return EFI_SUCCESS; }
EFI_STATUS EFIAPI InitSpiDevice ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { VOID *SmmSpiDeviceReg; // // Register for a callback when the SMM version of the SPI Device protocol // is installed. // EfiCreateProtocolNotifyEvent ( &gSmmSpiDeviceProtocolGuid, TPL_CALLBACK, SmmSpiDeviceReady, NULL, &SmmSpiDeviceReg ); return EFI_SUCCESS; }
/** This function initializes AcpiSdt protocol in ACPI table instance. @param[in] AcpiTableInstance Instance to construct **/ VOID SdtAcpiTableAcpiSdtConstructor ( IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance ) { VOID *Registration; InitializeListHead (&AcpiTableInstance->NotifyList); CopyMem (&AcpiTableInstance->AcpiSdtProtocol, &mAcpiSdtProtocolTemplate, sizeof(mAcpiSdtProtocolTemplate)); // // Register event for ExitPmAuth, so that we can uninstall ACPI SDT protocol after ExitPmAuth. // EfiCreateProtocolNotifyEvent ( &gEfiDxeSmmReadyToLockProtocolGuid, TPL_CALLBACK, ExitPmAuthNotification, NULL, &Registration ); return ; }
/** Initialize DXE Platform Policy. @param[in] ImageHandle Image handle of this driver. @param[in] SystemTable Global system service table. @retval EFI_SUCCESS Initialization complete. @retval EFI_UNSUPPORTED The chipset is unsupported by this driver. @retval EFI_OUT_OF_RESOURCES Do not have enough resources to initialize the driver. @retval EFI_DEVICE_ERROR Device error, driver exits abnormally. **/ EFI_STATUS EFIAPI PolicyInitDxeEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; VOID *Registration; // // Platform CherryView Policy Initialization // Status = ChvPlatformPolicyInit (ImageHandle); DEBUG ((DEBUG_INFO, "CherryView Platform Policy Initialization done\n")); ASSERT_EFI_ERROR (Status); // // Platform PCH Policy Initialization // Status = PchPlatformPolicyInit (ImageHandle); DEBUG ((DEBUG_INFO, "PCH Platform Policy Initialization done\n")); ASSERT_EFI_ERROR (Status); // // GOP policy // Status = PlatformGOPPolicyEntryPoint (ImageHandle, SystemTable); // // PPM Policy // EfiCreateProtocolNotifyEvent (&gEfiMpServiceProtocolGuid, TPL_CALLBACK, PpmPolicyEntryCallback, NULL, &Registration); return Status; }
/** The user Entry Point for the driver. The user code starts with this function as the real entry point for the image goes into a library that calls this function. @param[in] ImageHandle The firmware allocated handle for the EFI image. @param[in] SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS The entry point is executed successfully. @retval other Some error occurs when executing this entry point. **/ EFI_STATUS EFIAPI EblAddExternalCommands ( IN const EBL_COMMAND_TABLE *EntryArray, IN UINTN ArrayCount ) { if (mAddExternalCmdLibTemplate != NULL) { return EFI_ALREADY_STARTED; } mAddExternalCmdLibTemplate = EntryArray; mAddExternalCmdLibTemplateSize = ArrayCount; EfiCreateProtocolNotifyEvent ( &gEfiEblAddCommandProtocolGuid, TPL_CALLBACK, EblAddCommandNotificationEvent, NULL, &mEblCommandRegistration ); return EFI_SUCCESS; }
/** Hook point for AcpiVariableThunkPlatform for InstallAcpiS3Save. **/ VOID InstallAcpiS3SaveThunk ( VOID ) { EFI_STATUS Status; FRAMEWORK_EFI_MP_SERVICES_PROTOCOL *FrameworkMpService; UINTN VarSize; VOID *Registration; Status = gBS->LocateProtocol ( &gFrameworkEfiMpServiceProtocolGuid, NULL, (VOID**) &FrameworkMpService ); if (!EFI_ERROR (Status)) { // // On ECP platform, if framework CPU drivers are in use, The compatible version of ACPI variable set // should be produced by CPU driver. // VarSize = sizeof (mAcpiVariableSetCompatibility); Status = gRT->GetVariable ( ACPI_GLOBAL_VARIABLE, &gEfiAcpiVariableCompatiblityGuid, NULL, &VarSize, &mAcpiVariableSetCompatibility ); if (EFI_ERROR (Status) || (VarSize != sizeof (mAcpiVariableSetCompatibility))) { DEBUG ((EFI_D_ERROR, "FATAL ERROR: AcpiVariableSetCompatibility was not saved by CPU driver correctly. OS S3 may fail!\n")); mAcpiVariableSetCompatibility = NULL; } } else { // // Allocate/initialize the compatible version of Acpi Variable Set since Framework chipset/platform // driver need this variable. ACPI_GLOBAL_VARIABLE variable is not used in runtime phase, // so RT attribute is not needed for it. // mAcpiVariableSetCompatibility = AllocateMemoryBelow4G (EfiACPIMemoryNVS, sizeof(ACPI_VARIABLE_SET_COMPATIBILITY)); Status = gRT->SetVariable ( ACPI_GLOBAL_VARIABLE, &gEfiAcpiVariableCompatiblityGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, sizeof(mAcpiVariableSetCompatibility), &mAcpiVariableSetCompatibility ); if (!EFI_ERROR (Status)) { // // Register callback function upon VariableLockProtocol // to lock ACPI_GLOBAL_VARIABLE variable to avoid malicious code to update it. // EfiCreateProtocolNotifyEvent ( &gEdkiiVariableLockProtocolGuid, TPL_CALLBACK, VariableLockAcpiGlobalVariable, NULL, &Registration ); } else { DEBUG ((EFI_D_ERROR, "FATAL ERROR: AcpiVariableSetCompatibility cannot be saved: %r. OS S3 may fail!\n", Status)); gBS->FreePages ( (EFI_PHYSICAL_ADDRESS) (UINTN) mAcpiVariableSetCompatibility, EFI_SIZE_TO_PAGES (sizeof (ACPI_VARIABLE_SET_COMPATIBILITY)) ); mAcpiVariableSetCompatibility = NULL; } } DEBUG((EFI_D_INFO, "AcpiVariableSetCompatibility is 0x%8x\n", mAcpiVariableSetCompatibility)); }
/** The driver's entry point. It publishes EFI TCG Protocol. @param[in] ImageHandle The firmware allocated handle for the EFI image. @param[in] SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS The entry point is executed successfully. @retval other Some error occurs when executing this entry point. **/ EFI_STATUS EFIAPI DriverEntry ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; EFI_EVENT Event; VOID *Registration; if (!CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)){ DEBUG ((EFI_D_ERROR, "No TPM12 instance required!\n")); return EFI_UNSUPPORTED; } if (GetFirstGuidHob (&gTpmErrorHobGuid) != NULL) { DEBUG ((EFI_D_ERROR, "TPM error!\n")); return EFI_DEVICE_ERROR; } Status = Tpm12RequestUseTpm (); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "TPM not detected!\n")); return Status; } Status = GetTpmStatus (&mTcgDxeData.BsCap.TPMDeactivatedFlag); if (EFI_ERROR (Status)) { DEBUG (( EFI_D_ERROR, "Line %d in file " __FILE__ ":\n " "DriverEntry: TPM not working properly\n", __LINE__ )); return Status; } Status = gBS->InstallProtocolInterface ( &ImageHandle, &gEfiTcgProtocolGuid, EFI_NATIVE_INTERFACE, &mTcgDxeData.TcgProtocol ); if (!EFI_ERROR (Status) && (!mTcgDxeData.BsCap.TPMDeactivatedFlag) && mTcgDxeData.BsCap.TPMPresentFlag) { // // Setup the log area and copy event log from hob list to it // Status = SetupEventLog (); ASSERT_EFI_ERROR (Status); // // Measure handoff tables, Boot#### variables etc. // Status = EfiCreateEventReadyToBootEx ( TPL_CALLBACK, OnReadyToBoot, NULL, &Event ); Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY, OnExitBootServices, NULL, &gEfiEventExitBootServicesGuid, &Event ); // // Measure Exit Boot Service failed // Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY, OnExitBootServicesFailed, NULL, &gEventExitBootServicesFailedGuid, &Event ); } // // Install ACPI Table // EfiCreateProtocolNotifyEvent (&gEfiAcpiTableProtocolGuid, TPL_CALLBACK, InstallAcpiTable, NULL, &Registration); return Status; }
/** The driver's entry point. It publishes EFI TCG Protocol. @param[in] ImageHandle The firmware allocated handle for the EFI image. @param[in] SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS The entry point is executed successfully. @retval other Some error occurs when executing this entry point. **/ EFI_STATUS EFIAPI DriverEntry ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; EFI_EVENT Event; VOID *Registration; mTcgDxeData.TpmHandle = (TIS_TPM_HANDLE)(UINTN)TPM_BASE_ADDRESS; Status = TisPcRequestUseTpm (mTcgDxeData.TpmHandle); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "TPM not detected!\n")); return Status; } Status = GetTpmStatus (&mTcgDxeData.BsCap.TPMDeactivatedFlag); if (EFI_ERROR (Status)) { DEBUG (( EFI_D_ERROR, "Line %d in file " __FILE__ ":\n " "DriverEntry: TPM not working properly\n", __LINE__ )); return Status; } Status = gBS->InstallProtocolInterface ( &ImageHandle, &gEfiTcgProtocolGuid, EFI_NATIVE_INTERFACE, &mTcgDxeData.TcgProtocol ); // // Install ACPI Table // EfiCreateProtocolNotifyEvent (&gEfiAcpiTableProtocolGuid, TPL_CALLBACK, InstallAcpiTable, NULL, &Registration); if (!EFI_ERROR (Status) && !mTcgDxeData.BsCap.TPMDeactivatedFlag) { // // Setup the log area and copy event log from hob list to it // Status = SetupEventLog (); ASSERT_EFI_ERROR (Status); // // Measure handoff tables, Boot#### variables etc. // Status = EfiCreateEventReadyToBootEx ( TPL_CALLBACK, OnReadyToBoot, NULL, &Event ); Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY, OnExitBootServices, NULL, &gEfiEventExitBootServicesGuid, &Event ); } return Status; }
/** Entrypoint of Boot script exector driver, this function will be executed in normal boot phase and invoked by DXE dispatch. @param[in] ImageHandle The firmware allocated handle for the EFI image. @param[in] SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS The entry point is executed successfully. @retval other Some error occurs when executing this entry point. **/ EFI_STATUS EFIAPI BootScriptExecutorEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { UINTN BufferSize; UINTN Pages; BOOT_SCRIPT_EXECUTOR_VARIABLE *EfiBootScriptExecutorVariable; EFI_PHYSICAL_ADDRESS BootScriptExecutorBuffer; EFI_STATUS Status; VOID *DevicePath; EFI_EVENT ReadyToLockEvent; VOID *Registration; UINT32 RegEax; UINT32 RegEdx; if (!PcdGetBool (PcdAcpiS3Enable)) { return EFI_UNSUPPORTED; } // // Test if the gEfiCallerIdGuid of this image is already installed. if not, the entry // point is loaded by DXE code which is the first time loaded. or else, it is already // be reloaded be itself.This is a work-around // Status = gBS->LocateProtocol (&gEfiCallerIdGuid, NULL, &DevicePath); if (EFI_ERROR (Status)) { // // Create ReadyToLock event to reload BootScriptExecutor image // to RESERVED mem and save it to LockBox. // ReadyToLockEvent = EfiCreateProtocolNotifyEvent ( &gEfiDxeSmmReadyToLockProtocolGuid, TPL_NOTIFY, ReadyToLockEventNotify, NULL, &Registration ); ASSERT (ReadyToLockEvent != NULL); } else { // // the entry point is invoked after reloading. following code only run in RESERVED mem // if (PcdGetBool(PcdUse1GPageTable)) { AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); if (RegEax >= 0x80000001) { AsmCpuid (0x80000001, NULL, NULL, NULL, &RegEdx); if ((RegEdx & BIT26) != 0) { mPage1GSupport = TRUE; } } } BufferSize = sizeof (BOOT_SCRIPT_EXECUTOR_VARIABLE); BootScriptExecutorBuffer = 0xFFFFFFFF; Pages = EFI_SIZE_TO_PAGES(BufferSize); Status = gBS->AllocatePages ( AllocateMaxAddress, EfiReservedMemoryType, Pages, &BootScriptExecutorBuffer ); ASSERT_EFI_ERROR (Status); EfiBootScriptExecutorVariable = (BOOT_SCRIPT_EXECUTOR_VARIABLE *)(UINTN)BootScriptExecutorBuffer; EfiBootScriptExecutorVariable->BootScriptExecutorEntrypoint = (UINTN) S3BootScriptExecutorEntryFunction ; Status = SaveLockBox ( &gEfiBootScriptExecutorVariableGuid, &BootScriptExecutorBuffer, sizeof(BootScriptExecutorBuffer) ); ASSERT_EFI_ERROR (Status); // // Additional step for BootScript integrity // Save BootScriptExecutor context // Status = SaveLockBox ( &gEfiBootScriptExecutorContextGuid, EfiBootScriptExecutorVariable, sizeof(*EfiBootScriptExecutorVariable) ); ASSERT_EFI_ERROR (Status); Status = SetLockBoxAttributes (&gEfiBootScriptExecutorContextGuid, LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE); ASSERT_EFI_ERROR (Status); } return EFI_SUCCESS; }
/** This is the declaration of an EFI image entry point. This entry point is the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including both device drivers and bus drivers. @param ImageHandle The firmware allocated handle for the UEFI image. @param SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS The operation completed successfully. @retval Others An unexpected error occurred. **/ EFI_STATUS EFIAPI HttpDxeDriverEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; VOID *Registration; gBS->LocateProtocol ( &gEfiHttpUtilitiesProtocolGuid, NULL, (VOID **) &mHttpUtilities ); if (mHttpUtilities == NULL) { // // No Http utilities protocol, register a notify. // EfiCreateProtocolNotifyEvent ( &gEfiHttpUtilitiesProtocolGuid, TPL_CALLBACK, HttpUtilitiesInstalledCallback, NULL, &Registration ); } // // Install UEFI Driver Model protocol(s). // Status = EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, &gHttpDxeIp4DriverBinding, ImageHandle, &gHttpDxeComponentName, &gHttpDxeComponentName2 ); if (EFI_ERROR (Status)) { return Status; } Status = EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, &gHttpDxeIp6DriverBinding, NULL, &gHttpDxeComponentName, &gHttpDxeComponentName2 ); if (EFI_ERROR (Status)) { gBS->UninstallMultipleProtocolInterfaces ( ImageHandle, &gEfiDriverBindingProtocolGuid, &gHttpDxeIp4DriverBinding, &gEfiComponentName2ProtocolGuid, &gHttpDxeComponentName2, &gEfiComponentNameProtocolGuid, &gHttpDxeComponentName, NULL ); } return Status; }
/** Variable Driver main entry point. The Variable driver places the 4 EFI runtime services in the EFI System Table and installs arch protocols for variable read and write services being available. It also registers a notification function for an EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event. @param[in] ImageHandle The firmware allocated handle for the EFI image. @param[in] SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS Variable service successfully initialized. **/ EFI_STATUS EFIAPI VariableServiceInitialize ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; EFI_EVENT ReadyToBootEvent; EFI_EVENT EndOfDxeEvent; Status = VariableCommonInitialize (); ASSERT_EFI_ERROR (Status); Status = gBS->InstallMultipleProtocolInterfaces ( &mHandle, &gEdkiiVariableLockProtocolGuid, &mVariableLock, NULL ); ASSERT_EFI_ERROR (Status); Status = gBS->InstallMultipleProtocolInterfaces ( &mHandle, &gEdkiiVarCheckProtocolGuid, &mVarCheck, NULL ); ASSERT_EFI_ERROR (Status); SystemTable->RuntimeServices->GetVariable = VariableServiceGetVariable; SystemTable->RuntimeServices->GetNextVariableName = VariableServiceGetNextVariableName; SystemTable->RuntimeServices->SetVariable = VariableServiceSetVariable; SystemTable->RuntimeServices->QueryVariableInfo = VariableServiceQueryVariableInfo; // // Now install the Variable Runtime Architectural protocol on a new handle. // Status = gBS->InstallProtocolInterface ( &mHandle, &gEfiVariableArchProtocolGuid, EFI_NATIVE_INTERFACE, NULL ); ASSERT_EFI_ERROR (Status); // // Register FtwNotificationEvent () notify function. // EfiCreateProtocolNotifyEvent ( &gEfiFaultTolerantWriteProtocolGuid, TPL_CALLBACK, FtwNotificationEvent, (VOID *)SystemTable, &mFtwRegistration ); Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY, VariableClassAddressChangeEvent, NULL, &gEfiEventVirtualAddressChangeGuid, &mVirtualAddressChangeEvent ); ASSERT_EFI_ERROR (Status); // // Register the event handling function to reclaim variable for OS usage. // Status = EfiCreateEventReadyToBootEx ( TPL_NOTIFY, OnReadyToBoot, NULL, &ReadyToBootEvent ); ASSERT_EFI_ERROR (Status); // // Register the event handling function to set the End Of DXE flag. // Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY, OnEndOfDxe, NULL, &gEfiEndOfDxeEventGroupGuid, &EndOfDxeEvent ); ASSERT_EFI_ERROR (Status); return EFI_SUCCESS; }
/** The module Entry Point of the Firmware Performance Data Table DXE driver. @param[in] ImageHandle The firmware allocated handle for the EFI image. @param[in] SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS The entry point is executed successfully. @retval Other Some error occurs when executing this entry point. **/ EFI_STATUS EFIAPI FirmwarePerformanceDxeEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; EFI_HOB_GUID_TYPE *GuidHob; FIRMWARE_SEC_PERFORMANCE *Performance; VOID *Registration; // // Get Report Status Code Handler Protocol. // Status = gBS->LocateProtocol (&gEfiRscHandlerProtocolGuid, NULL, (VOID **) &mRscHandlerProtocol); ASSERT_EFI_ERROR (Status); // // Register report status code listener for OS Loader load and start. // Status = mRscHandlerProtocol->Register (FpdtStatusCodeListenerDxe, TPL_HIGH_LEVEL); ASSERT_EFI_ERROR (Status); // // Register the notify function to update FPDT on ExitBootServices Event. // Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY, FpdtExitBootServicesEventNotify, NULL, &gEfiEventExitBootServicesGuid, &mExitBootServicesEvent ); ASSERT_EFI_ERROR (Status); // // Create ready to boot event to install ACPI FPDT table. // Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY, FpdtReadyToBootEventNotify, NULL, &gEfiEventReadyToBootGuid, &mReadyToBootEvent ); ASSERT_EFI_ERROR (Status); // // Create legacy boot event to log OsLoaderStartImageStart for legacy boot. // Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY, FpdtLegacyBootEventNotify, NULL, &gEfiEventLegacyBootGuid, &mLegacyBootEvent ); ASSERT_EFI_ERROR (Status); // // Retrieve GUID HOB data that contains the ResetEnd. // GuidHob = GetFirstGuidHob (&gEfiFirmwarePerformanceGuid); if (GuidHob != NULL) { Performance = (FIRMWARE_SEC_PERFORMANCE *) GET_GUID_HOB_DATA (GuidHob); mBootPerformanceTableTemplate.BasicBoot.ResetEnd = Performance->ResetEnd; } else { // // SEC Performance Data Hob not found, ResetEnd in ACPI FPDT table will be 0. // DEBUG ((EFI_D_ERROR, "FPDT: WARNING: SEC Performance Data Hob not found, ResetEnd will be set to 0!\n")); } if (FeaturePcdGet (PcdFirmwarePerformanceDataTableS3Support)) { // // Register callback function upon VariableArchProtocol and LockBoxProtocol // to allocate S3 performance table memory and save the pointer to LockBox. // EfiCreateProtocolNotifyEvent ( &gEfiVariableArchProtocolGuid, TPL_CALLBACK, FpdtAllocateS3PerformanceTableMemory, NULL, &Registration ); EfiCreateProtocolNotifyEvent ( &gEfiLockBoxProtocolGuid, TPL_CALLBACK, FpdtAllocateS3PerformanceTableMemory, NULL, &Registration ); } else { // // Exclude S3 Performance Table Pointer from FPDT table template. // mFirmwarePerformanceTableTemplate.Header.Length -= sizeof (EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_POINTER_RECORD); } return EFI_SUCCESS; }