]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Pi/PiSmmCis.h
Add into MdePkg the common definitions in the Platform Initialization Specification...
[mirror_edk2.git] / MdePkg / Include / Pi / PiSmmCis.h
diff --git a/MdePkg/Include/Pi/PiSmmCis.h b/MdePkg/Include/Pi/PiSmmCis.h
new file mode 100644 (file)
index 0000000..e92bc57
--- /dev/null
@@ -0,0 +1,357 @@
+/** @file\r
+  Common definitions in the Platform Initialization Specification version 1.2\r
+  VOLUME 4 System Management Mode Core Interface version.\r
+\r
+  Copyright (c) 2009, Intel Corporation\r
+  All rights reserved. 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
+\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 _PI_SMMCIS_H_\r
+#define _PI_SMMCIS_H_\r
+\r
+#include <Pi/PiMultiPhase.h>\r
+#include <Protocol/SmmCpuIo.h>\r
+\r
+typedef struct _EFI_SMM_SYSTEM_TABLE  EFI_SMM_SYSTEM_TABLE;\r
+\r
+///\r
+/// The System Management System Table (SMST) signature\r
+///\r
+#define SMM_SMST_SIGNATURE            SIGNATURE_32 ('S', 'M', 'S', 'T')\r
+///\r
+/// The System Management System Table (SMST) revision is 1.0\r
+///\r
+#define EFI_SMM_SYSTEM_TABLE_REVISION ((1 << 16) | (0x00))\r
+\r
+/**\r
+  Adds, updates, or removes a configuration table entry from the System Management System Table.\r
+\r
+  The SmmInstallConfigurationTable() 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[in] SystemTable         A pointer to the SMM System Table (SMST).\r
+  @param[in] Guid                A pointer to the GUID for the entry to add, update, or remove.\r
+  @param[in] Table               A pointer to the buffer of the table to add.\r
+  @param[in] 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
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_INSTALL_CONFIGURATION_TABLE)(\r
+  IN CONST EFI_SMM_SYSTEM_TABLE  *SystemTable,\r
+  IN CONST EFI_GUID              *Guid,\r
+  IN VOID                        *Table,\r
+  IN UINTN                       TableSize\r
+  );\r
+\r
+/**\r
+  Function prototype for invoking a function on an Application Processor.\r
+\r
+  @param[in] Buffer  Pointer to private data buffer.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_AP_PROCEDURE)(\r
+  IN VOID  *Buffer\r
+  );\r
+\r
+/**\r
+  The SmmStartupThisAp() lets the caller to get one distinct application processor\r
+  (AP) in the enabled processor pool to execute a caller-provided code stream\r
+  while in SMM. It runs the given code on this processor and reports the status.\r
+  It must be noted that the supplied code stream will be run only on an enabled \r
+  processor which has also entered SMM. \r
+\r
+  @param[in]     Procedure       A pointer to the code stream to be run on the designated AP of the system.\r
+  @param[in]     CpuNumber       The zero-based index of the processor number of the AP on which the code stream is supposed to run.\r
+  @param[in,out] ProcArguments   Allow the caller to pass a list of parameters to the code that is run by the AP.\r
+\r
+  @retval EFI_SUCCESS            The call was successful and the return parameters are valid.\r
+  @retval EFI_INVALID_PARAMETER  The input arguments are out of range.\r
+  @retval EFI_INVALID_PARAMETER  The CPU requested is not available on this SMI invocation.\r
+  @retval EFI_INVALID_PARAMETER  The CPU cannot support an additional service invocation.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_STARTUP_THIS_AP)(\r
+  IN EFI_AP_PROCEDURE  Procedure,\r
+  IN UINTN             CpuNumber,\r
+  IN OUT VOID          *ProcArguments OPTIONAL\r
+  );\r
+\r
+/**\r
+  Function prototype for protocol install notification.\r
+\r
+  @param[in] Protocol   Points to the protocol's unique identifier.\r
+  @param[in] Interface  Points to the interface instance.\r
+  @param[in] Handle     The handle on which the interface was installed.\r
+\r
+  @return Status Code\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_NOTIFY_FN)(\r
+  IN CONST EFI_GUID  *Protocol,\r
+  IN VOID            *Interface,\r
+  IN EFI_HANDLE      Handle\r
+  );\r
+\r
+/**\r
+  Register a callback function be called when a particular protocol interface is installed.\r
+\r
+  The SmmRegisterProtocolNotify() function creates a registration Function that is to be \r
+  called whenever a protocol interface is installed for Protocol by \r
+  SmmInstallProtocolInterface().\r
+\r
+  @param[in]  Protocol          The unique ID of the protocol for which the event is to be registered.\r
+  @param[in]  Function          Points to the notification function.\r
+  @param[out] Registration      A pointer to a memory location to receive the registration value.\r
+\r
+  @retval EFI_SUCCESS           Successfully returned the registration record that has been added.\r
+  @retval EFI_INVALID_PARAMETER One or more of Protocol, Function and Registration is NULL.\r
+  @retval EFI_OUT_OF_RESOURCES  Not enough memory resource to finish the request.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_REGISTER_PROTOCOL_NOTIFY)(\r
+  IN  CONST EFI_GUID     *Protocol,\r
+  IN  EFI_SMM_NOTIFY_FN  Function,\r
+  OUT VOID               **Registration\r
+  );\r
+\r
+/**\r
+  Manage SMI of a particular type.\r
+\r
+  @param[in]     HandlerType     Points to the handler type or NULL for root SMI handlers.\r
+  @param[in]     Context         Points to an optional context buffer.\r
+  @param[in,out] CommBuffer      Points to the optional communication buffer.\r
+  @param[in,out] 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 SMI 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
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_INTERRUPT_MANAGE)(\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
+  Main entry point for an SMM handler dispatch or communicate-based callback.\r
+\r
+  @param[in]     DispatchHandle  The unique handle assigned to this handler by SmiHandlerRegister().\r
+  @param[in]     Context         Points to an optional handler context which was specified when the\r
+                                 handler was registered.\r
+  @param[in,out] CommBuffer      A pointer to a collection of data in memory that will\r
+                                 be conveyed from a non-SMM environment into an SMM environment.\r
+  @param[in,out] CommBufferSize  The size of the CommBuffer.\r
+\r
+  @retval EFI_SUCCESS                         The interrupt was handled and quiesced. No other handlers \r
+                                              should still be called.\r
+  @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED  The interrupt has been quiesced but other handlers should \r
+                                              still be called.\r
+  @retval EFI_WARN_INTERRUPT_SOURCE_PENDING   The interrupt is still pending and other handlers should still \r
+                                              be called.\r
+  @retval EFI_INTERRUPT_PENDING               The interrupt could not be quiesced.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_HANDLER_ENTRY_POINT2)(\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
+  Registers a handler to execute within SMM.\r
+\r
+  @param[in]  Handler            Handler service funtion pointer.\r
+  @param[in]  HandlerType        Points to the handler type or NULL for root SMI handlers.\r
+  @param[out] DispatchHandle     On return, contains a unique handle which can be used to later\r
+                                 unregister the handler function.\r
+\r
+  @retval EFI_SUCCESS            SMI handler added successfully.\r
+  @retval EFI_INVALID_PARAMETER  Handler is NULL or DispatchHandle is NULL.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_INTERRUPT_REGISTER)(\r
+  IN  EFI_SMM_HANDLER_ENTRY_POINT2  Handler,\r
+  IN  CONST EFI_GUID                *HandlerType OPTIONAL,\r
+  OUT EFI_HANDLE                    *DispatchHandle\r
+  );\r
+\r
+/**\r
+  Unregister a handler in SMM.\r
+\r
+  @param[in] 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
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_INTERRUPT_UNREGISTER)(\r
+  IN EFI_HANDLE  DispatchHandle\r
+  );\r
+\r
+///\r
+/// Processor information and functionality needed by SMM Foundation.\r
+///\r
+typedef struct _EFI_SMM_ENTRY_CONTEXT {\r
+  EFI_SMM_STARTUP_THIS_AP  SmmStartupThisAp;\r
+  ///\r
+  /// A number between zero and the NumberOfCpus field. This field designates which \r
+  /// processor is executing the SMM Foundation.\r
+  ///\r
+  UINTN                    CurrentlyExecutingCpu;\r
+  ///\r
+  /// The number of current operational processors in the platform.  This is a 1 based \r
+  /// counter.  This does not indicate the number of processors that entered SMM.\r
+  ///\r
+  UINTN                    NumberOfCpus;\r
+  ///\r
+  /// Points to an array, where each element describes the number of bytes in the \r
+  /// corresponding save state specified by CpuSaveState. There are always \r
+  /// NumberOfCpus entries in the array. \r
+  ///\r
+  UINTN                    *CpuSaveStateSize;\r
+  ///\r
+  /// Points to an array, where each element is a pointer to a CPU save state. The \r
+  /// corresponding element in CpuSaveStateSize specifies the number of bytes in the \r
+  /// save state area. There are always NumberOfCpus entries in the array.\r
+  ///\r
+  VOID                     **CpuSaveState;\r
+} EFI_SMM_ENTRY_CONTEXT;\r
+\r
+/**\r
+  This function is the main entry point to the SMM Foundation.\r
+\r
+  @param[in] SmmEntryContext  Processor information and functionality needed by SMM Foundation.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_SMM_ENTRY_POINT)(\r
+  IN CONST EFI_SMM_ENTRY_CONTEXT  *SmmEntryContext\r
+  );\r
+\r
+///\r
+/// System Management System Table (SMST)\r
+///\r
+/// The System Management System Table (SMST) is a table that contains a collection of common \r
+/// services for managing SMRAM allocation and providing basic I/O services. These services are \r
+/// intended for both preboot and runtime usage.\r
+///\r
+struct _EFI_SMM_SYSTEM_TABLE {\r
+  ///\r
+  /// The table header for the SMST.\r
+  ///\r
+  EFI_TABLE_HEADER                    Hdr;\r
+  ///\r
+  /// A pointer to a NULL-terminated Unicode string containing the vendor name.\r
+  /// It is permissible for this pointer to be NULL.\r
+  ///\r
+  CHAR16                              *SmmFirmwareVendor;\r
+  ///\r
+  /// The particular revision of the firmware.\r
+  ///\r
+  UINT32                              SmmFirmwareRevision;\r
+\r
+  EFI_SMM_INSTALL_CONFIGURATION_TABLE SmmInstallConfigurationTable;\r
+\r
+  ///\r
+  /// I/O Service\r
+  ///\r
+  EFI_SMM_CPU_IO_PROTOCOL             SmmIo;\r
+\r
+  ///\r
+  /// Runtime memory services\r
+  ///\r
+  EFI_ALLOCATE_POOL                   SmmAllocatePool;\r
+  EFI_FREE_POOL                       SmmFreePool;\r
+  EFI_ALLOCATE_PAGES                  SmmAllocatePages;\r
+  EFI_FREE_PAGES                      SmmFreePages;\r
+\r
+  ///\r
+  /// MP service\r
+  ///\r
+  EFI_SMM_STARTUP_THIS_AP             SmmStartupThisAp;\r
+\r
+  ///\r
+  /// CPU information records\r
+  ///\r
+\r
+  ///\r
+  /// A number between zero and and the NumberOfCpus field. This field designates \r
+  /// which processor is executing the SMM infrastructure.\r
+  ///\r
+  UINTN                               CurrentlyExecutingCpu;\r
+  ///\r
+  /// The number of current operational processors in the platform.  This is a 1 based counter.\r
+  ///\r
+  UINTN                               NumberOfCpus;\r
+  ///\r
+  /// Points to an array, where each element describes the number of bytes in the \r
+  /// corresponding save state specified by CpuSaveState. There are always \r
+  /// NumberOfCpus entries in the array. \r
+  ///\r
+  UINTN                               *CpuSaveStateSize;\r
+  ///\r
+  /// Points to an array, where each element is a pointer to a CPU save state. The \r
+  /// corresponding element in CpuSaveStateSize specifies the number of bytes in the \r
+  /// save state area. There are always NumberOfCpus entries in the array.\r
+  ///\r
+  VOID                                **CpuSaveState;\r
+\r
+  ///\r
+  /// Extensibility table\r
+  ///\r
+\r
+  ///\r
+  /// The number of UEFI Configuration Tables in the buffer SmmConfigurationTable.\r
+  ///\r
+  UINTN                               NumberOfTableEntries;\r
+  ///\r
+  /// A pointer to the UEFI Configuration Tables. The number of entries in the table is \r
+  /// NumberOfTableEntries. \r
+  ///\r
+  EFI_CONFIGURATION_TABLE             *SmmConfigurationTable;\r
+\r
+  ///\r
+  /// Protocol services\r
+  ///\r
+  EFI_INSTALL_PROTOCOL_INTERFACE      SmmInstallProtocolInterface;\r
+  EFI_UNINSTALL_PROTOCOL_INTERFACE    SmmUninstallProtocolInterface;\r
+  EFI_HANDLE_PROTOCOL                 SmmHandleProtocol;\r
+  EFI_SMM_REGISTER_PROTOCOL_NOTIFY    SmmRegisterProtocolNotify;\r
+  EFI_LOCATE_HANDLE                   SmmLocateHandle;\r
+  EFI_LOCATE_PROTOCOL                 SmmLocateProtocol;\r
+\r
+  ///\r
+  /// SMI Management functions\r
+  ///\r
+  EFI_SMM_INTERRUPT_MANAGE            SmiManage;\r
+  EFI_SMM_INTERRUPT_REGISTER          SmiHandlerRegister;\r
+  EFI_SMM_INTERRUPT_UNREGISTER        SmiHandlerUnRegister;\r
+};\r
+\r
+#endif\r