Home | History | Annotate | Download | only in SmmScriptLib
      1 /** @file
      2   Header file to define SMM S3 Save State Protocol as in PI1.2 Specification VOLUME 5 Standard.
      3 
      4   The thunk implementation for SmmScriptLib will ultilize the SmmSaveState Protocol to save SMM
      5   runtime s3 boot Script. This header file is to definiedSMM S3 Save State Protocol
      6 
      7   Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
      8 
      9   This program and the accompanying materials
     10   are licensed and made available under the terms and conditions
     11   of the BSD License which accompanies this distribution.  The
     12   full text of the license may be found at
     13   http://opensource.org/licenses/bsd-license.php
     14 
     15   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     16   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     17 
     18 **/
     19 #ifndef __PI_SMM_S3_SAVE_STATE_H__
     20 #define __PI_SMM_S3_SAVE_STATE_H__
     21 
     22 #define EFI_S3_SMM_SAVE_STATE_PROTOCOL_GUID \
     23     {0x320afe62, 0xe593, 0x49cb, { 0xa9, 0xf1, 0xd4, 0xc2, 0xf4, 0xaf, 0x1, 0x4c }}
     24 
     25 typedef VOID *EFI_S3_BOOT_SCRIPT_POSITION;
     26 
     27 typedef struct _EFI_S3_SMM_SAVE_STATE_PROTOCOL  EFI_S3_SAVE_STATE_PROTOCOL;
     28 
     29 /**
     30   Record operations that need to be replayed during an S3 resume.
     31 
     32   This function is used to store an OpCode to be replayed as part of the S3 resume boot path. It is
     33   assumed this protocol has platform specific mechanism to store the OpCode set and replay them
     34   during the S3 resume.
     35 
     36   @param[in]    This    A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
     37   @param[in]    OpCode  The operation code (opcode) number.
     38   @param[in]    ...     Argument list that is specific to each opcode. See the following subsections for the
     39                         definition of each opcode.
     40 
     41   @retval EFI_SUCCESS           The operation succeeded. A record was added into the specified
     42                                 script table.
     43   @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.
     44   @retval EFI_OUT_OF_RESOURCES  There is insufficient memory to store the boot script.
     45 **/
     46 typedef
     47 EFI_STATUS
     48 (EFIAPI *EFI_S3_SAVE_STATE_WRITE)(
     49    IN CONST EFI_S3_SAVE_STATE_PROTOCOL         *This,
     50    IN       UINT16                              OpCode,
     51    ...
     52 );
     53 
     54 /**
     55   Record operations that need to be replayed during an S3 resume.
     56 
     57   This function is used to store an OpCode to be replayed as part of the S3 resume boot path. It is
     58   assumed this protocol has platform specific mechanism to store the OpCode set and replay them
     59   during the S3 resume.
     60   The opcode is inserted before or after the specified position in the boot script table. If Position is
     61   NULL then that position is after the last opcode in the table (BeforeOrAfter is TRUE) or before
     62   the first opcode in the table (BeforeOrAfter is FALSE). The position which is pointed to by
     63   Position upon return can be used for subsequent insertions.
     64 
     65   This function has a variable parameter list. The exact parameter list depends on the OpCode that is
     66   passed into the function. If an unsupported OpCode or illegal parameter list is passed in, this
     67   function returns EFI_INVALID_PARAMETER.
     68   If there are not enough resources available for storing more scripts, this function returns
     69   EFI_OUT_OF_RESOURCES.
     70   OpCode values of 0x80 - 0xFE are reserved for implementation specific functions.
     71 
     72   @param[in]        This            A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
     73   @param[in]        BeforeOrAfter   Specifies whether the opcode is stored before (TRUE) or after (FALSE) the position
     74                                     in the boot script table specified by Position. If Position is NULL or points to
     75                                     NULL then the new opcode is inserted at the beginning of the table (if TRUE) or end
     76                                     of the table (if FALSE).
     77   @param[in, out]   Position        On entry, specifies the position in the boot script table where the opcode will be
     78                                     inserted, either before or after, depending on BeforeOrAfter. On exit, specifies
     79                                     the position of the inserted opcode in the boot script table.
     80   @param[in]        OpCode          The operation code (opcode) number. See "Related Definitions" in Write() for the
     81                                     defined opcode types.
     82   @param[in]        ...             Argument list that is specific to each opcode. See the following subsections for the
     83                                     definition of each opcode.
     84 
     85   @retval EFI_SUCCESS               The operation succeeded. An opcode was added into the script.
     86   @retval EFI_INVALID_PARAMETER     The Opcode is an invalid opcode value.
     87   @retval EFI_INVALID_PARAMETER     The Position is not a valid position in the boot script table.
     88   @retval EFI_OUT_OF_RESOURCES      There is insufficient memory to store the boot script table.
     89 **/
     90 typedef
     91 EFI_STATUS
     92 (EFIAPI *EFI_S3_SAVE_STATE_INSERT)(
     93    IN CONST EFI_S3_SAVE_STATE_PROTOCOL         *This,
     94    IN       BOOLEAN                             BeforeOrAfter,
     95    IN OUT   EFI_S3_BOOT_SCRIPT_POSITION         *Position       OPTIONAL,
     96    IN       UINT16                              OpCode,
     97    ...
     98 );
     99 
    100 /**
    101   Find a label within the boot script table and, if not present, optionally create it.
    102 
    103   If the label Label is already exists in the boot script table, then no new label is created, the
    104   position of the Label is returned in *Position and EFI_SUCCESS is returned.
    105   If the label Label does not already exist and CreateIfNotFound is TRUE, then it will be
    106   created before or after the specified position and EFI_SUCCESS is returned.
    107   If the label Label does not already exist and CreateIfNotFound is FALSE, then
    108   EFI_NOT_FOUND is returned.
    109 
    110   @param[in]      This                A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
    111   @param[in]      BeforeOrAfter       Specifies whether the label is stored before (TRUE) or after (FALSE) the position in
    112                                       the boot script table specified by Position. If Position is NULL or points to
    113                                       NULL then the new label is inserted at the beginning of the table (if TRUE) or end of
    114                                       the table (if FALSE).
    115   @param[in]      CreateIfNotFound    Specifies whether the label will be created if the label does not exists (TRUE) or not (FALSE).
    116   @param[in, out] Position            On entry, specifies the position in the boot script table where the label will be inserted,
    117                                       either before or after, depending on BeforeOrAfter. On exit, specifies the position
    118                                       of the inserted label in the boot script table.
    119   @param[in]      Label               Points to the label which will be inserted in the boot script table.
    120 
    121   @retval    EFI_SUCCESS              The label already exists or was inserted.
    122   @retval    EFI_NOT_FOUND            The label did not already exist and CreateifNotFound was FALSE.
    123   @retval    EFI_INVALID_PARAMETER    The Opcode is an invalid opcode value.
    124   @retval    EFI_INVALID_PARAMETER    The Position is not a valid position in the boot script table.
    125   @retval    EFI_OUT_OF_RESOURCES     There is insufficient memory to store the boot script.
    126 **/
    127 typedef
    128 EFI_STATUS
    129 (EFIAPI *EFI_S3_SAVE_STATE_LABEL)(
    130    IN CONST  EFI_S3_SAVE_STATE_PROTOCOL          *This,
    131    IN        BOOLEAN                               BeforeOrAfter,
    132    IN        BOOLEAN                               CreateIfNotFound,
    133    IN OUT    EFI_S3_BOOT_SCRIPT_POSITION           *Position OPTIONAL,
    134    IN CONST  CHAR8                           *Label
    135 );
    136 
    137 /**
    138   Compare two positions in the boot script table and return their relative position.
    139 
    140   This function compares two positions in the boot script table and returns their relative positions. If
    141   Position1 is before Position2, then -1 is returned. If Position1 is equal to Position2,
    142   then 0 is returned. If Position1 is after Position2, then 1 is returned.
    143 
    144   @param[in]    This                A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
    145   @param[in]    Position1           The positions in the boot script table to compare.
    146   @param[in]    Position2           The positions in the boot script table to compare.
    147   @param[out]   RelativePosition    On return, points to the result of the comparison.
    148 
    149   @retval   EFI_SUCCESS             The label already exists or was inserted.
    150   @retval   EFI_INVALID_PARAMETER   The Position1 or Position2 is not a valid position in the boot script table.
    151 **/
    152 typedef
    153 EFI_STATUS
    154 (EFIAPI *EFI_S3_SAVE_STATE_COMPARE)(
    155    IN CONST EFI_S3_SAVE_STATE_PROTOCOL         *This,
    156    IN       EFI_S3_BOOT_SCRIPT_POSITION         Position1,
    157    IN       EFI_S3_BOOT_SCRIPT_POSITION         Position2,
    158    OUT      UINTN                               *RelativePosition
    159 );
    160 
    161 typedef struct _EFI_S3_SMM_SAVE_STATE_PROTOCOL {
    162   EFI_S3_SAVE_STATE_WRITE   Write;
    163   EFI_S3_SAVE_STATE_INSERT  Insert;
    164   EFI_S3_SAVE_STATE_LABEL   Label;
    165   EFI_S3_SAVE_STATE_COMPARE Compare;
    166 } EFI_S3_SMM_SAVE_STATE_PROTOCOL;
    167 
    168 
    169 #endif // __S3_SAVE_STATE_H__
    170