X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FCore%2FDxe%2FDxeMain%2FDxeMain.c;h=d8c7cd02491cfcd6a715dcbd1ef01a72c4c26a14;hp=68fcca483d021c6d6f86c4f7e055ccce33b9b1ec;hb=e4c83a4f9cad7f2c362727cdeb3f5daf297ec270;hpb=bc6b5892b007447b1024d98004681aa7a3305ddf diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c index 68fcca483d..d8c7cd0249 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -1,8 +1,8 @@ /** @file DXE Core Main Entry Point -Copyright (c) 2006 - 2008, Intel Corporation.
-All rights reserved. This program and the accompanying materials +Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -23,12 +23,18 @@ EFI_HANDLE mDecompressHandle = NULL; // DXE Core globals for Architecture Protocols // EFI_SECURITY_ARCH_PROTOCOL *gSecurity = NULL; +EFI_SECURITY2_ARCH_PROTOCOL *gSecurity2 = NULL; EFI_CPU_ARCH_PROTOCOL *gCpu = NULL; EFI_METRONOME_ARCH_PROTOCOL *gMetronome = NULL; EFI_TIMER_ARCH_PROTOCOL *gTimer = NULL; EFI_BDS_ARCH_PROTOCOL *gBds = NULL; EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer = NULL; +// +// DXE Core globals for optional protocol dependencies +// +EFI_SMM_BASE2_PROTOCOL *gSmmBase2 = NULL; + // // DXE Core Global used to update core loaded image protocol handle // @@ -210,6 +216,11 @@ EFI_DECOMPRESS_PROTOCOL gEfiDecompress = { }; // +// For Loading modules at fixed address feature, the configuration table is to cache the top address below which to load +// Runtime code&boot time code +// +GLOBAL_REMOVE_IF_UNREFERENCED EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable = {0, 0}; + // Main entry point to the DXE Core // @@ -227,9 +238,30 @@ DxeMain ( IN VOID *HobStart ) { - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS MemoryBaseAddress; - UINT64 MemoryLength; + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS MemoryBaseAddress; + UINT64 MemoryLength; + PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; + UINTN Index; + EFI_HOB_GUID_TYPE *GuidHob; + EFI_VECTOR_HANDOFF_INFO *VectorInfoList; + EFI_VECTOR_HANDOFF_INFO *VectorInfo; + + // + // Setup the default exception handlers + // + VectorInfoList = NULL; + GuidHob = GetNextGuidHob (&gEfiVectorHandoffInfoPpiGuid, HobStart); + if (GuidHob != NULL) { + VectorInfoList = (EFI_VECTOR_HANDOFF_INFO *) (GET_GUID_HOB_DATA(GuidHob)); + } + Status = InitializeCpuExceptionHandlers (VectorInfoList); + ASSERT_EFI_ERROR (Status); + + // + // Initialize Debug Agent to support source level debug in DXE phase + // + InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_CORE, HobStart, NULL); // // Initialize Memory Services @@ -258,8 +290,15 @@ DxeMain ( // Call constructor for all libraries // ProcessLibraryConstructorList (gDxeCoreImageHandle, gDxeCoreST); - PERF_END (0,"PEI", NULL, 0) ; - PERF_START (0,"DXE", NULL, 0) ; + PERF_END (NULL,"PEI", NULL, 0) ; + PERF_START (NULL,"DXE", NULL, 0) ; + + // + // Report DXE Core image information to the PE/COFF Extra Action Library + // + ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)gDxeCoreLoadedImage->ImageBase; + ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageContext.ImageAddress); + PeCoffLoaderRelocateImageExtraAction (&ImageContext); // // Initialize the Global Coherency Domain Services @@ -285,12 +324,21 @@ DxeMain ( Status = CoreInstallConfigurationTable (&gEfiMemoryTypeInformationGuid, &gMemoryTypeInformation); ASSERT_EFI_ERROR (Status); + // + // If Loading modules At fixed address feature is enabled, install Load moduels at fixed address + // Configuration Table so that user could easily to retrieve the top address to load Dxe and PEI + // Code and Tseg base to load SMM driver. + // + if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0) { + Status = CoreInstallConfigurationTable (&gLoadFixedAddressConfigurationTableGuid, &gLoadModuleAtFixAddressConfigurationTable); + ASSERT_EFI_ERROR (Status); + } // // Report Status Code here for DXE_ENTRY_POINT once it is available // REPORT_STATUS_CODE ( EFI_PROGRESS_CODE, - FixedPcdGet32(PcdStatusCodeValueDxeCoreEntry) + (EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_ENTRY_POINT) ); // @@ -307,12 +355,50 @@ DxeMain ( DEBUG ((DEBUG_INFO | DEBUG_LOAD, "HOBLIST address in DXE = 0x%p\n", HobStart)); + DEBUG_CODE_BEGIN (); + EFI_PEI_HOB_POINTERS Hob; + + for (Hob.Raw = HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) { + if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_MEMORY_ALLOCATION) { + DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Memory Allocation 0x%08x 0x%0lx - 0x%0lx\n", \ + Hob.MemoryAllocation->AllocDescriptor.MemoryType, \ + Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress, \ + Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress + Hob.MemoryAllocation->AllocDescriptor.MemoryLength - 1)); + } + } + for (Hob.Raw = HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) { + if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV2) { + DEBUG ((DEBUG_INFO | DEBUG_LOAD, "FV2 Hob 0x%0lx - 0x%0lx\n", Hob.FirmwareVolume2->BaseAddress, Hob.FirmwareVolume2->BaseAddress + Hob.FirmwareVolume2->Length - 1)); + } else if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV) { + DEBUG ((DEBUG_INFO | DEBUG_LOAD, "FV Hob 0x%0lx - 0x%0lx\n", Hob.FirmwareVolume->BaseAddress, Hob.FirmwareVolume->BaseAddress + Hob.FirmwareVolume2->Length - 1)); + } + } + DEBUG_CODE_END (); + // // Initialize the Event Services // Status = CoreInitializeEventServices (); ASSERT_EFI_ERROR (Status); + // + // Get persisted vector hand-off info from GUIDeed HOB again due to HobStart may be updated, + // and install configuration table + // + GuidHob = GetNextGuidHob (&gEfiVectorHandoffInfoPpiGuid, HobStart); + if (GuidHob != NULL) { + VectorInfoList = (EFI_VECTOR_HANDOFF_INFO *) (GET_GUID_HOB_DATA(GuidHob)); + VectorInfo = VectorInfoList; + Index = 1; + while (VectorInfo->Attribute != EFI_VECTOR_HANDOFF_LAST_ENTRY) { + VectorInfo ++; + Index ++; + } + VectorInfo = AllocateCopyPool (sizeof (EFI_VECTOR_HANDOFF_INFO) * Index, (VOID *) VectorInfoList); + ASSERT (VectorInfo != NULL); + Status = CoreInstallConfigurationTable (&gEfiVectorHandoffTableGuid, (VOID *) VectorInfo); + ASSERT_EFI_ERROR (Status); + } // // Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs @@ -339,8 +425,9 @@ DxeMain ( // // Register for the GUIDs of the Architectural Protocols, so the rest of the // EFI Boot Services and EFI Runtime Services tables can be filled in. + // Also register for the GUIDs of optional protocols. // - CoreNotifyOnArchProtocolInstallation (); + CoreNotifyOnProtocolInstallation (); // // Produce Firmware Volume Protocols, one for each FV in the HOB list. @@ -360,16 +447,16 @@ DxeMain ( // // Initialize the DXE Dispatcher // - PERF_START (0,"CoreInitializeDispatcher", "DxeMain", 0) ; + PERF_START (NULL,"CoreInitializeDispatcher", "DxeMain", 0) ; CoreInitializeDispatcher (); - PERF_END (0,"CoreInitializeDispatcher", "DxeMain", 0) ; + PERF_END (NULL,"CoreInitializeDispatcher", "DxeMain", 0) ; // // Invoke the DXE Dispatcher // - PERF_START (0, "CoreDispatcher", "DxeMain", 0); + PERF_START (NULL, "CoreDispatcher", "DxeMain", 0); CoreDispatcher (); - PERF_END (0, "CoreDispatcher", "DxeMain", 0); + PERF_END (NULL, "CoreDispatcher", "DxeMain", 0); // // Display Architectural protocols that were not loaded if this is DEBUG build @@ -389,14 +476,24 @@ DxeMain ( // // Assert if the Architectural Protocols are not present. // - ASSERT_EFI_ERROR (CoreAllEfiServicesAvailable ()); + Status = CoreAllEfiServicesAvailable (); + if (EFI_ERROR(Status)) { + // + // Report Status code that some Architectural Protocols are not present. + // + REPORT_STATUS_CODE ( + EFI_ERROR_CODE | EFI_ERROR_MAJOR, + (EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_EC_NO_ARCH) + ); + } + ASSERT_EFI_ERROR (Status); // // Report Status code before transfer control to BDS // REPORT_STATUS_CODE ( EFI_PROGRESS_CODE, - FixedPcdGet32 (PcdStatusCodeValueDxeCoreHandoffToBds) + (EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT) ); // @@ -621,23 +718,11 @@ CoreExitBootServices ( ) { EFI_STATUS Status; - EFI_STATUS StatusTemp; - EFI_TCG_PLATFORM_PROTOCOL *TcgPlatformProtocol; // - // Measure invocation of ExitBootServices, - // which is defined by TCG_EFI_Platform_1_20_Final Specification + // Disable Timer // - TcgPlatformProtocol = NULL; - Status = CoreLocateProtocol ( - &gEfiTcgPlatformProtocolGuid, - NULL, - (VOID **) &TcgPlatformProtocol - ); - if (!EFI_ERROR (Status)) { - Status = TcgPlatformProtocol->MeasureAction (EFI_EXIT_BOOT_SERVICES_INVOCATION); - ASSERT_EFI_ERROR (Status); - } + gTimer->SetTimerPeriod (gTimer, 0); // // Terminate memory services if the MapKey matches @@ -645,13 +730,9 @@ CoreExitBootServices ( Status = CoreTerminateMemoryMap (MapKey); if (EFI_ERROR (Status)) { // - // Measure failure of ExitBootServices + // Notify other drivers that ExitBootServices fail // - if (TcgPlatformProtocol != NULL) { - StatusTemp = TcgPlatformProtocol->MeasureAction (EFI_EXIT_BOOT_SERVICES_FAILED); - ASSERT_EFI_ERROR (StatusTemp); - } - + CoreNotifySignalList (&gEventExitBootServicesFailedGuid); return Status; } @@ -661,22 +742,22 @@ CoreExitBootServices ( CoreNotifySignalList (&gEfiEventExitBootServicesGuid); // - // Disable Timer + // Report that ExitBootServices() has been called // - gTimer->SetTimerPeriod (gTimer, 0); + REPORT_STATUS_CODE ( + EFI_PROGRESS_CODE, + (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES) + ); // - // Disable CPU Interrupts + // Disable interrupt of Debug timer. // - gCpu->DisableInterrupt (gCpu); + SaveAndSetDebugTimerInterrupt (FALSE); // - // Report that ExitBootServices() has been called + // Disable CPU Interrupts // - REPORT_STATUS_CODE ( - EFI_PROGRESS_CODE, - FixedPcdGet32 (PcdStatusCodeValueBootServiceExit) - ); + gCpu->DisableInterrupt (gCpu); // // Clear the non-runtime values of the EFI System Table @@ -705,14 +786,6 @@ CoreExitBootServices ( // gRuntime->AtRuntime = TRUE; - // - // Measure success of ExitBootServices - // - if (TcgPlatformProtocol != NULL) { - StatusTemp = TcgPlatformProtocol->MeasureAction (EFI_EXIT_BOOT_SERVICES_SUCCEEDED); - ASSERT_EFI_ERROR (StatusTemp); - } - return Status; }