The internal header file includes the common header files, defines\r
internal structure and functions used by SmmCore module.\r
\r
- Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\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
#include <Guid/EventGroup.h>\r
#include <Guid/EventLegacyBios.h>\r
#include <Guid/MemoryProfile.h>\r
+#include <Guid/LoadModuleAtFixedAddress.h>\r
+#include <Guid/SmiHandlerProfile.h>\r
\r
#include <Library/BaseLib.h>\r
#include <Library/BaseMemoryLib.h>\r
BOOLEAN UnRegister;\r
} SMM_CORE_SMI_HANDLERS;\r
\r
+//\r
+// SMM_HANDLER - used for each SMM handler\r
+//\r
+\r
+#define SMI_ENTRY_SIGNATURE SIGNATURE_32('s','m','i','e')\r
+\r
+ typedef struct {\r
+ UINTN Signature;\r
+ LIST_ENTRY AllEntries; // All entries\r
+\r
+ EFI_GUID HandlerType; // Type of interrupt\r
+ LIST_ENTRY SmiHandlers; // All handlers\r
+} SMI_ENTRY;\r
+\r
+#define SMI_HANDLER_SIGNATURE SIGNATURE_32('s','m','i','h')\r
+\r
+ typedef struct {\r
+ UINTN Signature;\r
+ LIST_ENTRY Link; // Link on SMI_ENTRY.SmiHandlers\r
+ EFI_SMM_HANDLER_ENTRY_POINT2 Handler; // The smm handler's entry point\r
+ UINTN CallerAddr; // The address of caller who register the SMI handler.\r
+ SMI_ENTRY *SmiEntry;\r
+ VOID *Context; // for profile\r
+ UINTN ContextSize; // for profile\r
+} SMI_HANDLER;\r
+\r
//\r
// Structure for recording the state of an SMM Driver\r
//\r
// Image Page Number\r
//\r
UINTN NumberOfPage;\r
+ EFI_HANDLE SmmImageHandle;\r
+ EFI_LOADED_IMAGE_PROTOCOL SmmLoadedImage;\r
} EFI_SMM_DRIVER_ENTRY;\r
\r
#define EFI_HANDLE_SIGNATURE SIGNATURE_32('h','n','d','l')\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
+ @retval EFI_INVALID_PARAMETER Address not aligned, Address is zero or NumberOfPages is zero.\r
@return EFI_SUCCESS Pages successfully freed.\r
\r
**/\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
+ @retval EFI_INVALID_PARAMETER Address not aligned, Address is zero or NumberOfPages is zero.\r
@return EFI_SUCCESS Pages successfully freed.\r
\r
**/\r
OUT VOID **Interface\r
);\r
\r
+/**\r
+ Function returns an array of handles that support the requested protocol\r
+ in a buffer allocated from pool. This is a version of SmmLocateHandle()\r
+ that allocates a buffer for the caller.\r
+\r
+ @param SearchType Specifies which handle(s) are to be returned.\r
+ @param Protocol Provides the protocol to search by. This\r
+ parameter is only valid for SearchType\r
+ ByProtocol.\r
+ @param SearchKey Supplies the search key depending on the\r
+ SearchType.\r
+ @param NumberHandles The number of handles returned in Buffer.\r
+ @param Buffer A pointer to the buffer to return the requested\r
+ array of handles that support Protocol.\r
+\r
+ @retval EFI_SUCCESS The result array of handles was returned.\r
+ @retval EFI_NOT_FOUND No handles match the search.\r
+ @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the\r
+ matching results.\r
+ @retval EFI_INVALID_PARAMETER One or more paramters are not valid.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmLocateHandleBuffer (\r
+ IN EFI_LOCATE_SEARCH_TYPE SearchType,\r
+ IN EFI_GUID *Protocol OPTIONAL,\r
+ IN VOID *SearchKey OPTIONAL,\r
+ IN OUT UINTN *NumberHandles,\r
+ OUT EFI_HANDLE **Buffer\r
+ );\r
+\r
/**\r
Manage SMI of a particular type.\r
\r
VOID\r
);\r
\r
+/**\r
+ Initialize MemoryAttributes support.\r
+**/\r
+VOID\r
+EFIAPI\r
+SmmCoreInitializeMemoryAttributesTable (\r
+ VOID\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
+\r
+ @param[in, out] MemoryMapSize A pointer to the size, in bytes, of the\r
+ MemoryMap buffer. On input, this is the size of\r
+ the buffer allocated by the caller. On output,\r
+ it is the size of the buffer returned by the\r
+ firmware if the buffer was large enough, or the\r
+ size of the buffer needed to contain the map if\r
+ the buffer was too small.\r
+ @param[in, out] MemoryMap A pointer to the buffer in which firmware places\r
+ the current memory map.\r
+ @param[out] MapKey A pointer to the location in which firmware\r
+ returns the key for the current memory map.\r
+ @param[out] DescriptorSize A pointer to the location in which firmware\r
+ returns the size, in bytes, of an individual\r
+ EFI_MEMORY_DESCRIPTOR.\r
+ @param[out] DescriptorVersion A pointer to the location in which firmware\r
+ returns the version number associated with the\r
+ EFI_MEMORY_DESCRIPTOR.\r
+\r
+ @retval EFI_SUCCESS The memory map was returned in the MemoryMap\r
+ buffer.\r
+ @retval EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small. The current\r
+ buffer size needed to hold the memory map is\r
+ returned in MemoryMapSize.\r
+ @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmCoreGetMemoryMap (\r
+ IN OUT UINTN *MemoryMapSize,\r
+ IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,\r
+ OUT UINTN *MapKey,\r
+ OUT UINTN *DescriptorSize,\r
+ OUT UINT32 *DescriptorVersion\r
+ );\r
+\r
+/**\r
+ Initialize SmiHandler profile feature.\r
+**/\r
+VOID\r
+SmmCoreInitializeSmiHandlerProfile (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ This function is called by SmmChildDispatcher module to report\r
+ a new SMI handler is registered, to SmmCore.\r
+\r
+ @param This The protocol instance\r
+ @param HandlerGuid The GUID to identify the type of the handler.\r
+ For the SmmChildDispatch protocol, the HandlerGuid\r
+ must be the GUID of SmmChildDispatch protocol.\r
+ @param Handler The SMI handler.\r
+ @param CallerAddress The address of the module who registers the SMI handler.\r
+ @param Context The context of the SMI handler.\r
+ For the SmmChildDispatch protocol, the Context\r
+ must match the one defined for SmmChildDispatch protocol.\r
+ @param ContextSize The size of the context in bytes.\r
+ For the SmmChildDispatch protocol, the Context\r
+ must match the one defined for SmmChildDispatch protocol.\r
+\r
+ @retval EFI_SUCCESS The information is recorded.\r
+ @retval EFI_OUT_OF_RESOURCES There is no enough resource to record the information.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmiHandlerProfileRegisterHandler (\r
+ IN SMI_HANDLER_PROFILE_PROTOCOL *This,\r
+ IN EFI_GUID *HandlerGuid,\r
+ IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,\r
+ IN PHYSICAL_ADDRESS CallerAddress,\r
+ IN VOID *Context, OPTIONAL\r
+ IN UINTN ContextSize OPTIONAL\r
+ );\r
+\r
+/**\r
+ This function is called by SmmChildDispatcher module to report\r
+ an existing SMI handler is unregistered, to SmmCore.\r
+\r
+ @param This The protocol instance\r
+ @param HandlerGuid The GUID to identify the type of the handler.\r
+ For the SmmChildDispatch protocol, the HandlerGuid\r
+ must be the GUID of SmmChildDispatch protocol.\r
+ @param Handler The SMI handler.\r
+ @param Context The context of the SMI handler.\r
+ If it is NOT NULL, it will be used to check what is registered.\r
+ @param ContextSize The size of the context in bytes.\r
+ If Context is NOT NULL, it will be used to check what is registered.\r
+\r
+ @retval EFI_SUCCESS The original record is removed.\r
+ @retval EFI_NOT_FOUND There is no record for the HandlerGuid and handler.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmiHandlerProfileUnregisterHandler (\r
+ IN SMI_HANDLER_PROFILE_PROTOCOL *This,\r
+ IN EFI_GUID *HandlerGuid,\r
+ IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,\r
+ IN VOID *Context, OPTIONAL\r
+ IN UINTN ContextSize OPTIONAL\r
+ );\r
+\r
extern UINTN mFullSmramRangeCount;\r
extern EFI_SMRAM_DESCRIPTOR *mFullSmramRanges;\r
\r
+extern EFI_SMM_DRIVER_ENTRY *mSmmCoreDriverEntry;\r
+\r
extern EFI_LOADED_IMAGE_PROTOCOL *mSmmCoreLoadedImage;\r
\r
//\r
#define MAX_POOL_INDEX (MAX_POOL_SHIFT - MIN_POOL_SHIFT + 1)\r
\r
typedef struct {\r
- UINTN Size;\r
- BOOLEAN Available;\r
+ UINTN Size;\r
+ BOOLEAN Available;\r
+ EFI_MEMORY_TYPE Type;\r
} POOL_HEADER;\r
\r
typedef struct {\r
LIST_ENTRY Link;\r
} FREE_POOL_HEADER;\r
\r
-extern LIST_ENTRY mSmmPoolLists[MAX_POOL_INDEX];\r
+typedef enum {\r
+ SmmPoolTypeCode,\r
+ SmmPoolTypeData,\r
+ SmmPoolTypeMax,\r
+} SMM_POOL_TYPE;\r
+\r
+extern LIST_ENTRY mSmmPoolLists[SmmPoolTypeMax][MAX_POOL_INDEX];\r
\r
#endif\r