Ronak Kanabar | 1ae366f | 2023-06-07 01:21:56 +0530 | [diff] [blame^] | 1 | /** @file |
| 2 | S3 Save State Protocol as defined in PI 1.6(Errata A) Specification VOLUME 5 Standard. |
| 3 | |
| 4 | This protocol is used by DXE PI module to store or record various IO operations |
| 5 | to be replayed during an S3 resume. |
| 6 | This protocol is not required for all platforms. |
| 7 | |
| 8 | Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<BR> |
| 9 | SPDX-License-Identifier: BSD-2-Clause-Patent |
| 10 | |
| 11 | @par Revision Reference: |
| 12 | This PPI is defined in UEFI Platform Initialization Specification 1.2 Volume 5: |
| 13 | Standards |
| 14 | |
| 15 | **/ |
| 16 | |
| 17 | #ifndef __S3_SAVE_STATE_H__ |
| 18 | #define __S3_SAVE_STATE_H__ |
| 19 | |
| 20 | #define EFI_S3_SAVE_STATE_PROTOCOL_GUID \ |
| 21 | { 0xe857caf6, 0xc046, 0x45dc, { 0xbe, 0x3f, 0xee, 0x7, 0x65, 0xfb, 0xa8, 0x87 }} |
| 22 | |
| 23 | typedef VOID *EFI_S3_BOOT_SCRIPT_POSITION; |
| 24 | |
| 25 | typedef struct _EFI_S3_SAVE_STATE_PROTOCOL EFI_S3_SAVE_STATE_PROTOCOL; |
| 26 | |
| 27 | /** |
| 28 | Record operations that need to be replayed during an S3 resume. |
| 29 | |
| 30 | This function is used to store an OpCode to be replayed as part of the S3 resume boot path. It is |
| 31 | assumed this protocol has platform specific mechanism to store the OpCode set and replay them |
| 32 | during the S3 resume. |
| 33 | |
| 34 | @param[in] This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance. |
| 35 | @param[in] OpCode The operation code (opcode) number. |
| 36 | @param[in] ... Argument list that is specific to each opcode. See the following subsections for the |
| 37 | definition of each opcode. |
| 38 | |
| 39 | @retval EFI_SUCCESS The operation succeeded. A record was added into the specified |
| 40 | script table. |
| 41 | @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported. |
| 42 | @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script. |
| 43 | **/ |
| 44 | typedef |
| 45 | EFI_STATUS |
| 46 | (EFIAPI *EFI_S3_SAVE_STATE_WRITE)( |
| 47 | IN CONST EFI_S3_SAVE_STATE_PROTOCOL *This, |
| 48 | IN UINTN OpCode, |
| 49 | ... |
| 50 | ); |
| 51 | |
| 52 | /** |
| 53 | Record operations that need to be replayed during an S3 resume. |
| 54 | |
| 55 | This function is used to store an OpCode to be replayed as part of the S3 resume boot path. It is |
| 56 | assumed this protocol has platform specific mechanism to store the OpCode set and replay them |
| 57 | during the S3 resume. |
| 58 | The opcode is inserted before or after the specified position in the boot script table. If Position is |
| 59 | NULL then that position is after the last opcode in the table (BeforeOrAfter is TRUE) or before |
| 60 | the first opcode in the table (BeforeOrAfter is FALSE). The position which is pointed to by |
| 61 | Position upon return can be used for subsequent insertions. |
| 62 | |
| 63 | This function has a variable parameter list. The exact parameter list depends on the OpCode that is |
| 64 | passed into the function. If an unsupported OpCode or illegal parameter list is passed in, this |
| 65 | function returns EFI_INVALID_PARAMETER. |
| 66 | If there are not enough resources available for storing more scripts, this function returns |
| 67 | EFI_OUT_OF_RESOURCES. |
| 68 | OpCode values of 0x80 - 0xFE are reserved for implementation specific functions. |
| 69 | |
| 70 | @param[in] This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance. |
| 71 | @param[in] BeforeOrAfter Specifies whether the opcode is stored before (TRUE) or after (FALSE) the position |
| 72 | in the boot script table specified by Position. If Position is NULL or points to |
| 73 | NULL then the new opcode is inserted at the beginning of the table (if TRUE) or end |
| 74 | of the table (if FALSE). |
| 75 | @param[in, out] Position On entry, specifies the position in the boot script table where the opcode will be |
| 76 | inserted, either before or after, depending on BeforeOrAfter. On exit, specifies |
| 77 | the position of the inserted opcode in the boot script table. |
| 78 | @param[in] OpCode The operation code (opcode) number. See "Related Definitions" in Write() for the |
| 79 | defined opcode types. |
| 80 | @param[in] ... Argument list that is specific to each opcode. See the following subsections for the |
| 81 | definition of each opcode. |
| 82 | |
| 83 | @retval EFI_SUCCESS The operation succeeded. An opcode was added into the script. |
| 84 | @retval EFI_INVALID_PARAMETER The Opcode is an invalid opcode value. |
| 85 | @retval EFI_INVALID_PARAMETER The Position is not a valid position in the boot script table. |
| 86 | @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script table. |
| 87 | **/ |
| 88 | typedef |
| 89 | EFI_STATUS |
| 90 | (EFIAPI *EFI_S3_SAVE_STATE_INSERT)( |
| 91 | IN CONST EFI_S3_SAVE_STATE_PROTOCOL *This, |
| 92 | IN BOOLEAN BeforeOrAfter, |
| 93 | IN OUT EFI_S3_BOOT_SCRIPT_POSITION *Position OPTIONAL, |
| 94 | IN UINTN OpCode, |
| 95 | ... |
| 96 | ); |
| 97 | |
| 98 | /** |
| 99 | Find a label within the boot script table and, if not present, optionally create it. |
| 100 | |
| 101 | If the label Label is already exists in the boot script table, then no new label is created, the |
| 102 | position of the Label is returned in *Position and EFI_SUCCESS is returned. |
| 103 | If the label Label does not already exist and CreateIfNotFound is TRUE, then it will be |
| 104 | created before or after the specified position and EFI_SUCCESS is returned. |
| 105 | If the label Label does not already exist and CreateIfNotFound is FALSE, then |
| 106 | EFI_NOT_FOUND is returned. |
| 107 | |
| 108 | @param[in] This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance. |
| 109 | @param[in] BeforeOrAfter Specifies whether the label is stored before (TRUE) or after (FALSE) the position in |
| 110 | the boot script table specified by Position. If Position is NULL or points to |
| 111 | NULL then the new label is inserted at the beginning of the table (if TRUE) or end of |
| 112 | the table (if FALSE). |
| 113 | @param[in] CreateIfNotFound Specifies whether the label will be created if the label does not exists (TRUE) or not (FALSE). |
| 114 | @param[in, out] Position On entry, specifies the position in the boot script table where the label will be inserted, |
| 115 | either before or after, depending on BeforeOrAfter. On exit, specifies the position |
| 116 | of the inserted label in the boot script table. |
| 117 | @param[in] Label Points to the label which will be inserted in the boot script table. |
| 118 | |
| 119 | @retval EFI_SUCCESS The label already exists or was inserted. |
| 120 | @retval EFI_NOT_FOUND The label did not already exist and CreateifNotFound was FALSE. |
| 121 | @retval EFI_INVALID_PARAMETER The Label is NULL or points to an empty string. |
| 122 | @retval EFI_INVALID_PARAMETER The Position is not a valid position in the boot script table. |
| 123 | @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script. |
| 124 | **/ |
| 125 | typedef |
| 126 | EFI_STATUS |
| 127 | (EFIAPI *EFI_S3_SAVE_STATE_LABEL)( |
| 128 | IN CONST EFI_S3_SAVE_STATE_PROTOCOL *This, |
| 129 | IN BOOLEAN BeforeOrAfter, |
| 130 | IN BOOLEAN CreateIfNotFound, |
| 131 | IN OUT EFI_S3_BOOT_SCRIPT_POSITION *Position OPTIONAL, |
| 132 | IN CONST CHAR8 *Label |
| 133 | ); |
| 134 | |
| 135 | /** |
| 136 | Compare two positions in the boot script table and return their relative position. |
| 137 | |
| 138 | This function compares two positions in the boot script table and returns their relative positions. If |
| 139 | Position1 is before Position2, then -1 is returned. If Position1 is equal to Position2, |
| 140 | then 0 is returned. If Position1 is after Position2, then 1 is returned. |
| 141 | |
| 142 | @param[in] This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance. |
| 143 | @param[in] Position1 The positions in the boot script table to compare. |
| 144 | @param[in] Position2 The positions in the boot script table to compare. |
| 145 | @param[out] RelativePosition On return, points to the result of the comparison. |
| 146 | |
| 147 | @retval EFI_SUCCESS The operation succeeded. |
| 148 | @retval EFI_INVALID_PARAMETER The Position1 or Position2 is not a valid position in the boot script table. |
| 149 | @retval EFI_INVALID_PARAMETER The RelativePosition is NULL. |
| 150 | **/ |
| 151 | typedef |
| 152 | EFI_STATUS |
| 153 | (EFIAPI *EFI_S3_SAVE_STATE_COMPARE)( |
| 154 | IN CONST EFI_S3_SAVE_STATE_PROTOCOL *This, |
| 155 | IN EFI_S3_BOOT_SCRIPT_POSITION Position1, |
| 156 | IN EFI_S3_BOOT_SCRIPT_POSITION Position2, |
| 157 | OUT UINTN *RelativePosition |
| 158 | ); |
| 159 | |
| 160 | struct _EFI_S3_SAVE_STATE_PROTOCOL { |
| 161 | EFI_S3_SAVE_STATE_WRITE Write; |
| 162 | EFI_S3_SAVE_STATE_INSERT Insert; |
| 163 | EFI_S3_SAVE_STATE_LABEL Label; |
| 164 | EFI_S3_SAVE_STATE_COMPARE Compare; |
| 165 | }; |
| 166 | |
| 167 | extern EFI_GUID gEfiS3SaveStateProtocolGuid; |
| 168 | |
| 169 | #endif // __S3_SAVE_STATE_H__ |