1 /** @file 2 Internal header file for SMM S3 Boot Script Saver state driver. 3 4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> 5 6 This program and the accompanying materials 7 are licensed and made available under the terms and conditions 8 of the BSD License which accompanies this distribution. The 9 full text of the license may be found at 10 http://opensource.org/licenses/bsd-license.php 11 12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 14 15 **/ 16 #ifndef _INTERNAL_SMM_S3_SAVE_STATE_H_ 17 #define _INTERNAL_SMM_S3_SAVE_STATE_H_ 18 #include <PiDxe.h> 19 20 #include <Protocol/S3SmmSaveState.h> 21 22 #include <Library/BaseLib.h> 23 #include <Library/DebugLib.h> 24 #include <Library/UefiDriverEntryPoint.h> 25 #include <Library/SmmServicesTableLib.h> 26 #include <Library/S3BootScriptLib.h> 27 #include <Library/PcdLib.h> 28 #include <Library/SmbusLib.h> 29 #include <IndustryStandard/SmBus.h> 30 /** 31 Adds a record into S3 boot script table. 32 33 This function is used to store a boot script record into a given boot 34 script table. If the table specified by TableName is nonexistent in the 35 system, a new table will automatically be created and then the script record 36 will be added into the new table. This function is responsible for allocating 37 necessary memory for the script. 38 39 This function has a variable parameter list. The exact parameter list depends on 40 the OpCode that is passed into the function. If an unsupported OpCode or illegal 41 parameter list is passed in, this function returns EFI_INVALID_PARAMETER. 42 If there are not enough resources available for storing more scripts, this function returns 43 EFI_OUT_OF_RESOURCES. 44 45 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance. 46 @param OpCode The operation code (opcode) number. 47 @param ... Argument list that is specific to each opcode. 48 49 @retval EFI_SUCCESS The operation succeeded. A record was added into the 50 specified script table. 51 @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported. 52 If the opcode is unknow or not supported because of the PCD 53 Feature Flags. 54 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script. 55 56 **/ 57 EFI_STATUS 58 EFIAPI 59 BootScriptWrite ( 60 IN CONST EFI_S3_SAVE_STATE_PROTOCOL *This, 61 IN UINT16 OpCode, 62 ... 63 ); 64 /** 65 Insert a record into a specified Framework boot script table. 66 67 This function is used to store an OpCode to be replayed as part of the S3 resume boot path. It is 68 assumed this protocol has platform specific mechanism to store the OpCode set and replay them 69 during the S3 resume. 70 The opcode is inserted before or after the specified position in the boot script table. If Position is 71 NULL then that position is after the last opcode in the table (BeforeOrAfter is FALSE) or before 72 the first opcode in the table (BeforeOrAfter is TRUE). The position which is pointed to by 73 Position upon return can be used for subsequent insertions. 74 75 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance. 76 @param BeforeOrAfter Specifies whether the opcode is stored before (TRUE) or after (FALSE) the position 77 in the boot script table specified by Position. If Position is NULL or points to 78 NULL then the new opcode is inserted at the beginning of the table (if TRUE) or end 79 of the table (if FALSE). 80 @param Position On entry, specifies the position in the boot script table where the opcode will be 81 inserted, either before or after, depending on BeforeOrAfter. On exit, specifies 82 the position of the inserted opcode in the boot script table. 83 @param OpCode The operation code (opcode) number. 84 @param ... Argument list that is specific to each opcode. 85 86 @retval EFI_SUCCESS The operation succeeded. A record was added into the 87 specified script table. 88 @retval EFI_INVALID_PARAMETER The Opcode is an invalid opcode value or the Position is not a valid position in the boot script table.. 89 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script. 90 91 **/ 92 EFI_STATUS 93 EFIAPI 94 BootScriptInsert ( 95 IN CONST EFI_S3_SAVE_STATE_PROTOCOL *This, 96 IN BOOLEAN BeforeOrAfter, 97 IN OUT EFI_S3_BOOT_SCRIPT_POSITION *Position OPTIONAL, 98 IN UINT16 OpCode, 99 ... 100 ); 101 /** 102 Find a label within the boot script table and, if not present, optionally create it. 103 104 If the label Label is already exists in the boot script table, then no new label is created, the 105 position of the Label is returned in *Position and EFI_SUCCESS is returned. 106 If the label Label does not already exist and CreateIfNotFound is TRUE, then it will be 107 created before or after the specified position and EFI_SUCCESS is returned. 108 If the label Label does not already exist and CreateIfNotFound is FALSE, then 109 EFI_NOT_FOUND is returned. 110 111 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance. 112 @param BeforeOrAfter Specifies whether the label is stored before (TRUE) or after (FALSE) the position in 113 the boot script table specified by Position. If Position is NULL or points to 114 NULL then the new label is inserted at the beginning of the table (if TRUE) or end of 115 the table (if FALSE). 116 @param CreateIfNotFound Specifies whether the label will be created if the label does not exists (TRUE) or not 117 (FALSE). 118 @param Position On entry, specifies the position in the boot script table where the label will be inserted, 119 either before or after, depending on BeforeOrAfter. On exit, specifies the position 120 of the inserted label in the boot script table. 121 @param Label Points to the label which will be inserted in the boot script table. 122 123 @retval EFI_SUCCESS The label already exists or was inserted. 124 @retval EFI_INVALID_PARAMETER The Opcode is an invalid opcode value or the Position is not a valid position in the boot script table.. 125 126 **/ 127 EFI_STATUS 128 EFIAPI 129 BootScriptLabel ( 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 Compare two positions in the boot script table and return their relative position. 138 139 This function compares two positions in the boot script table and returns their relative positions. If 140 Position1 is before Position2, then -1 is returned. If Position1 is equal to Position2, 141 then 0 is returned. If Position1 is after Position2, then 1 is returned. 142 143 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance. 144 @param Position1 The positions in the boot script table to compare 145 @param Position2 The positions in the boot script table to compare 146 @param RelativePosition On return, points to the result of the comparison 147 148 @retval EFI_SUCCESS The operation succeeded. 149 @retval EFI_INVALID_PARAMETER The Position1 or Position2 is not a valid position in the boot script table. 150 151 **/ 152 EFI_STATUS 153 EFIAPI 154 BootScriptCompare ( 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 #endif //_INTERNAL_SMM_S3_SAVE_STATE_H_ 162