X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FCore%2FDxe%2FDxeMain.h;h=815a6b4bd844a452ace09c2e3932cfa03e3ecf2e;hb=1436aea4d5707e672672a11bda72be2c63c936c3;hp=75542b343298b611acdf04d64c8981759ed51c17;hpb=4888d15e74628fd373605d5d853fa3b172aeadc3;p=mirror_edk2.git diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h index 75542b3432..815a6b4bd8 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -2,22 +2,14 @@ The internal header file includes the common header files, defines internal structure and functions used by DxeCore module. -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 - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent **/ #ifndef _DXE_MAIN_H_ #define _DXE_MAIN_H_ - - #include #include @@ -42,7 +34,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include #include #include #include @@ -53,6 +44,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include #include #include @@ -69,6 +61,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include #include @@ -88,12 +81,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include #include #include #include - // // attributes for reserved memory before it is promoted to system memory // @@ -106,10 +97,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // #define EFI_MEMORY_PORT_IO 0x4000000000000000ULL - /// -/// EFI_DEP_REPLACE_TRUE - Used to dynamically patch the dependecy expression -/// to save time. A EFI_DEP_PUSH is evauated one an +/// EFI_DEP_REPLACE_TRUE - Used to dynamically patch the dependency expression +/// to save time. A EFI_DEP_PUSH is evaluated one an /// replaced with EFI_DEP_REPLACE_TRUE. If PI spec's Vol 2 /// Driver Execution Environment Core Interface use 0xff /// as new DEPEX opcode. EFI_DEP_REPLACE_TRUE should be @@ -123,11 +113,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define DEPEX_STACK_SIZE_INCREMENT 0x1000 typedef struct { - EFI_GUID *ProtocolGuid; - VOID **Protocol; - EFI_EVENT Event; - VOID *Registration; - BOOLEAN Present; + EFI_GUID *ProtocolGuid; + VOID **Protocol; + EFI_EVENT Event; + VOID *Registration; + BOOLEAN Present; } EFI_CORE_PROTOCOL_NOTIFY_ENTRY; // @@ -136,99 +126,166 @@ typedef struct { #define KNOWN_HANDLE_SIGNATURE SIGNATURE_32('k','n','o','w') typedef struct { - UINTN Signature; - LIST_ENTRY Link; // mFvHandleList - EFI_HANDLE Handle; - EFI_GUID FvNameGuid; + UINTN Signature; + LIST_ENTRY Link; // mFvHandleList + EFI_HANDLE Handle; + EFI_GUID FvNameGuid; } KNOWN_HANDLE; - -#define EFI_CORE_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('d','r','v','r') +#define EFI_CORE_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('d','r','v','r') typedef struct { - UINTN Signature; - LIST_ENTRY Link; // mDriverList + UINTN Signature; + LIST_ENTRY Link; // mDriverList - LIST_ENTRY ScheduledLink; // mScheduledQueue + LIST_ENTRY ScheduledLink; // mScheduledQueue - EFI_HANDLE FvHandle; - EFI_GUID FileName; - EFI_DEVICE_PATH_PROTOCOL *FvFileDevicePath; - EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv; + EFI_HANDLE FvHandle; + EFI_GUID FileName; + EFI_DEVICE_PATH_PROTOCOL *FvFileDevicePath; + EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv; - VOID *Depex; - UINTN DepexSize; + VOID *Depex; + UINTN DepexSize; - BOOLEAN Before; - BOOLEAN After; - EFI_GUID BeforeAfterGuid; + BOOLEAN Before; + BOOLEAN After; + EFI_GUID BeforeAfterGuid; - BOOLEAN Dependent; - BOOLEAN Unrequested; - BOOLEAN Scheduled; - BOOLEAN Untrusted; - BOOLEAN Initialized; - BOOLEAN DepexProtocolError; - - EFI_HANDLE ImageHandle; - BOOLEAN IsFvImage; + BOOLEAN Dependent; + BOOLEAN Unrequested; + BOOLEAN Scheduled; + BOOLEAN Untrusted; + BOOLEAN Initialized; + BOOLEAN DepexProtocolError; + EFI_HANDLE ImageHandle; + BOOLEAN IsFvImage; } EFI_CORE_DRIVER_ENTRY; // -//The data structure of GCD memory map entry +// The data structure of GCD memory map entry // #define EFI_GCD_MAP_SIGNATURE SIGNATURE_32('g','c','d','m') typedef struct { - UINTN Signature; - LIST_ENTRY Link; - EFI_PHYSICAL_ADDRESS BaseAddress; - UINT64 EndAddress; - UINT64 Capabilities; - UINT64 Attributes; - EFI_GCD_MEMORY_TYPE GcdMemoryType; - EFI_GCD_IO_TYPE GcdIoType; - EFI_HANDLE ImageHandle; - EFI_HANDLE DeviceHandle; + UINTN Signature; + LIST_ENTRY Link; + EFI_PHYSICAL_ADDRESS BaseAddress; + UINT64 EndAddress; + UINT64 Capabilities; + UINT64 Attributes; + EFI_GCD_MEMORY_TYPE GcdMemoryType; + EFI_GCD_IO_TYPE GcdIoType; + EFI_HANDLE ImageHandle; + EFI_HANDLE DeviceHandle; } EFI_GCD_MAP_ENTRY; +#define LOADED_IMAGE_PRIVATE_DATA_SIGNATURE SIGNATURE_32('l','d','r','i') + +typedef struct { + UINTN Signature; + /// Image handle + EFI_HANDLE Handle; + /// Image type + UINTN Type; + /// If entrypoint has been called + BOOLEAN Started; + /// The image's entry point + EFI_IMAGE_ENTRY_POINT EntryPoint; + /// loaded image protocol + EFI_LOADED_IMAGE_PROTOCOL Info; + /// Location in memory + EFI_PHYSICAL_ADDRESS ImageBasePage; + /// Number of pages + UINTN NumberOfPages; + /// Original fixup data + CHAR8 *FixupData; + /// Tpl of started image + EFI_TPL Tpl; + /// Status returned by started image + EFI_STATUS Status; + /// Size of ExitData from started image + UINTN ExitDataSize; + /// Pointer to exit data from started image + VOID *ExitData; + /// Pointer to pool allocation for context save/restore + VOID *JumpBuffer; + /// Pointer to buffer for context save/restore + BASE_LIBRARY_JUMP_BUFFER *JumpContext; + /// Machine type from PE image + UINT16 Machine; + /// PE/COFF Image Emulator Protocol pointer + EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *PeCoffEmu; + /// Runtime image list + EFI_RUNTIME_IMAGE_ENTRY *RuntimeData; + /// Pointer to Loaded Image Device Path Protocol + EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath; + /// PeCoffLoader ImageContext + PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; + /// Status returned by LoadImage() service. + EFI_STATUS LoadImageStatus; +} LOADED_IMAGE_PRIVATE_DATA; + +#define LOADED_IMAGE_PRIVATE_DATA_FROM_THIS(a) \ + CR(a, LOADED_IMAGE_PRIVATE_DATA, Info, LOADED_IMAGE_PRIVATE_DATA_SIGNATURE) + +#define IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE SIGNATURE_32 ('I','P','R','C') + +typedef struct { + UINT32 Signature; + LIST_ENTRY Link; + EFI_PHYSICAL_ADDRESS CodeSegmentBase; + UINT64 CodeSegmentSize; +} IMAGE_PROPERTIES_RECORD_CODE_SECTION; + +#define IMAGE_PROPERTIES_RECORD_SIGNATURE SIGNATURE_32 ('I','P','R','D') + +typedef struct { + UINT32 Signature; + LIST_ENTRY Link; + EFI_PHYSICAL_ADDRESS ImageBase; + UINT64 ImageSize; + UINTN CodeSegmentCount; + LIST_ENTRY CodeSegmentList; +} IMAGE_PROPERTIES_RECORD; + // // DXE Core Global Variables // -extern EFI_SYSTEM_TABLE *gDxeCoreST; -extern EFI_RUNTIME_SERVICES *gDxeCoreRT; -extern EFI_DXE_SERVICES *gDxeCoreDS; -extern EFI_HANDLE gDxeCoreImageHandle; +extern EFI_SYSTEM_TABLE *gDxeCoreST; +extern EFI_RUNTIME_SERVICES *gDxeCoreRT; +extern EFI_DXE_SERVICES *gDxeCoreDS; +extern EFI_HANDLE gDxeCoreImageHandle; + +extern BOOLEAN gMemoryMapTerminated; -extern EFI_DECOMPRESS_PROTOCOL gEfiDecompress; +extern EFI_DECOMPRESS_PROTOCOL gEfiDecompress; -extern EFI_RUNTIME_ARCH_PROTOCOL *gRuntime; -extern EFI_CPU_ARCH_PROTOCOL *gCpu; -extern EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer; -extern EFI_METRONOME_ARCH_PROTOCOL *gMetronome; -extern EFI_TIMER_ARCH_PROTOCOL *gTimer; -extern EFI_SECURITY_ARCH_PROTOCOL *gSecurity; -extern EFI_SECURITY2_ARCH_PROTOCOL *gSecurity2; -extern EFI_BDS_ARCH_PROTOCOL *gBds; -extern EFI_SMM_BASE2_PROTOCOL *gSmmBase2; +extern EFI_RUNTIME_ARCH_PROTOCOL *gRuntime; +extern EFI_CPU_ARCH_PROTOCOL *gCpu; +extern EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer; +extern EFI_METRONOME_ARCH_PROTOCOL *gMetronome; +extern EFI_TIMER_ARCH_PROTOCOL *gTimer; +extern EFI_SECURITY_ARCH_PROTOCOL *gSecurity; +extern EFI_SECURITY2_ARCH_PROTOCOL *gSecurity2; +extern EFI_BDS_ARCH_PROTOCOL *gBds; +extern EFI_SMM_BASE2_PROTOCOL *gSmmBase2; -extern EFI_TPL gEfiCurrentTpl; +extern EFI_TPL gEfiCurrentTpl; -extern EFI_GUID *gDxeCoreFileName; -extern EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage; +extern EFI_GUID *gDxeCoreFileName; +extern EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage; -extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1]; +extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1]; -extern BOOLEAN gDispatcherRunning; -extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate; +extern BOOLEAN gDispatcherRunning; +extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate; -extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable; -extern BOOLEAN gLoadFixedAddressCodeMemoryReady; +extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable; +extern BOOLEAN gLoadFixedAddressCodeMemoryReady; // // Service Initialization Functions // - - /** Called to initialize the pool. @@ -238,7 +295,6 @@ CoreInitializePool ( VOID ); - /** Called to initialize the memory map and add descriptors to the current descriptor list. @@ -262,7 +318,6 @@ CoreAddMemoryDescriptor ( IN UINT64 Attribute ); - /** Release memory lock on mGcdMemorySpaceLock. @@ -272,7 +327,6 @@ CoreReleaseGcdMemoryLock ( VOID ); - /** Acquire memory lock on mGcdMemorySpaceLock. @@ -282,7 +336,6 @@ CoreAcquireGcdMemoryLock ( VOID ); - /** External function. Initializes memory services based on the memory descriptor HOBs. This function is responsible for priming the memory @@ -305,8 +358,6 @@ CoreInitializeMemoryServices ( OUT UINT64 *MemoryLength ); - - /** External function. Initializes the GCD and memory services based on the memory descriptor HOBs. This function is responsible for priming the GCD map and the @@ -328,7 +379,6 @@ CoreInitializeGcdServices ( IN UINT64 MemoryLength ); - /** Initializes "event" support. @@ -340,7 +390,6 @@ CoreInitializeEventServices ( VOID ); - /** Add the Image Services to EFI Boot Services Table and install the protocol interfaces for this image. @@ -352,10 +401,9 @@ CoreInitializeEventServices ( **/ EFI_STATUS CoreInitializeImageServices ( - IN VOID *HobStart + IN VOID *HobStart ); - /** Creates an event that is fired everytime a Protocol of a specific type is installed. @@ -365,9 +413,8 @@ CoreNotifyOnProtocolInstallation ( VOID ); - /** - Return TRUE if all AP services are availible. + Return TRUE if all AP services are available. @retval EFI_SUCCESS All AP services are available @retval EFI_NOT_FOUND At least one AP service is not available @@ -378,7 +425,6 @@ CoreAllEfiServicesAvailable ( VOID ); - /** Calcualte the 32-bit CRC in a EFI table using the service provided by the gRuntime service. @@ -388,24 +434,22 @@ CoreAllEfiServicesAvailable ( **/ VOID CalculateEfiHdrCrc ( - IN OUT EFI_TABLE_HEADER *Hdr + IN OUT EFI_TABLE_HEADER *Hdr ); - /** Called by the platform code to process a tick. - @param Duration The number of 100ns elasped since the last call + @param Duration The number of 100ns elapsed since the last call to TimerTick **/ VOID EFIAPI CoreTimerTick ( - IN UINT64 Duration + IN UINT64 Duration ); - /** Initialize the dispatcher. Initialize the notification function that runs when an FV2 protocol is added to the system. @@ -416,7 +460,6 @@ CoreInitializeDispatcher ( VOID ); - /** This is the POSTFIX version of the dependency evaluator. This code does not need to handle Before or After, as it is not valid to call this @@ -432,10 +475,9 @@ CoreInitializeDispatcher ( **/ BOOLEAN CoreIsSchedulable ( - IN EFI_CORE_DRIVER_ENTRY *DriverEntry + IN EFI_CORE_DRIVER_ENTRY *DriverEntry ); - /** Preprocess dependency expression and update DriverEntry to reflect the state of Before, After, and SOR dependencies. If DriverEntry->Before @@ -450,11 +492,9 @@ CoreIsSchedulable ( **/ EFI_STATUS CorePreProcessDepex ( - IN EFI_CORE_DRIVER_ENTRY *DriverEntry + IN EFI_CORE_DRIVER_ENTRY *DriverEntry ); - - /** Terminates all boot services. @@ -468,11 +508,10 @@ CorePreProcessDepex ( EFI_STATUS EFIAPI CoreExitBootServices ( - IN EFI_HANDLE ImageHandle, - IN UINTN MapKey + IN EFI_HANDLE ImageHandle, + IN UINTN MapKey ); - /** Make sure the memory map is following all the construction rules, it is the last time to check memory map error before exit boot services. @@ -486,10 +525,9 @@ CoreExitBootServices ( **/ EFI_STATUS CoreTerminateMemoryMap ( - IN UINTN MapKey + IN UINTN MapKey ); - /** Signals all events in the EventGroup. @@ -498,11 +536,9 @@ CoreTerminateMemoryMap ( **/ VOID CoreNotifySignalList ( - IN EFI_GUID *EventGroup + IN EFI_GUID *EventGroup ); - - /** Boot Service called to add, modify, or remove a system configuration table from the EFI System Table. @@ -521,12 +557,10 @@ CoreNotifySignalList ( EFI_STATUS EFIAPI CoreInstallConfigurationTable ( - IN EFI_GUID *Guid, - IN VOID *Table + IN EFI_GUID *Guid, + IN VOID *Table ); - - /** Raise the task priority level to the new level. High level is implemented by disabling processor interrupts. @@ -539,11 +573,9 @@ CoreInstallConfigurationTable ( EFI_TPL EFIAPI CoreRaiseTpl ( - IN EFI_TPL NewTpl + IN EFI_TPL NewTpl ); - - /** Lowers the task priority to the previous value. If the new priority unmasks events at a higher priority, they are dispatched. @@ -554,11 +586,9 @@ CoreRaiseTpl ( VOID EFIAPI CoreRestoreTpl ( - IN EFI_TPL NewTpl + IN EFI_TPL NewTpl ); - - /** Introduces a fine-grained stall. @@ -572,11 +602,9 @@ CoreRestoreTpl ( EFI_STATUS EFIAPI CoreStall ( - IN UINTN Microseconds + IN UINTN Microseconds ); - - /** Sets the system's watchdog timer. @@ -602,14 +630,12 @@ CoreStall ( EFI_STATUS EFIAPI CoreSetWatchdogTimer ( - IN UINTN Timeout, - IN UINT64 WatchdogCode, - IN UINTN DataSize, - IN CHAR16 *WatchdogData OPTIONAL + IN UINTN Timeout, + IN UINT64 WatchdogCode, + IN UINTN DataSize, + IN CHAR16 *WatchdogData OPTIONAL ); - - /** Wrapper function to CoreInstallProtocolInterfaceNotify. This is the public API which Calls the private one which contains a BOOLEAN parameter for notifications @@ -627,13 +653,12 @@ CoreSetWatchdogTimer ( EFI_STATUS EFIAPI CoreInstallProtocolInterface ( - IN OUT EFI_HANDLE *UserHandle, - IN EFI_GUID *Protocol, - IN EFI_INTERFACE_TYPE InterfaceType, - IN VOID *Interface + IN OUT EFI_HANDLE *UserHandle, + IN EFI_GUID *Protocol, + IN EFI_INTERFACE_TYPE InterfaceType, + IN VOID *Interface ); - /** Installs a protocol interface into the boot services environment. @@ -653,15 +678,13 @@ CoreInstallProtocolInterface ( **/ EFI_STATUS CoreInstallProtocolInterfaceNotify ( - IN OUT EFI_HANDLE *UserHandle, - IN EFI_GUID *Protocol, - IN EFI_INTERFACE_TYPE InterfaceType, - IN VOID *Interface, - IN BOOLEAN Notify + IN OUT EFI_HANDLE *UserHandle, + IN EFI_GUID *Protocol, + IN EFI_INTERFACE_TYPE InterfaceType, + IN VOID *Interface, + IN BOOLEAN Notify ); - - /** Installs a list of protocol interface into the boot services environment. This function calls InstallProtocolInterface() in a loop. If any error @@ -686,12 +709,10 @@ CoreInstallProtocolInterfaceNotify ( EFI_STATUS EFIAPI CoreInstallMultipleProtocolInterfaces ( - IN OUT EFI_HANDLE *Handle, + IN OUT EFI_HANDLE *Handle, ... ); - - /** Uninstalls a list of protocol interface in the boot services environment. This function calls UnisatllProtocolInterface() in a loop. This is @@ -709,12 +730,10 @@ CoreInstallMultipleProtocolInterfaces ( EFI_STATUS EFIAPI CoreUninstallMultipleProtocolInterfaces ( - IN EFI_HANDLE Handle, + IN EFI_HANDLE Handle, ... ); - - /** Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface. @@ -732,14 +751,12 @@ CoreUninstallMultipleProtocolInterfaces ( EFI_STATUS EFIAPI CoreReinstallProtocolInterface ( - IN EFI_HANDLE UserHandle, - IN EFI_GUID *Protocol, - IN VOID *OldInterface, - IN VOID *NewInterface + IN EFI_HANDLE UserHandle, + IN EFI_GUID *Protocol, + IN VOID *OldInterface, + IN VOID *NewInterface ); - - /** Uninstalls all instances of a protocol:interfacer from a handle. If the last protocol interface is remove from the handle, the @@ -756,13 +773,11 @@ CoreReinstallProtocolInterface ( EFI_STATUS EFIAPI CoreUninstallProtocolInterface ( - IN EFI_HANDLE UserHandle, - IN EFI_GUID *Protocol, - IN VOID *Interface + IN EFI_HANDLE UserHandle, + IN EFI_GUID *Protocol, + IN VOID *Interface ); - - /** Queries a handle to determine if it supports a specified protocol. @@ -777,13 +792,11 @@ CoreUninstallProtocolInterface ( EFI_STATUS EFIAPI CoreHandleProtocol ( - IN EFI_HANDLE UserHandle, - IN EFI_GUID *Protocol, - OUT VOID **Interface + IN EFI_HANDLE UserHandle, + IN EFI_GUID *Protocol, + OUT VOID **Interface ); - - /** Locates the installed protocol handler for the handle, and invokes it to obtain the protocol interface. Usage information @@ -807,16 +820,14 @@ CoreHandleProtocol ( EFI_STATUS EFIAPI CoreOpenProtocol ( - IN EFI_HANDLE UserHandle, - IN EFI_GUID *Protocol, - OUT VOID **Interface OPTIONAL, - IN EFI_HANDLE ImageHandle, - IN EFI_HANDLE ControllerHandle, - IN UINT32 Attributes + IN EFI_HANDLE UserHandle, + IN EFI_GUID *Protocol, + OUT VOID **Interface OPTIONAL, + IN EFI_HANDLE ImageHandle, + IN EFI_HANDLE ControllerHandle, + IN UINT32 Attributes ); - - /** Return information about Opened protocols in the system @@ -831,14 +842,12 @@ CoreOpenProtocol ( EFI_STATUS EFIAPI CoreOpenProtocolInformation ( - IN EFI_HANDLE UserHandle, - IN EFI_GUID *Protocol, - OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer, - OUT UINTN *EntryCount + IN EFI_HANDLE UserHandle, + IN EFI_GUID *Protocol, + OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer, + OUT UINTN *EntryCount ); - - /** Closes a protocol on a handle that was opened using OpenProtocol(). @@ -867,14 +876,12 @@ CoreOpenProtocolInformation ( EFI_STATUS EFIAPI CoreCloseProtocol ( - IN EFI_HANDLE UserHandle, - IN EFI_GUID *Protocol, - IN EFI_HANDLE AgentHandle, - IN EFI_HANDLE ControllerHandle + IN EFI_HANDLE UserHandle, + IN EFI_GUID *Protocol, + IN EFI_HANDLE AgentHandle, + IN EFI_HANDLE ControllerHandle ); - - /** Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated from pool. @@ -901,13 +908,11 @@ CoreCloseProtocol ( EFI_STATUS EFIAPI CoreProtocolsPerHandle ( - IN EFI_HANDLE UserHandle, - OUT EFI_GUID ***ProtocolBuffer, - OUT UINTN *ProtocolBufferCount + IN EFI_HANDLE UserHandle, + OUT EFI_GUID ***ProtocolBuffer, + OUT UINTN *ProtocolBufferCount ); - - /** Add a new protocol notification record for the request protocol. @@ -924,12 +929,11 @@ CoreProtocolsPerHandle ( EFI_STATUS EFIAPI CoreRegisterProtocolNotify ( - IN EFI_GUID *Protocol, - IN EFI_EVENT Event, - OUT VOID **Registration + IN EFI_GUID *Protocol, + IN EFI_EVENT Event, + OUT VOID **Registration ); - /** Removes all the events in the protocol database that match Event. @@ -941,10 +945,9 @@ CoreRegisterProtocolNotify ( **/ EFI_STATUS CoreUnregisterProtocolNotify ( - IN EFI_EVENT Event + IN EFI_EVENT Event ); - /** Locates the requested handle(s) and returns them in Buffer. @@ -966,15 +969,13 @@ CoreUnregisterProtocolNotify ( EFI_STATUS EFIAPI CoreLocateHandle ( - IN EFI_LOCATE_SEARCH_TYPE SearchType, - IN EFI_GUID *Protocol OPTIONAL, - IN VOID *SearchKey OPTIONAL, - IN OUT UINTN *BufferSize, - OUT EFI_HANDLE *Buffer + IN EFI_LOCATE_SEARCH_TYPE SearchType, + IN EFI_GUID *Protocol OPTIONAL, + IN VOID *SearchKey OPTIONAL, + IN OUT UINTN *BufferSize, + OUT EFI_HANDLE *Buffer ); - - /** Locates the handle to a device on the device path that best matches the specified protocol. @@ -993,13 +994,11 @@ CoreLocateHandle ( EFI_STATUS EFIAPI CoreLocateDevicePath ( - IN EFI_GUID *Protocol, - IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, - OUT EFI_HANDLE *Device + IN EFI_GUID *Protocol, + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, + OUT EFI_HANDLE *Device ); - - /** Function returns an array of handles that support the requested protocol in a buffer allocated from pool. This is a version of CoreLocateHandle() @@ -1019,21 +1018,19 @@ CoreLocateDevicePath ( @retval EFI_NOT_FOUND No handles match the search. @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the matching results. - @retval EFI_INVALID_PARAMETER One or more paramters are not valid. + @retval EFI_INVALID_PARAMETER One or more parameters are not valid. **/ EFI_STATUS EFIAPI CoreLocateHandleBuffer ( - IN EFI_LOCATE_SEARCH_TYPE SearchType, - IN EFI_GUID *Protocol OPTIONAL, - IN VOID *SearchKey OPTIONAL, - IN OUT UINTN *NumberHandles, - OUT EFI_HANDLE **Buffer + IN EFI_LOCATE_SEARCH_TYPE SearchType, + IN EFI_GUID *Protocol OPTIONAL, + IN VOID *SearchKey OPTIONAL, + IN OUT UINTN *NumberHandles, + OUT EFI_HANDLE **Buffer ); - - /** Return the first Protocol Interface that matches the Protocol GUID. If Registration is passed in, return a Protocol Instance that was just add @@ -1058,7 +1055,6 @@ CoreLocateProtocol ( OUT VOID **Interface ); - /** return handle database key. @@ -1071,7 +1067,6 @@ CoreGetHandleDatabaseKey ( VOID ); - /** Go connect any handles that were created or modified while a image executed. @@ -1084,8 +1079,6 @@ CoreConnectHandlesByKey ( UINT64 Key ); - - /** Connects one or more drivers to a controller. @@ -1107,8 +1100,8 @@ CoreConnectHandlesByKey ( @retval EFI_NOT_FOUND 1) There are no EFI_DRIVER_BINDING_PROTOCOL instances present in the system. 2) No drivers were connected to ControllerHandle. - @retval EFI_SECURITY_VIOLATION - The user has no permission to start UEFI device drivers on the device path + @retval EFI_SECURITY_VIOLATION + The user has no permission to start UEFI device drivers on the device path associated with the ControllerHandle or specified by the RemainingDevicePath. **/ @@ -1121,8 +1114,6 @@ CoreConnectController ( IN BOOLEAN Recursive ); - - /** Disonnects a controller from a driver @@ -1163,8 +1154,6 @@ CoreDisconnectController ( IN EFI_HANDLE ChildHandle OPTIONAL ); - - /** Allocates pages from the memory map. @@ -1186,14 +1175,12 @@ CoreDisconnectController ( EFI_STATUS EFIAPI CoreAllocatePages ( - IN EFI_ALLOCATE_TYPE Type, - IN EFI_MEMORY_TYPE MemoryType, - IN UINTN NumberOfPages, + IN EFI_ALLOCATE_TYPE Type, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN NumberOfPages, IN OUT EFI_PHYSICAL_ADDRESS *Memory ); - - /** Frees previous allocated pages. @@ -1208,12 +1195,10 @@ CoreAllocatePages ( EFI_STATUS EFIAPI CoreFreePages ( - IN EFI_PHYSICAL_ADDRESS Memory, - IN UINTN NumberOfPages + IN EFI_PHYSICAL_ADDRESS Memory, + IN UINTN NumberOfPages ); - - /** This function returns a copy of the current memory map. The map is an array of memory descriptors, each of which describes a contiguous block of memory. @@ -1254,8 +1239,6 @@ CoreGetMemoryMap ( OUT UINT32 *DescriptorVersion ); - - /** Allocate pool of a particular type. @@ -1277,7 +1260,26 @@ CoreAllocatePool ( OUT VOID **Buffer ); +/** + Allocate pool of a particular type. + @param PoolType Type of pool to allocate + @param Size The amount of pool to allocate + @param Buffer The address to return a pointer to the allocated + pool + + @retval EFI_INVALID_PARAMETER PoolType not valid or Buffer is NULL + @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed. + @retval EFI_SUCCESS Pool successfully allocated. + +**/ +EFI_STATUS +EFIAPI +CoreInternalAllocatePool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN Size, + OUT VOID **Buffer + ); /** Frees pool. @@ -1291,10 +1293,25 @@ CoreAllocatePool ( EFI_STATUS EFIAPI CoreFreePool ( - IN VOID *Buffer + IN VOID *Buffer ); +/** + Frees pool. + + @param Buffer The allocated pool entry to free + @param PoolType Pointer to pool type + + @retval EFI_INVALID_PARAMETER Buffer is not a valid value. + @retval EFI_SUCCESS Pool successfully freed. +**/ +EFI_STATUS +EFIAPI +CoreInternalFreePool ( + IN VOID *Buffer, + OUT EFI_MEMORY_TYPE *PoolType OPTIONAL + ); /** Loads an EFI image into memory and returns a handle to the image. @@ -1323,26 +1340,24 @@ CoreFreePool ( @retval EFI_LOAD_ERROR Image was not loaded because the image format was corrupt or not understood. @retval EFI_DEVICE_ERROR Image was not loaded because the device returned a read error. - @retval EFI_ACCESS_DENIED Image was not loaded because the platform policy prohibits the + @retval EFI_ACCESS_DENIED Image was not loaded because the platform policy prohibits the image from being loaded. NULL is returned in *ImageHandle. - @retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a - valid EFI_LOADED_IMAGE_PROTOCOL. However, the current + @retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a + valid EFI_LOADED_IMAGE_PROTOCOL. However, the current platform policy specifies that the image should not be started. **/ EFI_STATUS EFIAPI CoreLoadImage ( - IN BOOLEAN BootPolicy, - IN EFI_HANDLE ParentImageHandle, - IN EFI_DEVICE_PATH_PROTOCOL *FilePath, - IN VOID *SourceBuffer OPTIONAL, - IN UINTN SourceSize, - OUT EFI_HANDLE *ImageHandle + IN BOOLEAN BootPolicy, + IN EFI_HANDLE ParentImageHandle, + IN EFI_DEVICE_PATH_PROTOCOL *FilePath, + IN VOID *SourceBuffer OPTIONAL, + IN UINTN SourceSize, + OUT EFI_HANDLE *ImageHandle ); - - /** Unloads an image. @@ -1350,7 +1365,7 @@ CoreLoadImage ( unloaded. @retval EFI_SUCCESS The image has been unloaded. - @retval EFI_UNSUPPORTED The image has been sarted, and does not support + @retval EFI_UNSUPPORTED The image has been started, and does not support unload. @retval EFI_INVALID_PARAMPETER ImageHandle is not a valid image handle. @@ -1361,8 +1376,6 @@ CoreUnloadImage ( IN EFI_HANDLE ImageHandle ); - - /** Transfer control to a loaded image's entry point. @@ -1390,8 +1403,6 @@ CoreStartImage ( OUT CHAR16 **ExitData OPTIONAL ); - - /** Terminates the currently loaded EFI image and returns control to boot services. @@ -1424,8 +1435,6 @@ CoreExit ( IN CHAR16 *ExitData OPTIONAL ); - - /** Creates an event. @@ -1447,15 +1456,13 @@ CoreExit ( EFI_STATUS EFIAPI CoreCreateEvent ( - IN UINT32 Type, - IN EFI_TPL NotifyTpl, - IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL - IN VOID *NotifyContext, OPTIONAL - OUT EFI_EVENT *Event + IN UINT32 Type, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL, + IN VOID *NotifyContext OPTIONAL, + OUT EFI_EVENT *Event ); - - /** Creates an event in a group. @@ -1479,12 +1486,12 @@ CoreCreateEvent ( EFI_STATUS EFIAPI CoreCreateEventEx ( - IN UINT32 Type, - IN EFI_TPL NotifyTpl, - IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL - IN CONST VOID *NotifyContext, OPTIONAL - IN CONST EFI_GUID *EventGroup, OPTIONAL - OUT EFI_EVENT *Event + IN UINT32 Type, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL, + IN CONST VOID *NotifyContext OPTIONAL, + IN CONST EFI_GUID *EventGroup OPTIONAL, + OUT EFI_EVENT *Event ); /** @@ -1510,12 +1517,12 @@ CoreCreateEventEx ( EFI_STATUS EFIAPI CoreCreateEventInternal ( - IN UINT32 Type, - IN EFI_TPL NotifyTpl, - IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL - IN CONST VOID *NotifyContext, OPTIONAL - IN CONST EFI_GUID *EventGroup, OPTIONAL - OUT EFI_EVENT *Event + IN UINT32 Type, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL, + IN CONST VOID *NotifyContext OPTIONAL, + IN CONST EFI_GUID *EventGroup OPTIONAL, + OUT EFI_EVENT *Event ); /** @@ -1536,13 +1543,11 @@ CoreCreateEventInternal ( EFI_STATUS EFIAPI CoreSetTimer ( - IN EFI_EVENT UserEvent, - IN EFI_TIMER_DELAY Type, - IN UINT64 TriggerTime + IN EFI_EVENT UserEvent, + IN EFI_TIMER_DELAY Type, + IN UINT64 TriggerTime ); - - /** Signals the event. Queues the event to be notified if needed. @@ -1555,11 +1560,9 @@ CoreSetTimer ( EFI_STATUS EFIAPI CoreSignalEvent ( - IN EFI_EVENT UserEvent + IN EFI_EVENT UserEvent ); - - /** Stops execution until an event is signaled. @@ -1577,13 +1580,11 @@ CoreSignalEvent ( EFI_STATUS EFIAPI CoreWaitForEvent ( - IN UINTN NumberOfEvents, - IN EFI_EVENT *UserEvents, - OUT UINTN *UserIndex + IN UINTN NumberOfEvents, + IN EFI_EVENT *UserEvents, + OUT UINTN *UserIndex ); - - /** Closes an event and frees the event structure. @@ -1596,11 +1597,9 @@ CoreWaitForEvent ( EFI_STATUS EFIAPI CoreCloseEvent ( - IN EFI_EVENT UserEvent + IN EFI_EVENT UserEvent ); - - /** Check the status of an event. @@ -1614,10 +1613,9 @@ CoreCloseEvent ( EFI_STATUS EFIAPI CoreCheckEvent ( - IN EFI_EVENT UserEvent + IN EFI_EVENT UserEvent ); - /** Adds reserved memory, system memory, or memory-mapped I/O resources to the global coherency domain of the processor. @@ -1639,7 +1637,6 @@ CoreAddMemorySpace ( IN UINT64 Capabilities ); - /** Allocates nonexistent memory, reserved memory, system memory, or memorymapped I/O resources from the global coherency domain of the processor. @@ -1669,7 +1666,6 @@ CoreAllocateMemorySpace ( IN EFI_HANDLE DeviceHandle OPTIONAL ); - /** Frees nonexistent memory, reserved memory, system memory, or memory-mapped I/O resources from the global coherency domain of the processor. @@ -1687,7 +1683,6 @@ CoreFreeMemorySpace ( IN UINT64 Length ); - /** Removes reserved memory, system memory, or memory-mapped I/O resources from the global coherency domain of the processor. @@ -1705,7 +1700,6 @@ CoreRemoveMemorySpace ( IN UINT64 Length ); - /** Retrieves the descriptor for a memory region containing a specified address. @@ -1723,7 +1717,6 @@ CoreGetMemorySpaceDescriptor ( OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Descriptor ); - /** Modifies the attributes for a memory region in the global coherency domain of the processor. @@ -1733,12 +1726,12 @@ CoreGetMemorySpaceDescriptor ( @param Attributes Specified attributes @retval EFI_SUCCESS The attributes were set for the memory region. - @retval EFI_INVALID_PARAMETER Length is zero. + @retval EFI_INVALID_PARAMETER Length is zero. @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. @retval EFI_UNSUPPORTED The bit mask of attributes is not support for the memory resource range specified by BaseAddress and Length. - @retval EFI_ACCESS_DEFINED The attributes for the memory resource range specified by + @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by BaseAddress and Length cannot be modified. @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of the memory resource range. @@ -1754,6 +1747,30 @@ CoreSetMemorySpaceAttributes ( IN UINT64 Attributes ); +/** + Modifies the capabilities for a memory region in the global coherency domain of the + processor. + + @param BaseAddress The physical address that is the start address of a memory region. + @param Length The size in bytes of the memory region. + @param Capabilities The bit mask of capabilities that the memory region supports. + + @retval EFI_SUCCESS The capabilities were set for the memory region. + @retval EFI_INVALID_PARAMETER Length is zero. + @retval EFI_UNSUPPORTED The capabilities specified by Capabilities do not include the + memory region attributes currently in use. + @retval EFI_ACCESS_DENIED The capabilities for the memory resource range specified by + BaseAddress and Length cannot be modified. + @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the capabilities + of the memory resource range. +**/ +EFI_STATUS +EFIAPI +CoreSetMemorySpaceCapabilities ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Capabilities + ); /** Returns a map of the memory resources in the global coherency domain of the @@ -1774,7 +1791,6 @@ CoreGetMemorySpaceMap ( OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR **MemorySpaceMap ); - /** Adds reserved I/O or I/O resources to the global coherency domain of the processor. @@ -1794,7 +1810,6 @@ CoreAddIoSpace ( IN UINT64 Length ); - /** Allocates nonexistent I/O, reserved I/O, or I/O resources from the global coherency domain of the processor. @@ -1824,7 +1839,6 @@ CoreAllocateIoSpace ( IN EFI_HANDLE DeviceHandle OPTIONAL ); - /** Frees nonexistent I/O, reserved I/O, or I/O resources from the global coherency domain of the processor. @@ -1842,7 +1856,6 @@ CoreFreeIoSpace ( IN UINT64 Length ); - /** Removes reserved I/O or I/O resources from the global coherency domain of the processor. @@ -1860,7 +1873,6 @@ CoreRemoveIoSpace ( IN UINT64 Length ); - /** Retrieves the descriptor for an I/O region containing a specified address. @@ -1878,7 +1890,6 @@ CoreGetIoSpaceDescriptor ( OUT EFI_GCD_IO_SPACE_DESCRIPTOR *Descriptor ); - /** Returns a map of the I/O resources in the global coherency domain of the processor. @@ -1897,7 +1908,6 @@ CoreGetIoSpaceMap ( OUT EFI_GCD_IO_SPACE_DESCRIPTOR **IoSpaceMap ); - /** This is the main Dispatcher for DXE and it exits when there are no more drivers to run. Drain the mScheduledQueue and load and start a PE @@ -1939,7 +1949,6 @@ CoreSchedule ( IN EFI_GUID *DriverName ); - /** Convert a driver from the Untrused back to the Scheduled state. @@ -1959,7 +1968,6 @@ CoreTrust ( IN EFI_GUID *DriverName ); - /** This routine is the driver initialization entry point. It initializes the libraries, and registers two notification functions. These notification @@ -1974,11 +1982,10 @@ CoreTrust ( EFI_STATUS EFIAPI FwVolDriverInit ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable ); - /** Entry point of the section extraction code. Initializes an instance of the section extraction interface and installs it on a new handle. @@ -1993,11 +2000,10 @@ FwVolDriverInit ( EFI_STATUS EFIAPI InitializeSectionExtraction ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable ); - /** This DXE service routine is used to process a firmware volume. In particular, it can be called by BDS to process a single firmware @@ -2018,13 +2024,13 @@ InitializeSectionExtraction ( EFI_STATUS EFIAPI CoreProcessFirmwareVolume ( - IN VOID *FvHeader, - IN UINTN Size, - OUT EFI_HANDLE *FVProtocolHandle + IN VOID *FvHeader, + IN UINTN Size, + OUT EFI_HANDLE *FVProtocolHandle ); // -//Functions used during debug buils +// Functions used during debug buils // /** @@ -2037,7 +2043,6 @@ CoreDisplayMissingArchProtocols ( VOID ); - /** Traverse the discovered list for any drivers that were discovered but not loaded because the dependency experessions evaluated to false. @@ -2048,21 +2053,6 @@ CoreDisplayDiscoveredNotDispatched ( VOID ); - -/** - Place holder function until all the Boot Services and Runtime Services are - available. - - @return EFI_NOT_AVAILABLE_YET - -**/ -EFI_STATUS -EFIAPI -CoreEfiNotAvailableYetArg0 ( - VOID - ); - - /** Place holder function until all the Boot Services and Runtime Services are available. @@ -2075,10 +2065,9 @@ CoreEfiNotAvailableYetArg0 ( EFI_STATUS EFIAPI CoreEfiNotAvailableYetArg1 ( - UINTN Arg1 + UINTN Arg1 ); - /** Place holder function until all the Boot Services and Runtime Services are available. @@ -2091,11 +2080,10 @@ CoreEfiNotAvailableYetArg1 ( EFI_STATUS EFIAPI CoreEfiNotAvailableYetArg2 ( - UINTN Arg1, - UINTN Arg2 + UINTN Arg1, + UINTN Arg2 ); - /** Place holder function until all the Boot Services and Runtime Services are available. @@ -2109,12 +2097,11 @@ CoreEfiNotAvailableYetArg2 ( EFI_STATUS EFIAPI CoreEfiNotAvailableYetArg3 ( - UINTN Arg1, - UINTN Arg2, - UINTN Arg3 + UINTN Arg1, + UINTN Arg2, + UINTN Arg3 ); - /** Place holder function until all the Boot Services and Runtime Services are available. @@ -2129,13 +2116,12 @@ CoreEfiNotAvailableYetArg3 ( EFI_STATUS EFIAPI CoreEfiNotAvailableYetArg4 ( - UINTN Arg1, - UINTN Arg2, - UINTN Arg3, - UINTN Arg4 + UINTN Arg1, + UINTN Arg2, + UINTN Arg3, + UINTN Arg4 ); - /** Place holder function until all the Boot Services and Runtime Services are available. @@ -2151,14 +2137,13 @@ CoreEfiNotAvailableYetArg4 ( EFI_STATUS EFIAPI CoreEfiNotAvailableYetArg5 ( - UINTN Arg1, - UINTN Arg2, - UINTN Arg3, - UINTN Arg4, - UINTN Arg5 + UINTN Arg1, + UINTN Arg2, + UINTN Arg3, + UINTN Arg4, + UINTN Arg5 ); - /** Given a compressed source buffer, this function retrieves the size of the uncompressed buffer and the size of the scratch buffer required to decompress @@ -2201,14 +2186,13 @@ CoreEfiNotAvailableYetArg5 ( EFI_STATUS EFIAPI DxeMainUefiDecompressGetInfo ( - IN EFI_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SourceSize, - OUT UINT32 *DestinationSize, - OUT UINT32 *ScratchSize + IN EFI_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SourceSize, + OUT UINT32 *DestinationSize, + OUT UINT32 *ScratchSize ); - /** Decompresses a compressed source buffer. @@ -2246,13 +2230,13 @@ DxeMainUefiDecompressGetInfo ( 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 + 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 ); /** @@ -2273,13 +2257,11 @@ DxeMainUefiDecompress ( EFI_STATUS EFIAPI OpenSectionStream ( - IN UINTN SectionStreamLength, - IN VOID *SectionStream, - OUT UINTN *SectionStreamHandle + IN UINTN SectionStreamLength, + IN VOID *SectionStream, + OUT UINTN *SectionStreamHandle ); - - /** SEP member function. Retrieves requested section from section stream. @@ -2295,7 +2277,7 @@ OpenSectionStream ( non-null on input, then the buffer is caller allocated. If Buffer is NULL, then the buffer is callee allocated. In either case, the - requried buffer size is returned in *BufferSize. + required buffer size is returned in *BufferSize. @param BufferSize On input, indicates the size of *Buffer if *Buffer is non-null on input. On output, indicates the required size (allocated size if @@ -2341,17 +2323,16 @@ OpenSectionStream ( EFI_STATUS EFIAPI GetSection ( - IN UINTN SectionStreamHandle, - IN EFI_SECTION_TYPE *SectionType, - IN EFI_GUID *SectionDefinitionGuid, - IN UINTN SectionInstance, - IN VOID **Buffer, - IN OUT UINTN *BufferSize, - OUT UINT32 *AuthenticationStatus, - IN BOOLEAN IsFfs3Fv + IN UINTN SectionStreamHandle, + IN EFI_SECTION_TYPE *SectionType, + IN EFI_GUID *SectionDefinitionGuid, + IN UINTN SectionInstance, + IN VOID **Buffer, + IN OUT UINTN *BufferSize, + OUT UINT32 *AuthenticationStatus, + IN BOOLEAN IsFfs3Fv ); - /** SEP member function. Deletes an existing section stream @@ -2368,8 +2349,8 @@ GetSection ( EFI_STATUS EFIAPI CloseSectionStream ( - IN UINTN StreamHandleToClose, - IN BOOLEAN FreeStreamBuffer + IN UINTN StreamHandleToClose, + IN BOOLEAN FreeStreamBuffer ); /** @@ -2388,7 +2369,6 @@ CoreInitializeDebugImageInfoTable ( VOID ); - /** Update the CRC32 in the Debug Table. Since the CRC32 service is made available by the Runtime driver, we have to @@ -2402,7 +2382,6 @@ CoreUpdateDebugTableCrc32 ( VOID ); - /** Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates the table if it's not large enough to accomidate another entry. @@ -2415,12 +2394,11 @@ CoreUpdateDebugTableCrc32 ( **/ VOID CoreNewDebugImageInfoEntry ( - IN UINT32 ImageInfoType, - IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, - IN EFI_HANDLE ImageHandle + IN UINT32 ImageInfoType, + IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, + IN EFI_HANDLE ImageHandle ); - /** Removes and frees an entry from the DebugImageInfo Table. @@ -2429,10 +2407,9 @@ CoreNewDebugImageInfoEntry ( **/ VOID CoreRemoveDebugImageInfoEntry ( - EFI_HANDLE ImageHandle + EFI_HANDLE ImageHandle ); - /** This routine consumes FV hobs and produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate. @@ -2446,8 +2423,8 @@ CoreRemoveDebugImageInfoEntry ( EFI_STATUS EFIAPI FwVolBlockDriverInit ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable ); /** @@ -2461,7 +2438,7 @@ FwVolBlockDriverInit ( **/ UINT32 GetFvbAuthenticationStatus ( - IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol + IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol ); /** @@ -2485,14 +2462,13 @@ GetFvbAuthenticationStatus ( **/ EFI_STATUS ProduceFVBProtocolOnBuffer ( - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN EFI_HANDLE ParentHandle, - IN UINT32 AuthenticationStatus, - OUT EFI_HANDLE *FvProtocol OPTIONAL + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_HANDLE ParentHandle, + IN UINT32 AuthenticationStatus, + OUT EFI_HANDLE *FvProtocol OPTIONAL ); - /** Raising to the task priority level of the mutual exclusion lock, and then acquires ownership of the lock. @@ -2507,7 +2483,6 @@ CoreAcquireLock ( IN EFI_LOCK *Lock ); - /** Initialize a basic mutual exclusion lock. Each lock provides mutual exclusion access at it's task priority @@ -2526,7 +2501,6 @@ CoreAcquireLockOrFail ( IN EFI_LOCK *Lock ); - /** Releases ownership of the mutual exclusion lock, and restores the previous task priority level. @@ -2541,24 +2515,8 @@ CoreReleaseLock ( IN EFI_LOCK *Lock ); - /** - An empty function to pass error checking of CreateEventEx (). - - @param Event Event whose notification function is being invoked. - @param Context Pointer to the notification function's context, - which is implementation-dependent. - -**/ -VOID -EFIAPI -CoreEmptyCallbackFunction ( - IN EFI_EVENT Event, - IN VOID *Context - ); - -/** - Read data from Firmware Block by FVB protocol Read. + Read data from Firmware Block by FVB protocol Read. The data may cross the multi block ranges. @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to read data. @@ -2576,11 +2534,11 @@ CoreEmptyCallbackFunction ( **/ EFI_STATUS ReadFvbData ( - IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb, - IN OUT EFI_LBA *StartLba, - IN OUT UINTN *Offset, - IN UINTN DataSize, - OUT UINT8 *Data + IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb, + IN OUT EFI_LBA *StartLba, + IN OUT UINTN *Offset, + IN UINTN DataSize, + OUT UINT8 *Data ); /** @@ -2601,8 +2559,8 @@ ReadFvbData ( **/ EFI_STATUS GetFwVolHeader ( - IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb, - OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader + IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb, + OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader ); /** @@ -2616,7 +2574,232 @@ GetFwVolHeader ( **/ BOOLEAN VerifyFvHeaderChecksum ( - IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader + IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader + ); + +/** + Initialize memory profile. + + @param HobStart The start address of the HOB. + +**/ +VOID +MemoryProfileInit ( + IN VOID *HobStart + ); + +/** + Install memory profile protocol. + +**/ +VOID +MemoryProfileInstallProtocol ( + VOID + ); + +/** + Register image to memory profile. + + @param DriverEntry Image info. + @param FileType Image file type. + + @return EFI_SUCCESS Register successfully. + @return EFI_UNSUPPORTED Memory profile unsupported, + or memory profile for the image is not required. + @return EFI_OUT_OF_RESOURCES No enough resource for this register. + +**/ +EFI_STATUS +RegisterMemoryProfileImage ( + IN LOADED_IMAGE_PRIVATE_DATA *DriverEntry, + IN EFI_FV_FILETYPE FileType + ); + +/** + Unregister image from memory profile. + + @param DriverEntry Image info. + + @return EFI_SUCCESS Unregister successfully. + @return EFI_UNSUPPORTED Memory profile unsupported, + or memory profile for the image is not required. + @return EFI_NOT_FOUND The image is not found. + +**/ +EFI_STATUS +UnregisterMemoryProfileImage ( + IN LOADED_IMAGE_PRIVATE_DATA *DriverEntry + ); + +/** + Update memory profile information. + + @param CallerAddress Address of caller who call Allocate or Free. + @param Action This Allocate or Free action. + @param MemoryType Memory type. + EfiMaxMemoryType means the MemoryType is unknown. + @param Size Buffer size. + @param Buffer Buffer address. + @param ActionString String for memory profile action. + Only needed for user defined allocate action. + + @return EFI_SUCCESS Memory profile is updated. + @return EFI_UNSUPPORTED Memory profile is unsupported, + or memory profile for the image is not required, + or memory profile for the memory type is not required. + @return EFI_ACCESS_DENIED It is during memory profile data getting. + @return EFI_ABORTED Memory profile recording is not enabled. + @return EFI_OUT_OF_RESOURCES No enough resource to update memory profile for allocate action. + @return EFI_NOT_FOUND No matched allocate info found for free action. + +**/ +EFI_STATUS +EFIAPI +CoreUpdateProfile ( + IN EFI_PHYSICAL_ADDRESS CallerAddress, + IN MEMORY_PROFILE_ACTION Action, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Size, // Valid for AllocatePages/FreePages/AllocatePool + IN VOID *Buffer, + IN CHAR8 *ActionString OPTIONAL + ); + +/** + Internal function. Converts a memory range to use new attributes. + + @param Start The first address of the range Must be page + aligned + @param NumberOfPages The number of pages to convert + @param NewAttributes The new attributes value for the range. + +**/ +VOID +CoreUpdateMemoryAttributes ( + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 NumberOfPages, + IN UINT64 NewAttributes + ); + +/** + Initialize MemoryAttrubutesTable support. +**/ +VOID +EFIAPI +CoreInitializeMemoryAttributesTable ( + VOID + ); + +/** + Initialize Memory Protection support. +**/ +VOID +EFIAPI +CoreInitializeMemoryProtection ( + VOID + ); + +/** + Install MemoryAttributesTable on memory allocation. + + @param[in] MemoryType EFI memory type. +**/ +VOID +InstallMemoryAttributesTableOnMemoryAllocation ( + IN EFI_MEMORY_TYPE MemoryType + ); + +/** + Insert image record. + + @param RuntimeImage Runtime image information +**/ +VOID +InsertImageRecord ( + IN EFI_RUNTIME_IMAGE_ENTRY *RuntimeImage + ); + +/** + Remove Image record. + + @param RuntimeImage Runtime image information +**/ +VOID +RemoveImageRecord ( + IN EFI_RUNTIME_IMAGE_ENTRY *RuntimeImage + ); + +/** + Protect UEFI image. + + @param[in] LoadedImage The loaded image protocol + @param[in] LoadedImageDevicePath The loaded image device path protocol +**/ +VOID +ProtectUefiImage ( + IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, + IN EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath + ); + +/** + Unprotect UEFI image. + + @param[in] LoadedImage The loaded image protocol + @param[in] LoadedImageDevicePath The loaded image device path protocol +**/ +VOID +UnprotectUefiImage ( + IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, + IN EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath + ); + +/** + ExitBootServices Callback function for memory protection. +**/ +VOID +MemoryProtectionExitBootServicesCallback ( + VOID + ); + +/** + Manage memory permission attributes on a memory range, according to the + configured DXE memory protection policy. + + @param OldType The old memory type of the range + @param NewType The new memory type of the range + @param Memory The base address of the range + @param Length The size of the range (in bytes) + + @return EFI_SUCCESS If the the CPU arch protocol is not installed yet + @return EFI_SUCCESS If no DXE memory protection policy has been configured + @return EFI_SUCCESS If OldType and NewType use the same permission attributes + @return other Return value of gCpu->SetMemoryAttributes() + +**/ +EFI_STATUS +EFIAPI +ApplyMemoryProtectionPolicy ( + IN EFI_MEMORY_TYPE OldType, + IN EFI_MEMORY_TYPE NewType, + IN EFI_PHYSICAL_ADDRESS Memory, + IN UINT64 Length + ); + +/** + Merge continous memory map entries whose have same attributes. + + @param MemoryMap A pointer to the buffer in which firmware places + the current memory map. + @param MemoryMapSize A pointer to the size, in bytes, of the + MemoryMap buffer. On input, this is the size of + the current memory map. On output, + it is the size of new memory map after merge. + @param DescriptorSize Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR. +**/ +VOID +MergeMemoryMap ( + IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, + IN OUT UINTN *MemoryMapSize, + IN UINTN DescriptorSize ); #endif