--- /dev/null
+/** @file\r
+ The internal header file includes the common header files, defines\r
+ internal structure and functions used by MmCore module.\r
+\r
+ Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>\r
+\r
+ This program and the accompanying materials are licensed and made available\r
+ under the terms and conditions of the BSD License which accompanies this\r
+ distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _MM_CORE_H_\r
+#define _MM_CORE_H_\r
+\r
+#include <PiMm.h>\r
+#include <StandaloneMm.h>\r
+\r
+#include <Protocol/DxeMmReadyToLock.h>\r
+#include <Protocol/MmReadyToLock.h>\r
+#include <Protocol/MmEndOfDxe.h>\r
+#include <Protocol/MmCommunication.h>\r
+#include <Protocol/LoadedImage.h>\r
+#include <Protocol/MmConfiguration.h>\r
+\r
+#include <Guid/Apriori.h>\r
+#include <Guid/EventGroup.h>\r
+#include <Guid/EventLegacyBios.h>\r
+#include <Guid/ZeroGuid.h>\r
+#include <Guid/MemoryProfile.h>\r
+#include <Guid/HobList.h>\r
+#include <Guid/MmFvDispatch.h>\r
+#include <Guid/MmramMemoryReserve.h>\r
+\r
+#include <Library/StandaloneMmCoreEntryPoint.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/PeCoffLib.h>\r
+#include <Library/CacheMaintenanceLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/ReportStatusCodeLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+#include <Library/StandaloneMmMemLib.h>\r
+#include <Library/HobLib.h>\r
+\r
+#include "StandaloneMmCorePrivateData.h"\r
+\r
+//\r
+// Used to build a table of MMI Handlers that the MM Core registers\r
+//\r
+typedef struct {\r
+ EFI_MM_HANDLER_ENTRY_POINT Handler;\r
+ EFI_GUID *HandlerType;\r
+ EFI_HANDLE DispatchHandle;\r
+ BOOLEAN UnRegister;\r
+} MM_CORE_MMI_HANDLERS;\r
+\r
+//\r
+// Structure for recording the state of an MM Driver\r
+//\r
+#define EFI_MM_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('s', 'd','r','v')\r
+\r
+typedef struct {\r
+ UINTN Signature;\r
+ LIST_ENTRY Link; // mDriverList\r
+\r
+ LIST_ENTRY ScheduledLink; // mScheduledQueue\r
+\r
+ EFI_HANDLE FvHandle;\r
+ EFI_GUID FileName;\r
+ VOID *Pe32Data;\r
+ UINTN Pe32DataSize;\r
+\r
+ VOID *Depex;\r
+ UINTN DepexSize;\r
+\r
+ BOOLEAN Before;\r
+ BOOLEAN After;\r
+ EFI_GUID BeforeAfterGuid;\r
+\r
+ BOOLEAN Dependent;\r
+ BOOLEAN Scheduled;\r
+ BOOLEAN Initialized;\r
+ BOOLEAN DepexProtocolError;\r
+\r
+ EFI_HANDLE ImageHandle;\r
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;\r
+ //\r
+ // Image EntryPoint in MMRAM\r
+ //\r
+ PHYSICAL_ADDRESS ImageEntryPoint;\r
+ //\r
+ // Image Buffer in MMRAM\r
+ //\r
+ PHYSICAL_ADDRESS ImageBuffer;\r
+ //\r
+ // Image Page Number\r
+ //\r
+ UINTN NumberOfPage;\r
+} EFI_MM_DRIVER_ENTRY;\r
+\r
+#define EFI_HANDLE_SIGNATURE SIGNATURE_32('h','n','d','l')\r
+\r
+///\r
+/// IHANDLE - contains a list of protocol handles\r
+///\r
+typedef struct {\r
+ UINTN Signature;\r
+ /// All handles list of IHANDLE\r
+ LIST_ENTRY AllHandles;\r
+ /// List of PROTOCOL_INTERFACE's for this handle\r
+ LIST_ENTRY Protocols;\r
+ UINTN LocateRequest;\r
+} IHANDLE;\r
+\r
+#define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)\r
+\r
+#define PROTOCOL_ENTRY_SIGNATURE SIGNATURE_32('p','r','t','e')\r
+\r
+///\r
+/// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol\r
+/// database. Each handler that supports this protocol is listed, along\r
+/// with a list of registered notifies.\r
+///\r
+typedef struct {\r
+ UINTN Signature;\r
+ /// Link Entry inserted to mProtocolDatabase\r
+ LIST_ENTRY AllEntries;\r
+ /// ID of the protocol\r
+ EFI_GUID ProtocolID;\r
+ /// All protocol interfaces\r
+ LIST_ENTRY Protocols;\r
+ /// Registerd notification handlers\r
+ LIST_ENTRY Notify;\r
+} PROTOCOL_ENTRY;\r
+\r
+#define PROTOCOL_INTERFACE_SIGNATURE SIGNATURE_32('p','i','f','c')\r
+\r
+///\r
+/// PROTOCOL_INTERFACE - each protocol installed on a handle is tracked\r
+/// with a protocol interface structure\r
+///\r
+typedef struct {\r
+ UINTN Signature;\r
+ /// Link on IHANDLE.Protocols\r
+ LIST_ENTRY Link;\r
+ /// Back pointer\r
+ IHANDLE *Handle;\r
+ /// Link on PROTOCOL_ENTRY.Protocols\r
+ LIST_ENTRY ByProtocol;\r
+ /// The protocol ID\r
+ PROTOCOL_ENTRY *Protocol;\r
+ /// The interface value\r
+ VOID *Interface;\r
+} PROTOCOL_INTERFACE;\r
+\r
+#define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('p','r','t','n')\r
+\r
+///\r
+/// PROTOCOL_NOTIFY - used for each register notification for a protocol\r
+///\r
+typedef struct {\r
+ UINTN Signature;\r
+ PROTOCOL_ENTRY *Protocol;\r
+ /// All notifications for this protocol\r
+ LIST_ENTRY Link;\r
+ /// Notification function\r
+ EFI_MM_NOTIFY_FN Function;\r
+ /// Last position notified\r
+ LIST_ENTRY *Position;\r
+} PROTOCOL_NOTIFY;\r
+\r
+//\r
+// MM Core Global Variables\r
+//\r
+extern MM_CORE_PRIVATE_DATA *gMmCorePrivate;\r
+extern EFI_MM_SYSTEM_TABLE gMmCoreMmst;\r
+extern LIST_ENTRY gHandleList;\r
+extern EFI_PHYSICAL_ADDRESS gLoadModuleAtFixAddressMmramBase;\r
+\r
+/**\r
+ Called to initialize the memory service.\r
+\r
+ @param MmramRangeCount Number of MMRAM Regions\r
+ @param MmramRanges Pointer to MMRAM Descriptors\r
+\r
+**/\r
+VOID\r
+MmInitializeMemoryServices (\r
+ IN UINTN MmramRangeCount,\r
+ IN EFI_MMRAM_DESCRIPTOR *MmramRanges\r
+ );\r
+\r
+/**\r
+ The MmInstallConfigurationTable() function is used to maintain the list\r
+ of configuration tables that are stored in the System Management System\r
+ Table. The list is stored as an array of (GUID, Pointer) pairs. The list\r
+ must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.\r
+\r
+ @param SystemTable A pointer to the MM System Table (SMST).\r
+ @param Guid A pointer to the GUID for the entry to add, update, or remove.\r
+ @param Table A pointer to the buffer of the table to add.\r
+ @param TableSize The size of the table to install.\r
+\r
+ @retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed.\r
+ @retval EFI_INVALID_PARAMETER Guid is not valid.\r
+ @retval EFI_NOT_FOUND An attempt was made to delete a non-existent entry.\r
+ @retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmInstallConfigurationTable (\r
+ IN CONST EFI_MM_SYSTEM_TABLE *SystemTable,\r
+ IN CONST EFI_GUID *Guid,\r
+ IN VOID *Table,\r
+ IN UINTN TableSize\r
+ );\r
+\r
+/**\r
+ Wrapper function to MmInstallProtocolInterfaceNotify. This is the public API which\r
+ Calls the private one which contains a BOOLEAN parameter for notifications\r
+\r
+ @param UserHandle The handle to install the protocol handler on,\r
+ or NULL if a new handle is to be allocated\r
+ @param Protocol The protocol to add to the handle\r
+ @param InterfaceType Indicates whether Interface is supplied in\r
+ native form.\r
+ @param Interface The interface for the protocol being added\r
+\r
+ @return Status code\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmInstallProtocolInterface (\r
+ IN OUT EFI_HANDLE *UserHandle,\r
+ IN EFI_GUID *Protocol,\r
+ IN EFI_INTERFACE_TYPE InterfaceType,\r
+ IN VOID *Interface\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
+ @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in 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
+MmAllocatePages (\r
+ IN EFI_ALLOCATE_TYPE Type,\r
+ IN EFI_MEMORY_TYPE MemoryType,\r
+ IN UINTN NumberOfPages,\r
+ 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
+ @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in 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
+MmInternalAllocatePages (\r
+ IN EFI_ALLOCATE_TYPE Type,\r
+ IN EFI_MEMORY_TYPE MemoryType,\r
+ IN UINTN NumberOfPages,\r
+ OUT EFI_PHYSICAL_ADDRESS *Memory\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, Address is zero or NumberOfPages is zero.\r
+ @return EFI_SUCCESS Pages successfully freed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmFreePages (\r
+ IN EFI_PHYSICAL_ADDRESS Memory,\r
+ 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, Address is zero or NumberOfPages is zero.\r
+ @return EFI_SUCCESS Pages successfully freed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmInternalFreePages (\r
+ IN EFI_PHYSICAL_ADDRESS Memory,\r
+ IN UINTN NumberOfPages\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\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
+MmAllocatePool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN Size,\r
+ 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\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
+MmInternalAllocatePool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN Size,\r
+ OUT 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
+MmFreePool (\r
+ 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
+MmInternalFreePool (\r
+ IN VOID *Buffer\r
+ );\r
+\r
+/**\r
+ Installs a protocol interface into the boot services environment.\r
+\r
+ @param UserHandle The handle to install the protocol handler on,\r
+ or NULL if a new handle is to be allocated\r
+ @param Protocol The protocol to add to the handle\r
+ @param InterfaceType Indicates whether Interface is supplied in\r
+ native form.\r
+ @param Interface The interface for the protocol being added\r
+ @param Notify indicates whether notify the notification list\r
+ for this protocol\r
+\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter\r
+ @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate\r
+ @retval EFI_SUCCESS Protocol interface successfully installed\r
+\r
+**/\r
+EFI_STATUS\r
+MmInstallProtocolInterfaceNotify (\r
+ IN OUT EFI_HANDLE *UserHandle,\r
+ IN EFI_GUID *Protocol,\r
+ IN EFI_INTERFACE_TYPE InterfaceType,\r
+ IN VOID *Interface,\r
+ IN BOOLEAN Notify\r
+ );\r
+\r
+/**\r
+ Uninstalls all instances of a protocol:interfacer from a handle.\r
+ If the last protocol interface is remove from the handle, the\r
+ handle is freed.\r
+\r
+ @param UserHandle The handle to remove the protocol handler from\r
+ @param Protocol The protocol, of protocol:interface, to remove\r
+ @param Interface The interface, of protocol:interface, to remove\r
+\r
+ @retval EFI_INVALID_PARAMETER Protocol is NULL.\r
+ @retval EFI_SUCCESS Protocol interface successfully uninstalled.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmUninstallProtocolInterface (\r
+ IN EFI_HANDLE UserHandle,\r
+ IN EFI_GUID *Protocol,\r
+ IN VOID *Interface\r
+ );\r
+\r
+/**\r
+ Queries a handle to determine if it supports a specified protocol.\r
+\r
+ @param UserHandle The handle being queried.\r
+ @param Protocol The published unique identifier of the protocol.\r
+ @param Interface Supplies the address where a pointer to the\r
+ corresponding Protocol Interface is returned.\r
+\r
+ @return The requested protocol interface for the handle\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmHandleProtocol (\r
+ IN EFI_HANDLE UserHandle,\r
+ IN EFI_GUID *Protocol,\r
+ OUT VOID **Interface\r
+ );\r
+\r
+/**\r
+ Add a new protocol notification record for the request protocol.\r
+\r
+ @param Protocol The requested protocol to add the notify\r
+ registration\r
+ @param Function Points to the notification function\r
+ @param Registration Returns the registration record\r
+\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter\r
+ @retval EFI_SUCCESS Successfully returned the registration record\r
+ that has been added\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmRegisterProtocolNotify (\r
+ IN CONST EFI_GUID *Protocol,\r
+ IN EFI_MM_NOTIFY_FN Function,\r
+ OUT VOID **Registration\r
+ );\r
+\r
+/**\r
+ Locates the requested handle(s) and returns them in Buffer.\r
+\r
+ @param SearchType The type of search to perform to locate the\r
+ handles\r
+ @param Protocol The protocol to search for\r
+ @param SearchKey Dependant on SearchType\r
+ @param BufferSize On input the size of Buffer. On output the\r
+ size of data returned.\r
+ @param Buffer The buffer to return the results in\r
+\r
+ @retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is\r
+ returned in BufferSize.\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter\r
+ @retval EFI_SUCCESS Successfully found the requested handle(s) and\r
+ returns them in Buffer.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmLocateHandle (\r
+ IN EFI_LOCATE_SEARCH_TYPE SearchType,\r
+ IN EFI_GUID *Protocol OPTIONAL,\r
+ IN VOID *SearchKey OPTIONAL,\r
+ IN OUT UINTN *BufferSize,\r
+ OUT EFI_HANDLE *Buffer\r
+ );\r
+\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
+ you find.\r
+\r
+ @param Protocol The protocol to search for\r
+ @param Registration Optional Registration Key returned from\r
+ RegisterProtocolNotify()\r
+ @param Interface Return the Protocol interface (instance).\r
+\r
+ @retval EFI_SUCCESS If a valid Interface is returned\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter\r
+ @retval EFI_NOT_FOUND Protocol interface not found\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmLocateProtocol (\r
+ IN EFI_GUID *Protocol,\r
+ IN VOID *Registration OPTIONAL,\r
+ OUT VOID **Interface\r
+ );\r
+\r
+/**\r
+ Manage MMI of a particular type.\r
+\r
+ @param HandlerType Points to the handler type or NULL for root MMI handlers.\r
+ @param Context Points to an optional context buffer.\r
+ @param CommBuffer Points to the optional communication buffer.\r
+ @param CommBufferSize Points to the size of the optional communication buffer.\r
+\r
+ @retval EFI_SUCCESS Interrupt source was processed successfully but not quiesced.\r
+ @retval EFI_INTERRUPT_PENDING One or more MMI sources could not be quiesced.\r
+ @retval EFI_WARN_INTERRUPT_SOURCE_PENDING Interrupt source was not handled or quiesced.\r
+ @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED Interrupt source was handled and quiesced.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmiManage (\r
+ IN CONST EFI_GUID *HandlerType,\r
+ IN CONST VOID *Context OPTIONAL,\r
+ IN OUT VOID *CommBuffer OPTIONAL,\r
+ IN OUT UINTN *CommBufferSize OPTIONAL\r
+ );\r
+\r
+/**\r
+ Registers a handler to execute within MM.\r
+\r
+ @param Handler Handler service funtion pointer.\r
+ @param HandlerType Points to the handler type or NULL for root MMI handlers.\r
+ @param DispatchHandle On return, contains a unique handle which can be used to later unregister the handler function.\r
+\r
+ @retval EFI_SUCCESS Handler register success.\r
+ @retval EFI_INVALID_PARAMETER Handler or DispatchHandle is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmiHandlerRegister (\r
+ IN EFI_MM_HANDLER_ENTRY_POINT Handler,\r
+ IN CONST EFI_GUID *HandlerType OPTIONAL,\r
+ OUT EFI_HANDLE *DispatchHandle\r
+ );\r
+\r
+/**\r
+ Unregister a handler in MM.\r
+\r
+ @param DispatchHandle The handle that was specified when the handler was registered.\r
+\r
+ @retval EFI_SUCCESS Handler function was successfully unregistered.\r
+ @retval EFI_INVALID_PARAMETER DispatchHandle does not refer to a valid handle.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmiHandlerUnRegister (\r
+ IN EFI_HANDLE DispatchHandle\r
+ );\r
+\r
+/**\r
+ This function is the main entry point for an MM handler dispatch\r
+ or communicate-based callback.\r
+\r
+ @param DispatchHandle The unique handle assigned to this handler by MmiHandlerRegister().\r
+ @param Context Points to an optional handler context which was specified when the handler was registered.\r
+ @param CommBuffer A pointer to a collection of data in memory that will\r
+ be conveyed from a non-MM environment into an MM environment.\r
+ @param CommBufferSize The size of the CommBuffer.\r
+\r
+ @return Status Code\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmDriverDispatchHandler (\r
+ IN EFI_HANDLE DispatchHandle,\r
+ IN CONST VOID *Context, OPTIONAL\r
+ IN OUT VOID *CommBuffer, OPTIONAL\r
+ IN OUT UINTN *CommBufferSize OPTIONAL\r
+ );\r
+\r
+/**\r
+ This function is the main entry point for an MM handler dispatch\r
+ or communicate-based callback.\r
+\r
+ @param DispatchHandle The unique handle assigned to this handler by MmiHandlerRegister().\r
+ @param Context Points to an optional handler context which was specified when the handler was registered.\r
+ @param CommBuffer A pointer to a collection of data in memory that will\r
+ be conveyed from a non-MM environment into an MM environment.\r
+ @param CommBufferSize The size of the CommBuffer.\r
+\r
+ @return Status Code\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmFvDispatchHandler (\r
+ IN EFI_HANDLE DispatchHandle,\r
+ IN CONST VOID *Context, OPTIONAL\r
+ IN OUT VOID *CommBuffer, OPTIONAL\r
+ IN OUT UINTN *CommBufferSize OPTIONAL\r
+ );\r
+\r
+/**\r
+ This function is the main entry point for an MM handler dispatch\r
+ or communicate-based callback.\r
+\r
+ @param DispatchHandle The unique handle assigned to this handler by MmiHandlerRegister().\r
+ @param Context Points to an optional handler context which was specified when the handler was registered.\r
+ @param CommBuffer A pointer to a collection of data in memory that will\r
+ be conveyed from a non-MM environment into an MM environment.\r
+ @param CommBufferSize The size of the CommBuffer.\r
+\r
+ @return Status Code\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmLegacyBootHandler (\r
+ IN EFI_HANDLE DispatchHandle,\r
+ IN CONST VOID *Context, OPTIONAL\r
+ IN OUT VOID *CommBuffer, OPTIONAL\r
+ IN OUT UINTN *CommBufferSize OPTIONAL\r
+ );\r
+\r
+/**\r
+ This function is the main entry point for an MM handler dispatch\r
+ or communicate-based callback.\r
+\r
+ @param DispatchHandle The unique handle assigned to this handler by MmiHandlerRegister().\r
+ @param Context Points to an optional handler context which was specified when the handler was registered.\r
+ @param CommBuffer A pointer to a collection of data in memory that will\r
+ be conveyed from a non-MM environment into an MM environment.\r
+ @param CommBufferSize The size of the CommBuffer.\r
+\r
+ @return Status Code\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmExitBootServiceHandler (\r
+ IN EFI_HANDLE DispatchHandle,\r
+ IN CONST VOID *Context, OPTIONAL\r
+ IN OUT VOID *CommBuffer, OPTIONAL\r
+ IN OUT UINTN *CommBufferSize OPTIONAL\r
+ );\r
+\r
+/**\r
+ This function is the main entry point for an MM handler dispatch\r
+ or communicate-based callback.\r
+\r
+ @param DispatchHandle The unique handle assigned to this handler by MmiHandlerRegister().\r
+ @param Context Points to an optional handler context which was specified when the handler was registered.\r
+ @param CommBuffer A pointer to a collection of data in memory that will\r
+ be conveyed from a non-MM environment into an MM environment.\r
+ @param CommBufferSize The size of the CommBuffer.\r
+\r
+ @return Status Code\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmReadyToBootHandler (\r
+ IN EFI_HANDLE DispatchHandle,\r
+ IN CONST VOID *Context, OPTIONAL\r
+ IN OUT VOID *CommBuffer, OPTIONAL\r
+ IN OUT UINTN *CommBufferSize OPTIONAL\r
+ );\r
+\r
+/**\r
+ This function is the main entry point for an MM handler dispatch\r
+ or communicate-based callback.\r
+\r
+ @param DispatchHandle The unique handle assigned to this handler by MmiHandlerRegister().\r
+ @param Context Points to an optional handler context which was specified when the handler was registered.\r
+ @param CommBuffer A pointer to a collection of data in memory that will\r
+ be conveyed from a non-MM environment into an MM environment.\r
+ @param CommBufferSize The size of the CommBuffer.\r
+\r
+ @return Status Code\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmReadyToLockHandler (\r
+ IN EFI_HANDLE DispatchHandle,\r
+ IN CONST VOID *Context, OPTIONAL\r
+ IN OUT VOID *CommBuffer, OPTIONAL\r
+ IN OUT UINTN *CommBufferSize OPTIONAL\r
+ );\r
+\r
+/**\r
+ This function is the main entry point for an MM handler dispatch\r
+ or communicate-based callback.\r
+\r
+ @param DispatchHandle The unique handle assigned to this handler by MmiHandlerRegister().\r
+ @param Context Points to an optional handler context which was specified when the handler was registered.\r
+ @param CommBuffer A pointer to a collection of data in memory that will\r
+ be conveyed from a non-MM environment into an MM environment.\r
+ @param CommBufferSize The size of the CommBuffer.\r
+\r
+ @return Status Code\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmEndOfDxeHandler (\r
+ IN EFI_HANDLE DispatchHandle,\r
+ IN CONST VOID *Context, OPTIONAL\r
+ IN OUT VOID *CommBuffer, OPTIONAL\r
+ IN OUT UINTN *CommBufferSize OPTIONAL\r
+ );\r
+\r
+/**\r
+ Place holder function until all the MM System Table Service are available.\r
+\r
+ @param Arg1 Undefined\r
+ @param Arg2 Undefined\r
+ @param Arg3 Undefined\r
+ @param Arg4 Undefined\r
+ @param Arg5 Undefined\r
+\r
+ @return EFI_NOT_AVAILABLE_YET\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmEfiNotAvailableYetArg5 (\r
+ UINTN Arg1,\r
+ UINTN Arg2,\r
+ UINTN Arg3,\r
+ UINTN Arg4,\r
+ UINTN Arg5\r
+ );\r
+\r
+//\r
+//Functions used during debug buils\r
+//\r
+\r
+/**\r
+ Traverse the discovered list for any drivers that were discovered but not loaded\r
+ because the dependency expressions evaluated to false.\r
+\r
+**/\r
+VOID\r
+MmDisplayDiscoveredNotDispatched (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Add free MMRAM region for use by memory service.\r
+\r
+ @param MemBase Base address of memory region.\r
+ @param MemLength Length of the memory region.\r
+ @param Type Memory type.\r
+ @param Attributes Memory region state.\r
+\r
+**/\r
+VOID\r
+MmAddMemoryRegion (\r
+ IN EFI_PHYSICAL_ADDRESS MemBase,\r
+ IN UINT64 MemLength,\r
+ IN EFI_MEMORY_TYPE Type,\r
+ IN UINT64 Attributes\r
+ );\r
+\r
+/**\r
+ Finds the protocol entry for the requested protocol.\r
+\r
+ @param Protocol The ID of the protocol\r
+ @param Create Create a new entry if not found\r
+\r
+ @return Protocol entry\r
+\r
+**/\r
+PROTOCOL_ENTRY *\r
+MmFindProtocolEntry (\r
+ IN EFI_GUID *Protocol,\r
+ IN BOOLEAN Create\r
+ );\r
+\r
+/**\r
+ Signal event for every protocol in protocol entry.\r
+\r
+ @param Prot Protocol interface\r
+\r
+**/\r
+VOID\r
+MmNotifyProtocol (\r
+ IN PROTOCOL_INTERFACE *Prot\r
+ );\r
+\r
+/**\r
+ Finds the protocol instance for the requested handle and protocol.\r
+ Note: This function doesn't do parameters checking, it's caller's responsibility\r
+ to pass in valid parameters.\r
+\r
+ @param Handle The handle to search the protocol on\r
+ @param Protocol GUID of the protocol\r
+ @param Interface The interface for the protocol being searched\r
+\r
+ @return Protocol instance (NULL: Not found)\r
+\r
+**/\r
+PROTOCOL_INTERFACE *\r
+MmFindProtocolInterface (\r
+ IN IHANDLE *Handle,\r
+ IN EFI_GUID *Protocol,\r
+ IN VOID *Interface\r
+ );\r
+\r
+/**\r
+ Removes Protocol from the protocol list (but not the handle list).\r
+\r
+ @param Handle The handle to remove protocol on.\r
+ @param Protocol GUID of the protocol to be moved\r
+ @param Interface The interface of the protocol\r
+\r
+ @return Protocol Entry\r
+\r
+**/\r
+PROTOCOL_INTERFACE *\r
+MmRemoveInterfaceFromProtocol (\r
+ IN IHANDLE *Handle,\r
+ IN EFI_GUID *Protocol,\r
+ IN VOID *Interface\r
+ );\r
+\r
+/**\r
+ This is the POSTFIX version of the dependency evaluator. This code does\r
+ not need to handle Before or After, as it is not valid to call this\r
+ routine in this case. POSTFIX means all the math is done on top of the stack.\r
+\r
+ @param DriverEntry DriverEntry element to update.\r
+\r
+ @retval TRUE If driver is ready to run.\r
+ @retval FALSE If driver is not ready to run or some fatal error\r
+ was found.\r
+\r
+**/\r
+BOOLEAN\r
+MmIsSchedulable (\r
+ IN EFI_MM_DRIVER_ENTRY *DriverEntry\r
+ );\r
+\r
+/**\r
+ Dump MMRAM information.\r
+\r
+**/\r
+VOID\r
+DumpMmramInfo (\r
+ VOID\r
+ );\r
+\r
+extern UINTN mMmramRangeCount;\r
+extern EFI_MMRAM_DESCRIPTOR *mMmramRanges;\r
+extern EFI_SYSTEM_TABLE *mEfiSystemTable;\r
+\r
+#endif\r