X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FCore%2FDxe%2FDxeMain.h;h=bbb424bdb00ac59c095fb5cb3ff11361fb936219;hb=57df17fe26cd;hp=fefe5bec19d36f09e2cb49e9daae4e691022b689;hpb=ca92a370b992ced17c954f6d35e9c8c9b1068838;p=mirror_edk2.git
diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h
index fefe5bec19..bbb424bdb0 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.h
+++ b/MdeModulePkg/Core/Dxe/DxeMain.h
@@ -2,14 +2,8 @@
The internal header file includes the common header files, defines
internal structure and functions used by DxeCore module.
-Copyright (c) 2006 - 2016, 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
**/
@@ -53,6 +47,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include
#include
#include
+#include
#include
#include
#include
@@ -69,7 +64,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include
#include
#include
-#include
#include
#include
@@ -90,7 +84,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include
#include
#include
-#include
#include
#include
#include
@@ -110,8 +103,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
@@ -124,31 +117,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
///
#define DEPEX_STACK_SIZE_INCREMENT 0x1000
-#if defined (MDE_CPU_IPF)
-///
-/// For Itanium machines make the default allocations 8K aligned
-///
-#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE * 2)
-#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE * 2)
-
-#elif defined (MDE_CPU_AARCH64)
-///
-/// 64-bit ARM systems allow the OS to execute with 64 KB page size,
-/// so for improved interoperability with the firmware, align the
-/// runtime regions to 64 KB as well
-///
-#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (SIZE_64KB)
-#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE)
-
-#else
-///
-/// For genric EFI machines make the default allocations 4K aligned
-///
-#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE)
-#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE)
-
-#endif
-
typedef struct {
EFI_GUID *ProtocolGuid;
VOID **Protocol;
@@ -224,43 +192,45 @@ 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;
+ /// 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 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;
@@ -268,6 +238,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
//
@@ -276,6 +266,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;
@@ -444,7 +436,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
@@ -472,7 +464,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
**/
@@ -1096,7 +1088,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
@@ -1184,8 +1176,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.
**/
@@ -1269,33 +1261,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.
@@ -1314,24 +1279,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.
@@ -1435,6 +1382,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.
@@ -1443,7 +1391,8 @@ CoreFreePool (
EFI_STATUS
EFIAPI
CoreInternalFreePool (
- IN VOID *Buffer
+ IN VOID *Buffer,
+ OUT EFI_MEMORY_TYPE *PoolType OPTIONAL
);
/**
@@ -1473,10 +1422,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.
**/
@@ -1500,7 +1449,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.
@@ -1883,7 +1832,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
@@ -2225,19 +2174,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
@@ -2471,7 +2407,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
@@ -2717,24 +2653,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.
@@ -2821,11 +2741,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
@@ -2836,11 +2758,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
);
@@ -2851,20 +2775,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
);
/**
@@ -2901,6 +2836,25 @@ 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.
@@ -2921,4 +2875,78 @@ 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