]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/S3SaveState.h
Add @par at file header to indicate the specification version.
[mirror_edk2.git] / MdePkg / Include / Protocol / S3SaveState.h
1 /** @file
2 S3 Save State Protocol as defined in PI1.2 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, Intel Corporation
9 All rights reserved. This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
13
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16
17 @par Revision Reference:
18 This PPI is defined in UEFI Platform Initialization Specification 1.2 Volume 5:
19 Standards
20
21 **/
22
23 #ifndef __S3_SAVE_STATE_H__
24 #define __S3_SAVE_STATE_H__
25
26 #define EFI_S3_SAVE_STATE_PROTOCOL_GUID \
27 { 0xe857caf6, 0xc046, 0x45dc, { 0xbe, 0x3f, 0xee, 0x7, 0x65, 0xfb, 0xa8, 0x87 }}
28
29 //*******************************************
30 // EFI Boot Script Opcode definitions
31 //*******************************************
32 #define EFI_BOOT_SCRIPT_IO_WRITE_OPCODE 0x00
33 #define EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE 0x01
34 #define EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE 0x02
35 #define EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE 0x03
36 #define EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE 0x04
37 #define EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE 0x05
38 #define EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE 0x06
39 #define EFI_BOOT_SCRIPT_STALL_OPCODE 0x07
40 #define EFI_BOOT_SCRIPT_DISPATCH_OPCODE 0x08
41 #define EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE 0x09
42 #define EFI_BOOT_SCRIPT_INFORMATION_OPCODE 0x0A
43 #define EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE 0x0B
44 #define EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE 0x0C
45 #define EFI_BOOT_SCRIPT_IO_POLL_OPCODE 0x0D
46 #define EFI_BOOT_SCRIPT_MEM_POLL_OPCODE 0x0E
47 #define EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE 0x0F
48 #define EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE 0x10
49
50 //*******************************************
51 // EFI_BOOT_SCRIPT_WIDTH
52 //*******************************************
53 typedef enum {
54 EfiBootScriptWidthUint8,
55 EfiBootScriptWidthUint16,
56 EfiBootScriptWidthUint32,
57 EfiBootScriptWidthUint64,
58 EfiBootScriptWidthFifoUint8,
59 EfiBootScriptWidthFifoUint16,
60 EfiBootScriptWidthFifoUint32,
61 EfiBootScriptWidthFifoUint64,
62 EfiBootScriptWidthFillUint8,
63 EfiBootScriptWidthFillUint16,
64 EfiBootScriptWidthFillUint32,
65 EfiBootScriptWidthFillUint64,
66 EfiBootScriptWidthMaximum
67 } EFI_BOOT_SCRIPT_WIDTH;
68
69 typedef VOID *EFI_S3_BOOT_SCRIPT_POSITION;
70
71 typedef struct _EFI_S3_SAVE_STATE_PROTOCOL EFI_S3_SAVE_STATE_PROTOCOL;
72
73 /**
74 Record operations that need to be replayed during an S3 resume.
75
76 This function is used to store an OpCode to be replayed as part of the S3 resume boot path. It is
77 assumed this protocol has platform specific mechanism to store the OpCode set and replay them
78 during the S3 resume.
79
80 @param[in] This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
81 @param[in] OpCode The operation code (opcode) number.
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. A record was added into the specified
86 script table.
87 @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.
88 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
89 **/
90 typedef
91 EFI_STATUS
92 (EFIAPI *EFI_S3_SAVE_STATE_WRITE)(
93 IN CONST struct _EFI_S3_SAVE_STATE_PROTOCOL *This,
94 IN UINT16 OpCode,
95 ...
96 );
97
98 /**
99 Record operations that need to be replayed during an S3 resume.
100
101 This function is used to store an OpCode to be replayed as part of the S3 resume boot path. It is
102 assumed this protocol has platform specific mechanism to store the OpCode set and replay them
103 during the S3 resume.
104 The opcode is inserted before or after the specified position in the boot script table. If Position is
105 NULL then that position is after the last opcode in the table (BeforeOrAfter is TRUE) or before
106 the first opcode in the table (BeforeOrAfter is FALSE). The position which is pointed to by
107 Position upon return can be used for subsequent insertions.
108
109 This function has a variable parameter list. The exact parameter list depends on the OpCode that is
110 passed into the function. If an unsupported OpCode or illegal parameter list is passed in, this
111 function returns EFI_INVALID_PARAMETER.
112 If there are not enough resources available for storing more scripts, this function returns
113 EFI_OUT_OF_RESOURCES.
114 OpCode values of 0x80 - 0xFE are reserved for implementation specific functions.
115
116 @param[in] This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
117 @param[in] BeforeOrAfter Specifies whether the opcode is stored before (TRUE) or after (FALSE) the position
118 in the boot script table specified by Position. If Position is NULL or points to
119 NULL then the new opcode is inserted at the beginning of the table (if TRUE) or end
120 of the table (if FALSE).
121 @param[in, out] Position On entry, specifies the position in the boot script table where the opcode will be
122 inserted, either before or after, depending on BeforeOrAfter. On exit, specifies
123 the position of the inserted opcode in the boot script table.
124 @param[in] OpCode The operation code (opcode) number. See "Related Definitions" in Write() for the
125 defined opcode types.
126 @param[in] ... Argument list that is specific to each opcode. See the following subsections for the
127 definition of each opcode.
128
129 @retval EFI_SUCCESS The operation succeeded. An opcode was added into the script.
130 @retval EFI_INVALID_PARAMETER The Opcode is an invalid opcode value.
131 @retval EFI_INVALID_PARAMETER The Position is not a valid position in the boot script table.
132 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script table.
133 **/
134 typedef
135 EFI_STATUS
136 (EFIAPI *EFI_S3_SAVE_STATE_INSERT)(
137 IN struct _EFI_S3_SAVE_STATE_PROTOCOL *This,
138 IN BOOLEAN BeforeOrAfter,
139 IN OUT EFI_S3_BOOT_SCRIPT_POSITION *Position OPTIONAL,
140 IN UINT16 OpCode,
141 ...
142 );
143
144 /**
145 Find a label within the boot script table and, if not present, optionally create it.
146
147 If the label Label is already exists in the boot script table, then no new label is created, the
148 position of the Label is returned in *Position and EFI_SUCCESS is returned.
149 If the label Label does not already exist and CreateIfNotFound is TRUE, then it will be
150 created before or after the specified position and EFI_SUCCESS is returned.
151 If the label Label does not already exist and CreateIfNotFound is FALSE, then
152 EFI_NOT_FOUND is returned.
153
154 @param[in] This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
155 @param[in] BeforeOrAfter Specifies whether the label is stored before (TRUE) or after (FALSE) the position in
156 the boot script table specified by Position. If Position is NULL or points to
157 NULL then the new label is inserted at the beginning of the table (if TRUE) or end of
158 the table (if FALSE).
159 @param[in] CreateIfNotFound Specifies whether the label will be created if the label does not exists (TRUE) or not (FALSE).
160 @param[in, out] Position On entry, specifies the position in the boot script table where the label will be inserted,
161 either before or after, depending on BeforeOrAfter. On exit, specifies the position
162 of the inserted label in the boot script table.
163 @param[in] Label Points to the label which will be inserted in the boot script table.
164
165 @retval EFI_SUCCESS The label already exists or was inserted.
166 @retval EFI_NOT_FOUND The label did not already exist and CreateifNotFound was FALSE.
167 @retval EFI_INVALID_PARAMETER The Opcode is an invalid opcode value.
168 @retval EFI_INVALID_PARAMETER The Position is not a valid position in the boot script table.
169 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
170 **/
171 typedef
172 EFI_STATUS
173 (EFIAPI *EFI_S3_SAVE_STATE_LABEL)(
174 IN struct _EFI_S3_SAVE_STATE_PROTOCOL *This,
175 IN BOOLEAN BeforeOrAfter,
176 IN BOOLEAN CreateIfNotFound,
177 IN OUT EFI_S3_BOOT_SCRIPT_POSITION *Position OPTIONAL,
178 IN CONST CHAR8 *Label
179 );
180
181 /**
182 Compare two positions in the boot script table and return their relative position.
183
184 This function compares two positions in the boot script table and returns their relative positions. If
185 Position1 is before Position2, then -1 is returned. If Position1 is equal to Position2,
186 then 0 is returned. If Position1 is after Position2, then 1 is returned.
187
188 @param[in] This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
189 @param[in] Position1 The positions in the boot script table to compare.
190 @param[in] Position2 The positions in the boot script table to compare.
191 @param[out] RelativePosition On return, points to the result of the comparison.
192
193 @retval EFI_SUCCESS The label already exists or was inserted.
194 @retval EFI_INVALID_PARAMETER The Position1 or Position2 is not a valid position in the boot script table.
195 **/
196 typedef
197 EFI_STATUS
198 (EFIAPI *EFI_S3_SAVE_STATE_COMPARE)(
199 IN struct _EFI_S3_SAVE_STATE_PROTOCOL *This,
200 IN EFI_S3_BOOT_SCRIPT_POSITION Position1,
201 IN EFI_S3_BOOT_SCRIPT_POSITION Position2,
202 OUT UINTN *RelativePosition
203 );
204
205 struct _EFI_S3_SAVE_STATE_PROTOCOL {
206 EFI_S3_SAVE_STATE_WRITE Write;
207 EFI_S3_SAVE_STATE_INSERT Insert;
208 EFI_S3_SAVE_STATE_LABEL Label;
209 EFI_S3_SAVE_STATE_COMPARE Compare;
210 };
211
212 extern EFI_GUID gEfiS3SaveStateProtocolGuid;
213
214 #endif // __S3_SAVE_STATE_H__