X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FCore%2FDxe%2FDxeMain%2FDxeMain.c;h=1ac5cc17212d590479723f9216e85e3f69852fe3;hp=36a7ec6be6ba8b80cb4c93027ff7d6f4308efefe;hb=84edd20bd0756ef5719835498d4283435d6b5e77;hpb=0803854bc1e211dded35c5c02d0428285a2da407 diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c index 36a7ec6be6..1ac5cc1721 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 - 2010, 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,6 +23,7 @@ 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; @@ -215,8 +216,8 @@ 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 +// 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}; @@ -237,15 +238,38 @@ 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 // CoreInitializeMemoryServices (&HobStart, &MemoryBaseAddress, &MemoryLength); + MemoryProfileInit (HobStart); + // // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table @@ -271,6 +295,14 @@ DxeMain ( PERF_END (NULL,"PEI", NULL, 0) ; PERF_START (NULL,"DXE", NULL, 0) ; + // + // Report DXE Core image information to the PE/COFF Extra Action Library + // + ZeroMem (&ImageContext, sizeof (ImageContext)); + ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)gDxeCoreLoadedImage->ImageBase; + ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageContext.ImageAddress); + PeCoffLoaderRelocateImageExtraAction (&ImageContext); + // // Initialize the Global Coherency Domain Services // @@ -294,11 +326,11 @@ DxeMain ( // Status = CoreInstallConfigurationTable (&gEfiMemoryTypeInformationGuid, &gMemoryTypeInformation); ASSERT_EFI_ERROR (Status); - + // - // If Loading modules At fixed address feature is enabled, install Load moduels at fixed address + // 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. + // Code and Tseg base to load SMM driver. // if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0) { Status = CoreInstallConfigurationTable (&gLoadFixedAddressConfigurationTableGuid, &gLoadModuleAtFixAddressConfigurationTable); @@ -331,7 +363,7 @@ DxeMain ( 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 %08x %0lx - %0lx\n", \ + 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)); @@ -339,9 +371,9 @@ DxeMain ( } 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 %08x %0lx - %0lx\n", Hob.FirmwareVolume2->BaseAddress, Hob.FirmwareVolume2->BaseAddress + Hob.FirmwareVolume2->Length - 1, Hob.ResourceDescriptor->ResourceType)); + 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 %08x %0lx - %0lx\n", Hob.FirmwareVolume->BaseAddress, Hob.FirmwareVolume->BaseAddress + Hob.FirmwareVolume2->Length - 1, Hob.ResourceDescriptor->ResourceType)); + 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 (); @@ -352,6 +384,26 @@ DxeMain ( Status = CoreInitializeEventServices (); ASSERT_EFI_ERROR (Status); + MemoryProfileInstallProtocol (); + + // + // 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 @@ -378,8 +430,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. @@ -428,7 +481,17 @@ 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 @@ -661,29 +724,28 @@ CoreExitBootServices ( { EFI_STATUS Status; + // + // Disable Timer + // + gTimer->SetTimerPeriod (gTimer, 0); + // // Terminate memory services if the MapKey matches // Status = CoreTerminateMemoryMap (MapKey); if (EFI_ERROR (Status)) { + // + // Notify other drivers that ExitBootServices fail + // + CoreNotifySignalList (&gEventExitBootServicesFailedGuid); return Status; } - // - // Disable Timer - // - gTimer->SetTimerPeriod (gTimer, 0); - // // Notify other drivers that we are exiting boot services. // CoreNotifySignalList (&gEfiEventExitBootServicesGuid); - // - // Disable CPU Interrupts - // - gCpu->DisableInterrupt (gCpu); - // // Report that ExitBootServices() has been called // @@ -692,6 +754,16 @@ CoreExitBootServices ( (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES) ); + // + // Disable interrupt of Debug timer. + // + SaveAndSetDebugTimerInterrupt (FALSE); + + // + // Disable CPU Interrupts + // + gCpu->DisableInterrupt (gCpu); + // // Clear the non-runtime values of the EFI System Table // @@ -789,7 +861,7 @@ DxeMainUefiDecompressGetInfo ( implementation. It is the caller's responsibility to allocate and free the Destination and Scratch buffers. If the compressed source data specified by Source and SourceSize is - sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If + successfully decompressed into Destination, then EFI_SUCCESS is returned. If the compressed source data specified by Source and SourceSize is not in a valid compressed data format, then EFI_INVALID_PARAMETER is returned.