X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FCore%2FDxe%2FDxeMain.h;h=bb2bfab370ff8ec32bb749336b9383684ad54d8d;hp=3d999f906fa2254c969346e85ea0fd32fdf2f79b;hb=84edd20bd0756ef5719835498d4283435d6b5e77;hpb=130f16022c545c2fbb0d561fe7cf5c2f1b086cfa diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h index 3d999f906f..bb2bfab370 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -2,8 +2,8 @@ The internal header file includes the common header files, defines internal structure and functions used by DxeCore module. -Copyright (c) 2006 - 2008, Intel Corporation.
-All rights reserved. This program and the accompanying materials +Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -25,6 +25,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include #include #include @@ -39,8 +40,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include #include +#include #include #include #include @@ -48,11 +49,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include +#include #include -#include +#include +#include #include #include +#include #include #include #include @@ -61,7 +64,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include - +#include +#include +#include +#include +#include +#include +#include #include #include @@ -74,21 +83,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include +#include #include #include #include #include #include +#include +#include +#include +#include -#include "DebugImageInfo.h" -#include "Library.h" -#include "FwVolBlock.h" -#include "FwVolDriver.h" -#include "Gcd.h" -#include "Imem.h" -#include "Image.h" -#include "Exec.h" -#include "Handle.h" // // attributes for reserved memory before it is promoted to system memory @@ -124,21 +130,22 @@ typedef struct { EFI_EVENT Event; VOID *Registration; BOOLEAN Present; -} ARCHITECTURAL_PROTOCOL_ENTRY; +} EFI_CORE_PROTOCOL_NOTIFY_ENTRY; // // DXE Dispatcher Data structures // -#define KNOWN_HANDLE_SIGNATURE EFI_SIGNATURE_32('k','n','o','w') +#define KNOWN_HANDLE_SIGNATURE SIGNATURE_32('k','n','o','w') typedef struct { UINTN Signature; LIST_ENTRY Link; // mFvHandleList EFI_HANDLE Handle; + EFI_GUID FvNameGuid; } KNOWN_HANDLE; -#define EFI_CORE_DRIVER_ENTRY_SIGNATURE EFI_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 @@ -165,13 +172,14 @@ typedef struct { BOOLEAN DepexProtocolError; EFI_HANDLE ImageHandle; + BOOLEAN IsFvImage; } EFI_CORE_DRIVER_ENTRY; // //The data structure of GCD memory map entry // -#define EFI_GCD_MAP_SIGNATURE EFI_SIGNATURE_32('g','c','d','m') +#define EFI_GCD_MAP_SIGNATURE SIGNATURE_32('g','c','d','m') typedef struct { UINTN Signature; LIST_ENTRY Link; @@ -185,6 +193,56 @@ typedef struct { 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/retore + VOID *JumpBuffer; + /// Pointer to buffer for context save/retore + BASE_LIBRARY_JUMP_BUFFER *JumpContext; + /// Machine type from PE image + UINT16 Machine; + /// EBC Protocol pointer + EFI_EBC_PROTOCOL *Ebc; + /// Runtime image list + EFI_RUNTIME_IMAGE_ENTRY *RuntimeData; + /// Pointer to Loaded Image Device Path Protocl + 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) + // // DXE Core Global Variables // @@ -201,7 +259,9 @@ 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; @@ -213,6 +273,8 @@ extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMem extern BOOLEAN gDispatcherRunning; extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate; +extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable; +extern BOOLEAN gLoadFixedAddressCodeMemoryReady; // // Service Initialization Functions // @@ -274,12 +336,11 @@ CoreAcquireGcdMemoryLock ( /** - 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 - memory map, so memory allocations and resource allocations can be made. The first - part of this function can not depend on any memory services until at least one - memory descriptor is provided to the memory services. Then the memory services - can be used to intialize the GCD map. + External function. Initializes memory services based on the memory + descriptor HOBs. This function is responsible for priming the memory + map, so memory allocations and resource allocations can be made. + The first part of this function can not depend on any memory services + until at least one memory descriptor is provided to the memory services. @param HobStart The start address of the HOB. @param MemoryBaseAddress Start address of memory region found to init DXE @@ -301,11 +362,8 @@ CoreInitializeMemoryServices ( /** 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 - memory map, so memory allocations and resource allocations can be made. The first - part of this function can not depend on any memory services until at least one - memory descriptor is provided to the memory services. Then the memory services - can be used to intialize the GCD map. The HobStart will be relocated to a pool - buffer. + memory map, so memory allocations and resource allocations can be made. The + HobStart will be relocated to a pool buffer. @param HobStart The start address of the HOB @param MemoryBaseAddress Start address of memory region found to init DXE @@ -324,7 +382,7 @@ CoreInitializeGcdServices ( /** - Initializes "event" support and populates parts of the System and Runtime Table. + Initializes "event" support. @retval EFI_SUCCESS Always return success @@ -355,7 +413,7 @@ CoreInitializeImageServices ( **/ VOID -CoreNotifyOnArchProtocolInstallation ( +CoreNotifyOnProtocolInstallation ( VOID ); @@ -669,8 +727,12 @@ 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 @@ -920,6 +982,20 @@ CoreRegisterProtocolNotify ( ); +/** + Removes all the events in the protocol database that match Event. + + @param Event The event to search for in the protocol + database. + + @return EFI_SUCCESS when done searching the entire database. + +**/ +EFI_STATUS +CoreUnregisterProtocolNotify ( + IN EFI_EVENT Event + ); + /** Locates the requested handle(s) and returns them in Buffer. @@ -1012,8 +1088,8 @@ CoreLocateHandleBuffer ( /** Return the first Protocol Interface that matches the Protocol GUID. If - Registration is pasased in return a Protocol Instance that was just add - to the system. If Retistration is NULL return the first Protocol Interface + Registration is passed in, return a Protocol Instance that was just add + to the system. If Registration is NULL return the first Protocol Interface you find. @param Protocol The protocol to search for @@ -1065,19 +1141,27 @@ CoreConnectHandlesByKey ( /** 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. - - @return Status code. + @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. + + @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 @@ -1110,8 +1194,7 @@ CoreConnectController ( @retval EFI_SUCCESS DriverImageHandle is not NULL, and on entry DriverImageHandle is not managing ControllerHandle. - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid - EFI_HANDLE. + @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. @retval EFI_INVALID_PARAMETER DriverImageHandle is not NULL, and it is not a valid EFI_HANDLE. @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it @@ -1161,7 +1244,32 @@ CoreAllocatePages ( IN OUT EFI_PHYSICAL_ADDRESS *Memory ); +/** + Allocates pages from the memory map. + + @param Type The type of allocation to perform + @param MemoryType The type of memory to turn the allocated pages + into + @param NumberOfPages The number of pages to allocate + @param Memory A pointer to receive the base allocated memory + address + + @return Status. On success, Memory is filled in with the base address allocated + @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in + spec. + @retval EFI_NOT_FOUND Could not allocate pages match the requirement. + @retval EFI_OUT_OF_RESOURCES No enough pages to allocate. + @retval EFI_SUCCESS Pages successfully allocated. +**/ +EFI_STATUS +EFIAPI +CoreInternalAllocatePages ( + IN EFI_ALLOCATE_TYPE Type, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN NumberOfPages, + IN OUT EFI_PHYSICAL_ADDRESS *Memory + ); /** Frees previous allocated pages. @@ -1181,7 +1289,23 @@ CoreFreePages ( IN UINTN NumberOfPages ); +/** + Frees previous allocated pages. + @param Memory Base address of memory being freed + @param NumberOfPages The number of pages to free + + @retval EFI_NOT_FOUND Could not find the entry that covers the range + @retval EFI_INVALID_PARAMETER Address not aligned + @return EFI_SUCCESS -Pages successfully freed. + +**/ +EFI_STATUS +EFIAPI +CoreInternalFreePages ( + IN EFI_PHYSICAL_ADDRESS Memory, + IN UINTN NumberOfPages + ); /** This function returns a copy of the current memory map. The map is an array of @@ -1233,7 +1357,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. @@ -1246,7 +1370,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. @@ -1263,7 +1406,20 @@ CoreFreePool ( IN VOID *Buffer ); +/** + Frees pool. + @param Buffer The allocated pool entry to free + + @retval EFI_INVALID_PARAMETER Buffer is not a valid value. + @retval EFI_SUCCESS Pool successfully freed. + +**/ +EFI_STATUS +EFIAPI +CoreInternalFreePool ( + IN VOID *Buffer + ); /** Loads an EFI image into memory and returns a handle to the image. @@ -1289,6 +1445,14 @@ CoreFreePool ( protocol for loading the file. @retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient resources. + @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 + 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 + platform policy specifies that the image should not be started. **/ EFI_STATUS @@ -1330,7 +1494,7 @@ CoreUnloadImage ( @param ImageHandle Handle of image to be started. @param ExitDataSize Pointer of the size to ExitData @param ExitData Pointer to a pointer to a data buffer that - includes a Null-terminated Unicode string, + includes a Null-terminated string, optionally followed by additional binary data. The string is a description that the caller may use to further indicate the reason for the @@ -1338,6 +1502,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. @@ -1387,7 +1552,7 @@ CoreExit ( /** - Creates a general-purpose event structure. + Creates an event. @param Type The type of event to create and its mode and attributes @@ -1417,7 +1582,7 @@ CoreCreateEvent ( /** - 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 @@ -1447,7 +1612,36 @@ CoreCreateEventEx ( 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. @@ -1562,6 +1756,7 @@ CoreCheckEvent ( **/ EFI_STATUS +EFIAPI CoreAddMemorySpace ( IN EFI_GCD_MEMORY_TYPE GcdMemoryType, IN EFI_PHYSICAL_ADDRESS BaseAddress, @@ -1588,6 +1783,7 @@ CoreAddMemorySpace ( **/ EFI_STATUS +EFIAPI CoreAllocateMemorySpace ( IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType, IN EFI_GCD_MEMORY_TYPE GcdMemoryType, @@ -1610,6 +1806,7 @@ CoreAllocateMemorySpace ( **/ EFI_STATUS +EFIAPI CoreFreeMemorySpace ( IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length @@ -1627,6 +1824,7 @@ CoreFreeMemorySpace ( **/ EFI_STATUS +EFIAPI CoreRemoveMemorySpace ( IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length @@ -1644,6 +1842,7 @@ CoreRemoveMemorySpace ( **/ EFI_STATUS +EFIAPI CoreGetMemorySpaceDescriptor ( IN EFI_PHYSICAL_ADDRESS BaseAddress, OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Descriptor @@ -1658,11 +1857,22 @@ 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_DEFINED 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 +EFIAPI CoreSetMemorySpaceAttributes ( IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, @@ -1683,6 +1893,7 @@ CoreSetMemorySpaceAttributes ( **/ EFI_STATUS +EFIAPI CoreGetMemorySpaceMap ( OUT UINTN *NumberOfDescriptors, OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR **MemorySpaceMap @@ -1701,6 +1912,7 @@ CoreGetMemorySpaceMap ( **/ EFI_STATUS +EFIAPI CoreAddIoSpace ( IN EFI_GCD_IO_TYPE GcdIoType, IN EFI_PHYSICAL_ADDRESS BaseAddress, @@ -1726,6 +1938,7 @@ CoreAddIoSpace ( **/ EFI_STATUS +EFIAPI CoreAllocateIoSpace ( IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType, IN EFI_GCD_IO_TYPE GcdIoType, @@ -1748,6 +1961,7 @@ CoreAllocateIoSpace ( **/ EFI_STATUS +EFIAPI CoreFreeIoSpace ( IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length @@ -1765,6 +1979,7 @@ CoreFreeIoSpace ( **/ EFI_STATUS +EFIAPI CoreRemoveIoSpace ( IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length @@ -1782,6 +1997,7 @@ CoreRemoveIoSpace ( **/ EFI_STATUS +EFIAPI CoreGetIoSpaceDescriptor ( IN EFI_PHYSICAL_ADDRESS BaseAddress, OUT EFI_GCD_IO_SPACE_DESCRIPTOR *Descriptor @@ -1800,6 +2016,7 @@ CoreGetIoSpaceDescriptor ( **/ EFI_STATUS +EFIAPI CoreGetIoSpaceMap ( OUT UINTN *NumberOfDescriptors, OUT EFI_GCD_IO_SPACE_DESCRIPTOR **IoSpaceMap @@ -1868,29 +2085,6 @@ CoreTrust ( ); -/** - Helper function called as part of the code needed - to allocate the proper sized buffer for various - EFI interfaces. - - @param Status Current status - @param Buffer Current allocated buffer, or NULL - @param BufferSize Current buffer size needed - - @retval TRUE if the buffer was reallocated and the caller - should try the API again. - @retval FALSE buffer could not be allocated and the caller - should not try the API again. - -**/ -BOOLEAN -CoreGrowBuffer ( - IN OUT EFI_STATUS *Status, - IN OUT VOID **Buffer, - IN UINTN BufferSize - ); - - /** This routine is the driver initialization entry point. It initializes the libraries, and registers two notification functions. These notification @@ -1947,6 +2141,7 @@ InitializeSectionExtraction ( **/ EFI_STATUS +EFIAPI CoreProcessFirmwareVolume ( IN VOID *FvHeader, IN UINTN Size, @@ -2246,6 +2441,7 @@ OpenSectionStream ( function returns anything other than EFI_SUCCESS, the value of *AuthenticationStatus is undefined. + @param IsFfs3Fv Indicates the FV format. @retval EFI_SUCCESS Section was retrieved successfully @retval EFI_PROTOCOL_ERROR A GUID defined section was encountered in the @@ -2276,7 +2472,8 @@ GetSection ( IN UINTN SectionInstance, IN VOID **Buffer, IN OUT UINTN *BufferSize, - OUT UINT32 *AuthenticationStatus + OUT UINT32 *AuthenticationStatus, + IN BOOLEAN IsFfs3Fv ); @@ -2284,6 +2481,8 @@ GetSection ( 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. @@ -2294,7 +2493,327 @@ GetSection ( EFI_STATUS EFIAPI CloseSectionStream ( - IN UINTN StreamHandleToClose + IN UINTN StreamHandleToClose, + IN BOOLEAN FreeStreamBuffer + ); + +/** + Creates and initializes the DebugImageInfo Table. Also creates the configuration + table and registers it into the system table. + + Note: + This function allocates memory, frees it, and then allocates memory at an + address within the initial allocation. Since this function is called early + in DXE core initialization (before drivers are dispatched), this should not + be a problem. + +**/ +VOID +CoreInitializeDebugImageInfoTable ( + VOID + ); + + +/** + Update the CRC32 in the Debug Table. + Since the CRC32 service is made available by the Runtime driver, we have to + wait for the Runtime Driver to be installed before the CRC32 can be computed. + This function is called elsewhere by the core when the runtime architectural + protocol is produced. + +**/ +VOID +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. + + @param ImageInfoType type of debug image information + @param LoadedImage pointer to the loaded image protocol for the image being + loaded + @param ImageHandle image handle for the image being loaded + +**/ +VOID +CoreNewDebugImageInfoEntry ( + IN UINT32 ImageInfoType, + IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, + IN EFI_HANDLE ImageHandle + ); + + +/** + Removes and frees an entry from the DebugImageInfo Table. + + @param ImageHandle image handle for the image being unloaded + +**/ +VOID +CoreRemoveDebugImageInfoEntry ( + EFI_HANDLE ImageHandle + ); + + +/** + This routine consumes FV hobs and produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate. + + @param ImageHandle The image handle. + @param SystemTable The system table. + + @retval EFI_SUCCESS Successfully initialized firmware volume block + driver. + +**/ +EFI_STATUS +EFIAPI +FwVolBlockDriverInit ( + 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 + buffer. + + @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 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. + @retval EFI_OUT_OF_RESOURCES No enough buffer to be allocated. + @retval EFI_SUCCESS Successfully produced a FVB protocol on given + buffer. + +**/ +EFI_STATUS +ProduceFVBProtocolOnBuffer ( + 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. + + @param Lock The lock to acquire + + @return Lock owned + +**/ +VOID +CoreAcquireLock ( + IN EFI_LOCK *Lock + ); + + +/** + Initialize a basic mutual exclusion lock. Each lock + provides mutual exclusion access at it's task priority + level. Since there is no-premption (at any TPL) or + multiprocessor support, acquiring the lock only consists + of raising to the locks TPL. + + @param Lock The EFI_LOCK structure to initialize + + @retval EFI_SUCCESS Lock Owned. + @retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned. + +**/ +EFI_STATUS +CoreAcquireLockOrFail ( + IN EFI_LOCK *Lock + ); + + +/** + Releases ownership of the mutual exclusion lock, and + restores the previous task priority level. + + @param Lock The lock to release + + @return Lock unowned + +**/ +VOID +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. + 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. + + @retval TRUE Register success. + @retval FALSE Register fail. + +**/ +BOOLEAN +RegisterMemoryProfileImage ( + IN LOADED_IMAGE_PRIVATE_DATA *DriverEntry, + IN EFI_FV_FILETYPE FileType + ); + +/** + Unregister image from memory profile. + + @param DriverEntry Image info. + + @retval TRUE Unregister success. + @retval FALSE Unregister fail. + +**/ +BOOLEAN +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. + @param Size Buffer size. + @param Buffer Buffer address. + + @retval TRUE Profile udpate success. + @retval FALSE Profile update fail. + +**/ +BOOLEAN +CoreUpdateProfile ( + IN EFI_PHYSICAL_ADDRESS CallerAddress, + IN MEMORY_PROFILE_ACTION Action, + IN EFI_MEMORY_TYPE MemoryType, // Valid for AllocatePages/AllocatePool + IN UINTN Size, // Valid for AllocatePages/FreePages/AllocatePool + IN VOID *Buffer ); #endif