smmbase.h

来自「EFI BIOS是Intel提出的下一代的BIOS标准。这里上传的Edk源代码是」· C头文件 代码 · 共 798 行 · 第 1/2 页

H
798
字号
  UINT16  Opcode;
  UINT64  Rip;
  UINT64  DataOffset;
  UINT8   Rsvd1[8];
  UINT8   St0Mm0[10], Rsvd2[6];
  UINT8   St1Mm1[10], Rsvd3[6];
  UINT8   St2Mm2[10], Rsvd4[6];
  UINT8   St3Mm3[10], Rsvd5[6];
  UINT8   St4Mm4[10], Rsvd6[6];
  UINT8   St5Mm5[10], Rsvd7[6];
  UINT8   St6Mm6[10], Rsvd8[6];
  UINT8   St7Mm7[10], Rsvd9[6];
  UINT8   Xmm0[16];
  UINT8   Xmm1[16];
  UINT8   Xmm2[16];
  UINT8   Xmm3[16];
  UINT8   Xmm4[16];
  UINT8   Xmm5[16];
  UINT8   Xmm6[16];
  UINT8   Xmm7[16];
  UINT8   Xmm8[16];
  UINT8   Xmm9[16];
  UINT8   Xmm10[16];
  UINT8   Xmm11[16];
  UINT8   Xmm12[16];
  UINT8   Xmm13[16];
  UINT8   Xmm14[16];
  UINT8   Xmm15[16];
  UINT8   Rsvd10[6 * 16];
} EFI_SMM_OPTIONAL_FP_SAVE_STATE64;

struct _EFI_SMM_SYSTEM_TABLE;

typedef
EFI_STATUS
(EFIAPI *EFI_SMM_INSTALL_CONFIGURATION_TABLE) (
  IN EFI_SMM_SYSTEM_TABLE         * SystemTable,
  IN EFI_GUID                     * Guid,
  IN VOID                         *Table,
  IN UINTN                        TableSize
  )
/*++

  Routine Description:
    The SmmInstallConfigurationTable() function is used to maintain the list 
    of configuration tables that are stored in the System Management System 
    Table.  The list is stored as an array of (GUID, Pointer) pairs.  The list 
    must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.

  Arguments:
    SystemTable - A pointer to the SMM System Table.
    Guid        - A pointer to the GUID for the entry to add, update, or remove.
    Table       - A pointer to the buffer of the table to add.  
    TableSize   - The size of the table to install.

  Returns:
    EFI_SUCCESS             - The (Guid, Table) pair was added, updated, or removed.
    EFI_INVALID_PARAMETER   - Guid is not valid.
    EFI_NOT_FOUND           - An attempt was made to delete a non-existent entry.
    EFI_OUT_OF_RESOURCES    - There is not enough memory available to complete the operation. 

--*/
;

//
// System Management System Table (SMST)
//
typedef struct _EFI_SMM_SYSTEM_TABLE {
  EFI_TABLE_HEADER                    Hdr;

  CHAR16                              *SmmFirmwareVendor;
  UINT32                              SmmFirmwareRevision;

  EFI_SMM_INSTALL_CONFIGURATION_TABLE SmmInstallConfigurationTable;

  //
  // I/O Services
  //
  EFI_GUID                            EfiSmmCpuIoGuid;
  EFI_SMM_CPU_IO_INTERFACE            SmmIo;

  //
  // Runtime memory service
  //
  EFI_SMMCORE_ALLOCATE_POOL           SmmAllocatePool;
  EFI_SMMCORE_FREE_POOL               SmmFreePool;
  EFI_SMMCORE_ALLOCATE_PAGES          SmmAllocatePages;
  EFI_SMMCORE_FREE_PAGES              SmmFreePages;

  //
  // MP service
  //
  EFI_SMM_STARTUP_THIS_AP             SmmStartupThisAp;

  //
  // CPU information records
  //
  UINTN                               CurrentlyExecutingCpu;
  UINTN                               NumberOfCpus;
  EFI_SMM_CPU_SAVE_STATE              *CpuSaveState;
  EFI_SMM_OPTIONAL_FP_SAVE_STATE      *CpuOptionalFloatingPointState;

  //
  // Extensibility table
  //
  UINTN                               NumberOfTableEntries;
  EFI_CONFIGURATION_TABLE             *SmmConfigurationTable;

} EFI_SMM_SYSTEM_TABLE;

//
// SMM Handler Definition
//
#define EFI_HANDLER_SUCCESS         0x0000
#define EFI_HANDLER_CRITICAL_EXIT   0x0001
#define EFI_HANDLER_SOURCE_QUIESCED 0x0002
#define EFI_HANDLER_SOURCE_PENDING  0x0003

//
// Structure of Communicate Buffer
//
typedef struct {
  EFI_GUID              HeaderGuid;
  UINTN                 MessageLength;
  UINT8                 Data[1];
} EFI_SMM_COMMUNICATE_HEADER;

typedef
EFI_STATUS
(EFIAPI *EFI_SMM_HANDLER_ENTRY_POINT) (
  IN EFI_HANDLE             SmmImageHandle,
  IN OUT VOID               *CommunicationBuffer OPTIONAL,
  IN OUT UINTN              *SourceSize OPTIONAL
  );

typedef
EFI_STATUS
(EFIAPI *EFI_SMM_CALLBACK_ENTRY_POINT) (
  IN EFI_HANDLE             SmmImageHandle,
  IN OUT VOID               *CommunicationBuffer OPTIONAL,
  IN OUT UINTN              *SourceSize OPTIONAL
  );

typedef struct {
  EFI_HANDLE                SmmHandler;
  EFI_DEVICE_PATH_PROTOCOL  *HandlerDevicePath;
} EFI_HANDLER_DESCRIPTOR;

//
// SMM Base Protocol Definition
//
typedef
EFI_STATUS
(EFIAPI *EFI_SMM_REGISTER_HANDLER) (
  IN EFI_SMM_BASE_PROTOCOL                           * This,
  IN  EFI_DEVICE_PATH_PROTOCOL                       * FilePath,
  IN  VOID                                           *SourceBuffer OPTIONAL,
  IN  UINTN                                          SourceSize,
  OUT EFI_HANDLE                                     * ImageHandle,
  IN  BOOLEAN                                        LegacyIA32Binary OPTIONAL
  )
/*++

  Routine Description:
    Register a given driver into SMRAM.  This is the equivalent of performing
    the LoadImage/StartImage into System Management Mode.

  Arguments:
    This                  - Protocol instance pointer.
    SourceBuffer          - Optional source buffer in case of the image file
                            being in memory.
    SourceSize            - Size of the source image file, if in memory.
    ImageHandle           - Pointer to the handle that reflects the driver 
                            loaded into SMM.
    LegacyIA32Binary      - The binary image to load is legacy 16 bit code.

  Returns:
    EFI_SUCCESS           - The operation was successful.
    EFI_OUT_OF_RESOURCES  - There were no additional SMRAM resources to load the handler
    EFI_UNSUPPORTED       - This platform does not support 16-bit handlers.
    EFI_UNSUPPORTED       - In runtime.
    EFI_INVALID_PARAMETER - The handlers was not the correct image type

--*/
;

typedef
EFI_STATUS
(EFIAPI *EFI_SMM_UNREGISTER_HANDLER) (
  IN EFI_SMM_BASE_PROTOCOL          * This,
  IN EFI_HANDLE                     ImageHandle
  )
/*++

  Routine Description:
    Remove a given driver SMRAM.  This is the equivalent of performing
    the UnloadImage System Management Mode.

  Arguments:
    This                  - Protocol instance pointer.
    ImageHandle           - Pointer to the handle that reflects the driver 
                            loaded into SMM.

  Returns:
    EFI_SUCCESS           - The operation was successful
    EFI_INVALID_PARAMETER - The handler did not exist
    EFI_UNSUPPORTED       - In runtime.

--*/
;

typedef
EFI_STATUS
(EFIAPI *EFI_SMM_COMMUNICATE) (
  IN EFI_SMM_BASE_PROTOCOL          * This,
  IN EFI_HANDLE                     ImageHandle,
  IN OUT VOID                       *CommunicationBuffer,
  IN OUT UINTN                      *SourceSize
  )
/*++

  Routine Description:
    The SMM Inter-module Communicate Service Communicate() function 
    provides a services to send/received messages from a registered 
    EFI service.  The BASE protocol driver is responsible for doing 
    any of the copies such that the data lives in boot-service accessible RAM.

  Arguments:
    This                  - Protocol instance pointer.
    ImageHandle           - Pointer to the handle that reflects the driver 
                            loaded into SMM.
    CommunicationBuffer   - Pointer to the buffer to convey into SMRAM.
    SourceSize            - Size of the contents of buffer..

  Returns:
    EFI_SUCCESS           - The message was successfully posted
    EFI_INVALID_PARAMETER - The buffer was NULL

--*/
;

typedef
EFI_STATUS
(EFIAPI *EFI_SMM_CALLBACK_SERVICE) (
  IN EFI_SMM_BASE_PROTOCOL                            * This,
  IN EFI_HANDLE                                       SmmImageHandle,
  IN EFI_SMM_CALLBACK_ENTRY_POINT                     CallbackAddress,
  IN BOOLEAN                                          MakeLast OPTIONAL,
  IN BOOLEAN                                          FloatingPointSave OPTIONAL
  )
/*++

  Routine Description:
    Register a callback to execute within SMM.   
    This allows receipt of messages created with the Boot Service COMMUNICATE.

  Arguments:
    This                  - Protocol instance pointer.
    CallbackAddress       - Address of the callback service
    MakeFirst             - If present, will stipulate that the handler is posted 
                            to be the first module executed in the dispatch table.
    MakeLast              - If present, will stipulate that the handler is posted 
                            to be last executed in the dispatch table.
    FloatingPointSave     - This is an optional parameter which informs the 
                            EFI_SMM_ACCESS_PROTOCOL Driver core if it needs to save 
                            the floating point register state.  If any of the handlers 
                            require this, then the state will be saved for all of the handlers.

  Returns:
    EFI_SUCCESS           - The operation was successful
    EFI_OUT_OF_RESOURCES  - Not enough space in the dispatch queue
    EFI_UNSUPPORTED       - In runtime.
    EFI_UNSUPPORTED       - Not in SMM.

--*/
;

typedef
EFI_STATUS
(EFIAPI *EFI_SMM_ALLOCATE_POOL) (
  IN EFI_SMM_BASE_PROTOCOL          * This,
  IN EFI_MEMORY_TYPE                PoolType,
  IN UINTN                          Size,
  OUT VOID                          **Buffer
  )
/*++

  Routine Description:
    The SmmAllocatePool() function allocates a memory region of Size bytes from memory of 
    type PoolType and returns the address of the allocated memory in the location referenced 
    by Buffer.  This function allocates pages from EFI SMRAM Memory as needed to grow the 
    requested pool type.  All allocations are eight-byte aligned.

  Arguments:
    This                  - Protocol instance pointer.
    PoolType              - The type of pool to allocate.  
                            The only supported type is EfiRuntimeServicesData; 
                            the interface will internally map this runtime request to SMRAM.
    Size                  - The number of bytes to allocate from the pool.
    Buffer                - A pointer to a pointer to the allocated buffer if the call 
                            succeeds; undefined otherwise.

  Returns:
    EFI_SUCCESS           - The requested number of bytes was allocated.
    EFI_OUT_OF_RESOURCES  - The pool requested could not be allocated.
    EFI_INVALID_PARAMETER - PoolType was invalid.
    EFI_UNSUPPORTED       - In runtime.

--*/
;

typedef
EFI_STATUS
(EFIAPI *EFI_SMM_FREE_POOL) (
  IN EFI_SMM_BASE_PROTOCOL          * This,
  IN VOID                           *Buffer
  )
/*++

  Routine Description:
    The SmmFreePool() function returns the memory specified by Buffer to the system.  
    On return, the memory's type is EFI SMRAM Memory.  The Buffer that is freed must 
    have been allocated by SmmAllocatePool().

  Arguments:
    This                  - Protocol instance pointer.
    Buffer                - Pointer to the buffer allocation.

  Returns:
    EFI_SUCCESS           - The memory was returned to the system.
    EFI_INVALID_PARAMETER - Buffer was invalid.
    EFI_UNSUPPORTED       - In runtime.

--*/
;

typedef
EFI_STATUS
(EFIAPI *EFI_SMM_INSIDE_OUT) (
  IN EFI_SMM_BASE_PROTOCOL          * This,
  OUT BOOLEAN                       *InSmm
  )
/*++

  Routine Description:
    This routine tells caller if execution context is SMM or not.

  Arguments:
    This                  - Protocol instance pointer.

  Returns:
    EFI_SUCCESS           - The operation was successful

--*/
;

typedef
EFI_STATUS
(EFIAPI *EFI_SMM_GET_SMST_LOCATION) (
  IN EFI_SMM_BASE_PROTOCOL          * This,
  IN OUT EFI_SMM_SYSTEM_TABLE       **Smst
  )
/*++

  Routine Description:
    The GetSmstLocation() function returns the locatin of the System Management 
    Service Table.  The use of the API is such that a driver can discover the 
    location of the SMST in its entry point and then cache it in some driver 
    global variable so that the SMST can be invoked in subsequent callbacks.

  Arguments:
    This                  - Protocol instance pointer.
    Smst                  - Pointer to the SMST.

  Returns:
    EFI_SUCCESS           - The operation was successful
    EFI_INVALID_PARAMETER - Smst was invalid.  
    EFI_UNSUPPORTED       - Not in SMM.

--*/
;

typedef struct _EFI_SMM_BASE_PROTOCOL {
  EFI_SMM_REGISTER_HANDLER    Register;
  EFI_SMM_UNREGISTER_HANDLER  UnRegister;
  EFI_SMM_COMMUNICATE         Communicate;
  EFI_SMM_CALLBACK_SERVICE    RegisterCallback;
  EFI_SMM_INSIDE_OUT          InSmm;
  EFI_SMM_ALLOCATE_POOL       SmmAllocatePool;
  EFI_SMM_FREE_POOL           SmmFreePool;
  EFI_SMM_GET_SMST_LOCATION   GetSmstLocation;
} EFI_SMM_BASE_PROTOCOL;

extern EFI_GUID gEfiSmmBaseProtocolGuid;
extern EFI_GUID gEfiSmmCpuIoGuid;
extern EFI_GUID gEfiSmmCommunicateHeaderGuid;

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?