X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FCore%2FDxe%2FDxeMain.h;h=815a6b4bd844a452ace09c2e3932cfa03e3ecf2e;hb=1436aea4d5707e672672a11bda72be2c63c936c3;hp=c084dc821364fc0b0a38da5eb4d9cd38bc5d6e2e;hpb=6c85d1621713403f20e5c013fa8db161a1c8c4f3;p=mirror_edk2.git diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h index c084dc8213..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 - 2011, 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 @@ -41,7 +33,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include +#include #include #include #include @@ -52,6 +44,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include #include #include @@ -63,8 +56,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include #include +#include +#include +#include #include #include @@ -84,10 +81,9 @@ 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 @@ -101,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 @@ -118,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; // @@ -131,96 +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; + 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 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 EFI_DECOMPRESS_PROTOCOL gEfiDecompress; +extern BOOLEAN gMemoryMapTerminated; -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_BDS_ARCH_PROTOCOL *gBds; -extern EFI_SMM_BASE2_PROTOCOL *gSmmBase2; +extern EFI_DECOMPRESS_PROTOCOL gEfiDecompress; -extern EFI_TPL gEfiCurrentTpl; +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_GUID *gDxeCoreFileName; -extern EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage; +extern EFI_TPL gEfiCurrentTpl; -extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1]; +extern EFI_GUID *gDxeCoreFileName; +extern EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage; -extern BOOLEAN gDispatcherRunning; -extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate; +extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1]; -extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable; -extern BOOLEAN gLoadFixedAddressCodeMemoryReady; +extern BOOLEAN gDispatcherRunning; +extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate; + +extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable; +extern BOOLEAN gLoadFixedAddressCodeMemoryReady; // // Service Initialization Functions // - - /** Called to initialize the pool. @@ -230,7 +295,6 @@ CoreInitializePool ( VOID ); - /** Called to initialize the memory map and add descriptors to the current descriptor list. @@ -254,7 +318,6 @@ CoreAddMemoryDescriptor ( IN UINT64 Attribute ); - /** Release memory lock on mGcdMemorySpaceLock. @@ -264,7 +327,6 @@ CoreReleaseGcdMemoryLock ( VOID ); - /** Acquire memory lock on mGcdMemorySpaceLock. @@ -274,7 +336,6 @@ CoreAcquireGcdMemoryLock ( VOID ); - /** External function. Initializes memory services based on the memory descriptor HOBs. This function is responsible for priming the memory @@ -297,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 @@ -320,7 +379,6 @@ CoreInitializeGcdServices ( IN UINT64 MemoryLength ); - /** Initializes "event" support. @@ -332,7 +390,6 @@ CoreInitializeEventServices ( VOID ); - /** Add the Image Services to EFI Boot Services Table and install the protocol interfaces for this image. @@ -344,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. @@ -357,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 @@ -370,7 +425,6 @@ CoreAllEfiServicesAvailable ( VOID ); - /** Calcualte the 32-bit CRC in a EFI table using the service provided by the gRuntime service. @@ -380,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. @@ -408,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 @@ -424,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 @@ -442,11 +492,9 @@ CoreIsSchedulable ( **/ EFI_STATUS CorePreProcessDepex ( - IN EFI_CORE_DRIVER_ENTRY *DriverEntry + IN EFI_CORE_DRIVER_ENTRY *DriverEntry ); - - /** Terminates all boot services. @@ -460,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. @@ -478,10 +525,9 @@ CoreExitBootServices ( **/ EFI_STATUS CoreTerminateMemoryMap ( - IN UINTN MapKey + IN UINTN MapKey ); - /** Signals all events in the EventGroup. @@ -490,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. @@ -513,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. @@ -531,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. @@ -546,11 +586,9 @@ CoreRaiseTpl ( VOID EFIAPI CoreRestoreTpl ( - IN EFI_TPL NewTpl + IN EFI_TPL NewTpl ); - - /** Introduces a fine-grained stall. @@ -564,11 +602,9 @@ CoreRestoreTpl ( EFI_STATUS EFIAPI CoreStall ( - IN UINTN Microseconds + IN UINTN Microseconds ); - - /** Sets the system's watchdog timer. @@ -594,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 @@ -619,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. @@ -645,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 @@ -667,19 +698,21 @@ CoreInstallProtocolInterfaceNotify ( arguments to InstallProtocolInterface(). All the protocols are added to Handle. + @retval EFI_SUCCESS All the protocol interface was installed. + @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols. + @retval EFI_ALREADY_STARTED A Device Path Protocol instance was passed in that is already present in + the handle database. @retval EFI_INVALID_PARAMETER Handle is NULL. - @retval EFI_SUCCESS Protocol interfaces successfully installed. + @retval EFI_INVALID_PARAMETER Protocol is already installed on the handle specified by Handle. **/ 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 @@ -697,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. @@ -720,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 @@ -744,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. @@ -765,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 @@ -795,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 @@ -819,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(). @@ -855,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. @@ -889,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. @@ -912,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. @@ -929,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. @@ -954,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. @@ -981,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() @@ -1007,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 @@ -1046,7 +1055,6 @@ CoreLocateProtocol ( OUT VOID **Interface ); - /** return handle database key. @@ -1059,7 +1067,6 @@ CoreGetHandleDatabaseKey ( VOID ); - /** Go connect any handles that were created or modified while a image executed. @@ -1072,24 +1079,30 @@ CoreConnectHandlesByKey ( UINT64 Key ); - - /** Connects one or more drivers to a controller. - @param ControllerHandle Handle of the controller to be - connected. - @param DriverImageHandle DriverImageHandle A pointer to an - ordered list of driver image - handles. - @param RemainingDevicePath RemainingDevicePath A pointer to - the device path that specifies a - child of the controller specified - by ControllerHandle. - @param Recursive Whether the function would be - called recursively or not. + @param ControllerHandle The handle of the controller to which driver(s) are to be connected. + @param DriverImageHandle A pointer to an ordered list handles that support the + EFI_DRIVER_BINDING_PROTOCOL. + @param RemainingDevicePath A pointer to the device path that specifies a child of the + controller specified by ControllerHandle. + @param Recursive If TRUE, then ConnectController() is called recursively + until the entire tree of controllers below the controller specified + by ControllerHandle have been created. If FALSE, then + the tree of controllers is only expanded one level. - @return Status code. + @retval EFI_SUCCESS 1) One or more drivers were connected to ControllerHandle. + 2) No drivers were connected to ControllerHandle, but + RemainingDevicePath is not NULL, and it is an End Device + Path Node. + @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. + @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 + associated with the ControllerHandle or specified by the RemainingDevicePath. **/ EFI_STATUS @@ -1101,8 +1114,6 @@ CoreConnectController ( IN BOOLEAN Recursive ); - - /** Disonnects a controller from a driver @@ -1143,8 +1154,6 @@ CoreDisconnectController ( IN EFI_HANDLE ChildHandle OPTIONAL ); - - /** Allocates pages from the memory map. @@ -1166,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. @@ -1188,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. @@ -1234,8 +1239,6 @@ CoreGetMemoryMap ( OUT UINT32 *DescriptorVersion ); - - /** Allocate pool of a particular type. @@ -1244,7 +1247,7 @@ CoreGetMemoryMap ( @param Buffer The address to return a pointer to the allocated pool - @retval EFI_INVALID_PARAMETER PoolType not valid + @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. @@ -1257,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. @@ -1271,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. @@ -1303,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. @@ -1330,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. @@ -1341,8 +1376,6 @@ CoreUnloadImage ( IN EFI_HANDLE ImageHandle ); - - /** Transfer control to a loaded image's entry point. @@ -1357,6 +1390,7 @@ CoreUnloadImage ( @retval EFI_INVALID_PARAMETER Invalid parameter @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate + @retval EFI_SECURITY_VIOLATION The current platform policy specifies that the image should not be started. @retval EFI_SUCCESS Successfully transfer control to the image's entry point. @@ -1369,8 +1403,6 @@ CoreStartImage ( OUT CHAR16 **ExitData OPTIONAL ); - - /** Terminates the currently loaded EFI image and returns control to boot services. @@ -1403,10 +1435,8 @@ CoreExit ( IN CHAR16 *ExitData OPTIONAL ); - - /** - Creates a general-purpose event structure. + Creates an event. @param Type The type of event to create and its mode and attributes @@ -1426,17 +1456,15 @@ 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 a general-purpose event structure + Creates an event in a group. @param Type The type of event to create and its mode and attributes @@ -1458,15 +1486,44 @@ 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 ); +/** + Creates a general-purpose event structure + @param Type The type of event to create and its mode and + attributes + @param NotifyTpl The task priority level of event notifications + @param NotifyFunction Pointer to the events notification function + @param NotifyContext Pointer to the notification functions context; + corresponds to parameter "Context" in the + notification function + @param EventGroup GUID for EventGroup if NULL act the same as + gBS->CreateEvent(). + @param Event Pointer to the newly created event if the call + succeeds; undefined otherwise + + @retval EFI_SUCCESS The event structure was created + @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value + @retval EFI_OUT_OF_RESOURCES The event could not be allocated + +**/ +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 + ); /** Sets the type of timer and the trigger time for a timer event. @@ -1486,13 +1543,11 @@ CoreCreateEventEx ( 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. @@ -1505,11 +1560,9 @@ CoreSetTimer ( EFI_STATUS EFIAPI CoreSignalEvent ( - IN EFI_EVENT UserEvent + IN EFI_EVENT UserEvent ); - - /** Stops execution until an event is signaled. @@ -1527,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. @@ -1546,11 +1597,9 @@ CoreWaitForEvent ( EFI_STATUS EFIAPI CoreCloseEvent ( - IN EFI_EVENT UserEvent + IN EFI_EVENT UserEvent ); - - /** Check the status of an event. @@ -1564,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. @@ -1589,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. @@ -1619,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. @@ -1637,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. @@ -1655,7 +1700,6 @@ CoreRemoveMemorySpace ( IN UINT64 Length ); - /** Retrieves the descriptor for a memory region containing a specified address. @@ -1673,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. @@ -1682,8 +1725,18 @@ CoreGetMemorySpaceDescriptor ( @param Length Specified length @param Attributes Specified attributes - @retval EFI_SUCCESS Successfully set attribute of a segment of - memory space. + @retval EFI_SUCCESS The attributes were set for the memory region. + @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_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. + @retval EFI_NOT_AVAILABLE_YET The attributes cannot be set because CPU architectural protocol is + not available yet. **/ EFI_STATUS @@ -1694,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 @@ -1714,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. @@ -1734,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. @@ -1764,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. @@ -1782,7 +1856,6 @@ CoreFreeIoSpace ( IN UINT64 Length ); - /** Removes reserved I/O or I/O resources from the global coherency domain of the processor. @@ -1800,7 +1873,6 @@ CoreRemoveIoSpace ( IN UINT64 Length ); - /** Retrieves the descriptor for an I/O region containing a specified address. @@ -1818,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. @@ -1837,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 @@ -1879,7 +1949,6 @@ CoreSchedule ( IN EFI_GUID *DriverName ); - /** Convert a driver from the Untrused back to the Scheduled state. @@ -1899,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 @@ -1914,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. @@ -1933,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 @@ -1958,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 // /** @@ -1977,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. @@ -1988,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. @@ -2015,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. @@ -2031,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. @@ -2049,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. @@ -2069,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. @@ -2091,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 @@ -2141,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. @@ -2186,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 ); /** @@ -2213,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. @@ -2235,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 @@ -2281,21 +2323,22 @@ 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 @param StreamHandleToClose Indicates the stream to close + @param FreeStreamBuffer TRUE - Need to free stream buffer; + FALSE - No need to free stream buffer. @retval EFI_SUCCESS The section stream is closed sucessfully. @retval EFI_OUT_OF_RESOURCES Memory allocation failed. @@ -2306,7 +2349,8 @@ GetSection ( EFI_STATUS EFIAPI CloseSectionStream ( - IN UINTN StreamHandleToClose + IN UINTN StreamHandleToClose, + IN BOOLEAN FreeStreamBuffer ); /** @@ -2325,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 @@ -2339,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. @@ -2352,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. @@ -2366,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. @@ -2383,10 +2423,23 @@ CoreRemoveDebugImageInfoEntry ( EFI_STATUS EFIAPI FwVolBlockDriverInit ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable ); +/** + + Get FVB authentication status + + @param FvbProtocol FVB protocol. + + @return Authentication status. + +**/ +UINT32 +GetFvbAuthenticationStatus ( + IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol + ); /** This routine produces a firmware volume block protocol on a given @@ -2395,8 +2448,10 @@ FwVolBlockDriverInit ( @param BaseAddress base address of the firmware volume image @param Length length of the firmware volume image @param ParentHandle handle of parent firmware volume, if this image - came from an FV image file in another firmware + came from an FV image file and section in another firmware volume (ala capsules) + @param AuthenticationStatus Authentication status inherited, if this image + came from an FV image file and section in another firmware volume. @param FvProtocol Firmware volume block protocol produced. @retval EFI_VOLUME_CORRUPTED Volume corrupted. @@ -2407,13 +2462,13 @@ FwVolBlockDriverInit ( **/ EFI_STATUS ProduceFVBProtocolOnBuffer ( - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN EFI_HANDLE ParentHandle, - 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. @@ -2428,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 @@ -2447,7 +2501,6 @@ CoreAcquireLockOrFail ( IN EFI_LOCK *Lock ); - /** Releases ownership of the mutual exclusion lock, and restores the previous task priority level. @@ -2462,20 +2515,291 @@ CoreReleaseLock ( IN EFI_LOCK *Lock ); +/** + 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. + @param StartLba Pointer to StartLba. + On input, the start logical block index from which to read. + On output,the end logical block index after reading. + @param Offset Pointer to Offset + On input, offset into the block at which to begin reading. + On output, offset into the end block after reading. + @param DataSize Size of data to be read. + @param Data Pointer to Buffer that the data will be read into. + + @retval EFI_SUCCESS Successfully read data from firmware block. + @retval others +**/ +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 + ); + +/** + Given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and + copy the real length volume header into it. + + @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to + read the volume header + @param FwVolHeader Pointer to pointer to allocated buffer in which + the volume header is returned. + + @retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated. + @retval EFI_SUCCESS Successfully read volume header to the allocated + buffer. + @retval EFI_INVALID_PARAMETER The FV Header signature is not as expected or + the file system could not be understood. + +**/ +EFI_STATUS +GetFwVolHeader ( + IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb, + OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader + ); + +/** + Verify checksum of the firmware volume header. + + @param FvHeader Points to the firmware volume header to be checked + + @retval TRUE Checksum verification passed + @retval FALSE Checksum verification failed + +**/ +BOOLEAN +VerifyFvHeaderChecksum ( + 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 + ); /** - An empty function to pass error checking of CreateEventEx (). + Internal function. Converts a memory range to use new attributes. - @param Event Event whose notification function is being invoked. - @param Context Pointer to the notification function's context, - which is implementation-dependent. + @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 -CoreEmptyCallbackFunction ( - IN EFI_EVENT Event, - IN VOID *Context +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