]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/DxeMain.h
MdeModulePkg DxeCore/PiSmmCore: Add UEFI memory and SMRAM profile support.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / DxeMain.h
index 2004e389e572a9956629f23daf17923638a1628a..bb2bfab370ff8ec32bb749336b9383684ad54d8d 100644 (file)
@@ -2,8 +2,8 @@
   The internal header file includes the common header files, defines\r
   internal structure and functions used by DxeCore module.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2014, 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
 http://opensource.org/licenses/bsd-license.php\r
@@ -25,6 +25,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/DevicePath.h>\r
 #include <Protocol/Runtime.h>\r
 #include <Protocol/LoadFile.h>\r
+#include <Protocol/LoadFile2.h>\r
 #include <Protocol/DriverBinding.h>\r
 #include <Protocol/VariableWrite.h>\r
 #include <Protocol/PlatformDriverOverride.h>\r
@@ -39,8 +40,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/StatusCode.h>\r
 #include <Protocol/Decompress.h>\r
 #include <Protocol/LoadPe32Image.h>\r
-#include <Protocol/FirmwareVolumeDispatch.h>\r
 #include <Protocol/Security.h>\r
+#include <Protocol/Security2.h>\r
 #include <Protocol/Ebc.h>\r
 #include <Protocol/Reset.h>\r
 #include <Protocol/Cpu.h>\r
@@ -48,11 +49,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/FirmwareVolumeBlock.h>\r
 #include <Protocol/Capsule.h>\r
 #include <Protocol/BusSpecificDriverOverride.h>\r
-#include <Protocol/Performance.h>\r
+#include <Protocol/DriverFamilyOverride.h>\r
 #include <Protocol/TcgService.h>\r
-#include <Protocol/TcgPlatform.h>\r
+#include <Protocol/HiiPackageList.h>\r
+#include <Protocol/SmmBase2.h>\r
 #include <Guid/MemoryTypeInformation.h>\r
 #include <Guid/FirmwareFileSystem2.h>\r
+#include <Guid/FirmwareFileSystem3.h>\r
 #include <Guid/HobList.h>\r
 #include <Guid/DebugImageInfoTable.h>\r
 #include <Guid/FileInfo.h>\r
@@ -61,7 +64,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Guid/MemoryAllocationHob.h>\r
 #include <Guid/EventLegacyBios.h>\r
 #include <Guid/EventGroup.h>\r
-\r
+#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/ZeroGuid.h>\r
+#include <Guid/MemoryProfile.h>\r
 \r
 #include <Library/DxeCoreEntryPoint.h>\r
 #include <Library/DebugLib.h>\r
@@ -74,21 +83,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/CacheMaintenanceLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/PeCoffLib.h>\r
+#include <Library/PeCoffGetEntryPointLib.h>\r
+#include <Library/PeCoffExtraActionLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/DevicePathLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/ReportStatusCodeLib.h>\r
+#include <Library/TimerLib.h>\r
+#include <Library/DxeServicesLib.h>\r
+#include <Library/DebugAgentLib.h>\r
+#include <Library/CpuExceptionHandlerLib.h>\r
 \r
-#include "DebugImageInfo.h"\r
-#include "Library.h"\r
-#include "FwVolBlock.h"\r
-#include "FwVolDriver.h"\r
-#include "Gcd.h"\r
-#include "Imem.h"\r
-#include "Image.h"\r
-#include "Exec.h"\r
-#include "Hand.h"\r
 \r
 //\r
 // attributes for reserved memory before it is promoted to system memory\r
@@ -124,21 +130,22 @@ typedef struct {
   EFI_EVENT                   Event;\r
   VOID                        *Registration;\r
   BOOLEAN                     Present;\r
-} ARCHITECTURAL_PROTOCOL_ENTRY;\r
+} EFI_CORE_PROTOCOL_NOTIFY_ENTRY;\r
 \r
 //\r
 // DXE Dispatcher Data structures\r
 //\r
 \r
-#define KNOWN_HANDLE_SIGNATURE  EFI_SIGNATURE_32('k','n','o','w')\r
+#define KNOWN_HANDLE_SIGNATURE  SIGNATURE_32('k','n','o','w')\r
 typedef struct {\r
   UINTN           Signature;\r
   LIST_ENTRY      Link;         // mFvHandleList\r
   EFI_HANDLE      Handle;\r
+  EFI_GUID        FvNameGuid;\r
 } KNOWN_HANDLE;\r
 \r
 \r
-#define EFI_CORE_DRIVER_ENTRY_SIGNATURE EFI_SIGNATURE_32('d','r','v','r')\r
+#define EFI_CORE_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('d','r','v','r')\r
 typedef struct {\r
   UINTN                           Signature;\r
   LIST_ENTRY                      Link;             // mDriverList\r
@@ -165,13 +172,14 @@ typedef struct {
   BOOLEAN                         DepexProtocolError;\r
 \r
   EFI_HANDLE                      ImageHandle;\r
+  BOOLEAN                         IsFvImage;\r
 \r
 } EFI_CORE_DRIVER_ENTRY;\r
 \r
 //\r
 //The data structure of GCD memory map entry\r
 //\r
-#define EFI_GCD_MAP_SIGNATURE  EFI_SIGNATURE_32('g','c','d','m')\r
+#define EFI_GCD_MAP_SIGNATURE  SIGNATURE_32('g','c','d','m')\r
 typedef struct {\r
   UINTN                 Signature;\r
   LIST_ENTRY            Link;\r
@@ -185,6 +193,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
@@ -201,7 +259,9 @@ extern EFI_WATCHDOG_TIMER_ARCH_PROTOCOL         *gWatchdogTimer;
 extern EFI_METRONOME_ARCH_PROTOCOL              *gMetronome;\r
 extern EFI_TIMER_ARCH_PROTOCOL                  *gTimer;\r
 extern EFI_SECURITY_ARCH_PROTOCOL               *gSecurity;\r
+extern EFI_SECURITY2_ARCH_PROTOCOL              *gSecurity2;\r
 extern EFI_BDS_ARCH_PROTOCOL                    *gBds;\r
+extern EFI_SMM_BASE2_PROTOCOL                   *gSmmBase2;\r
 \r
 extern EFI_TPL                                  gEfiCurrentTpl;\r
 \r
@@ -213,6 +273,8 @@ extern EFI_MEMORY_TYPE_INFORMATION              gMemoryTypeInformation[EfiMaxMem
 extern BOOLEAN                                  gDispatcherRunning;\r
 extern EFI_RUNTIME_ARCH_PROTOCOL                gRuntimeTemplate;\r
 \r
+extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE    gLoadModuleAtFixAddressConfigurationTable;\r
+extern BOOLEAN                                       gLoadFixedAddressCodeMemoryReady;\r
 //\r
 // Service Initialization Functions\r
 //\r
@@ -274,12 +336,11 @@ CoreAcquireGcdMemoryLock (
 \r
 \r
 /**\r
-  External function. Initializes the GCD and memory services based on the memory\r
-  descriptor HOBs.  This function is responsible for priming the GCD map and the\r
-  memory map, so memory allocations and resource allocations can be made.  The first\r
-  part of this function can not depend on any memory services until at least one\r
-  memory descriptor is provided to the memory services.  Then the memory services\r
-  can be used to intialize the GCD map.\r
+  External function. Initializes memory services based on the memory\r
+  descriptor HOBs.  This function is responsible for priming the memory\r
+  map, so memory allocations and resource allocations can be made.\r
+  The first part of this function can not depend on any memory services\r
+  until at least one memory descriptor is provided to the memory services.\r
 \r
   @param  HobStart               The start address of the HOB.\r
   @param  MemoryBaseAddress      Start address of memory region found to init DXE\r
@@ -301,11 +362,8 @@ CoreInitializeMemoryServices (
 /**\r
   External function. Initializes the GCD and memory services based on the memory\r
   descriptor HOBs.  This function is responsible for priming the GCD map and the\r
-  memory map, so memory allocations and resource allocations can be made.  The first\r
-  part of this function can not depend on any memory services until at least one\r
-  memory descriptor is provided to the memory services.  Then the memory services\r
-  can be used to intialize the GCD map. The HobStart will be relocated to a pool\r
-  buffer.\r
+  memory map, so memory allocations and resource allocations can be made. The\r
+  HobStart will be relocated to a pool buffer.\r
 \r
   @param  HobStart               The start address of the HOB\r
   @param  MemoryBaseAddress      Start address of memory region found to init DXE\r
@@ -324,7 +382,7 @@ CoreInitializeGcdServices (
 \r
 \r
 /**\r
-  Initializes "event" support and populates parts of the System and Runtime Table.\r
+  Initializes "event" support.\r
 \r
   @retval EFI_SUCCESS            Always return success\r
 \r
@@ -355,7 +413,7 @@ CoreInitializeImageServices (
 \r
 **/\r
 VOID\r
-CoreNotifyOnArchProtocolInstallation (\r
+CoreNotifyOnProtocolInstallation (\r
   VOID\r
   );\r
 \r
@@ -669,8 +727,12 @@ CoreInstallProtocolInterfaceNotify (
                                  arguments to InstallProtocolInterface(). All the\r
                                  protocols are added to Handle.\r
 \r
+  @retval EFI_SUCCESS            All the protocol interface was installed.\r
+  @retval EFI_OUT_OF_RESOURCES   There was not enough memory in pool to install all the protocols.\r
+  @retval EFI_ALREADY_STARTED    A Device Path Protocol instance was passed in that is already present in\r
+                                 the handle database.\r
   @retval EFI_INVALID_PARAMETER  Handle is NULL.\r
-  @retval EFI_SUCCESS            Protocol interfaces successfully installed.\r
+  @retval EFI_INVALID_PARAMETER  Protocol is already installed on the handle specified by Handle.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -920,6 +982,20 @@ CoreRegisterProtocolNotify (
   );\r
 \r
 \r
+/**\r
+  Removes all the events in the protocol database that match Event.\r
+\r
+  @param  Event                  The event to search for in the protocol\r
+                                 database.\r
+\r
+  @return EFI_SUCCESS when done searching the entire database.\r
+\r
+**/\r
+EFI_STATUS\r
+CoreUnregisterProtocolNotify (\r
+  IN EFI_EVENT      Event\r
+  );\r
+\r
 \r
 /**\r
   Locates the requested handle(s) and returns them in Buffer.\r
@@ -1012,8 +1088,8 @@ CoreLocateHandleBuffer (
 \r
 /**\r
   Return the first Protocol Interface that matches the Protocol GUID. If\r
-  Registration is pasased in return a Protocol Instance that was just add\r
-  to the system. If Retistration is NULL return the first Protocol Interface\r
+  Registration is passed in, return a Protocol Instance that was just add\r
+  to the system. If Registration is NULL return the first Protocol Interface\r
   you find.\r
 \r
   @param  Protocol               The protocol to search for\r
@@ -1065,19 +1141,27 @@ CoreConnectHandlesByKey (
 /**\r
   Connects one or more drivers to a controller.\r
 \r
-  @param  ControllerHandle                      Handle of the controller to be\r
-                                                connected.\r
-  @param  DriverImageHandle                     DriverImageHandle A pointer to an\r
-                                                ordered list of driver image\r
-                                                handles.\r
-  @param  RemainingDevicePath                   RemainingDevicePath A pointer to\r
-                                                the device path that specifies a\r
-                                                child of the controller specified\r
-                                                by ControllerHandle.\r
-  @param  Recursive                             Whether the function would be\r
-                                                called recursively or not.\r
-\r
-  @return Status code.\r
+  @param  ControllerHandle      The handle of the controller to which driver(s) are to be connected.\r
+  @param  DriverImageHandle     A pointer to an ordered list handles that support the\r
+                                EFI_DRIVER_BINDING_PROTOCOL.\r
+  @param  RemainingDevicePath   A pointer to the device path that specifies a child of the\r
+                                controller specified by ControllerHandle.\r
+  @param  Recursive             If TRUE, then ConnectController() is called recursively\r
+                                until the entire tree of controllers below the controller specified\r
+                                by ControllerHandle have been created. If FALSE, then\r
+                                the tree of controllers is only expanded one level.\r
+\r
+  @retval EFI_SUCCESS           1) One or more drivers were connected to ControllerHandle.\r
+                                2) No drivers were connected to ControllerHandle, but\r
+                                RemainingDevicePath is not NULL, and it is an End Device\r
+                                Path Node.\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
+  @retval EFI_NOT_FOUND         1) There are no EFI_DRIVER_BINDING_PROTOCOL instances\r
+                                present in the system.\r
+                                2) No drivers were connected to ControllerHandle.\r
+  @retval EFI_SECURITY_VIOLATION \r
+                                The user has no permission to start UEFI device drivers on the device path \r
+                                associated with the ControllerHandle or specified by the RemainingDevicePath.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1110,8 +1194,7 @@ CoreConnectController (
   @retval EFI_SUCCESS                           DriverImageHandle is not NULL,\r
                                                 and on entry DriverImageHandle is\r
                                                 not managing ControllerHandle.\r
-  @retval EFI_INVALID_PARAMETER                 ControllerHandle is not a valid\r
-                                                EFI_HANDLE.\r
+  @retval EFI_INVALID_PARAMETER                 ControllerHandle is NULL.\r
   @retval EFI_INVALID_PARAMETER                 DriverImageHandle is not NULL,\r
                                                 and it is not a valid EFI_HANDLE.\r
   @retval EFI_INVALID_PARAMETER                 ChildHandle is not NULL, and it\r
@@ -1161,7 +1244,32 @@ CoreAllocatePages (
   IN OUT EFI_PHYSICAL_ADDRESS  *Memory\r
   );\r
 \r
+/**\r
+  Allocates pages from the memory map.\r
+\r
+  @param  Type                   The type of allocation to perform\r
+  @param  MemoryType             The type of memory to turn the allocated pages\r
+                                 into\r
+  @param  NumberOfPages          The number of pages to allocate\r
+  @param  Memory                 A pointer to receive the base allocated memory\r
+                                 address\r
+\r
+  @return Status. On success, Memory is filled in with the base address allocated\r
+  @retval EFI_INVALID_PARAMETER  Parameters violate checking rules defined in\r
+                                 spec.\r
+  @retval EFI_NOT_FOUND          Could not allocate pages match the requirement.\r
+  @retval EFI_OUT_OF_RESOURCES   No enough pages to allocate.\r
+  @retval EFI_SUCCESS            Pages successfully allocated.\r
 \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CoreInternalAllocatePages (\r
+  IN EFI_ALLOCATE_TYPE      Type,\r
+  IN EFI_MEMORY_TYPE        MemoryType,\r
+  IN UINTN                  NumberOfPages,\r
+  IN OUT EFI_PHYSICAL_ADDRESS  *Memory\r
+  );\r
 \r
 /**\r
   Frees previous allocated pages.\r
@@ -1181,7 +1289,23 @@ CoreFreePages (
   IN UINTN                  NumberOfPages\r
   );\r
 \r
+/**\r
+  Frees previous allocated pages.\r
 \r
+  @param  Memory                 Base address of memory being freed\r
+  @param  NumberOfPages          The number of pages to free\r
+\r
+  @retval EFI_NOT_FOUND          Could not find the entry that covers the range\r
+  @retval EFI_INVALID_PARAMETER  Address not aligned\r
+  @return EFI_SUCCESS         -Pages successfully freed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CoreInternalFreePages (\r
+  IN EFI_PHYSICAL_ADDRESS   Memory,\r
+  IN UINTN                  NumberOfPages\r
+  );\r
 \r
 /**\r
   This function returns a copy of the current memory map. The map is an array of\r
@@ -1233,7 +1357,7 @@ CoreGetMemoryMap (
   @param  Buffer                 The address to return a pointer to the allocated\r
                                  pool\r
 \r
-  @retval EFI_INVALID_PARAMETER  PoolType not valid\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
@@ -1246,7 +1370,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
@@ -1263,7 +1406,20 @@ CoreFreePool (
   IN VOID        *Buffer\r
   );\r
 \r
+/**\r
+  Frees pool.\r
 \r
+  @param  Buffer                 The allocated pool entry to free\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
+  );\r
 \r
 /**\r
   Loads an EFI image into memory and returns a handle to the image.\r
@@ -1289,6 +1445,14 @@ CoreFreePool (
                                   protocol for loading the file.\r
   @retval EFI_OUT_OF_RESOURCES    Image was not loaded due to insufficient\r
                                   resources.\r
+  @retval EFI_LOAD_ERROR          Image was not loaded because the image format was corrupt or not\r
+                                  understood.\r
+  @retval EFI_DEVICE_ERROR        Image was not loaded because the device returned a read error.\r
+  @retval EFI_ACCESS_DENIED       Image was not loaded because the platform policy prohibits the \r
+                                  image from being loaded. NULL is returned in *ImageHandle.\r
+  @retval EFI_SECURITY_VIOLATION  Image was loaded and an ImageHandle was created with a \r
+                                  valid EFI_LOADED_IMAGE_PROTOCOL. However, the current \r
+                                  platform policy specifies that the image should not be started.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1330,7 +1494,7 @@ CoreUnloadImage (
   @param  ImageHandle             Handle of image to be started.\r
   @param  ExitDataSize            Pointer of the size to ExitData\r
   @param  ExitData                Pointer to a pointer to a data buffer that\r
-                                  includes a Null-terminated Unicode string,\r
+                                  includes a Null-terminated string,\r
                                   optionally followed by additional binary data.\r
                                   The string is a description that the caller may\r
                                   use to further indicate the reason for the\r
@@ -1338,6 +1502,7 @@ CoreUnloadImage (
 \r
   @retval EFI_INVALID_PARAMETER   Invalid parameter\r
   @retval EFI_OUT_OF_RESOURCES    No enough buffer to allocate\r
+  @retval EFI_SECURITY_VIOLATION  The current platform policy specifies that the image should not be started.\r
   @retval EFI_SUCCESS             Successfully transfer control to the image's\r
                                   entry point.\r
 \r
@@ -1387,7 +1552,7 @@ CoreExit (
 \r
 \r
 /**\r
-  Creates a general-purpose event structure.\r
+  Creates an event.\r
 \r
   @param  Type                   The type of event to create and its mode and\r
                                  attributes\r
@@ -1417,7 +1582,7 @@ CoreCreateEvent (
 \r
 \r
 /**\r
-  Creates a general-purpose event structure\r
+  Creates an event in a group.\r
 \r
   @param  Type                   The type of event to create and its mode and\r
                                  attributes\r
@@ -1447,7 +1612,36 @@ CoreCreateEventEx (
   OUT EFI_EVENT               *Event\r
   );\r
 \r
+/**\r
+  Creates a general-purpose event structure\r
 \r
+  @param  Type                   The type of event to create and its mode and\r
+                                 attributes\r
+  @param  NotifyTpl              The task priority level of event notifications\r
+  @param  NotifyFunction         Pointer to the events notification function\r
+  @param  NotifyContext          Pointer to the notification functions context;\r
+                                 corresponds to parameter "Context" in the\r
+                                 notification function\r
+  @param  EventGroup             GUID for EventGroup if NULL act the same as\r
+                                 gBS->CreateEvent().\r
+  @param  Event                  Pointer to the newly created event if the call\r
+                                 succeeds; undefined otherwise\r
+\r
+  @retval EFI_SUCCESS            The event structure was created\r
+  @retval EFI_INVALID_PARAMETER  One of the parameters has an invalid value\r
+  @retval EFI_OUT_OF_RESOURCES   The event could not be allocated\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CoreCreateEventInternal (\r
+  IN UINT32                   Type,\r
+  IN EFI_TPL                  NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY         NotifyFunction, OPTIONAL\r
+  IN CONST VOID               *NotifyContext, OPTIONAL\r
+  IN CONST EFI_GUID           *EventGroup,    OPTIONAL\r
+  OUT EFI_EVENT               *Event\r
+  );\r
 \r
 /**\r
   Sets the type of timer and the trigger time for a timer event.\r
@@ -1562,6 +1756,7 @@ CoreCheckEvent (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 CoreAddMemorySpace (\r
   IN EFI_GCD_MEMORY_TYPE   GcdMemoryType,\r
   IN EFI_PHYSICAL_ADDRESS  BaseAddress,\r
@@ -1588,6 +1783,7 @@ CoreAddMemorySpace (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 CoreAllocateMemorySpace (\r
   IN     EFI_GCD_ALLOCATE_TYPE  GcdAllocateType,\r
   IN     EFI_GCD_MEMORY_TYPE    GcdMemoryType,\r
@@ -1610,6 +1806,7 @@ CoreAllocateMemorySpace (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 CoreFreeMemorySpace (\r
   IN EFI_PHYSICAL_ADDRESS  BaseAddress,\r
   IN UINT64                Length\r
@@ -1627,6 +1824,7 @@ CoreFreeMemorySpace (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 CoreRemoveMemorySpace (\r
   IN EFI_PHYSICAL_ADDRESS  BaseAddress,\r
   IN UINT64                Length\r
@@ -1644,6 +1842,7 @@ CoreRemoveMemorySpace (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 CoreGetMemorySpaceDescriptor (\r
   IN  EFI_PHYSICAL_ADDRESS             BaseAddress,\r
   OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR  *Descriptor\r
@@ -1658,11 +1857,22 @@ CoreGetMemorySpaceDescriptor (
   @param  Length                 Specified length\r
   @param  Attributes             Specified attributes\r
 \r
-  @retval EFI_SUCCESS            Successfully set attribute of a segment of\r
-                                 memory space.\r
+  @retval EFI_SUCCESS           The attributes were set for the memory region.\r
+  @retval EFI_INVALID_PARAMETER Length is zero. \r
+  @retval EFI_UNSUPPORTED       The processor does not support one or more bytes of the memory\r
+                                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
+                                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
+  @retval EFI_NOT_AVAILABLE_YET The attributes cannot be set because CPU architectural protocol is\r
+                                not available yet.\r
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 CoreSetMemorySpaceAttributes (\r
   IN EFI_PHYSICAL_ADDRESS  BaseAddress,\r
   IN UINT64                Length,\r
@@ -1683,6 +1893,7 @@ CoreSetMemorySpaceAttributes (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 CoreGetMemorySpaceMap (\r
   OUT UINTN                            *NumberOfDescriptors,\r
   OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR  **MemorySpaceMap\r
@@ -1701,6 +1912,7 @@ CoreGetMemorySpaceMap (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 CoreAddIoSpace (\r
   IN EFI_GCD_IO_TYPE       GcdIoType,\r
   IN EFI_PHYSICAL_ADDRESS  BaseAddress,\r
@@ -1726,6 +1938,7 @@ CoreAddIoSpace (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 CoreAllocateIoSpace (\r
   IN     EFI_GCD_ALLOCATE_TYPE  GcdAllocateType,\r
   IN     EFI_GCD_IO_TYPE        GcdIoType,\r
@@ -1748,6 +1961,7 @@ CoreAllocateIoSpace (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 CoreFreeIoSpace (\r
   IN EFI_PHYSICAL_ADDRESS  BaseAddress,\r
   IN UINT64                Length\r
@@ -1765,6 +1979,7 @@ CoreFreeIoSpace (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 CoreRemoveIoSpace (\r
   IN EFI_PHYSICAL_ADDRESS  BaseAddress,\r
   IN UINT64                Length\r
@@ -1782,6 +1997,7 @@ CoreRemoveIoSpace (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 CoreGetIoSpaceDescriptor (\r
   IN  EFI_PHYSICAL_ADDRESS         BaseAddress,\r
   OUT EFI_GCD_IO_SPACE_DESCRIPTOR  *Descriptor\r
@@ -1800,6 +2016,7 @@ CoreGetIoSpaceDescriptor (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 CoreGetIoSpaceMap (\r
   OUT UINTN                        *NumberOfDescriptors,\r
   OUT EFI_GCD_IO_SPACE_DESCRIPTOR  **IoSpaceMap\r
@@ -1868,29 +2085,6 @@ CoreTrust (
   );\r
 \r
 \r
-/**\r
-  Helper function called as part of the code needed\r
-  to allocate the proper sized buffer for various\r
-  EFI interfaces.\r
-\r
-  @param  Status                 Current status\r
-  @param  Buffer                 Current allocated buffer, or NULL\r
-  @param  BufferSize             Current buffer size needed\r
-\r
-  @retval TRUE                   if the buffer was reallocated and the caller\r
-                                 should try the API again.\r
-  @retval FALSE                  buffer could not be allocated and the caller\r
-                                 should not try the API again.\r
-\r
-**/\r
-BOOLEAN\r
-CoreGrowBuffer (\r
-  IN OUT EFI_STATUS   *Status,\r
-  IN OUT VOID         **Buffer,\r
-  IN UINTN            BufferSize\r
-  );\r
-\r
-\r
 /**\r
   This routine is the driver initialization entry point.  It initializes the\r
   libraries, and registers two notification functions.  These notification\r
@@ -1947,6 +2141,7 @@ InitializeSectionExtraction (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 CoreProcessFirmwareVolume (\r
   IN VOID                             *FvHeader,\r
   IN UINTN                            Size,\r
@@ -2246,6 +2441,7 @@ OpenSectionStream (
                                 function returns anything other than\r
                                 EFI_SUCCESS, the value of *AuthenticationStatus\r
                                 is undefined.\r
+  @param  IsFfs3Fv              Indicates the FV format.\r
 \r
   @retval EFI_SUCCESS           Section was retrieved successfully\r
   @retval EFI_PROTOCOL_ERROR    A GUID defined section was encountered in the\r
@@ -2276,7 +2472,8 @@ GetSection (
   IN UINTN                                              SectionInstance,\r
   IN VOID                                               **Buffer,\r
   IN OUT UINTN                                          *BufferSize,\r
-  OUT UINT32                                            *AuthenticationStatus\r
+  OUT UINT32                                            *AuthenticationStatus,\r
+  IN BOOLEAN                                            IsFfs3Fv\r
   );\r
 \r
 \r
@@ -2284,6 +2481,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
@@ -2294,7 +2493,327 @@ GetSection (
 EFI_STATUS\r
 EFIAPI\r
 CloseSectionStream (\r
-  IN  UINTN                                     StreamHandleToClose\r
+  IN  UINTN                                     StreamHandleToClose,\r
+  IN  BOOLEAN                                   FreeStreamBuffer\r
+  );\r
+\r
+/**\r
+  Creates and initializes the DebugImageInfo Table.  Also creates the configuration\r
+  table and registers it into the system table.\r
+\r
+  Note:\r
+    This function allocates memory, frees it, and then allocates memory at an\r
+    address within the initial allocation. Since this function is called early\r
+    in DXE core initialization (before drivers are dispatched), this should not\r
+    be a problem.\r
+\r
+**/\r
+VOID\r
+CoreInitializeDebugImageInfoTable (\r
+  VOID\r
+  );\r
+\r
+\r
+/**\r
+  Update the CRC32 in the Debug Table.\r
+  Since the CRC32 service is made available by the Runtime driver, we have to\r
+  wait for the Runtime Driver to be installed before the CRC32 can be computed.\r
+  This function is called elsewhere by the core when the runtime architectural\r
+  protocol is produced.\r
+\r
+**/\r
+VOID\r
+CoreUpdateDebugTableCrc32 (\r
+  VOID\r
+  );\r
+\r
+\r
+/**\r
+  Adds a new DebugImageInfo structure to the DebugImageInfo Table.  Re-Allocates\r
+  the table if it's not large enough to accomidate another entry.\r
+\r
+  @param  ImageInfoType  type of debug image information\r
+  @param  LoadedImage    pointer to the loaded image protocol for the image being\r
+                         loaded\r
+  @param  ImageHandle    image handle for the image being loaded\r
+\r
+**/\r
+VOID\r
+CoreNewDebugImageInfoEntry (\r
+  IN  UINT32                      ImageInfoType,\r
+  IN  EFI_LOADED_IMAGE_PROTOCOL   *LoadedImage,\r
+  IN  EFI_HANDLE                  ImageHandle\r
+  );\r
+\r
+\r
+/**\r
+  Removes and frees an entry from the DebugImageInfo Table.\r
+\r
+  @param  ImageHandle    image handle for the image being unloaded\r
+\r
+**/\r
+VOID\r
+CoreRemoveDebugImageInfoEntry (\r
+  EFI_HANDLE ImageHandle\r
+  );\r
+\r
+\r
+/**\r
+  This routine consumes FV hobs and produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.\r
+\r
+  @param  ImageHandle            The image handle.\r
+  @param  SystemTable            The system table.\r
+\r
+  @retval EFI_SUCCESS            Successfully initialized firmware volume block\r
+                                 driver.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FwVolBlockDriverInit (\r
+  IN EFI_HANDLE                 ImageHandle,\r
+  IN EFI_SYSTEM_TABLE           *SystemTable\r
+  );\r
+\r
+/**\r
+\r
+  Get FVB authentication status\r
+\r
+  @param FvbProtocol    FVB protocol.\r
+\r
+  @return Authentication status.\r
+\r
+**/\r
+UINT32\r
+GetFvbAuthenticationStatus (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *FvbProtocol\r
+  );\r
+\r
+/**\r
+  This routine produces a firmware volume block protocol on a given\r
+  buffer.\r
+\r
+  @param  BaseAddress            base address of the firmware volume image\r
+  @param  Length                 length of the firmware volume image\r
+  @param  ParentHandle           handle of parent firmware volume, if this image\r
+                                 came from an FV image file and section in another firmware\r
+                                 volume (ala capsules)\r
+  @param  AuthenticationStatus   Authentication status inherited, if this image\r
+                                 came from an FV image file and section in another firmware volume.\r
+  @param  FvProtocol             Firmware volume block protocol produced.\r
+\r
+  @retval EFI_VOLUME_CORRUPTED   Volume corrupted.\r
+  @retval EFI_OUT_OF_RESOURCES   No enough buffer to be allocated.\r
+  @retval EFI_SUCCESS            Successfully produced a FVB protocol on given\r
+                                 buffer.\r
+\r
+**/\r
+EFI_STATUS\r
+ProduceFVBProtocolOnBuffer (\r
+  IN EFI_PHYSICAL_ADDRESS   BaseAddress,\r
+  IN UINT64                 Length,\r
+  IN EFI_HANDLE             ParentHandle,\r
+  IN UINT32                 AuthenticationStatus,\r
+  OUT EFI_HANDLE            *FvProtocol  OPTIONAL\r
+  );\r
+\r
+\r
+/**\r
+  Raising to the task priority level of the mutual exclusion\r
+  lock, and then acquires ownership of the lock.\r
+\r
+  @param  Lock               The lock to acquire\r
+\r
+  @return Lock owned\r
+\r
+**/\r
+VOID\r
+CoreAcquireLock (\r
+  IN EFI_LOCK  *Lock\r
+  );\r
+\r
+\r
+/**\r
+  Initialize a basic mutual exclusion lock.   Each lock\r
+  provides mutual exclusion access at it's task priority\r
+  level.  Since there is no-premption (at any TPL) or\r
+  multiprocessor support, acquiring the lock only consists\r
+  of raising to the locks TPL.\r
+\r
+  @param  Lock               The EFI_LOCK structure to initialize\r
+\r
+  @retval EFI_SUCCESS        Lock Owned.\r
+  @retval EFI_ACCESS_DENIED  Reentrant Lock Acquisition, Lock not Owned.\r
+\r
+**/\r
+EFI_STATUS\r
+CoreAcquireLockOrFail (\r
+  IN EFI_LOCK  *Lock\r
+  );\r
+\r
+\r
+/**\r
+  Releases ownership of the mutual exclusion lock, and\r
+  restores the previous task priority level.\r
+\r
+  @param  Lock               The lock to release\r
+\r
+  @return Lock unowned\r
+\r
+**/\r
+VOID\r
+CoreReleaseLock (\r
+  IN EFI_LOCK  *Lock\r
+  );\r
+\r
+\r
+/**\r
+  An empty function to pass error checking of CreateEventEx ().\r
+\r
+  @param  Event                 Event whose notification function is being invoked.\r
+  @param  Context               Pointer to the notification function's context,\r
+                                which is implementation-dependent.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CoreEmptyCallbackFunction (\r
+  IN EFI_EVENT                Event,\r
+  IN VOID                     *Context\r
+  );\r
+\r
+/**\r
+  Read data from Firmware Block by FVB protocol Read. \r
+  The data may cross the multi block ranges.\r
+\r
+  @param  Fvb                   The FW_VOL_BLOCK_PROTOCOL instance from which to read data.\r
+  @param  StartLba              Pointer to StartLba.\r
+                                On input, the start logical block index from which to read.\r
+                                On output,the end logical block index after reading.\r
+  @param  Offset                Pointer to Offset\r
+                                On input, offset into the block at which to begin reading.\r
+                                On output, offset into the end block after reading.\r
+  @param  DataSize              Size of data to be read.\r
+  @param  Data                  Pointer to Buffer that the data will be read into.\r
+\r
+  @retval EFI_SUCCESS           Successfully read data from firmware block.\r
+  @retval others\r
+**/\r
+EFI_STATUS\r
+ReadFvbData (\r
+  IN     EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *Fvb,\r
+  IN OUT EFI_LBA                                *StartLba,\r
+  IN OUT UINTN                                  *Offset,\r
+  IN     UINTN                                  DataSize,\r
+  OUT    UINT8                                  *Data\r
+  );\r
+\r
+/**\r
+  Given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and\r
+  copy the real length volume header into it.\r
+\r
+  @param  Fvb                   The FW_VOL_BLOCK_PROTOCOL instance from which to\r
+                                read the volume header\r
+  @param  FwVolHeader           Pointer to pointer to allocated buffer in which\r
+                                the volume header is returned.\r
+\r
+  @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
+GetFwVolHeader (\r
+  IN     EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *Fvb,\r
+  OUT    EFI_FIRMWARE_VOLUME_HEADER             **FwVolHeader\r
+  );\r
+\r
+/**\r
+  Verify checksum of the firmware volume header.\r
+\r
+  @param  FvHeader       Points to the firmware volume header to be checked\r
+\r
+  @retval TRUE           Checksum verification passed\r
+  @retval FALSE          Checksum verification failed\r
+\r
+**/\r
+BOOLEAN\r
+VerifyFvHeaderChecksum (\r
+  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
+  @retval TRUE          Register success.\r
+  @retval FALSE         Register fail.\r
+\r
+**/\r
+BOOLEAN\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
+  @retval TRUE          Unregister success.\r
+  @retval FALSE         Unregister fail.\r
+\r
+**/\r
+BOOLEAN\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
+  @param Size           Buffer size.\r
+  @param Buffer         Buffer address.\r
+\r
+  @retval TRUE          Profile udpate success.\r
+  @retval FALSE         Profile update fail.\r
+\r
+**/\r
+BOOLEAN\r
+CoreUpdateProfile (\r
+  IN EFI_PHYSICAL_ADDRESS   CallerAddress,\r
+  IN MEMORY_PROFILE_ACTION  Action,\r
+  IN EFI_MEMORY_TYPE        MemoryType, // Valid for AllocatePages/AllocatePool\r
+  IN UINTN                  Size,       // Valid for AllocatePages/FreePages/AllocatePool\r
+  IN VOID                   *Buffer\r
   );\r
 \r
 #endif\r