X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FCore%2FDxe%2FDxeMain.h;h=2dec9da5e35b0302c9b8d4952b383b7d1d543df1;hb=5267926134d17e86672b84fd57b438f05ffa68e1;hp=1e98df9cdfe244ed1c8c90556cdb21f486ad11b5;hpb=9f2c0260b1727ba2f249e5a6f4c07b51e9ce3881;p=mirror_edk2.git diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h index 1e98df9cdf..2dec9da5e3 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -2,7 +2,7 @@ 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.
+Copyright (c) 2006 - 2018, 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 @@ -69,7 +69,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include #include #include @@ -90,7 +89,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include #include #include #include @@ -110,8 +108,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. /// -/// 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 @@ -199,43 +197,43 @@ typedef struct { typedef struct { UINTN Signature; /// Image handle - EFI_HANDLE Handle; + EFI_HANDLE Handle; /// Image type - UINTN Type; + UINTN Type; /// If entrypoint has been called - BOOLEAN Started; + BOOLEAN Started; /// The image's entry point - EFI_IMAGE_ENTRY_POINT EntryPoint; + EFI_IMAGE_ENTRY_POINT EntryPoint; /// loaded image protocol - EFI_LOADED_IMAGE_PROTOCOL Info; + EFI_LOADED_IMAGE_PROTOCOL Info; /// Location in memory - EFI_PHYSICAL_ADDRESS ImageBasePage; + EFI_PHYSICAL_ADDRESS ImageBasePage; /// Number of pages - UINTN NumberOfPages; + UINTN NumberOfPages; /// Original fixup data - CHAR8 *FixupData; + CHAR8 *FixupData; /// Tpl of started image - EFI_TPL Tpl; + EFI_TPL Tpl; /// Status returned by started image - EFI_STATUS Status; + EFI_STATUS Status; /// Size of ExitData from started image - UINTN ExitDataSize; + 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; + 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; + UINT16 Machine; /// EBC Protocol pointer - EFI_EBC_PROTOCOL *Ebc; + EFI_EBC_PROTOCOL *Ebc; /// Runtime image list - EFI_RUNTIME_IMAGE_ENTRY *RuntimeData; - /// Pointer to Loaded Image Device Path Protocl - EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath; + 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; + PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; /// Status returned by LoadImage() service. EFI_STATUS LoadImageStatus; } LOADED_IMAGE_PRIVATE_DATA; @@ -243,6 +241,26 @@ typedef struct { #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 // @@ -251,6 +269,8 @@ extern EFI_RUNTIME_SERVICES *gDxeCoreRT; extern EFI_DXE_SERVICES *gDxeCoreDS; extern EFI_HANDLE gDxeCoreImageHandle; +extern BOOLEAN gMemoryMapTerminated; + extern EFI_DECOMPRESS_PROTOCOL gEfiDecompress; extern EFI_RUNTIME_ARCH_PROTOCOL *gRuntime; @@ -419,7 +439,7 @@ CoreNotifyOnProtocolInstallation ( /** - 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 @@ -447,7 +467,7 @@ CalculateEfiHdrCrc ( /** 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 **/ @@ -1071,7 +1091,7 @@ 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 @@ -1159,8 +1179,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. **/ @@ -1244,33 +1264,6 @@ 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. @@ -1289,24 +1282,6 @@ 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 memory descriptors, each of which describes a contiguous block of memory. @@ -1410,6 +1385,7 @@ CoreFreePool ( 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. @@ -1418,7 +1394,8 @@ CoreFreePool ( EFI_STATUS EFIAPI CoreInternalFreePool ( - IN VOID *Buffer + IN VOID *Buffer, + OUT EFI_MEMORY_TYPE *PoolType OPTIONAL ); /** @@ -1448,10 +1425,10 @@ CoreInternalFreePool ( @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. **/ @@ -1475,7 +1452,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. @@ -1858,7 +1835,7 @@ 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 @@ -2200,19 +2177,6 @@ CoreDisplayDiscoveredNotDispatched ( ); -/** - 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 @@ -2446,7 +2410,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 @@ -2692,24 +2656,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. @@ -2796,11 +2744,13 @@ MemoryProfileInstallProtocol ( @param DriverEntry Image info. @param FileType Image file type. - @retval TRUE Register success. - @retval FALSE Register fail. + @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. **/ -BOOLEAN +EFI_STATUS RegisterMemoryProfileImage ( IN LOADED_IMAGE_PRIVATE_DATA *DriverEntry, IN EFI_FV_FILETYPE FileType @@ -2811,11 +2761,13 @@ RegisterMemoryProfileImage ( @param DriverEntry Image info. - @retval TRUE Unregister success. - @retval FALSE Unregister fail. + @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. **/ -BOOLEAN +EFI_STATUS UnregisterMemoryProfileImage ( IN LOADED_IMAGE_PRIVATE_DATA *DriverEntry ); @@ -2826,20 +2778,31 @@ UnregisterMemoryProfileImage ( @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. - @retval TRUE Profile udpate success. - @retval FALSE Profile update fail. + @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. **/ -BOOLEAN +EFI_STATUS +EFIAPI CoreUpdateProfile ( IN EFI_PHYSICAL_ADDRESS CallerAddress, IN MEMORY_PROFILE_ACTION Action, - IN EFI_MEMORY_TYPE MemoryType, // Valid for AllocatePages/AllocatePool + IN EFI_MEMORY_TYPE MemoryType, IN UINTN Size, // Valid for AllocatePages/FreePages/AllocatePool - IN VOID *Buffer + IN VOID *Buffer, + IN CHAR8 *ActionString OPTIONAL ); /** @@ -2858,4 +2821,135 @@ CoreUpdateMemoryAttributes ( IN UINT64 NewAttributes ); +/** + Initialize PropertiesTable support. +**/ +VOID +EFIAPI +CoreInitializePropertiesTable ( + VOID + ); + +/** + 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