2009-08-24 17:35:55 +02:00
|
|
|
/** @file
|
|
|
|
DXE Core Main Entry Point
|
|
|
|
|
2018-03-19 08:02:59 +01:00
|
|
|
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
2019-04-04 01:05:13 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2009-08-24 17:35:55 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "DxeMain.h"
|
|
|
|
|
|
|
|
//
|
|
|
|
// DXE Core Global Variables for Protocols from PEI
|
|
|
|
//
|
|
|
|
EFI_HANDLE mDecompressHandle = NULL;
|
|
|
|
|
|
|
|
//
|
|
|
|
// DXE Core globals for Architecture Protocols
|
|
|
|
//
|
|
|
|
EFI_SECURITY_ARCH_PROTOCOL *gSecurity = NULL;
|
2012-08-22 04:32:12 +02:00
|
|
|
EFI_SECURITY2_ARCH_PROTOCOL *gSecurity2 = NULL;
|
2009-08-24 17:35:55 +02:00
|
|
|
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;
|
|
|
|
|
2010-02-13 02:57:22 +01:00
|
|
|
//
|
|
|
|
// DXE Core globals for optional protocol dependencies
|
|
|
|
//
|
|
|
|
EFI_SMM_BASE2_PROTOCOL *gSmmBase2 = NULL;
|
|
|
|
|
2009-08-24 17:35:55 +02:00
|
|
|
//
|
|
|
|
// DXE Core Global used to update core loaded image protocol handle
|
|
|
|
//
|
|
|
|
EFI_GUID *gDxeCoreFileName;
|
|
|
|
EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage;
|
|
|
|
|
|
|
|
//
|
|
|
|
// DXE Core Module Variables
|
|
|
|
//
|
|
|
|
EFI_BOOT_SERVICES mBootServices = {
|
|
|
|
{
|
|
|
|
EFI_BOOT_SERVICES_SIGNATURE, // Signature
|
|
|
|
EFI_BOOT_SERVICES_REVISION, // Revision
|
|
|
|
sizeof (EFI_BOOT_SERVICES), // HeaderSize
|
|
|
|
0, // CRC32
|
|
|
|
0 // Reserved
|
|
|
|
},
|
|
|
|
(EFI_RAISE_TPL) CoreRaiseTpl, // RaiseTPL
|
|
|
|
(EFI_RESTORE_TPL) CoreRestoreTpl, // RestoreTPL
|
|
|
|
(EFI_ALLOCATE_PAGES) CoreAllocatePages, // AllocatePages
|
|
|
|
(EFI_FREE_PAGES) CoreFreePages, // FreePages
|
|
|
|
(EFI_GET_MEMORY_MAP) CoreGetMemoryMap, // GetMemoryMap
|
|
|
|
(EFI_ALLOCATE_POOL) CoreAllocatePool, // AllocatePool
|
|
|
|
(EFI_FREE_POOL) CoreFreePool, // FreePool
|
|
|
|
(EFI_CREATE_EVENT) CoreCreateEvent, // CreateEvent
|
|
|
|
(EFI_SET_TIMER) CoreSetTimer, // SetTimer
|
|
|
|
(EFI_WAIT_FOR_EVENT) CoreWaitForEvent, // WaitForEvent
|
|
|
|
(EFI_SIGNAL_EVENT) CoreSignalEvent, // SignalEvent
|
|
|
|
(EFI_CLOSE_EVENT) CoreCloseEvent, // CloseEvent
|
|
|
|
(EFI_CHECK_EVENT) CoreCheckEvent, // CheckEvent
|
|
|
|
(EFI_INSTALL_PROTOCOL_INTERFACE) CoreInstallProtocolInterface, // InstallProtocolInterface
|
|
|
|
(EFI_REINSTALL_PROTOCOL_INTERFACE) CoreReinstallProtocolInterface, // ReinstallProtocolInterface
|
|
|
|
(EFI_UNINSTALL_PROTOCOL_INTERFACE) CoreUninstallProtocolInterface, // UninstallProtocolInterface
|
|
|
|
(EFI_HANDLE_PROTOCOL) CoreHandleProtocol, // HandleProtocol
|
|
|
|
(VOID *) NULL, // Reserved
|
|
|
|
(EFI_REGISTER_PROTOCOL_NOTIFY) CoreRegisterProtocolNotify, // RegisterProtocolNotify
|
|
|
|
(EFI_LOCATE_HANDLE) CoreLocateHandle, // LocateHandle
|
|
|
|
(EFI_LOCATE_DEVICE_PATH) CoreLocateDevicePath, // LocateDevicePath
|
|
|
|
(EFI_INSTALL_CONFIGURATION_TABLE) CoreInstallConfigurationTable, // InstallConfigurationTable
|
|
|
|
(EFI_IMAGE_LOAD) CoreLoadImage, // LoadImage
|
|
|
|
(EFI_IMAGE_START) CoreStartImage, // StartImage
|
|
|
|
(EFI_EXIT) CoreExit, // Exit
|
|
|
|
(EFI_IMAGE_UNLOAD) CoreUnloadImage, // UnloadImage
|
|
|
|
(EFI_EXIT_BOOT_SERVICES) CoreExitBootServices, // ExitBootServices
|
|
|
|
(EFI_GET_NEXT_MONOTONIC_COUNT) CoreEfiNotAvailableYetArg1, // GetNextMonotonicCount
|
|
|
|
(EFI_STALL) CoreStall, // Stall
|
|
|
|
(EFI_SET_WATCHDOG_TIMER) CoreSetWatchdogTimer, // SetWatchdogTimer
|
|
|
|
(EFI_CONNECT_CONTROLLER) CoreConnectController, // ConnectController
|
|
|
|
(EFI_DISCONNECT_CONTROLLER) CoreDisconnectController, // DisconnectController
|
|
|
|
(EFI_OPEN_PROTOCOL) CoreOpenProtocol, // OpenProtocol
|
|
|
|
(EFI_CLOSE_PROTOCOL) CoreCloseProtocol, // CloseProtocol
|
|
|
|
(EFI_OPEN_PROTOCOL_INFORMATION) CoreOpenProtocolInformation, // OpenProtocolInformation
|
|
|
|
(EFI_PROTOCOLS_PER_HANDLE) CoreProtocolsPerHandle, // ProtocolsPerHandle
|
|
|
|
(EFI_LOCATE_HANDLE_BUFFER) CoreLocateHandleBuffer, // LocateHandleBuffer
|
|
|
|
(EFI_LOCATE_PROTOCOL) CoreLocateProtocol, // LocateProtocol
|
|
|
|
(EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) CoreInstallMultipleProtocolInterfaces, // InstallMultipleProtocolInterfaces
|
|
|
|
(EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) CoreUninstallMultipleProtocolInterfaces, // UninstallMultipleProtocolInterfaces
|
|
|
|
(EFI_CALCULATE_CRC32) CoreEfiNotAvailableYetArg3, // CalculateCrc32
|
|
|
|
(EFI_COPY_MEM) CopyMem, // CopyMem
|
|
|
|
(EFI_SET_MEM) SetMem, // SetMem
|
|
|
|
(EFI_CREATE_EVENT_EX) CoreCreateEventEx // CreateEventEx
|
|
|
|
};
|
|
|
|
|
|
|
|
EFI_DXE_SERVICES mDxeServices = {
|
|
|
|
{
|
|
|
|
DXE_SERVICES_SIGNATURE, // Signature
|
|
|
|
DXE_SERVICES_REVISION, // Revision
|
|
|
|
sizeof (DXE_SERVICES), // HeaderSize
|
|
|
|
0, // CRC32
|
|
|
|
0 // Reserved
|
|
|
|
},
|
|
|
|
(EFI_ADD_MEMORY_SPACE) CoreAddMemorySpace, // AddMemorySpace
|
|
|
|
(EFI_ALLOCATE_MEMORY_SPACE) CoreAllocateMemorySpace, // AllocateMemorySpace
|
|
|
|
(EFI_FREE_MEMORY_SPACE) CoreFreeMemorySpace, // FreeMemorySpace
|
|
|
|
(EFI_REMOVE_MEMORY_SPACE) CoreRemoveMemorySpace, // RemoveMemorySpace
|
|
|
|
(EFI_GET_MEMORY_SPACE_DESCRIPTOR) CoreGetMemorySpaceDescriptor, // GetMemorySpaceDescriptor
|
|
|
|
(EFI_SET_MEMORY_SPACE_ATTRIBUTES) CoreSetMemorySpaceAttributes, // SetMemorySpaceAttributes
|
|
|
|
(EFI_GET_MEMORY_SPACE_MAP) CoreGetMemorySpaceMap, // GetMemorySpaceMap
|
|
|
|
(EFI_ADD_IO_SPACE) CoreAddIoSpace, // AddIoSpace
|
|
|
|
(EFI_ALLOCATE_IO_SPACE) CoreAllocateIoSpace, // AllocateIoSpace
|
|
|
|
(EFI_FREE_IO_SPACE) CoreFreeIoSpace, // FreeIoSpace
|
|
|
|
(EFI_REMOVE_IO_SPACE) CoreRemoveIoSpace, // RemoveIoSpace
|
|
|
|
(EFI_GET_IO_SPACE_DESCRIPTOR) CoreGetIoSpaceDescriptor, // GetIoSpaceDescriptor
|
|
|
|
(EFI_GET_IO_SPACE_MAP) CoreGetIoSpaceMap, // GetIoSpaceMap
|
|
|
|
(EFI_DISPATCH) CoreDispatcher, // Dispatch
|
|
|
|
(EFI_SCHEDULE) CoreSchedule, // Schedule
|
|
|
|
(EFI_TRUST) CoreTrust, // Trust
|
|
|
|
(EFI_PROCESS_FIRMWARE_VOLUME) CoreProcessFirmwareVolume, // ProcessFirmwareVolume
|
2014-11-20 02:23:49 +01:00
|
|
|
(EFI_SET_MEMORY_SPACE_CAPABILITIES)CoreSetMemorySpaceCapabilities, // SetMemorySpaceCapabilities
|
2009-08-24 17:35:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
EFI_SYSTEM_TABLE mEfiSystemTableTemplate = {
|
|
|
|
{
|
|
|
|
EFI_SYSTEM_TABLE_SIGNATURE, // Signature
|
|
|
|
EFI_SYSTEM_TABLE_REVISION, // Revision
|
|
|
|
sizeof (EFI_SYSTEM_TABLE), // HeaderSize
|
|
|
|
0, // CRC32
|
|
|
|
0 // Reserved
|
|
|
|
},
|
|
|
|
NULL, // FirmwareVendor
|
|
|
|
0, // FirmwareRevision
|
|
|
|
NULL, // ConsoleInHandle
|
|
|
|
NULL, // ConIn
|
|
|
|
NULL, // ConsoleOutHandle
|
|
|
|
NULL, // ConOut
|
|
|
|
NULL, // StandardErrorHandle
|
|
|
|
NULL, // StdErr
|
|
|
|
NULL, // RuntimeServices
|
|
|
|
&mBootServices, // BootServices
|
|
|
|
0, // NumberOfConfigurationTableEntries
|
|
|
|
NULL // ConfigurationTable
|
|
|
|
};
|
|
|
|
|
|
|
|
EFI_RUNTIME_SERVICES mEfiRuntimeServicesTableTemplate = {
|
|
|
|
{
|
|
|
|
EFI_RUNTIME_SERVICES_SIGNATURE, // Signature
|
|
|
|
EFI_RUNTIME_SERVICES_REVISION, // Revision
|
|
|
|
sizeof (EFI_RUNTIME_SERVICES), // HeaderSize
|
|
|
|
0, // CRC32
|
|
|
|
0 // Reserved
|
|
|
|
},
|
|
|
|
(EFI_GET_TIME) CoreEfiNotAvailableYetArg2, // GetTime
|
|
|
|
(EFI_SET_TIME) CoreEfiNotAvailableYetArg1, // SetTime
|
|
|
|
(EFI_GET_WAKEUP_TIME) CoreEfiNotAvailableYetArg3, // GetWakeupTime
|
|
|
|
(EFI_SET_WAKEUP_TIME) CoreEfiNotAvailableYetArg2, // SetWakeupTime
|
|
|
|
(EFI_SET_VIRTUAL_ADDRESS_MAP) CoreEfiNotAvailableYetArg4, // SetVirtualAddressMap
|
|
|
|
(EFI_CONVERT_POINTER) CoreEfiNotAvailableYetArg2, // ConvertPointer
|
|
|
|
(EFI_GET_VARIABLE) CoreEfiNotAvailableYetArg5, // GetVariable
|
|
|
|
(EFI_GET_NEXT_VARIABLE_NAME) CoreEfiNotAvailableYetArg3, // GetNextVariableName
|
|
|
|
(EFI_SET_VARIABLE) CoreEfiNotAvailableYetArg5, // SetVariable
|
|
|
|
(EFI_GET_NEXT_HIGH_MONO_COUNT) CoreEfiNotAvailableYetArg1, // GetNextHighMonotonicCount
|
|
|
|
(EFI_RESET_SYSTEM) CoreEfiNotAvailableYetArg4, // ResetSystem
|
|
|
|
(EFI_UPDATE_CAPSULE) CoreEfiNotAvailableYetArg3, // UpdateCapsule
|
|
|
|
(EFI_QUERY_CAPSULE_CAPABILITIES) CoreEfiNotAvailableYetArg4, // QueryCapsuleCapabilities
|
|
|
|
(EFI_QUERY_VARIABLE_INFO) CoreEfiNotAvailableYetArg4 // QueryVariableInfo
|
|
|
|
};
|
|
|
|
|
|
|
|
EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate = {
|
|
|
|
INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.ImageHead),
|
|
|
|
INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.EventHead),
|
|
|
|
|
|
|
|
//
|
|
|
|
// Make sure Size != sizeof (EFI_MEMORY_DESCRIPTOR). This will
|
|
|
|
// prevent people from having pointer math bugs in their code.
|
|
|
|
// now you have to use *DescriptorSize to make things work.
|
|
|
|
//
|
|
|
|
sizeof (EFI_MEMORY_DESCRIPTOR) + sizeof (UINT64) - (sizeof (EFI_MEMORY_DESCRIPTOR) % sizeof (UINT64)),
|
|
|
|
EFI_MEMORY_DESCRIPTOR_VERSION,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
FALSE
|
|
|
|
};
|
|
|
|
|
|
|
|
EFI_RUNTIME_ARCH_PROTOCOL *gRuntime = &gRuntimeTemplate;
|
|
|
|
|
|
|
|
//
|
|
|
|
// DXE Core Global Variables for the EFI System Table, Boot Services Table,
|
|
|
|
// DXE Services Table, and Runtime Services Table
|
|
|
|
//
|
|
|
|
EFI_DXE_SERVICES *gDxeCoreDS = &mDxeServices;
|
|
|
|
EFI_SYSTEM_TABLE *gDxeCoreST = NULL;
|
|
|
|
|
|
|
|
//
|
|
|
|
// For debug initialize gDxeCoreRT to template. gDxeCoreRT must be allocated from RT memory
|
|
|
|
// but gDxeCoreRT is used for ASSERT () and DEBUG () type macros so lets give it
|
|
|
|
// a value that will not cause debug infrastructure to crash early on.
|
|
|
|
//
|
|
|
|
EFI_RUNTIME_SERVICES *gDxeCoreRT = &mEfiRuntimeServicesTableTemplate;
|
|
|
|
EFI_HANDLE gDxeCoreImageHandle = NULL;
|
|
|
|
|
2016-04-20 11:27:40 +02:00
|
|
|
BOOLEAN gMemoryMapTerminated = FALSE;
|
2009-08-24 17:35:55 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// EFI Decompress Protocol
|
|
|
|
//
|
|
|
|
EFI_DECOMPRESS_PROTOCOL gEfiDecompress = {
|
|
|
|
DxeMainUefiDecompressGetInfo,
|
|
|
|
DxeMainUefiDecompress
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
2010-02-27 18:04:12 +01:00
|
|
|
// 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
|
2010-02-05 08:54:16 +01:00
|
|
|
//
|
2010-02-08 04:13:09 +01:00
|
|
|
GLOBAL_REMOVE_IF_UNREFERENCED EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable = {0, 0};
|
2010-02-05 08:54:16 +01:00
|
|
|
|
2009-08-24 17:35:55 +02:00
|
|
|
// Main entry point to the DXE Core
|
|
|
|
//
|
|
|
|
|
|
|
|
/**
|
|
|
|
Main entry point to DXE Core.
|
|
|
|
|
|
|
|
@param HobStart Pointer to the beginning of the HOB List from PEI.
|
|
|
|
|
|
|
|
@return This function should never return.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
DxeMain (
|
|
|
|
IN VOID *HobStart
|
|
|
|
)
|
|
|
|
{
|
2010-08-07 01:09:49 +02:00
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_PHYSICAL_ADDRESS MemoryBaseAddress;
|
|
|
|
UINT64 MemoryLength;
|
|
|
|
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
|
2013-11-22 07:15:51 +01:00
|
|
|
UINTN Index;
|
|
|
|
EFI_HOB_GUID_TYPE *GuidHob;
|
|
|
|
EFI_VECTOR_HANDOFF_INFO *VectorInfoList;
|
|
|
|
EFI_VECTOR_HANDOFF_INFO *VectorInfo;
|
2016-02-29 17:08:45 +01:00
|
|
|
VOID *EntryPoint;
|
2009-08-24 17:35:55 +02:00
|
|
|
|
2012-03-15 06:20:41 +01:00
|
|
|
//
|
|
|
|
// Setup the default exception handlers
|
|
|
|
//
|
2013-11-22 07:15:51 +01:00
|
|
|
VectorInfoList = NULL;
|
|
|
|
GuidHob = GetNextGuidHob (&gEfiVectorHandoffInfoPpiGuid, HobStart);
|
|
|
|
if (GuidHob != NULL) {
|
|
|
|
VectorInfoList = (EFI_VECTOR_HANDOFF_INFO *) (GET_GUID_HOB_DATA(GuidHob));
|
|
|
|
}
|
2017-12-07 13:17:32 +01:00
|
|
|
Status = InitializeCpuExceptionHandlersEx (VectorInfoList, NULL);
|
2013-11-22 07:15:51 +01:00
|
|
|
ASSERT_EFI_ERROR (Status);
|
2018-06-27 15:08:52 +02:00
|
|
|
|
2010-02-27 18:04:12 +01:00
|
|
|
//
|
|
|
|
// Initialize Debug Agent to support source level debug in DXE phase
|
|
|
|
//
|
2010-07-19 04:26:09 +02:00
|
|
|
InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_CORE, HobStart, NULL);
|
2010-02-27 18:04:12 +01:00
|
|
|
|
2009-08-24 17:35:55 +02:00
|
|
|
//
|
|
|
|
// Initialize Memory Services
|
|
|
|
//
|
|
|
|
CoreInitializeMemoryServices (&HobStart, &MemoryBaseAddress, &MemoryLength);
|
|
|
|
|
2014-11-12 04:27:48 +01:00
|
|
|
MemoryProfileInit (HobStart);
|
|
|
|
|
2009-08-24 17:35:55 +02:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
|
|
|
gDxeCoreST = AllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE), &mEfiSystemTableTemplate);
|
|
|
|
ASSERT (gDxeCoreST != NULL);
|
|
|
|
|
|
|
|
gDxeCoreRT = AllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES), &mEfiRuntimeServicesTableTemplate);
|
|
|
|
ASSERT (gDxeCoreRT != NULL);
|
|
|
|
|
|
|
|
gDxeCoreST->RuntimeServices = gDxeCoreRT;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Start the Image Services.
|
|
|
|
//
|
|
|
|
Status = CoreInitializeImageServices (HobStart);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Initialize the Global Coherency Domain Services
|
|
|
|
//
|
|
|
|
Status = CoreInitializeGcdServices (&HobStart, MemoryBaseAddress, MemoryLength);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
MdeModulePkg DxeCore: Move ProcessLibraryConstructorList()
to right after CoreInitializeGcdServices().
Why?
Some platforms maybe report both below 4G and above 4G memory resource hob as tested,
then CoreInitializeMemoryServices() will find and add the tested above 4G memory resource hob to memory descriptor for early memory allocation services,
then if ProcessLibraryConstructorList() that has library constructor tries to allocate below 4G memory and will fail.
In fact, the following CoreInitializeGcdServices() will add all the memory resource hob to GCD map,
and add the tested below 4G memory resource hob to memory descriptor,
but it has been too late for ProcessLibraryConstructorList().
Also move below two lines as they are needed to be after
the constructor of DxeCorePerfomanceLib.
PERF_END (NULL,"PEI", NULL, 0) ;
PERF_START (NULL,"DXE", NULL, 0) ;
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18146 6f19259b-4bc3-4df7-8a09-765794883524
2015-08-04 03:41:48 +02:00
|
|
|
//
|
|
|
|
// Call constructor for all libraries
|
|
|
|
//
|
|
|
|
ProcessLibraryConstructorList (gDxeCoreImageHandle, gDxeCoreST);
|
2018-06-22 10:56:21 +02:00
|
|
|
PERF_CROSSMODULE_END ("PEI");
|
|
|
|
PERF_CROSSMODULE_BEGIN ("DXE");
|
MdeModulePkg DxeCore: Move ProcessLibraryConstructorList()
to right after CoreInitializeGcdServices().
Why?
Some platforms maybe report both below 4G and above 4G memory resource hob as tested,
then CoreInitializeMemoryServices() will find and add the tested above 4G memory resource hob to memory descriptor for early memory allocation services,
then if ProcessLibraryConstructorList() that has library constructor tries to allocate below 4G memory and will fail.
In fact, the following CoreInitializeGcdServices() will add all the memory resource hob to GCD map,
and add the tested below 4G memory resource hob to memory descriptor,
but it has been too late for ProcessLibraryConstructorList().
Also move below two lines as they are needed to be after
the constructor of DxeCorePerfomanceLib.
PERF_END (NULL,"PEI", NULL, 0) ;
PERF_START (NULL,"DXE", NULL, 0) ;
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18146 6f19259b-4bc3-4df7-8a09-765794883524
2015-08-04 03:41:48 +02:00
|
|
|
|
2016-04-21 03:47:00 +02:00
|
|
|
//
|
|
|
|
// 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);
|
|
|
|
ImageContext.SizeOfHeaders = PeCoffGetSizeOfHeaders ((VOID*)(UINTN)ImageContext.ImageAddress);
|
|
|
|
Status = PeCoffLoaderGetEntryPoint ((VOID*)(UINTN)ImageContext.ImageAddress, &EntryPoint);
|
|
|
|
if (Status == EFI_SUCCESS) {
|
|
|
|
ImageContext.EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)EntryPoint;
|
|
|
|
}
|
2016-04-29 09:39:18 +02:00
|
|
|
ImageContext.Handle = (VOID *)(UINTN)gDxeCoreLoadedImage->ImageBase;
|
|
|
|
ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;
|
2016-04-21 03:47:00 +02:00
|
|
|
PeCoffLoaderRelocateImageExtraAction (&ImageContext);
|
|
|
|
|
2009-08-24 17:35:55 +02:00
|
|
|
//
|
|
|
|
// Install the DXE Services Table into the EFI System Tables's Configuration Table
|
|
|
|
//
|
|
|
|
Status = CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid, gDxeCoreDS);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Install the HOB List into the EFI System Tables's Configuration Table
|
|
|
|
//
|
|
|
|
Status = CoreInstallConfigurationTable (&gEfiHobListGuid, HobStart);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Install Memory Type Information Table into the EFI System Tables's Configuration Table
|
|
|
|
//
|
|
|
|
Status = CoreInstallConfigurationTable (&gEfiMemoryTypeInformationGuid, &gMemoryTypeInformation);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
2010-02-27 18:04:12 +01:00
|
|
|
|
2010-02-05 08:54:16 +01:00
|
|
|
//
|
2010-02-27 18:04:12 +01:00
|
|
|
// If Loading modules At fixed address feature is enabled, install Load moduels at fixed address
|
2010-02-05 08:54:16 +01:00
|
|
|
// Configuration Table so that user could easily to retrieve the top address to load Dxe and PEI
|
2010-02-27 18:04:12 +01:00
|
|
|
// Code and Tseg base to load SMM driver.
|
2010-02-05 08:54:16 +01:00
|
|
|
//
|
2010-02-10 07:10:53 +01:00
|
|
|
if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0) {
|
2010-02-05 08:54:16 +01:00
|
|
|
Status = CoreInstallConfigurationTable (&gLoadFixedAddressConfigurationTableGuid, &gLoadModuleAtFixAddressConfigurationTable);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2009-08-24 17:35:55 +02:00
|
|
|
//
|
|
|
|
// Report Status Code here for DXE_ENTRY_POINT once it is available
|
|
|
|
//
|
|
|
|
REPORT_STATUS_CODE (
|
|
|
|
EFI_PROGRESS_CODE,
|
2010-01-27 05:00:58 +01:00
|
|
|
(EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_ENTRY_POINT)
|
2009-08-24 17:35:55 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Create the aligned system table pointer structure that is used by external
|
|
|
|
// debuggers to locate the system table... Also, install debug image info
|
|
|
|
// configuration table.
|
|
|
|
//
|
|
|
|
CoreInitializeDebugImageInfoTable ();
|
|
|
|
CoreNewDebugImageInfoEntry (
|
|
|
|
EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL,
|
|
|
|
gDxeCoreLoadedImage,
|
|
|
|
gDxeCoreImageHandle
|
|
|
|
);
|
|
|
|
|
|
|
|
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) {
|
2010-02-16 04:05:59 +01:00
|
|
|
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Memory Allocation 0x%08x 0x%0lx - 0x%0lx\n", \
|
2009-08-24 17:44:35 +02:00
|
|
|
Hob.MemoryAllocation->AllocDescriptor.MemoryType, \
|
2009-08-24 17:35:55 +02:00
|
|
|
Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress, \
|
2009-08-24 17:44:35 +02:00
|
|
|
Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress + Hob.MemoryAllocation->AllocDescriptor.MemoryLength - 1));
|
2009-08-24 17:35:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for (Hob.Raw = HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {
|
2017-10-03 15:48:47 +02:00
|
|
|
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.FirmwareVolume->Length - 1
|
|
|
|
));
|
|
|
|
} else 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
|
|
|
|
));
|
|
|
|
DEBUG ((
|
|
|
|
DEBUG_INFO | DEBUG_LOAD,
|
|
|
|
" %g - %g\n",
|
|
|
|
&Hob.FirmwareVolume2->FvName,
|
|
|
|
&Hob.FirmwareVolume2->FileName
|
|
|
|
));
|
|
|
|
} else if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV3) {
|
|
|
|
DEBUG ((
|
|
|
|
DEBUG_INFO | DEBUG_LOAD,
|
|
|
|
"FV3 Hob 0x%0lx - 0x%0lx - 0x%x - 0x%x\n",
|
|
|
|
Hob.FirmwareVolume3->BaseAddress,
|
|
|
|
Hob.FirmwareVolume3->BaseAddress + Hob.FirmwareVolume3->Length - 1,
|
|
|
|
Hob.FirmwareVolume3->AuthenticationStatus,
|
|
|
|
Hob.FirmwareVolume3->ExtractedFv
|
|
|
|
));
|
|
|
|
if (Hob.FirmwareVolume3->ExtractedFv) {
|
|
|
|
DEBUG ((
|
|
|
|
DEBUG_INFO | DEBUG_LOAD,
|
|
|
|
" %g - %g\n",
|
|
|
|
&Hob.FirmwareVolume3->FvName,
|
|
|
|
&Hob.FirmwareVolume3->FileName
|
|
|
|
));
|
|
|
|
}
|
2009-08-24 17:35:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
DEBUG_CODE_END ();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Initialize the Event Services
|
|
|
|
//
|
|
|
|
Status = CoreInitializeEventServices ();
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2014-11-12 04:27:48 +01:00
|
|
|
MemoryProfileInstallProtocol ();
|
|
|
|
|
2015-06-05 14:08:12 +02:00
|
|
|
CoreInitializePropertiesTable ();
|
2016-01-29 12:55:32 +01:00
|
|
|
CoreInitializeMemoryAttributesTable ();
|
2017-01-14 08:04:10 +01:00
|
|
|
CoreInitializeMemoryProtection ();
|
2015-06-05 14:08:12 +02:00
|
|
|
|
2013-11-22 07:15:51 +01:00
|
|
|
//
|
|
|
|
// 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);
|
|
|
|
}
|
2009-08-24 17:35:55 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs
|
|
|
|
//
|
|
|
|
// These Protocols are not architectural. This implementation is sharing code between
|
|
|
|
// PEI and DXE in order to save FLASH space. These Protocols could also be implemented
|
|
|
|
// as part of the DXE Core. However, that would also require the DXE Core to be ported
|
|
|
|
// each time a different CPU is used, a different Decompression algorithm is used, or a
|
|
|
|
// different Image type is used. By placing these Protocols in PEI, the DXE Core remains
|
|
|
|
// generic, and only PEI and the Arch Protocols need to be ported from Platform to Platform,
|
|
|
|
// and from CPU to CPU.
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components
|
|
|
|
//
|
|
|
|
Status = CoreInstallMultipleProtocolInterfaces (
|
|
|
|
&mDecompressHandle,
|
|
|
|
&gEfiDecompressProtocolGuid, &gEfiDecompress,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
//
|
|
|
|
// 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.
|
2010-02-16 21:59:57 +01:00
|
|
|
// Also register for the GUIDs of optional protocols.
|
2009-08-24 17:35:55 +02:00
|
|
|
//
|
2010-02-16 21:59:57 +01:00
|
|
|
CoreNotifyOnProtocolInstallation ();
|
2009-08-24 17:35:55 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Produce Firmware Volume Protocols, one for each FV in the HOB list.
|
|
|
|
//
|
|
|
|
Status = FwVolBlockDriverInit (gDxeCoreImageHandle, gDxeCoreST);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
Status = FwVolDriverInit (gDxeCoreImageHandle, gDxeCoreST);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Produce the Section Extraction Protocol
|
|
|
|
//
|
|
|
|
Status = InitializeSectionExtraction (gDxeCoreImageHandle, gDxeCoreST);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Initialize the DXE Dispatcher
|
|
|
|
//
|
|
|
|
CoreInitializeDispatcher ();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Invoke the DXE Dispatcher
|
|
|
|
//
|
|
|
|
CoreDispatcher ();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Display Architectural protocols that were not loaded if this is DEBUG build
|
|
|
|
//
|
|
|
|
DEBUG_CODE_BEGIN ();
|
|
|
|
CoreDisplayMissingArchProtocols ();
|
|
|
|
DEBUG_CODE_END ();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Display any drivers that were not dispatched because dependency expression
|
|
|
|
// evaluated to false if this is a debug build
|
|
|
|
//
|
|
|
|
DEBUG_CODE_BEGIN ();
|
|
|
|
CoreDisplayDiscoveredNotDispatched ();
|
|
|
|
DEBUG_CODE_END ();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Assert if the Architectural Protocols are not present.
|
|
|
|
//
|
2012-10-30 05:23:40 +01:00
|
|
|
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)
|
2018-06-27 15:08:52 +02:00
|
|
|
);
|
2012-10-30 05:23:40 +01:00
|
|
|
}
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
2009-08-24 17:35:55 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Report Status code before transfer control to BDS
|
|
|
|
//
|
|
|
|
REPORT_STATUS_CODE (
|
|
|
|
EFI_PROGRESS_CODE,
|
2010-01-27 05:00:58 +01:00
|
|
|
(EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT)
|
2009-08-24 17:35:55 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Transfer control to the BDS Architectural Protocol
|
|
|
|
//
|
|
|
|
gBds->Entry (gBds);
|
|
|
|
|
|
|
|
//
|
|
|
|
// BDS should never return
|
|
|
|
//
|
|
|
|
ASSERT (FALSE);
|
|
|
|
CpuDeadLoop ();
|
2016-06-19 03:31:16 +02:00
|
|
|
|
|
|
|
UNREACHABLE ();
|
2009-08-24 17:35:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Place holder function until all the Boot Services and Runtime Services are
|
|
|
|
available.
|
|
|
|
|
|
|
|
@param Arg1 Undefined
|
|
|
|
|
|
|
|
@return EFI_NOT_AVAILABLE_YET
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
CoreEfiNotAvailableYetArg1 (
|
|
|
|
UINTN Arg1
|
|
|
|
)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// This function should never be executed. If it does, then the architectural protocols
|
|
|
|
// have not been designed correctly. The CpuBreakpoint () is commented out for now until the
|
|
|
|
// DXE Core and all the Architectural Protocols are complete.
|
|
|
|
//
|
|
|
|
|
|
|
|
return EFI_NOT_AVAILABLE_YET;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Place holder function until all the Boot Services and Runtime Services are available.
|
|
|
|
|
|
|
|
@param Arg1 Undefined
|
|
|
|
@param Arg2 Undefined
|
|
|
|
|
|
|
|
@return EFI_NOT_AVAILABLE_YET
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
CoreEfiNotAvailableYetArg2 (
|
|
|
|
UINTN Arg1,
|
|
|
|
UINTN Arg2
|
|
|
|
)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// This function should never be executed. If it does, then the architectural protocols
|
|
|
|
// have not been designed correctly. The CpuBreakpoint () is commented out for now until the
|
|
|
|
// DXE Core and all the Architectural Protocols are complete.
|
|
|
|
//
|
|
|
|
|
|
|
|
return EFI_NOT_AVAILABLE_YET;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Place holder function until all the Boot Services and Runtime Services are available.
|
|
|
|
|
|
|
|
@param Arg1 Undefined
|
|
|
|
@param Arg2 Undefined
|
|
|
|
@param Arg3 Undefined
|
|
|
|
|
|
|
|
@return EFI_NOT_AVAILABLE_YET
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
CoreEfiNotAvailableYetArg3 (
|
|
|
|
UINTN Arg1,
|
|
|
|
UINTN Arg2,
|
|
|
|
UINTN Arg3
|
|
|
|
)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// This function should never be executed. If it does, then the architectural protocols
|
|
|
|
// have not been designed correctly. The CpuBreakpoint () is commented out for now until the
|
|
|
|
// DXE Core and all the Architectural Protocols are complete.
|
|
|
|
//
|
|
|
|
|
|
|
|
return EFI_NOT_AVAILABLE_YET;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Place holder function until all the Boot Services and Runtime Services are available.
|
|
|
|
|
|
|
|
@param Arg1 Undefined
|
|
|
|
@param Arg2 Undefined
|
|
|
|
@param Arg3 Undefined
|
|
|
|
@param Arg4 Undefined
|
|
|
|
|
|
|
|
@return EFI_NOT_AVAILABLE_YET
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
CoreEfiNotAvailableYetArg4 (
|
|
|
|
UINTN Arg1,
|
|
|
|
UINTN Arg2,
|
|
|
|
UINTN Arg3,
|
|
|
|
UINTN Arg4
|
|
|
|
)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// This function should never be executed. If it does, then the architectural protocols
|
|
|
|
// have not been designed correctly. The CpuBreakpoint () is commented out for now until the
|
|
|
|
// DXE Core and all the Architectural Protocols are complete.
|
|
|
|
//
|
|
|
|
|
|
|
|
return EFI_NOT_AVAILABLE_YET;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Place holder function until all the Boot Services and Runtime Services are available.
|
|
|
|
|
|
|
|
@param Arg1 Undefined
|
|
|
|
@param Arg2 Undefined
|
|
|
|
@param Arg3 Undefined
|
|
|
|
@param Arg4 Undefined
|
|
|
|
@param Arg5 Undefined
|
|
|
|
|
|
|
|
@return EFI_NOT_AVAILABLE_YET
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
CoreEfiNotAvailableYetArg5 (
|
|
|
|
UINTN Arg1,
|
|
|
|
UINTN Arg2,
|
|
|
|
UINTN Arg3,
|
|
|
|
UINTN Arg4,
|
|
|
|
UINTN Arg5
|
|
|
|
)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// This function should never be executed. If it does, then the architectural protocols
|
|
|
|
// have not been designed correctly. The CpuBreakpoint () is commented out for now until the
|
|
|
|
// DXE Core and all the Architectural Protocols are complete.
|
|
|
|
//
|
|
|
|
|
|
|
|
return EFI_NOT_AVAILABLE_YET;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Calcualte the 32-bit CRC in a EFI table using the service provided by the
|
|
|
|
gRuntime service.
|
|
|
|
|
|
|
|
@param Hdr Pointer to an EFI standard header
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
CalculateEfiHdrCrc (
|
|
|
|
IN OUT EFI_TABLE_HEADER *Hdr
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINT32 Crc;
|
|
|
|
|
|
|
|
Hdr->CRC32 = 0;
|
|
|
|
|
|
|
|
//
|
|
|
|
// If gBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then
|
|
|
|
// Crc will come back as zero if we set it to zero here
|
|
|
|
//
|
|
|
|
Crc = 0;
|
|
|
|
gBS->CalculateCrc32 ((UINT8 *)Hdr, Hdr->HeaderSize, &Crc);
|
|
|
|
Hdr->CRC32 = Crc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Terminates all boot services.
|
|
|
|
|
|
|
|
@param ImageHandle Handle that identifies the exiting image.
|
|
|
|
@param MapKey Key to the latest memory map.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS Boot Services terminated
|
|
|
|
@retval EFI_INVALID_PARAMETER MapKey is incorrect.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
CoreExitBootServices (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN UINTN MapKey
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
2010-11-03 04:21:29 +01:00
|
|
|
//
|
|
|
|
// Disable Timer
|
|
|
|
//
|
|
|
|
gTimer->SetTimerPeriod (gTimer, 0);
|
|
|
|
|
2009-08-24 17:35:55 +02:00
|
|
|
//
|
|
|
|
// Terminate memory services if the MapKey matches
|
|
|
|
//
|
|
|
|
Status = CoreTerminateMemoryMap (MapKey);
|
|
|
|
if (EFI_ERROR (Status)) {
|
2012-08-02 08:34:20 +02:00
|
|
|
//
|
2018-06-27 15:08:52 +02:00
|
|
|
// Notify other drivers that ExitBootServices fail
|
2012-08-02 08:34:20 +02:00
|
|
|
//
|
|
|
|
CoreNotifySignalList (&gEventExitBootServicesFailedGuid);
|
2009-08-24 17:35:55 +02:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2016-04-20 11:27:40 +02:00
|
|
|
gMemoryMapTerminated = TRUE;
|
|
|
|
|
2009-08-24 17:35:55 +02:00
|
|
|
//
|
|
|
|
// Notify other drivers that we are exiting boot services.
|
|
|
|
//
|
|
|
|
CoreNotifySignalList (&gEfiEventExitBootServicesGuid);
|
|
|
|
|
2014-02-13 04:37:07 +01:00
|
|
|
//
|
|
|
|
// Report that ExitBootServices() has been called
|
|
|
|
//
|
|
|
|
REPORT_STATUS_CODE (
|
|
|
|
EFI_PROGRESS_CODE,
|
|
|
|
(EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES)
|
|
|
|
);
|
|
|
|
|
2018-03-19 08:02:59 +01:00
|
|
|
MemoryProtectionExitBootServicesCallback();
|
|
|
|
|
2010-03-13 17:52:46 +01:00
|
|
|
//
|
|
|
|
// Disable interrupt of Debug timer.
|
|
|
|
//
|
|
|
|
SaveAndSetDebugTimerInterrupt (FALSE);
|
|
|
|
|
2009-08-24 17:35:55 +02:00
|
|
|
//
|
|
|
|
// Disable CPU Interrupts
|
|
|
|
//
|
|
|
|
gCpu->DisableInterrupt (gCpu);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Clear the non-runtime values of the EFI System Table
|
|
|
|
//
|
|
|
|
gDxeCoreST->BootServices = NULL;
|
|
|
|
gDxeCoreST->ConIn = NULL;
|
|
|
|
gDxeCoreST->ConsoleInHandle = NULL;
|
|
|
|
gDxeCoreST->ConOut = NULL;
|
|
|
|
gDxeCoreST->ConsoleOutHandle = NULL;
|
|
|
|
gDxeCoreST->StdErr = NULL;
|
|
|
|
gDxeCoreST->StandardErrorHandle = NULL;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Recompute the 32-bit CRC of the EFI System Table
|
|
|
|
//
|
|
|
|
CalculateEfiHdrCrc (&gDxeCoreST->Hdr);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Zero out the Boot Service Table
|
|
|
|
//
|
|
|
|
ZeroMem (gBS, sizeof (EFI_BOOT_SERVICES));
|
|
|
|
gBS = NULL;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Update the AtRuntime field in Runtiem AP.
|
|
|
|
//
|
|
|
|
gRuntime->AtRuntime = TRUE;
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Given a compressed source buffer, this function retrieves the size of the
|
|
|
|
uncompressed buffer and the size of the scratch buffer required to decompress
|
|
|
|
the compressed source buffer.
|
|
|
|
|
|
|
|
The GetInfo() function retrieves the size of the uncompressed buffer and the
|
|
|
|
temporary scratch buffer required to decompress the buffer specified by Source
|
|
|
|
and SourceSize. If the size of the uncompressed buffer or the size of the
|
|
|
|
scratch buffer cannot be determined from the compressed data specified by
|
|
|
|
Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the
|
|
|
|
size of the uncompressed buffer is returned in DestinationSize, the size of
|
|
|
|
the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.
|
|
|
|
The GetInfo() function does not have scratch buffer available to perform a
|
|
|
|
thorough checking of the validity of the source data. It just retrieves the
|
|
|
|
"Original Size" field from the beginning bytes of the source data and output
|
|
|
|
it as DestinationSize. And ScratchSize is specific to the decompression
|
|
|
|
implementation.
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
|
|
|
|
@param Source The source buffer containing the compressed data.
|
|
|
|
@param SourceSize The size, in bytes, of the source buffer.
|
|
|
|
@param DestinationSize A pointer to the size, in bytes, of the
|
|
|
|
uncompressed buffer that will be generated when the
|
|
|
|
compressed buffer specified by Source and
|
|
|
|
SourceSize is decompressed.
|
|
|
|
@param ScratchSize A pointer to the size, in bytes, of the scratch
|
|
|
|
buffer that is required to decompress the
|
|
|
|
compressed buffer specified by Source and
|
|
|
|
SourceSize.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The size of the uncompressed data was returned in
|
|
|
|
DestinationSize and the size of the scratch buffer
|
|
|
|
was returned in ScratchSize.
|
|
|
|
@retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of
|
|
|
|
the scratch buffer cannot be determined from the
|
|
|
|
compressed data specified by Source and
|
|
|
|
SourceSize.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DxeMainUefiDecompressGetInfo (
|
|
|
|
IN EFI_DECOMPRESS_PROTOCOL *This,
|
|
|
|
IN VOID *Source,
|
|
|
|
IN UINT32 SourceSize,
|
|
|
|
OUT UINT32 *DestinationSize,
|
|
|
|
OUT UINT32 *ScratchSize
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (Source == NULL || DestinationSize == NULL || ScratchSize == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
return UefiDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Decompresses a compressed source buffer.
|
|
|
|
|
|
|
|
The Decompress() function extracts decompressed data to its original form.
|
|
|
|
This protocol is designed so that the decompression algorithm can be
|
|
|
|
implemented without using any memory services. As a result, the Decompress()
|
|
|
|
Function is not allowed to call AllocatePool() or AllocatePages() in its
|
|
|
|
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
|
2014-05-13 11:14:00 +02:00
|
|
|
successfully decompressed into Destination, then EFI_SUCCESS is returned. If
|
2009-08-24 17:35:55 +02:00
|
|
|
the compressed source data specified by Source and SourceSize is not in a
|
|
|
|
valid compressed data format, then EFI_INVALID_PARAMETER is returned.
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
|
|
|
|
@param Source The source buffer containing the compressed data.
|
|
|
|
@param SourceSize SourceSizeThe size of source data.
|
|
|
|
@param Destination On output, the destination buffer that contains
|
|
|
|
the uncompressed data.
|
|
|
|
@param DestinationSize The size of the destination buffer. The size of
|
|
|
|
the destination buffer needed is obtained from
|
|
|
|
EFI_DECOMPRESS_PROTOCOL.GetInfo().
|
|
|
|
@param Scratch A temporary scratch buffer that is used to perform
|
|
|
|
the decompression.
|
|
|
|
@param ScratchSize The size of scratch buffer. The size of the
|
|
|
|
scratch buffer needed is obtained from GetInfo().
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS Decompression completed successfully, and the
|
|
|
|
uncompressed buffer is returned in Destination.
|
|
|
|
@retval EFI_INVALID_PARAMETER The source buffer specified by Source and
|
|
|
|
SourceSize is corrupted (not in a valid
|
|
|
|
compressed format).
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DxeMainUefiDecompress (
|
|
|
|
IN EFI_DECOMPRESS_PROTOCOL *This,
|
|
|
|
IN VOID *Source,
|
|
|
|
IN UINT32 SourceSize,
|
|
|
|
IN OUT VOID *Destination,
|
|
|
|
IN UINT32 DestinationSize,
|
|
|
|
IN OUT VOID *Scratch,
|
|
|
|
IN UINT32 ScratchSize
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
UINT32 TestDestinationSize;
|
|
|
|
UINT32 TestScratchSize;
|
|
|
|
|
|
|
|
if (Source == NULL || Destination== NULL || Scratch == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = UefiDecompressGetInfo (Source, SourceSize, &TestDestinationSize, &TestScratchSize);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ScratchSize < TestScratchSize || DestinationSize < TestDestinationSize) {
|
|
|
|
return RETURN_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
return UefiDecompress (Source, Destination, Scratch);
|
|
|
|
}
|