]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/DxeMain.h
MdeModulePkg: Use IsZeroGuid API for zero GUID checking
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / DxeMain.h
index 1e057a5d9376aceff624e2d21bf973a67998c837..aefeeb7d399bc672a1e000cd56462f7d0e8fc50a 100644 (file)
@@ -2,7 +2,7 @@
   The internal header file includes the common header files, defines\r
   internal structure and functions used by DxeCore module.\r
 \r
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -67,6 +67,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Guid/EventExitBootServiceFailed.h>\r
 #include <Guid/LoadModuleAtFixedAddress.h>\r
 #include <Guid/IdleLoopEvent.h>\r
+#include <Guid/VectorHandoffTable.h>\r
+#include <Ppi/VectorHandoffInfo.h>\r
+#include <Guid/MemoryProfile.h>\r
 \r
 #include <Library/DxeCoreEntryPoint.h>\r
 #include <Library/DebugLib.h>\r
@@ -120,6 +123,31 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 ///\r
 #define DEPEX_STACK_SIZE_INCREMENT  0x1000\r
 \r
+#if defined (MDE_CPU_IPF)\r
+///\r
+/// For Itanium machines make the default allocations 8K aligned\r
+///\r
+#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT  (EFI_PAGE_SIZE * 2)\r
+#define DEFAULT_PAGE_ALLOCATION                     (EFI_PAGE_SIZE * 2)\r
+\r
+#elif defined (MDE_CPU_AARCH64)\r
+///\r
+/// 64-bit ARM systems allow the OS to execute with 64 KB page size,\r
+/// so for improved interoperability with the firmware, align the\r
+/// runtime regions to 64 KB as well\r
+///\r
+#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT  (SIZE_64KB)\r
+#define DEFAULT_PAGE_ALLOCATION                     (EFI_PAGE_SIZE)\r
+\r
+#else\r
+///\r
+/// For genric EFI machines make the default allocations 4K aligned\r
+///\r
+#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT  (EFI_PAGE_SIZE)\r
+#define DEFAULT_PAGE_ALLOCATION                     (EFI_PAGE_SIZE)\r
+\r
+#endif\r
+\r
 typedef struct {\r
   EFI_GUID                    *ProtocolGuid;\r
   VOID                        **Protocol;\r
@@ -189,6 +217,56 @@ typedef struct {
   EFI_HANDLE            DeviceHandle;\r
 } EFI_GCD_MAP_ENTRY;\r
 \r
+\r
+#define LOADED_IMAGE_PRIVATE_DATA_SIGNATURE   SIGNATURE_32('l','d','r','i')\r
+\r
+typedef struct {\r
+  UINTN                       Signature;\r
+  /// Image handle\r
+  EFI_HANDLE                  Handle;   \r
+  /// Image type\r
+  UINTN                       Type;           \r
+  /// If entrypoint has been called\r
+  BOOLEAN                     Started;        \r
+  /// The image's entry point\r
+  EFI_IMAGE_ENTRY_POINT       EntryPoint;     \r
+  /// loaded image protocol\r
+  EFI_LOADED_IMAGE_PROTOCOL   Info;           \r
+  /// Location in memory\r
+  EFI_PHYSICAL_ADDRESS        ImageBasePage;  \r
+  /// Number of pages\r
+  UINTN                       NumberOfPages;  \r
+  /// Original fixup data\r
+  CHAR8                       *FixupData;     \r
+  /// Tpl of started image\r
+  EFI_TPL                     Tpl;            \r
+  /// Status returned by started image\r
+  EFI_STATUS                  Status;         \r
+  /// Size of ExitData from started image\r
+  UINTN                       ExitDataSize;   \r
+  /// Pointer to exit data from started image\r
+  VOID                        *ExitData;      \r
+  /// Pointer to pool allocation for context save/retore\r
+  VOID                        *JumpBuffer;    \r
+  /// Pointer to buffer for context save/retore\r
+  BASE_LIBRARY_JUMP_BUFFER    *JumpContext;  \r
+  /// Machine type from PE image\r
+  UINT16                      Machine;        \r
+  /// EBC Protocol pointer\r
+  EFI_EBC_PROTOCOL            *Ebc;           \r
+  /// Runtime image list\r
+  EFI_RUNTIME_IMAGE_ENTRY     *RuntimeData;   \r
+  /// Pointer to Loaded Image Device Path Protocl\r
+  EFI_DEVICE_PATH_PROTOCOL    *LoadedImageDevicePath;  \r
+  /// PeCoffLoader ImageContext\r
+  PE_COFF_LOADER_IMAGE_CONTEXT  ImageContext; \r
+  /// Status returned by LoadImage() service.\r
+  EFI_STATUS                  LoadImageStatus;\r
+} LOADED_IMAGE_PRIVATE_DATA;\r
+\r
+#define LOADED_IMAGE_PRIVATE_DATA_FROM_THIS(a) \\r
+          CR(a, LOADED_IMAGE_PRIVATE_DATA, Info, LOADED_IMAGE_PRIVATE_DATA_SIGNATURE)\r
+\r
 //\r
 // DXE Core Global Variables\r
 //\r
@@ -197,6 +275,8 @@ extern EFI_RUNTIME_SERVICES                     *gDxeCoreRT;
 extern EFI_DXE_SERVICES                         *gDxeCoreDS;\r
 extern EFI_HANDLE                               gDxeCoreImageHandle;\r
 \r
+extern BOOLEAN                                  gMemoryMapTerminated;\r
+\r
 extern EFI_DECOMPRESS_PROTOCOL                  gEfiDecompress;\r
 \r
 extern EFI_RUNTIME_ARCH_PROTOCOL                *gRuntime;\r
@@ -1190,8 +1270,6 @@ CoreAllocatePages (
   IN OUT EFI_PHYSICAL_ADDRESS  *Memory\r
   );\r
 \r
-\r
-\r
 /**\r
   Frees previous allocated pages.\r
 \r
@@ -1210,8 +1288,6 @@ CoreFreePages (
   IN UINTN                  NumberOfPages\r
   );\r
 \r
-\r
-\r
 /**\r
   This function returns a copy of the current memory map. The map is an array of\r
   memory descriptors, each of which describes a contiguous block of memory.\r
@@ -1275,7 +1351,26 @@ CoreAllocatePool (
   OUT VOID            **Buffer\r
   );\r
 \r
+/**\r
+  Allocate pool of a particular type.\r
+\r
+  @param  PoolType               Type of pool to allocate\r
+  @param  Size                   The amount of pool to allocate\r
+  @param  Buffer                 The address to return a pointer to the allocated\r
+                                 pool\r
+\r
+  @retval EFI_INVALID_PARAMETER  PoolType not valid or Buffer is NULL\r
+  @retval EFI_OUT_OF_RESOURCES   Size exceeds max pool size or allocation failed.\r
+  @retval EFI_SUCCESS            Pool successfully allocated.\r
 \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CoreInternalAllocatePool (\r
+  IN EFI_MEMORY_TYPE  PoolType,\r
+  IN UINTN            Size,\r
+  OUT VOID            **Buffer\r
+  );\r
 \r
 /**\r
   Frees pool.\r
@@ -1292,7 +1387,22 @@ CoreFreePool (
   IN VOID        *Buffer\r
   );\r
 \r
+/**\r
+  Frees pool.\r
+\r
+  @param  Buffer                 The allocated pool entry to free\r
+  @param  PoolType               Pointer to pool type\r
+\r
+  @retval EFI_INVALID_PARAMETER  Buffer is not a valid value.\r
+  @retval EFI_SUCCESS            Pool successfully freed.\r
 \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CoreInternalFreePool (\r
+  IN VOID               *Buffer,\r
+  OUT EFI_MEMORY_TYPE   *PoolType OPTIONAL\r
+  );\r
 \r
 /**\r
   Loads an EFI image into memory and returns a handle to the image.\r
@@ -1736,7 +1846,7 @@ CoreGetMemorySpaceDescriptor (
                                 resource range specified by BaseAddress and Length.\r
   @retval EFI_UNSUPPORTED       The bit mask of attributes is not support for the memory resource\r
                                 range specified by BaseAddress and Length.\r
-  @retval EFI_ACCESS_DEFINED    The attributes for the memory resource range specified by\r
+  @retval EFI_ACCESS_DENIED     The attributes for the memory resource range specified by\r
                                 BaseAddress and Length cannot be modified.\r
   @retval EFI_OUT_OF_RESOURCES  There are not enough system resources to modify the attributes of\r
                                 the memory resource range.\r
@@ -1753,6 +1863,32 @@ CoreSetMemorySpaceAttributes (
   );\r
 \r
 \r
+/**\r
+  Modifies the capabilities for a memory region in the global coherency domain of the\r
+  processor.\r
+\r
+  @param  BaseAddress      The physical address that is the start address of a memory region.\r
+  @param  Length           The size in bytes of the memory region.\r
+  @param  Capabilities     The bit mask of capabilities that the memory region supports.\r
+\r
+  @retval EFI_SUCCESS           The capabilities were set for the memory region.\r
+  @retval EFI_INVALID_PARAMETER Length is zero.\r
+  @retval EFI_UNSUPPORTED       The capabilities specified by Capabilities do not include the\r
+                                memory region attributes currently in use.\r
+  @retval EFI_ACCESS_DENIED     The capabilities for the memory resource range specified by\r
+                                BaseAddress and Length cannot be modified.\r
+  @retval EFI_OUT_OF_RESOURCES  There are not enough system resources to modify the capabilities\r
+                                of the memory resource range.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CoreSetMemorySpaceCapabilities (\r
+  IN EFI_PHYSICAL_ADDRESS  BaseAddress,\r
+  IN UINT64                Length,\r
+  IN UINT64                Capabilities\r
+  );\r
+\r
+\r
 /**\r
   Returns a map of the memory resources in the global coherency domain of the\r
   processor.\r
@@ -2293,7 +2429,7 @@ OpenSectionStream (
                                 non-null on input, then the buffer is caller\r
                                 allocated.  If Buffer is NULL, then the buffer\r
                                 is callee allocated.  In either case, the\r
-                                requried buffer size is returned in *BufferSize.\r
+                                required buffer size is returned in *BufferSize.\r
   @param  BufferSize            On input, indicates the size of *Buffer if\r
                                 *Buffer is non-null on input.  On output,\r
                                 indicates the required size (allocated size if\r
@@ -2354,6 +2490,8 @@ GetSection (
   SEP member function.  Deletes an existing section stream\r
 \r
   @param  StreamHandleToClose    Indicates the stream to close\r
+  @param  FreeStreamBuffer       TRUE - Need to free stream buffer;\r
+                                 FALSE - No need to free stream buffer.\r
 \r
   @retval EFI_SUCCESS            The section stream is closed sucessfully.\r
   @retval EFI_OUT_OF_RESOURCES   Memory allocation failed.\r
@@ -2364,7 +2502,8 @@ GetSection (
 EFI_STATUS\r
 EFIAPI\r
 CloseSectionStream (\r
-  IN  UINTN                                     StreamHandleToClose\r
+  IN  UINTN                                     StreamHandleToClose,\r
+  IN  BOOLEAN                                   FreeStreamBuffer\r
   );\r
 \r
 /**\r
@@ -2590,6 +2729,8 @@ ReadFvbData (
   @retval EFI_OUT_OF_RESOURCES  No enough buffer could be allocated.\r
   @retval EFI_SUCCESS           Successfully read volume header to the allocated\r
                                 buffer.\r
+  @retval EFI_INVALID_PARAMETER The FV Header signature is not as expected or\r
+                                the file system could not be understood.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -2612,4 +2753,155 @@ VerifyFvHeaderChecksum (
   IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader\r
   );\r
 \r
+/**\r
+  Initialize memory profile.\r
+\r
+  @param HobStart   The start address of the HOB.\r
+\r
+**/\r
+VOID\r
+MemoryProfileInit (\r
+  IN VOID   *HobStart\r
+  );\r
+\r
+/**\r
+  Install memory profile protocol.\r
+\r
+**/\r
+VOID\r
+MemoryProfileInstallProtocol (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Register image to memory profile.\r
+\r
+  @param DriverEntry    Image info.\r
+  @param FileType       Image file type.\r
+\r
+  @return EFI_SUCCESS           Register successfully.\r
+  @return EFI_UNSUPPORTED       Memory profile unsupported,\r
+                                or memory profile for the image is not required.\r
+  @return EFI_OUT_OF_RESOURCES  No enough resource for this register.\r
+\r
+**/\r
+EFI_STATUS\r
+RegisterMemoryProfileImage (\r
+  IN LOADED_IMAGE_PRIVATE_DATA  *DriverEntry,\r
+  IN EFI_FV_FILETYPE            FileType\r
+  );\r
+\r
+/**\r
+  Unregister image from memory profile.\r
+\r
+  @param DriverEntry    Image info.\r
+\r
+  @return EFI_SUCCESS           Unregister successfully.\r
+  @return EFI_UNSUPPORTED       Memory profile unsupported,\r
+                                or memory profile for the image is not required.\r
+  @return EFI_NOT_FOUND         The image is not found.\r
+\r
+**/\r
+EFI_STATUS\r
+UnregisterMemoryProfileImage (\r
+  IN LOADED_IMAGE_PRIVATE_DATA  *DriverEntry\r
+  );\r
+\r
+/**\r
+  Update memory profile information.\r
+\r
+  @param CallerAddress  Address of caller who call Allocate or Free.\r
+  @param Action         This Allocate or Free action.\r
+  @param MemoryType     Memory type.\r
+                        EfiMaxMemoryType means the MemoryType is unknown.\r
+  @param Size           Buffer size.\r
+  @param Buffer         Buffer address.\r
+  @param ActionString   String for memory profile action.\r
+                        Only needed for user defined allocate action.\r
+\r
+  @return EFI_SUCCESS           Memory profile is updated.\r
+  @return EFI_UNSUPPORTED       Memory profile is unsupported,\r
+                                or memory profile for the image is not required,\r
+                                or memory profile for the memory type is not required.\r
+  @return EFI_ACCESS_DENIED     It is during memory profile data getting.\r
+  @return EFI_ABORTED           Memory profile recording is not enabled.\r
+  @return EFI_OUT_OF_RESOURCES  No enough resource to update memory profile for allocate action.\r
+  @return EFI_NOT_FOUND         No matched allocate info found for free action.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CoreUpdateProfile (\r
+  IN EFI_PHYSICAL_ADDRESS   CallerAddress,\r
+  IN MEMORY_PROFILE_ACTION  Action,\r
+  IN EFI_MEMORY_TYPE        MemoryType,\r
+  IN UINTN                  Size,       // Valid for AllocatePages/FreePages/AllocatePool\r
+  IN VOID                   *Buffer,\r
+  IN CHAR8                  *ActionString OPTIONAL\r
+  );\r
+\r
+/**\r
+  Internal function.  Converts a memory range to use new attributes.\r
+\r
+  @param  Start                  The first address of the range Must be page\r
+                                 aligned\r
+  @param  NumberOfPages          The number of pages to convert\r
+  @param  NewAttributes          The new attributes value for the range.\r
+\r
+**/\r
+VOID\r
+CoreUpdateMemoryAttributes (\r
+  IN EFI_PHYSICAL_ADDRESS  Start,\r
+  IN UINT64                NumberOfPages,\r
+  IN UINT64                NewAttributes\r
+  );\r
+\r
+/**\r
+  Initialize PropertiesTable support.\r
+**/\r
+VOID\r
+EFIAPI\r
+CoreInitializePropertiesTable (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Initialize MemoryAttrubutesTable support.\r
+**/\r
+VOID\r
+EFIAPI\r
+CoreInitializeMemoryAttributesTable (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Install MemoryAttributesTable on memory allocation.\r
+\r
+  @param[in] MemoryType EFI memory type.\r
+**/\r
+VOID\r
+InstallMemoryAttributesTableOnMemoryAllocation (\r
+  IN EFI_MEMORY_TYPE    MemoryType\r
+  );\r
+\r
+/**\r
+  Insert image record.\r
+\r
+  @param  RuntimeImage    Runtime image information\r
+**/\r
+VOID\r
+InsertImageRecord (\r
+  IN EFI_RUNTIME_IMAGE_ENTRY  *RuntimeImage\r
+  );\r
+\r
+/**\r
+  Remove Image record.\r
+\r
+  @param  RuntimeImage    Runtime image information\r
+**/\r
+VOID\r
+RemoveImageRecord (\r
+  IN EFI_RUNTIME_IMAGE_ENTRY  *RuntimeImage\r
+  );\r
+\r
 #endif\r