/** The module Entry Point of the Efi System Resource 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 EsrtFmpEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; EFI_EVENT EsrtReadyToBootEvent; // // Register notify function to install ESRT on ReadyToBoot Event. // Status = EfiCreateEventReadyToBootEx ( TPL_CALLBACK, EsrtReadyToBootEventNotify, NULL, &EsrtReadyToBootEvent ); ASSERT_EFI_ERROR (Status); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "EsrtFmpDxe: Failed to register for ready to boot\n")); } 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; }
/** Create an EFI event in the Ready To Boot Event Group. Prior to UEFI 2.0 this was done via a non-standard UEFI extension, and this library abstracts the implementation mechanism of this event from the caller. This function abstracts the creation of the Ready to Boot Event. The Framework moved from a proprietary to UEFI 2.0-based mechanism. This library abstracts the caller from how this event is created to prevent the code form having to change with the version of the specification supported. If ReadyToBootEvent is NULL, then ASSERT(). @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). @retval EFI_SUCCESS Event was created. @retval Other Event was not created. **/ EFI_STATUS EFIAPI EfiCreateEventReadyToBoot ( OUT EFI_EVENT *ReadyToBootEvent ) { return EfiCreateEventReadyToBootEx ( TPL_CALLBACK, InternalEmptyFunction, NULL, ReadyToBootEvent ); }
/** Entry Point for TCG MOR Control driver. @param[in] ImageHandle Image handle of this driver. @param[in] SystemTable A Pointer to the EFI System Table. @retval EFI_SUCEESS @return Others Some error occurs. **/ EFI_STATUS EFIAPI MorDriverEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; UINTN DataSize; EFI_EVENT Event; /// /// The firmware is required to create the MemoryOverwriteRequestControl UEFI variable. /// DataSize = sizeof (mMorControl); Status = gRT->GetVariable ( MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME, &gEfiMemoryOverwriteControlDataGuid, NULL, &DataSize, &mMorControl ); if (EFI_ERROR (Status)) { // // Set default value to 0 // mMorControl = 0; Status = gRT->SetVariable ( MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME, &gEfiMemoryOverwriteControlDataGuid, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, DataSize, &mMorControl ); DEBUG ((EFI_D_INFO, "TcgMor: Create MOR variable! Status = %r\n", Status)); } else { // // Create a Ready To Boot Event and Clear the MorControl bit in the call back function. // DEBUG ((EFI_D_INFO, "TcgMor: Create ReadyToBoot Event for MorControl Bit cleanning!\n")); Status = EfiCreateEventReadyToBootEx ( TPL_CALLBACK, OnReadyToBoot, NULL, &Event ); } return Status; }
/** 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; }
/** Main entry for this driver. @param ImageHandle Image Handle this driver. @param SystemTable Pointer to SystemTable. @retval EFI_SUCESS This function always complete successfully. **/ EFI_STATUS EFIAPI EfiDriverEntryPoint( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE* SystemTable ) { EFI_STATUS Status; EFI_EVENT ReadyToBootEvent; Status = EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, &gOpalDriverBinding, ImageHandle, &gOpalComponentName, &gOpalComponentName2 ); if (EFI_ERROR(Status)) { DEBUG((DEBUG_ERROR, "Install protocols to Opal driver Handle failed\n")); return Status ; } // // Initialize Driver object // ZeroMem(&mOpalDriver, sizeof(mOpalDriver)); mOpalDriver.Handle = ImageHandle; // // register a ReadyToBoot event callback for sending BlockSid command // Status = EfiCreateEventReadyToBootEx ( TPL_CALLBACK, ReadyToBootCallback, (VOID *) &ImageHandle, &ReadyToBootEvent ); // // Install Hii packages. // HiiInstall(); return Status; }
/** Entry point for Acpi platform 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 Driver initialized successfully. @retval EFI_LOAD_ERROR Failed to Initialize or has been loaded. @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources. **/ EFI_STATUS EFIAPI AcpiPlatformEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; EFI_STATUS AcpiStatus; EFI_ACPI_SUPPORT_PROTOCOL *AcpiSupport; EFI_FIRMWARE_VOLUME_PROTOCOL *FwVol; INTN Instance; EFI_ACPI_COMMON_HEADER *CurrentTable; UINTN TableHandle; UINT32 FvStatus; UINT32 Size; EFI_EVENT Event; EFI_ACPI_TABLE_VERSION TableVersion; UINTN VarSize; UINTN SysCfgSize; EFI_HANDLE Handle; EFI_PS2_POLICY_PROTOCOL *Ps2Policy; EFI_PEI_HOB_POINTERS GuidHob; UINT8 PortData; EFI_MP_SERVICES_PROTOCOL *MpService; UINTN MaximumNumberOfCPUs; UINTN NumberOfEnabledCPUs; UINT32 Data32; PCH_STEPPING pchStepping; mFirstNotify = FALSE; TableVersion = EFI_ACPI_TABLE_VERSION_2_0; Instance = 0; CurrentTable = NULL; TableHandle = 0; Data32 = 0; // // Update HOB variable for PCI resource information. // Get the HOB list. If it is not present, then ASSERT. // GuidHob.Raw = GetHobList (); if (GuidHob.Raw != NULL) { if ((GuidHob.Raw = GetNextGuidHob (&gEfiPlatformInfoGuid, GuidHob.Raw)) != NULL) { mPlatformInfo = GET_GUID_HOB_DATA (GuidHob.Guid); } } // // Search for the Memory Configuration GUID HOB. If it is not present, then // there's nothing we can do. It may not exist on the update path. // VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( L"Setup", &mSystemConfigurationGuid, NULL, &VarSize, &mSystemConfiguration ); ASSERT_EFI_ERROR (Status); // // Find the AcpiSupport protocol. // Status = LocateSupportProtocol (&gEfiAcpiSupportProtocolGuid, (VOID **) &AcpiSupport, 0); ASSERT_EFI_ERROR (Status); // // Locate the firmware volume protocol. // Status = LocateSupportProtocol (&gEfiFirmwareVolumeProtocolGuid, (VOID **) &FwVol, 1); ASSERT_EFI_ERROR (Status); // // Read the current system configuration variable store. // SysCfgSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable ( L"Setup", &gEfiNormalSetupGuid, NULL, &SysCfgSize, &mSystemConfig ); Status = EFI_SUCCESS; Instance = 0; // // TBD: Need re-design based on the ValleyTrail platform. // Status = gBS->LocateProtocol ( &gEfiMpServiceProtocolGuid, NULL, (VOID **) &MpService ); if (EFI_ERROR (Status)) { return Status; } // // Determine the number of processors. // MpService->GetNumberOfProcessors ( MpService, &MaximumNumberOfCPUs, &NumberOfEnabledCPUs ); // // Allocate and initialize the NVS area for SMM and ASL communication. // Status = gBS->AllocatePool ( EfiACPIMemoryNVS, sizeof (EFI_GLOBAL_NVS_AREA), (void **)&mGlobalNvsArea.Area ); ASSERT_EFI_ERROR (Status); gBS->SetMem ( mGlobalNvsArea.Area, sizeof (EFI_GLOBAL_NVS_AREA), 0 ); DEBUG((EFI_D_ERROR, "mGlobalNvsArea.Area is at 0x%X\n", mGlobalNvsArea.Area)); // // Update global NVS area for ASL and SMM init code to use. // mGlobalNvsArea.Area->ApicEnable = 1; mGlobalNvsArea.Area->EmaEnable = 0; mGlobalNvsArea.Area->NumberOfBatteries = 1; mGlobalNvsArea.Area->BatteryCapacity0 = 100; mGlobalNvsArea.Area->BatteryStatus0 = 84; mGlobalNvsArea.Area->OnboardCom = 1; mGlobalNvsArea.Area->IdeMode = 0; mGlobalNvsArea.Area->PowerState = 0; mGlobalNvsArea.Area->LogicalProcessorCount = (UINT8)NumberOfEnabledCPUs; mGlobalNvsArea.Area->PassiveThermalTripPoint = mSystemConfiguration.PassiveThermalTripPoint; mGlobalNvsArea.Area->PassiveTc1Value = mSystemConfiguration.PassiveTc1Value; mGlobalNvsArea.Area->PassiveTc2Value = mSystemConfiguration.PassiveTc2Value; mGlobalNvsArea.Area->PassiveTspValue = mSystemConfiguration.PassiveTspValue; mGlobalNvsArea.Area->CriticalThermalTripPoint = mSystemConfiguration.CriticalThermalTripPoint; mGlobalNvsArea.Area->IgdPanelType = mSystemConfiguration.IgdFlatPanel; mGlobalNvsArea.Area->IgdPanelScaling = mSystemConfiguration.PanelScaling; mGlobalNvsArea.Area->IgdSciSmiMode = 0; mGlobalNvsArea.Area->IgdTvFormat = 0; mGlobalNvsArea.Area->IgdTvMinor = 0; mGlobalNvsArea.Area->IgdSscConfig = 1; mGlobalNvsArea.Area->IgdBiaConfig = mSystemConfiguration.IgdLcdIBia; mGlobalNvsArea.Area->IgdBlcConfig = mSystemConfiguration.IgdLcdIGmchBlc; mGlobalNvsArea.Area->IgdDvmtMemSize = mSystemConfiguration.IgdDvmt50TotalAlloc; mGlobalNvsArea.Area->IgdPAVP = mSystemConfiguration.PavpMode; mGlobalNvsArea.Area->AlsEnable = mSystemConfiguration.AlsEnable; mGlobalNvsArea.Area->BacklightControlSupport = 2; mGlobalNvsArea.Area->BrightnessPercentage = 100; mGlobalNvsArea.Area->IgdState = 1; mGlobalNvsArea.Area->LidState = 1; mGlobalNvsArea.Area->DeviceId1 = 0x80000100 ; mGlobalNvsArea.Area->DeviceId2 = 0x80000400 ; mGlobalNvsArea.Area->DeviceId3 = 0x80000200 ; mGlobalNvsArea.Area->DeviceId4 = 0x04; mGlobalNvsArea.Area->DeviceId5 = 0x05; mGlobalNvsArea.Area->NumberOfValidDeviceId = 4 ; mGlobalNvsArea.Area->CurrentDeviceList = 0x0F ; mGlobalNvsArea.Area->PreviousDeviceList = 0x0F ; mGlobalNvsArea.Area->UartSelection = mSystemConfiguration.UartInterface; mGlobalNvsArea.Area->PcuUart1Enable = mSystemConfiguration.PcuUart1; mGlobalNvsArea.Area->NativePCIESupport = 1; // // Update BootMode: 0:ACPI mode; 1:PCI mode // mGlobalNvsArea.Area->LpssSccMode = mSystemConfiguration.LpssPciModeEnabled; if (mSystemConfiguration.LpssMipiHsi == 0) { mGlobalNvsArea.Area->MipiHsiAddr = 0; mGlobalNvsArea.Area->MipiHsiLen = 0; mGlobalNvsArea.Area->MipiHsi1Addr = 0; mGlobalNvsArea.Area->MipiHsi1Len = 0; } // // Platform Flavor // mGlobalNvsArea.Area->PlatformFlavor = mPlatformInfo->PlatformFlavor; // // Update the Platform id // mGlobalNvsArea.Area->BoardID = mPlatformInfo->BoardId; // // Update the Board Revision // mGlobalNvsArea.Area->FabID = mPlatformInfo->BoardRev; // // Update SOC Stepping // mGlobalNvsArea.Area->SocStepping = (UINT8)(PchStepping()); mGlobalNvsArea.Area->OtgMode = mSystemConfiguration.PchUsbOtg; pchStepping = PchStepping(); if (mSystemConfiguration.UsbAutoMode == 1) { // // Auto mode is enabled. // if (PchA0 == pchStepping) { // // For A0, EHCI is enabled as default. // mSystemConfiguration.PchUsb20 = 1; mSystemConfiguration.PchUsb30Mode = 0; mSystemConfiguration.UsbXhciSupport = 0; DEBUG ((EFI_D_INFO, "EHCI is enabled as default. SOC 0x%x\n", pchStepping)); } else { // // For A1 and later, XHCI is enabled as default. // mSystemConfiguration.PchUsb20 = 0; mSystemConfiguration.PchUsb30Mode = 1; mSystemConfiguration.UsbXhciSupport = 1; DEBUG ((EFI_D_INFO, "XHCI is enabled as default. SOC 0x%x\n", pchStepping)); } } mGlobalNvsArea.Area->XhciMode = mSystemConfiguration.PchUsb30Mode; mGlobalNvsArea.Area->Stepping = mPlatformInfo->IchRevision; // // Override invalid Pre-Boot Driver and XhciMode combination. // if ((mSystemConfiguration.UsbXhciSupport == 0) && (mSystemConfiguration.PchUsb30Mode == 3)) { mGlobalNvsArea.Area->XhciMode = 2; } if ((mSystemConfiguration.UsbXhciSupport == 1) && (mSystemConfiguration.PchUsb30Mode == 2)) { mGlobalNvsArea.Area->XhciMode = 3; } DEBUG ((EFI_D_ERROR, "ACPI NVS XHCI:0x%x\n", mGlobalNvsArea.Area->XhciMode)); mGlobalNvsArea.Area->PmicEnable = GLOBAL_NVS_DEVICE_DISABLE; mGlobalNvsArea.Area->BatteryChargingSolution = GLOBAL_NVS_DEVICE_DISABLE; mGlobalNvsArea.Area->ISPDevSel = mSystemConfiguration.ISPDevSel; mGlobalNvsArea.Area->LpeEnable = mSystemConfiguration.Lpe; if (mSystemConfiguration.ISPEn == 0) { mGlobalNvsArea.Area->ISPDevSel = GLOBAL_NVS_DEVICE_DISABLE; } mGlobalNvsArea.Area->WittEnable = mSystemConfiguration.WittEnable; mGlobalNvsArea.Area->UtsEnable = mSystemConfiguration.UtsEnable; mGlobalNvsArea.Area->SarEnable = mSystemConfiguration.SAR1; mGlobalNvsArea.Area->ReservedO = 1; SettingI2CTouchAddress(); mGlobalNvsArea.Area->IdleReserve= mSystemConfiguration.IdleReserve; // // Read BMBOUND and store it in GlobalNVS to pass into ASL. // // BUGBUG: code was moved into silicon reference code. // if (mSystemConfiguration.eMMCBootMode== 1) { // // Auto detect mode. // DEBUG ((EFI_D_ERROR, "Auto detect mode------------start\n")); // // Silicon Steppings. // switch (PchStepping()) { case PchA0: // A0/A1 case PchA1: DEBUG ((EFI_D_ERROR, "SOC A0/A1: eMMC 4.41 Configuration\n")); mSystemConfiguration.LpsseMMCEnabled = 1; mSystemConfiguration.LpsseMMC45Enabled = 0; break; case PchB0: // B0 and later. default: DEBUG ((EFI_D_ERROR, "SOC B0 and later: eMMC 4.5 Configuration\n")); mSystemConfiguration.LpsseMMCEnabled = 0; mSystemConfiguration.LpsseMMC45Enabled = 1; break; } } else if (mSystemConfiguration.eMMCBootMode == 2) { // // eMMC 4.41 // DEBUG ((EFI_D_ERROR, "Force to eMMC 4.41 Configuration\n")); mSystemConfiguration.LpsseMMCEnabled = 1; mSystemConfiguration.LpsseMMC45Enabled = 0; } else if (mSystemConfiguration.eMMCBootMode == 3) { // // eMMC 4.5 // DEBUG ((EFI_D_ERROR, "Force to eMMC 4.5 Configuration\n")); mSystemConfiguration.LpsseMMCEnabled = 0; mSystemConfiguration.LpsseMMC45Enabled = 1; } else { // // Disable eMMC controllers. // DEBUG ((EFI_D_ERROR, "Disable eMMC controllers\n")); mSystemConfiguration.LpsseMMCEnabled = 0; mSystemConfiguration.LpsseMMC45Enabled = 0; } mGlobalNvsArea.Area->emmcVersion = 0; if (mSystemConfiguration.LpsseMMCEnabled) { DEBUG ((EFI_D_ERROR, "mGlobalNvsArea.Area->emmcVersion = 0\n")); mGlobalNvsArea.Area->emmcVersion = 0; } if (mSystemConfiguration.LpsseMMC45Enabled) { DEBUG ((EFI_D_ERROR, "mGlobalNvsArea.Area->emmcVersion = 1\n")); mGlobalNvsArea.Area->emmcVersion = 1; } mGlobalNvsArea.Area->SdCardRemovable = mSystemConfiguration.SdCardRemovable; // // Microsoft IOT // if ((mSystemConfiguration.LpssHsuart0FlowControlEnabled == 1) && \ (mSystemConfiguration.LpssPwm0Enabled == 0) && \ (mSystemConfiguration.LpssPwm1Enabled == 0)) { mGlobalNvsArea.Area->MicrosoftIoT = GLOBAL_NVS_DEVICE_ENABLE; DEBUG ((EFI_D_ERROR, "JP1 is set to be MSFT IOT configuration.\n")); } else { mGlobalNvsArea.Area->MicrosoftIoT = GLOBAL_NVS_DEVICE_DISABLE; DEBUG ((EFI_D_ERROR, "JP1 is not set to be MSFT IOT configuration.\n")); } // // SIO related option. // Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (void **)&mCpuIo); ASSERT_EFI_ERROR (Status); mGlobalNvsArea.Area->WPCN381U = GLOBAL_NVS_DEVICE_DISABLE; mGlobalNvsArea.Area->DockedSioPresent = GLOBAL_NVS_DEVICE_DISABLE; if (mGlobalNvsArea.Area->DockedSioPresent != GLOBAL_NVS_DEVICE_ENABLE) { // // Check ID for SIO WPCN381U. // Status = mCpuIo->Io.Read ( mCpuIo, EfiCpuIoWidthUint8, WPCN381U_CONFIG_INDEX, 1, &PortData ); ASSERT_EFI_ERROR (Status); if (PortData != 0xFF) { PortData = 0x20; Status = mCpuIo->Io.Write ( mCpuIo, EfiCpuIoWidthUint8, WPCN381U_CONFIG_INDEX, 1, &PortData ); ASSERT_EFI_ERROR (Status); Status = mCpuIo->Io.Read ( mCpuIo, EfiCpuIoWidthUint8, WPCN381U_CONFIG_DATA, 1, &PortData ); ASSERT_EFI_ERROR (Status); if ((PortData == WPCN381U_CHIP_ID) || (PortData == WDCP376_CHIP_ID)) { mGlobalNvsArea.Area->WPCN381U = GLOBAL_NVS_DEVICE_ENABLE; mGlobalNvsArea.Area->OnboardCom = GLOBAL_NVS_DEVICE_ENABLE; mGlobalNvsArea.Area->OnboardComCir = GLOBAL_NVS_DEVICE_DISABLE; } } } // // Get Ps2 policy to set. Will be use if present. // Status = gBS->LocateProtocol ( &gEfiPs2PolicyProtocolGuid, NULL, (VOID **)&Ps2Policy ); if (!EFI_ERROR (Status)) { Status = Ps2Policy->Ps2InitHardware (ImageHandle); } mGlobalNvsArea.Area->SDIOMode = mSystemConfiguration.LpssSdioMode; Handle = NULL; Status = gBS->InstallMultipleProtocolInterfaces ( &Handle, &gEfiGlobalNvsAreaProtocolGuid, &mGlobalNvsArea, NULL ); // // Read tables from the storage file. // while (!EFI_ERROR (Status)) { CurrentTable = NULL; Status = FwVol->ReadSection ( FwVol, &gEfiAcpiTableStorageGuid, EFI_SECTION_RAW, Instance, (VOID **) &CurrentTable, (UINTN *) &Size, &FvStatus ); if (!EFI_ERROR (Status)) { // // Allow platform specific code to reject the table or update it. // AcpiStatus = AcpiPlatformHooksIsActiveTable (CurrentTable); if (!EFI_ERROR (AcpiStatus)) { // // Perform any table specific updates. // AcpiStatus = PlatformUpdateTables (CurrentTable); if (!EFI_ERROR (AcpiStatus)) { // // Add the table. // TableHandle = 0; AcpiStatus = AcpiSupport->SetAcpiTable ( AcpiSupport, CurrentTable, TRUE, TableVersion, &TableHandle ); ASSERT_EFI_ERROR (AcpiStatus); } } // // Increment the instance. // Instance++; } } Status = EfiCreateEventReadyToBootEx ( TPL_NOTIFY, OnReadyToBoot, NULL, &Event ); // // Finished. // return EFI_SUCCESS; }
/** 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; }
/** 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; }
/** Main entry for the Coreboot Support DXE module. @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 CbDxeEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; EFI_EVENT ReadyToBootEvent; EFI_HOB_GUID_TYPE *GuidHob; SYSTEM_TABLE_INFO *pSystemTableInfo; ACPI_BOARD_INFO *pAcpiBoardInfo; Status = EFI_SUCCESS; // // Report MMIO/IO Resources // Status = CbReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFEE00000, SIZE_1MB, 0, SystemTable); // LAPIC ASSERT_EFI_ERROR (Status); Status = CbReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFEC00000, SIZE_4KB, 0, SystemTable); // IOAPIC ASSERT_EFI_ERROR (Status); Status = CbReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFED00000, SIZE_1KB, 0, SystemTable); // HPET ASSERT_EFI_ERROR (Status); // // Find the system table information guid hob // GuidHob = GetFirstGuidHob (&gUefiSystemTableInfoGuid); ASSERT (GuidHob != NULL); pSystemTableInfo = (SYSTEM_TABLE_INFO *)GET_GUID_HOB_DATA (GuidHob); // // Install Acpi Table // if (pSystemTableInfo->AcpiTableBase != 0 && pSystemTableInfo->AcpiTableSize != 0) { DEBUG ((EFI_D_ERROR, "Install Acpi Table at 0x%x, length 0x%x\n", (UINTN)pSystemTableInfo->AcpiTableBase, pSystemTableInfo->AcpiTableSize)); Status = gBS->InstallConfigurationTable (&gEfiAcpiTableGuid, (VOID *)(UINTN)pSystemTableInfo->AcpiTableBase); ASSERT_EFI_ERROR (Status); } // // Install Smbios Table // if (pSystemTableInfo->SmbiosTableBase != 0 && pSystemTableInfo->SmbiosTableSize != 0) { DEBUG ((EFI_D_ERROR, "Install Smbios Table at 0x%x, length 0x%x\n", (UINTN)pSystemTableInfo->SmbiosTableBase, pSystemTableInfo->SmbiosTableSize)); Status = gBS->InstallConfigurationTable (&gEfiSmbiosTableGuid, (VOID *)(UINTN)pSystemTableInfo->SmbiosTableBase); ASSERT_EFI_ERROR (Status); } // // Find the acpi board information guid hob // GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid); ASSERT (GuidHob != NULL); pAcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob); mPmCtrlReg = (UINTN)pAcpiBoardInfo->PmCtrlRegBase; DEBUG ((EFI_D_ERROR, "PmCtrlReg at 0x%x\n", mPmCtrlReg)); // // Register callback on the ready to boot event // in order to enable SCI // ReadyToBootEvent = NULL; Status = EfiCreateEventReadyToBootEx ( TPL_CALLBACK, OnReadyToBoot, NULL, &ReadyToBootEvent ); ASSERT_EFI_ERROR (Status); return EFI_SUCCESS; }
/********************************************************************************* * Name: FchDxeInit * * Description * Entry point of the AMD FCH DXE driver * Perform the configuration init, resource reservation, early post init * and install all the supported protocol * * Input * ImageHandle : EFI Image Handle for the DXE driver * SystemTable : pointer to the EFI system table * * Output * EFI_SUCCESS : Module initialized successfully * EFI_ERROR : Initialization failed (see error for more details) * *********************************************************************************/ EFI_STATUS EFIAPI FchDxeInit ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { FCH_DXE_PRIVATE *FchPrivate; EFI_STATUS Status; EFI_HANDLE Handle; FCH_DATA_BLOCK *FchDataBlock; // // Initialize EFI library // // // Initialize the configuration structure and private data area // // Allocate memory for the private data Status = gBS->AllocatePool ( EfiACPIMemoryNVS, sizeof (FCH_DXE_PRIVATE), &FchPrivate ); ASSERT_EFI_ERROR (Status); // Initialize the private data structure FchPrivate->Signature = FCH_DXE_PRIVATE_DATA_SIGNATURE; // Initialize the FCHInit protocol FchPrivate->FchInit.Revision = FCH_INIT_REV; FchPrivate->FchInit.FchRev = FCH_VERSION; FchPrivate->FchInit.FpUsbOverCurrent = UsbOverCurrentControl; FchDataBlock = FchLocateHeapBuffer (); gBS->CopyMem ( &FchPrivate->FchInit.FchPolicy, FchDataBlock, sizeof (FCH_DATA_BLOCK) ); // // Publish the FCHInit protocol // Handle = ImageHandle; Status = gBS->InstallProtocolInterface ( &Handle, &gFchInitProtocolGuid, EFI_NATIVE_INTERFACE, &FchPrivate->FchInit ); if (EFI_ERROR (Status)) { return (Status); } Status = EfiCreateEventReadyToBootEx ( TPL_CALLBACK, FchInitOnReadyToBoot, (VOID*) &(FchPrivate->FchInit.FchPolicy), &FchPrivate->EventReadyToBoot ); Handle = ImageHandle; Status = gBS->InstallProtocolInterface ( &Handle, &gFchInitDonePolicyProtocolGuid, EFI_NATIVE_INTERFACE, NULL ); return (Status); }
EFI_STATUS EFIAPI SmmAccessDriverEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) /*++ Routine Description: Installs an SMM Access Protocol. Arguments: ImageHandle - Handle for the image of this driver. SystemTable - Pointer to the EFI System Table. Returns: EFI_SUCCESS - Protocol successfully started and installed. EFI_UNSUPPORTED - Protocol can't be started. EFI_NOT_FOUND - Protocol not found. --*/ { EFI_STATUS Status; EFI_EVENT BootEvent; EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo; UINTN Index; EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *DescriptorBlock; EFI_HOB_GUID_TYPE *GuidHob; // // Initialize private data // ZeroMem (&mSmmAccess, sizeof (mSmmAccess)); Status = gBS->LocateProtocol ( &gEfiPciRootBridgeIoProtocolGuid, NULL, (VOID **) &PciRootBridgeIo ); ASSERT_EFI_ERROR (Status); // // Build SMM related information // mSmmAccess.Signature = SMM_ACCESS_PRIVATE_DATA_SIGNATURE; mSmmAccess.Handle = NULL; mSmmAccess.PciRootBridgeIo = PciRootBridgeIo; // // Get Hob list // GuidHob = GetFirstGuidHob (&gEfiSmmPeiSmramMemoryReserveGuid); DescriptorBlock = GET_GUID_HOB_DATA (GuidHob); ASSERT (DescriptorBlock); // // Get CPU Max bus number // mSmmAccess.MaxBusNumber = PCI_BUS_NUMBER_QNC; for (Index = 0; Index < MAX_CPU_SOCKET; Index++) { mSmmAccess.SocketPopulated[Index] = TRUE; } // // Use the hob to publish SMRAM capabilities // ASSERT (DescriptorBlock->NumberOfSmmReservedRegions <= MAX_SMRAM_RANGES); for (Index = 0; Index < DescriptorBlock->NumberOfSmmReservedRegions; Index++) { mSmmAccess.SmramDesc[Index].PhysicalStart = DescriptorBlock->Descriptor[Index].PhysicalStart; mSmmAccess.SmramDesc[Index].CpuStart = DescriptorBlock->Descriptor[Index].CpuStart; mSmmAccess.SmramDesc[Index].PhysicalSize = DescriptorBlock->Descriptor[Index].PhysicalSize; mSmmAccess.SmramDesc[Index].RegionState = DescriptorBlock->Descriptor[Index].RegionState; DEBUG ((EFI_D_INFO, "SM RAM index[%d] startaddr:%08X Size :%08X\n", Index, mSmmAccess.SmramDesc[Index].CpuStart, mSmmAccess.SmramDesc[Index].PhysicalSize)); } mSmmAccess.NumberRegions = Index; mSmmAccess.SmmAccess.Open = Open; mSmmAccess.SmmAccess.Close = Close; mSmmAccess.SmmAccess.Lock = Lock; mSmmAccess.SmmAccess.GetCapabilities = GetCapabilities; mSmmAccess.SmmAccess.LockState = FALSE; mSmmAccess.SmmAccess.OpenState = FALSE; mSmmAccess.SMMRegionState = EFI_SMRAM_CLOSED; // // Install our protocol interfaces on the device's handle // Status = gBS->InstallMultipleProtocolInterfaces ( &mSmmAccess.Handle, &gEfiSmmAccess2ProtocolGuid, &mSmmAccess.SmmAccess, NULL ); ASSERT_EFI_ERROR (Status); DEBUG ((EFI_D_INFO, "SMM Base: %08X\n", (UINT32)(mSmmAccess.SmramDesc[mSmmAccess.NumberRegions-1].PhysicalStart))); DEBUG ((EFI_D_INFO, "SMM Size: %08X\n", (UINT32)(mSmmAccess.SmramDesc[mSmmAccess.NumberRegions-1].PhysicalSize))); mSmmAccess.TsegSize = (UINT8)(mSmmAccess.SmramDesc[mSmmAccess.NumberRegions-1].PhysicalSize); // // T Seg setting done in QPI RC // // // Prior ReadyToBoot, lock CSEG // Status = EfiCreateEventReadyToBootEx( TPL_NOTIFY, SmmAccessOnBoot, NULL, &BootEvent ); ASSERT (!EFI_ERROR (Status)); return EFI_SUCCESS; }
/******************************************************************************** * Name: AmdFchWheaInitEntry * * Description * AmdFchWheaInit Entrypoint * * Input * ImageHandle : EFI Image Handle for the DXE driver * SystemTable : pointer to the EFI system table * * Output * EFI_SUCCESS : Module initialized successfully * EFI_ERROR : Initialization failed (see error for more details) * *********************************************************************************/ EFI_STATUS AmdFchWheaInitEntry ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; FCH_INIT_PROTOCOL *AmdFchInit; EFI_EVENT InstallAmdTableEvent; EFI_HANDLE Handle; UINT8 *buffer; Status = gBS->LocateProtocol ( &gFchInitProtocolGuid, NULL, &AmdFchInit ); ASSERT_EFI_ERROR (Status); if (AmdFchInit->FchPolicy.Gpp.PcieAer == 0) { return Status; } Status = EfiCreateEventReadyToBootEx ( TPL_CALLBACK, AmdWheaCheckInstallTables, NULL, &InstallAmdTableEvent ); // // Allocate memory and Initialize for Data block // Status = gBS->AllocatePool ( EfiReservedMemoryType, sizeof (AMD_FCH_WHEA_EINJ_BUFFER), (VOID **)&buffer ); if (EFI_ERROR (Status)) { return Status; } ZeroMem (buffer, sizeof (AMD_FCH_WHEA_EINJ_BUFFER)); mEinjData = (AMD_FCH_WHEA_EINJ_BUFFER *)buffer; mEinjData->Valid = FALSE; mEinjData->PlatformEinjValid = FALSE; // // Allocate memory and Initialize for Error Data block // Status = gBS->AllocatePool ( EfiReservedMemoryType, MAX_ERROR_BLOCK_SIZE, (VOID **)&buffer ); if (EFI_ERROR (Status)) { return Status; } ZeroMem (buffer, MAX_ERROR_BLOCK_SIZE); mEinjData->AmdHwErrBlk = (GENERIC_ERROR_STATUS_BLOCK *)buffer; AmdErrBlkAddressUpdate (); Handle = ImageHandle; Status = gBS->InstallProtocolInterface ( &Handle, &gEfiAmdFchWheaDataProtocolGuid, EFI_NATIVE_INTERFACE, mEinjData ); if (EFI_ERROR (Status)) { return (Status); } return Status; }