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