]>
Commit | Line | Data |
---|---|---|
bdfde462 | 1 | /** @file\r |
2 | Implementation for S3 Boot Script Saver state driver.\r | |
3 | \r | |
96072947 | 4 | Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r |
bdfde462 | 5 | \r |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions\r | |
8 | of the BSD License which accompanies this distribution. The\r | |
9 | full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | **/\r | |
16 | #include "InternalS3SaveState.h"\r | |
17 | \r | |
18 | EFI_HANDLE mHandle = NULL;\r | |
19 | EFI_S3_SAVE_STATE_PROTOCOL mS3SaveState = {\r | |
20 | BootScriptWrite,\r | |
21 | BootScriptInsert,\r | |
22 | BootScriptLabel,\r | |
23 | BootScriptCompare\r | |
24 | };\r | |
25 | /**\r | |
26 | Internal function to add IO write opcode to the table.\r | |
27 | \r | |
28 | @param Marker The variable argument list to get the opcode\r | |
29 | and associated attributes.\r | |
30 | \r | |
31 | @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r | |
32 | @retval EFI_SUCCESS Opcode is added.\r | |
33 | \r | |
34 | **/\r | |
35 | EFI_STATUS\r | |
36 | BootScriptWriteIoWrite (\r | |
37 | IN VA_LIST Marker\r | |
38 | )\r | |
39 | {\r | |
40 | S3_BOOT_SCRIPT_LIB_WIDTH Width;\r | |
41 | UINT64 Address;\r | |
42 | UINTN Count;\r | |
43 | UINT8 *Buffer;\r | |
44 | \r | |
45 | Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r | |
46 | Address = VA_ARG (Marker, UINT64);\r | |
47 | Count = VA_ARG (Marker, UINTN);\r | |
48 | Buffer = VA_ARG (Marker, UINT8 *);\r | |
49 | \r | |
50 | return S3BootScriptSaveIoWrite (Width, Address, Count, Buffer);\r | |
51 | }\r | |
52 | /**\r | |
53 | Internal function to add IO read/write opcode to the table.\r | |
54 | \r | |
55 | @param Marker The variable argument list to get the opcode\r | |
56 | and associated attributes.\r | |
57 | \r | |
58 | @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r | |
59 | @retval EFI_SUCCESS Opcode is added.\r | |
60 | \r | |
61 | **/\r | |
62 | EFI_STATUS\r | |
63 | BootScriptWriteIoReadWrite (\r | |
64 | IN VA_LIST Marker\r | |
65 | )\r | |
66 | {\r | |
67 | S3_BOOT_SCRIPT_LIB_WIDTH Width;\r | |
68 | UINT64 Address;\r | |
69 | UINT8 *Data;\r | |
70 | UINT8 *DataMask;\r | |
71 | \r | |
72 | Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r | |
73 | Address = VA_ARG (Marker, UINT64);\r | |
74 | Data = VA_ARG (Marker, UINT8 *);\r | |
75 | DataMask = VA_ARG (Marker, UINT8 *);\r | |
76 | \r | |
77 | return S3BootScriptSaveIoReadWrite (Width, Address, Data, DataMask);\r | |
78 | }\r | |
79 | \r | |
80 | /**\r | |
81 | Internal function to add memory write opcode to the table.\r | |
82 | \r | |
83 | @param Marker The variable argument list to get the opcode\r | |
84 | and associated attributes.\r | |
85 | \r | |
86 | @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r | |
87 | @retval EFI_SUCCESS Opcode is added.\r | |
88 | \r | |
89 | **/\r | |
90 | EFI_STATUS\r | |
91 | BootScriptWriteMemWrite (\r | |
92 | IN VA_LIST Marker\r | |
93 | )\r | |
94 | {\r | |
95 | S3_BOOT_SCRIPT_LIB_WIDTH Width;\r | |
96 | UINT64 Address;\r | |
97 | UINTN Count;\r | |
98 | UINT8 *Buffer;\r | |
99 | \r | |
100 | Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r | |
101 | Address = VA_ARG (Marker, UINT64);\r | |
102 | Count = VA_ARG (Marker, UINTN);\r | |
103 | Buffer = VA_ARG (Marker, UINT8 *);\r | |
104 | \r | |
105 | return S3BootScriptSaveMemWrite (Width, Address, Count, Buffer);\r | |
106 | }\r | |
107 | \r | |
108 | /**\r | |
109 | Internal function to add memory read/write opcode to the table.\r | |
110 | \r | |
111 | @param Marker The variable argument list to get the opcode\r | |
112 | and associated attributes.\r | |
113 | \r | |
114 | @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r | |
115 | @retval EFI_SUCCESS Opcode is added.\r | |
116 | \r | |
117 | **/\r | |
118 | EFI_STATUS\r | |
119 | BootScriptWriteMemReadWrite (\r | |
120 | IN VA_LIST Marker\r | |
121 | )\r | |
122 | {\r | |
123 | S3_BOOT_SCRIPT_LIB_WIDTH Width;\r | |
124 | UINT64 Address;\r | |
125 | UINT8 *Data;\r | |
126 | UINT8 *DataMask;\r | |
127 | \r | |
128 | Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r | |
129 | Address = VA_ARG (Marker, UINT64);\r | |
130 | Data = VA_ARG (Marker, UINT8 *);\r | |
131 | DataMask = VA_ARG (Marker, UINT8 *);\r | |
132 | \r | |
133 | return S3BootScriptSaveMemReadWrite (Width, Address, Data, DataMask);\r | |
134 | }\r | |
135 | \r | |
136 | /**\r | |
137 | Internal function to add PciCfg write opcode to the table.\r | |
138 | \r | |
139 | @param Marker The variable argument list to get the opcode\r | |
140 | and associated attributes.\r | |
141 | \r | |
142 | @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r | |
143 | @retval EFI_SUCCESS Opcode is added.\r | |
144 | \r | |
145 | **/\r | |
146 | EFI_STATUS\r | |
147 | BootScriptWritePciCfgWrite (\r | |
148 | IN VA_LIST Marker\r | |
149 | )\r | |
150 | {\r | |
151 | S3_BOOT_SCRIPT_LIB_WIDTH Width;\r | |
152 | UINT64 Address;\r | |
153 | UINTN Count;\r | |
154 | UINT8 *Buffer;\r | |
155 | \r | |
156 | Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r | |
157 | Address = VA_ARG (Marker, UINT64);\r | |
158 | Count = VA_ARG (Marker, UINTN);\r | |
159 | Buffer = VA_ARG (Marker, UINT8 *);\r | |
160 | \r | |
161 | return S3BootScriptSavePciCfgWrite (Width, Address, Count, Buffer);\r | |
162 | }\r | |
163 | \r | |
164 | /**\r | |
165 | Internal function to PciCfg read/write opcode to the table.\r | |
166 | \r | |
167 | @param Marker The variable argument list to get the opcode\r | |
168 | and associated attributes.\r | |
169 | \r | |
170 | @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r | |
171 | @retval EFI_SUCCESS Opcode is added.\r | |
172 | \r | |
173 | **/\r | |
174 | EFI_STATUS\r | |
175 | BootScriptWritePciCfgReadWrite (\r | |
176 | IN VA_LIST Marker\r | |
177 | )\r | |
178 | {\r | |
179 | S3_BOOT_SCRIPT_LIB_WIDTH Width;\r | |
180 | UINT64 Address;\r | |
181 | UINT8 *Data;\r | |
182 | UINT8 *DataMask;\r | |
183 | \r | |
184 | Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r | |
185 | Address = VA_ARG (Marker, UINT64);\r | |
186 | Data = VA_ARG (Marker, UINT8 *);\r | |
187 | DataMask = VA_ARG (Marker, UINT8 *);\r | |
188 | \r | |
189 | return S3BootScriptSavePciCfgReadWrite (Width, Address, Data, DataMask);\r | |
190 | }\r | |
191 | /**\r | |
192 | Internal function to add PciCfg2 write opcode to the table.\r | |
193 | \r | |
194 | @param Marker The variable argument list to get the opcode\r | |
195 | and associated attributes.\r | |
196 | \r | |
197 | @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r | |
198 | @retval EFI_SUCCESS Opcode is added.\r | |
199 | \r | |
200 | **/\r | |
201 | EFI_STATUS\r | |
202 | BootScriptWritePciCfg2Write (\r | |
203 | IN VA_LIST Marker\r | |
204 | )\r | |
205 | {\r | |
206 | S3_BOOT_SCRIPT_LIB_WIDTH Width;\r | |
207 | UINT64 Address;\r | |
208 | UINTN Count;\r | |
209 | UINT8 *Buffer;\r | |
210 | UINT16 Segment;\r | |
211 | \r | |
212 | Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r | |
213 | Address = VA_ARG (Marker, UINT64);\r | |
214 | Count = VA_ARG (Marker, UINTN);\r | |
215 | Buffer = VA_ARG (Marker, UINT8 *);\r | |
216 | Segment = VA_ARG (Marker, UINT16);\r | |
217 | \r | |
218 | return S3BootScriptSavePciCfg2Write (Width, Segment, Address, Count, Buffer);\r | |
219 | }\r | |
220 | \r | |
221 | /**\r | |
222 | Internal function to PciCfg2 read/write opcode to the table.\r | |
223 | \r | |
224 | @param Marker The variable argument list to get the opcode\r | |
225 | and associated attributes.\r | |
226 | \r | |
227 | @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r | |
228 | @retval EFI_SUCCESS Opcode is added.\r | |
229 | \r | |
230 | **/\r | |
231 | EFI_STATUS\r | |
232 | BootScriptWritePciCfg2ReadWrite (\r | |
233 | IN VA_LIST Marker\r | |
234 | )\r | |
235 | {\r | |
236 | S3_BOOT_SCRIPT_LIB_WIDTH Width;\r | |
237 | UINT16 Segment;\r | |
238 | UINT64 Address;\r | |
239 | UINT8 *Data;\r | |
240 | UINT8 *DataMask;\r | |
241 | \r | |
242 | Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r | |
243 | Address = VA_ARG (Marker, UINT64);\r | |
244 | Segment = VA_ARG (Marker, UINT16);\r | |
245 | Data = VA_ARG (Marker, UINT8 *);\r | |
246 | DataMask = VA_ARG (Marker, UINT8 *);\r | |
247 | \r | |
248 | return S3BootScriptSavePciCfg2ReadWrite (Width, Segment, Address, Data, DataMask);\r | |
249 | }\r | |
250 | /**\r | |
251 | Internal function to add smbus excute opcode to the table.\r | |
252 | \r | |
253 | @param Marker The variable argument list to get the opcode\r | |
254 | and associated attributes.\r | |
255 | \r | |
256 | @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r | |
257 | @retval EFI_SUCCESS Opcode is added.\r | |
258 | \r | |
259 | **/\r | |
260 | EFI_STATUS\r | |
261 | BootScriptWriteSmbusExecute (\r | |
262 | IN VA_LIST Marker\r | |
263 | )\r | |
264 | {\r | |
265 | EFI_SMBUS_DEVICE_ADDRESS SlaveAddress;\r | |
266 | EFI_SMBUS_DEVICE_COMMAND Command;\r | |
267 | EFI_SMBUS_OPERATION Operation;\r | |
268 | BOOLEAN PecCheck;\r | |
269 | VOID *Buffer;\r | |
270 | UINTN *DataSize;\r | |
271 | UINTN SmBusAddress;\r | |
272 | \r | |
273 | SlaveAddress.SmbusDeviceAddress = VA_ARG (Marker, UINTN);\r | |
274 | Command = VA_ARG (Marker, EFI_SMBUS_DEVICE_COMMAND);\r | |
275 | Operation = VA_ARG (Marker, EFI_SMBUS_OPERATION);\r | |
276 | PecCheck = VA_ARG (Marker, BOOLEAN);\r | |
277 | SmBusAddress = SMBUS_LIB_ADDRESS (SlaveAddress.SmbusDeviceAddress,Command,0,PecCheck);\r | |
278 | DataSize = VA_ARG (Marker, UINTN *); \r | |
279 | Buffer = VA_ARG (Marker, VOID *);\r | |
280 | \r | |
281 | return S3BootScriptSaveSmbusExecute (SmBusAddress, Operation, DataSize, Buffer);\r | |
282 | }\r | |
283 | /**\r | |
284 | Internal function to add stall opcode to the table.\r | |
285 | \r | |
286 | @param Marker The variable argument list to get the opcode\r | |
287 | and associated attributes.\r | |
288 | \r | |
289 | @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r | |
290 | @retval EFI_SUCCESS Opcode is added.\r | |
291 | \r | |
292 | **/\r | |
293 | EFI_STATUS\r | |
294 | BootScriptWriteStall (\r | |
295 | IN VA_LIST Marker\r | |
296 | )\r | |
297 | {\r | |
298 | UINT32 Duration;\r | |
299 | \r | |
300 | Duration = VA_ARG (Marker, UINT32);\r | |
301 | \r | |
302 | return S3BootScriptSaveStall (Duration);\r | |
303 | }\r | |
304 | \r | |
305 | /**\r | |
306 | Internal function to add Save jmp address according to DISPATCH_OPCODE. \r | |
307 | We ignore "Context" parameter\r | |
308 | \r | |
309 | @param Marker The variable argument list to get the opcode\r | |
310 | and associated attributes.\r | |
311 | \r | |
312 | @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r | |
313 | @retval EFI_SUCCESS Opcode is added.\r | |
314 | \r | |
315 | **/\r | |
316 | EFI_STATUS\r | |
317 | BootScriptWriteDispatch (\r | |
318 | IN VA_LIST Marker\r | |
319 | )\r | |
320 | {\r | |
321 | VOID *EntryPoint;\r | |
322 | \r | |
323 | EntryPoint = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);\r | |
324 | return S3BootScriptSaveDispatch (EntryPoint);\r | |
325 | }\r | |
326 | \r | |
327 | /**\r | |
328 | Internal function to add memory pool operation to the table. \r | |
329 | \r | |
330 | @param Marker The variable argument list to get the opcode\r | |
331 | and associated attributes.\r | |
332 | \r | |
333 | @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r | |
334 | @retval EFI_SUCCESS Opcode is added.\r | |
335 | \r | |
336 | **/\r | |
337 | EFI_STATUS\r | |
338 | BootScriptWriteMemPoll (\r | |
339 | IN VA_LIST Marker\r | |
340 | )\r | |
341 | {\r | |
342 | S3_BOOT_SCRIPT_LIB_WIDTH Width; \r | |
343 | UINT64 Address; \r | |
344 | VOID *Data; \r | |
345 | VOID *DataMask; \r | |
346 | UINTN Delay; \r | |
347 | \r | |
348 | Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH); \r | |
349 | Address = VA_ARG (Marker, UINT64); \r | |
350 | Data = VA_ARG (Marker, VOID *); \r | |
351 | DataMask = VA_ARG (Marker, VOID *); \r | |
352 | Delay = (UINTN)VA_ARG (Marker, UINT64); \r | |
353 | //\r | |
354 | // According to the spec, the interval between 2 pools is 100ns\r | |
355 | // \r | |
356 | return S3BootScriptSaveMemPoll (Width, Address, DataMask, Data, 100, Delay); \r | |
357 | \r | |
358 | }\r | |
359 | \r | |
360 | /**\r | |
361 | Internal function to add Save jmp address according to DISPATCH_OPCODE2. \r | |
362 | The "Context" parameter is not ignored.\r | |
363 | \r | |
364 | @param Marker The variable argument list to get the opcode\r | |
365 | and associated attributes.\r | |
366 | \r | |
367 | @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r | |
368 | @retval EFI_SUCCESS Opcode is added.\r | |
369 | \r | |
370 | **/\r | |
371 | EFI_STATUS\r | |
372 | BootScriptWriteDispatch2 (\r | |
373 | IN VA_LIST Marker\r | |
374 | )\r | |
375 | {\r | |
376 | VOID *EntryPoint;\r | |
377 | VOID *Context; \r | |
378 | \r | |
379 | EntryPoint = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);\r | |
380 | Context = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);\r | |
381 | \r | |
382 | return S3BootScriptSaveDispatch2 (EntryPoint, Context);\r | |
383 | }\r | |
384 | /**\r | |
385 | Internal function to add INFORAMTION opcode node to the table\r | |
386 | list.\r | |
387 | @param Marker The variable argument list to get the opcode\r | |
388 | and associated attributes.\r | |
389 | \r | |
390 | @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.\r | |
391 | @retval EFI_SUCCESS The opcode entry is added to the table\r | |
392 | successfully.\r | |
393 | **/\r | |
394 | EFI_STATUS\r | |
395 | BootScriptWriteInformation (\r | |
396 | IN VA_LIST Marker\r | |
397 | )\r | |
398 | {\r | |
399 | UINT32 InformationLength;\r | |
400 | EFI_PHYSICAL_ADDRESS Information; \r | |
401 | \r | |
402 | InformationLength = VA_ARG (Marker, UINT32);\r | |
403 | Information = VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);\r | |
404 | return S3BootScriptSaveInformation (InformationLength, (VOID*)(UINTN)Information);\r | |
405 | }\r | |
406 | /**\r | |
407 | Internal function to add IO poll opcode node to the table\r | |
408 | @param Marker The variable argument list to get the opcode\r | |
409 | and associated attributes.\r | |
410 | \r | |
411 | @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.\r | |
412 | @retval EFI_SUCCESS The opcode entry is added to the table\r | |
413 | successfully.\r | |
414 | **/\r | |
415 | EFI_STATUS\r | |
416 | BootScriptWriteIoPoll (\r | |
417 | IN VA_LIST Marker\r | |
418 | )\r | |
419 | {\r | |
420 | S3_BOOT_SCRIPT_LIB_WIDTH Width;\r | |
421 | UINT64 Address; \r | |
422 | VOID *Data; \r | |
423 | VOID *DataMask; \r | |
424 | UINT64 Delay; \r | |
425 | \r | |
426 | Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH); \r | |
427 | Address = VA_ARG (Marker, UINT64); \r | |
428 | Data = VA_ARG (Marker, VOID *); \r | |
429 | DataMask = VA_ARG (Marker, VOID *); \r | |
430 | Delay = (UINT64)VA_ARG (Marker, UINT64); \r | |
431 | \r | |
432 | return S3BootScriptSaveIoPoll (Width, Address, Data, DataMask, Delay);\r | |
433 | }\r | |
434 | /**\r | |
435 | Internal function to add PCI config poll opcode node to the table\r | |
436 | \r | |
437 | @param Marker The variable argument list to get the opcode\r | |
438 | and associated attributes.\r | |
439 | \r | |
440 | @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.\r | |
441 | @retval EFI_SUCCESS The opcode entry is added to the table\r | |
442 | successfully.\r | |
443 | **/\r | |
444 | EFI_STATUS\r | |
445 | BootScriptWritePciConfigPoll (\r | |
446 | IN VA_LIST Marker\r | |
447 | )\r | |
448 | {\r | |
449 | S3_BOOT_SCRIPT_LIB_WIDTH Width;\r | |
450 | UINT64 Address;\r | |
451 | VOID *Data;\r | |
452 | VOID *DataMask;\r | |
453 | UINT64 Delay;\r | |
454 | \r | |
455 | \r | |
456 | Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH); \r | |
457 | Address = VA_ARG (Marker, UINT64); \r | |
458 | Data = VA_ARG (Marker, VOID *); \r | |
459 | DataMask = VA_ARG (Marker, VOID *); \r | |
460 | Delay = (UINT64)VA_ARG (Marker, UINT64); \r | |
461 | \r | |
462 | return S3BootScriptSavePciPoll (Width, Address, Data, DataMask, Delay);\r | |
463 | }\r | |
464 | /**\r | |
465 | Internal function to add PCI config 2 poll opcode node to the table\r | |
466 | \r | |
467 | @param Marker The variable argument list to get the opcode\r | |
468 | and associated attributes.\r | |
469 | \r | |
470 | @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.\r | |
471 | @retval EFI_SUCCESS The opcode entry is added to the table\r | |
472 | successfully.\r | |
473 | **/\r | |
474 | EFI_STATUS\r | |
475 | BootScriptWritePciConfig2Poll (\r | |
476 | IN VA_LIST Marker\r | |
477 | )\r | |
478 | {\r | |
479 | S3_BOOT_SCRIPT_LIB_WIDTH Width;\r | |
480 | UINT16 Segment;\r | |
481 | UINT64 Address;\r | |
482 | VOID *Data;\r | |
483 | VOID *DataMask;\r | |
484 | UINT64 Delay;\r | |
485 | \r | |
486 | Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH); \r | |
487 | Segment = VA_ARG (Marker, UINT16); \r | |
488 | Address = VA_ARG (Marker, UINT64); \r | |
489 | Data = VA_ARG (Marker, VOID *); \r | |
490 | DataMask = VA_ARG (Marker, VOID *); \r | |
491 | Delay = (UINT64)VA_ARG (Marker, UINT64); \r | |
492 | \r | |
493 | return S3BootScriptSavePci2Poll (Width, Segment, Address, Data, DataMask, Delay);\r | |
494 | }\r | |
495 | \r | |
496 | \r | |
497 | /**\r | |
498 | Adds a record into S3 boot script table.\r | |
499 | \r | |
500 | This function is used to store a boot script record into a given boot\r | |
501 | script table. If the table specified by TableName is nonexistent in the \r | |
502 | system, a new table will automatically be created and then the script record \r | |
503 | will be added into the new table. This function is responsible for allocating \r | |
504 | necessary memory for the script.\r | |
505 | \r | |
506 | This function has a variable parameter list. The exact parameter list depends on \r | |
507 | the OpCode that is passed into the function. If an unsupported OpCode or illegal \r | |
508 | parameter list is passed in, this function returns EFI_INVALID_PARAMETER.\r | |
509 | If there are not enough resources available for storing more scripts, this function returns\r | |
510 | EFI_OUT_OF_RESOURCES.\r | |
511 | \r | |
512 | @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.\r | |
513 | @param OpCode The operation code (opcode) number.\r | |
514 | @param ... Argument list that is specific to each opcode. \r | |
515 | \r | |
516 | @retval EFI_SUCCESS The operation succeeded. A record was added into the\r | |
517 | specified script table.\r | |
518 | @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.\r | |
519 | If the opcode is unknow or not supported because of the PCD \r | |
520 | Feature Flags.\r | |
521 | @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.\r | |
522 | \r | |
523 | **/\r | |
524 | EFI_STATUS\r | |
525 | EFIAPI\r | |
526 | BootScriptWrite (\r | |
527 | IN CONST EFI_S3_SAVE_STATE_PROTOCOL *This,\r | |
528 | IN UINT16 OpCode,\r | |
529 | ...\r | |
530 | )\r | |
531 | {\r | |
532 | EFI_STATUS Status;\r | |
533 | VA_LIST Marker; \r | |
534 | //\r | |
535 | // Build script according to opcode\r | |
536 | //\r | |
537 | switch (OpCode) {\r | |
538 | \r | |
539 | case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE:\r | |
540 | VA_START (Marker, OpCode);\r | |
541 | Status = BootScriptWriteIoWrite (Marker);\r | |
542 | VA_END (Marker);\r | |
543 | break;\r | |
544 | \r | |
545 | case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE:\r | |
546 | VA_START (Marker, OpCode);\r | |
547 | Status = BootScriptWriteIoReadWrite (Marker);\r | |
548 | VA_END (Marker);\r | |
549 | break;\r | |
550 | \r | |
551 | case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE:\r | |
552 | VA_START (Marker, OpCode);\r | |
553 | Status = BootScriptWriteMemWrite (Marker);\r | |
554 | VA_END (Marker); \r | |
555 | break;\r | |
556 | \r | |
557 | case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE:\r | |
558 | VA_START (Marker, OpCode);\r | |
559 | Status = BootScriptWriteMemReadWrite (Marker);\r | |
560 | VA_END (Marker);\r | |
561 | break;\r | |
562 | \r | |
563 | case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE:\r | |
564 | VA_START (Marker, OpCode);\r | |
565 | Status = BootScriptWritePciCfgWrite (Marker);\r | |
566 | VA_END (Marker);\r | |
567 | break;\r | |
568 | \r | |
569 | case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE:\r | |
570 | VA_START (Marker, OpCode);\r | |
571 | Status = BootScriptWritePciCfgReadWrite (Marker);\r | |
572 | VA_END (Marker);\r | |
573 | break;\r | |
574 | \r | |
575 | case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE:\r | |
576 | VA_START (Marker, OpCode);\r | |
577 | Status = BootScriptWriteSmbusExecute (Marker);\r | |
578 | VA_END (Marker);\r | |
579 | break;\r | |
580 | \r | |
581 | case EFI_BOOT_SCRIPT_STALL_OPCODE:\r | |
582 | VA_START (Marker, OpCode);\r | |
583 | Status = BootScriptWriteStall (Marker);\r | |
584 | VA_END (Marker);\r | |
585 | \r | |
586 | break;\r | |
587 | \r | |
588 | case EFI_BOOT_SCRIPT_DISPATCH_OPCODE:\r | |
589 | VA_START (Marker, OpCode);\r | |
590 | Status = BootScriptWriteDispatch (Marker);\r | |
591 | VA_END (Marker);\r | |
592 | break;\r | |
593 | \r | |
594 | case EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE:\r | |
595 | VA_START (Marker, OpCode);\r | |
596 | Status = BootScriptWriteDispatch2 (Marker);\r | |
597 | VA_END (Marker);\r | |
598 | break;\r | |
599 | \r | |
600 | case EFI_BOOT_SCRIPT_INFORMATION_OPCODE:\r | |
601 | VA_START (Marker, OpCode);\r | |
602 | Status = BootScriptWriteInformation (Marker);\r | |
603 | VA_END (Marker);\r | |
604 | break;\r | |
605 | \r | |
606 | case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE:\r | |
607 | VA_START (Marker, OpCode);\r | |
608 | Status = BootScriptWriteMemPoll (Marker);\r | |
609 | VA_END (Marker);\r | |
610 | break;\r | |
611 | \r | |
612 | case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE:\r | |
613 | VA_START (Marker, OpCode);\r | |
614 | Status = BootScriptWritePciCfg2Write (Marker);\r | |
615 | VA_END (Marker);\r | |
616 | break;\r | |
617 | \r | |
618 | case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE:\r | |
619 | VA_START (Marker, OpCode);\r | |
620 | Status = BootScriptWritePciCfg2ReadWrite (Marker);\r | |
621 | VA_END (Marker);\r | |
622 | break;\r | |
623 | \r | |
624 | case EFI_BOOT_SCRIPT_IO_POLL_OPCODE: \r | |
625 | VA_START (Marker, OpCode);\r | |
626 | Status = BootScriptWriteIoPoll (Marker);\r | |
627 | VA_END (Marker);\r | |
628 | break; \r | |
629 | \r | |
630 | case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE: \r | |
631 | VA_START (Marker, OpCode);\r | |
632 | Status = BootScriptWritePciConfigPoll (Marker);\r | |
633 | VA_END (Marker);\r | |
634 | break; \r | |
635 | \r | |
636 | case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE:\r | |
637 | VA_START (Marker, OpCode);\r | |
638 | Status = BootScriptWritePciConfig2Poll (Marker);\r | |
639 | VA_END (Marker);\r | |
640 | break; \r | |
641 | \r | |
642 | default:\r | |
643 | Status = EFI_INVALID_PARAMETER;\r | |
644 | break;\r | |
645 | }\r | |
646 | \r | |
647 | return Status;\r | |
648 | }\r | |
649 | /**\r | |
650 | Insert a record into a specified Framework boot script table.\r | |
651 | \r | |
652 | This function is used to store an OpCode to be replayed as part of the S3 resume boot path. It is\r | |
653 | assumed this protocol has platform specific mechanism to store the OpCode set and replay them\r | |
654 | during the S3 resume.\r | |
655 | The opcode is inserted before or after the specified position in the boot script table. If Position is\r | |
656 | NULL then that position is after the last opcode in the table (BeforeOrAfter is FALSE) or before\r | |
657 | the first opcode in the table (BeforeOrAfter is TRUE). The position which is pointed to by\r | |
658 | Position upon return can be used for subsequent insertions.\r | |
659 | \r | |
660 | @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.\r | |
661 | @param BeforeOrAfter Specifies whether the opcode is stored before (TRUE) or after (FALSE) the position\r | |
662 | in the boot script table specified by Position. If Position is NULL or points to\r | |
663 | NULL then the new opcode is inserted at the beginning of the table (if TRUE) or end\r | |
664 | of the table (if FALSE).\r | |
665 | @param Position On entry, specifies the position in the boot script table where the opcode will be\r | |
666 | inserted, either before or after, depending on BeforeOrAfter. On exit, specifies\r | |
667 | the position of the inserted opcode in the boot script table.\r | |
668 | @param OpCode The operation code (opcode) number.\r | |
669 | @param ... Argument list that is specific to each opcode. \r | |
670 | \r | |
671 | @retval EFI_SUCCESS The operation succeeded. A record was added into the\r | |
672 | specified script table.\r | |
673 | @retval EFI_INVALID_PARAMETER The Opcode is an invalid opcode value or the Position is not a valid position in the boot script table..\r | |
674 | @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.\r | |
675 | \r | |
676 | **/\r | |
677 | EFI_STATUS\r | |
678 | EFIAPI\r | |
679 | BootScriptInsert (\r | |
680 | IN CONST EFI_S3_SAVE_STATE_PROTOCOL *This,\r | |
681 | IN BOOLEAN BeforeOrAfter,\r | |
682 | IN OUT EFI_S3_BOOT_SCRIPT_POSITION *Position OPTIONAL,\r | |
683 | IN UINT16 OpCode,\r | |
684 | ...\r | |
685 | )\r | |
686 | {\r | |
687 | EFI_STATUS Status;\r | |
688 | VA_LIST Marker; \r | |
689 | //\r | |
690 | // Build script according to opcode\r | |
691 | //\r | |
692 | switch (OpCode) {\r | |
693 | \r | |
694 | case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE:\r | |
695 | VA_START (Marker, OpCode);\r | |
696 | Status = BootScriptWriteIoWrite (Marker);\r | |
697 | VA_END (Marker);\r | |
698 | break;\r | |
699 | \r | |
700 | case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE:\r | |
701 | VA_START (Marker, OpCode);\r | |
702 | Status = BootScriptWriteIoReadWrite (Marker);\r | |
703 | VA_END (Marker);\r | |
704 | break;\r | |
705 | \r | |
706 | case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE:\r | |
707 | VA_START (Marker, OpCode);\r | |
708 | Status = BootScriptWriteMemWrite (Marker);\r | |
709 | VA_END (Marker); \r | |
710 | break;\r | |
711 | \r | |
712 | case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE:\r | |
713 | VA_START (Marker, OpCode);\r | |
714 | Status = BootScriptWriteMemReadWrite (Marker);\r | |
715 | VA_END (Marker);\r | |
716 | break;\r | |
717 | \r | |
718 | case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE:\r | |
719 | VA_START (Marker, OpCode);\r | |
720 | Status = BootScriptWritePciCfgWrite (Marker);\r | |
721 | VA_END (Marker);\r | |
722 | break;\r | |
723 | \r | |
724 | case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE:\r | |
725 | VA_START (Marker, OpCode);\r | |
726 | Status = BootScriptWritePciCfgReadWrite (Marker);\r | |
727 | VA_END (Marker);\r | |
728 | break;\r | |
729 | \r | |
730 | case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE:\r | |
731 | VA_START (Marker, OpCode);\r | |
732 | Status = BootScriptWriteSmbusExecute (Marker);\r | |
733 | VA_END (Marker);\r | |
734 | break;\r | |
735 | \r | |
736 | case EFI_BOOT_SCRIPT_STALL_OPCODE:\r | |
737 | VA_START (Marker, OpCode);\r | |
738 | Status = BootScriptWriteStall (Marker);\r | |
739 | VA_END (Marker);\r | |
740 | \r | |
741 | break;\r | |
742 | \r | |
743 | case EFI_BOOT_SCRIPT_DISPATCH_OPCODE:\r | |
744 | VA_START (Marker, OpCode);\r | |
745 | Status = BootScriptWriteDispatch (Marker);\r | |
746 | VA_END (Marker);\r | |
747 | break;\r | |
748 | \r | |
749 | case EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE:\r | |
750 | VA_START (Marker, OpCode);\r | |
751 | Status = BootScriptWriteDispatch2 (Marker);\r | |
752 | VA_END (Marker);\r | |
753 | break;\r | |
754 | \r | |
755 | case EFI_BOOT_SCRIPT_INFORMATION_OPCODE:\r | |
756 | VA_START (Marker, OpCode);\r | |
757 | Status = BootScriptWriteInformation (Marker);\r | |
758 | VA_END (Marker);\r | |
759 | break;\r | |
760 | \r | |
761 | case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE:\r | |
762 | VA_START (Marker, OpCode);\r | |
763 | Status = BootScriptWriteMemPoll (Marker);\r | |
764 | VA_END (Marker);\r | |
765 | break;\r | |
766 | \r | |
767 | case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE:\r | |
768 | VA_START (Marker, OpCode);\r | |
769 | Status = BootScriptWritePciCfg2Write (Marker);\r | |
770 | VA_END (Marker);\r | |
771 | break;\r | |
772 | \r | |
773 | case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE:\r | |
774 | VA_START (Marker, OpCode);\r | |
775 | Status = BootScriptWritePciCfg2ReadWrite (Marker);\r | |
776 | VA_END (Marker);\r | |
777 | break;\r | |
778 | \r | |
779 | case EFI_BOOT_SCRIPT_IO_POLL_OPCODE: \r | |
780 | VA_START (Marker, OpCode);\r | |
781 | Status = BootScriptWriteIoPoll (Marker);\r | |
782 | VA_END (Marker);\r | |
783 | break; \r | |
784 | \r | |
785 | case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE: \r | |
786 | VA_START (Marker, OpCode);\r | |
787 | Status = BootScriptWritePciConfigPoll (Marker);\r | |
788 | VA_END (Marker);\r | |
789 | break; \r | |
790 | \r | |
791 | case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE:\r | |
792 | VA_START (Marker, OpCode);\r | |
793 | Status = BootScriptWritePciConfig2Poll (Marker);\r | |
794 | VA_END (Marker);\r | |
795 | break; \r | |
796 | \r | |
797 | default:\r | |
798 | Status = EFI_INVALID_PARAMETER;\r | |
799 | break;\r | |
800 | }\r | |
801 | \r | |
802 | if (!EFI_ERROR (Status)) {\r | |
803 | Status = S3BootScriptMoveLastOpcode (BeforeOrAfter, Position);\r | |
804 | }\r | |
805 | return Status;\r | |
806 | }\r | |
807 | /**\r | |
808 | Find a label within the boot script table and, if not present, optionally create it.\r | |
809 | \r | |
810 | If the label Label is already exists in the boot script table, then no new label is created, the\r | |
811 | position of the Label is returned in *Position and EFI_SUCCESS is returned.\r | |
812 | If the label Label does not already exist and CreateIfNotFound is TRUE, then it will be\r | |
813 | created before or after the specified position and EFI_SUCCESS is returned.\r | |
814 | If the label Label does not already exist and CreateIfNotFound is FALSE, then\r | |
815 | EFI_NOT_FOUND is returned.\r | |
816 | \r | |
817 | @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.\r | |
818 | @param BeforeOrAfter Specifies whether the label is stored before (TRUE) or after (FALSE) the position in\r | |
819 | the boot script table specified by Position. If Position is NULL or points to\r | |
820 | NULL then the new label is inserted at the beginning of the table (if TRUE) or end of\r | |
821 | the table (if FALSE).\r | |
822 | @param CreateIfNotFound Specifies whether the label will be created if the label does not exists (TRUE) or not\r | |
823 | (FALSE).\r | |
824 | @param Position On entry, specifies the position in the boot script table where the label will be inserted,\r | |
825 | either before or after, depending on BeforeOrAfter. On exit, specifies the position\r | |
826 | of the inserted label in the boot script table.\r | |
827 | @param Label Points to the label which will be inserted in the boot script table.\r | |
828 | \r | |
829 | @retval EFI_SUCCESS The label already exists or was inserted.\r | |
96072947 JY |
830 | @retval EFI_INVALID_PARAMETER The Label is NULL or points to an empty string.\r |
831 | @retval EFI_INVALID_PARAMETER The Position is not a valid position in the boot script table.\r | |
bdfde462 | 832 | \r |
833 | **/\r | |
834 | EFI_STATUS\r | |
835 | EFIAPI\r | |
836 | BootScriptLabel (\r | |
837 | IN CONST EFI_S3_SAVE_STATE_PROTOCOL *This,\r | |
838 | IN BOOLEAN BeforeOrAfter,\r | |
839 | IN BOOLEAN CreateIfNotFound,\r | |
840 | IN OUT EFI_S3_BOOT_SCRIPT_POSITION *Position OPTIONAL,\r | |
841 | IN CONST CHAR8 *Label\r | |
842 | )\r | |
843 | {\r | |
844 | return S3BootScriptLabel (BeforeOrAfter, CreateIfNotFound, Position, Label);\r | |
845 | }\r | |
846 | /**\r | |
847 | Compare two positions in the boot script table and return their relative position.\r | |
848 | \r | |
849 | This function compares two positions in the boot script table and returns their relative positions. If\r | |
850 | Position1 is before Position2, then -1 is returned. If Position1 is equal to Position2,\r | |
851 | then 0 is returned. If Position1 is after Position2, then 1 is returned.\r | |
852 | \r | |
853 | @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.\r | |
854 | @param Position1 The positions in the boot script table to compare\r | |
855 | @param Position2 The positions in the boot script table to compare\r | |
856 | @param RelativePosition On return, points to the result of the comparison\r | |
857 | \r | |
858 | @retval EFI_SUCCESS The operation succeeded. \r | |
859 | @retval EFI_INVALID_PARAMETER The Position1 or Position2 is not a valid position in the boot script table.\r | |
96072947 | 860 | @retval EFI_INVALID_PARAMETER The RelativePosition is NULL.\r |
bdfde462 | 861 | \r |
862 | **/\r | |
863 | EFI_STATUS\r | |
864 | EFIAPI \r | |
865 | BootScriptCompare (\r | |
866 | IN CONST EFI_S3_SAVE_STATE_PROTOCOL *This,\r | |
867 | IN EFI_S3_BOOT_SCRIPT_POSITION Position1,\r | |
868 | IN EFI_S3_BOOT_SCRIPT_POSITION Position2,\r | |
869 | OUT UINTN *RelativePosition\r | |
870 | )\r | |
871 | {\r | |
872 | return S3BootScriptCompare (Position1, Position2, RelativePosition);\r | |
873 | }\r | |
874 | /**\r | |
875 | This routine is entry point of ScriptSave driver.\r | |
876 | \r | |
877 | @param ImageHandle Handle for this drivers loaded image protocol.\r | |
878 | @param SystemTable EFI system table.\r | |
879 | \r | |
880 | @retval EFI_OUT_OF_RESOURCES No enough resource\r | |
881 | @retval EFI_SUCCESS Succesfully installed the ScriptSave driver.\r | |
882 | @retval other Errors occured.\r | |
883 | \r | |
884 | **/\r | |
885 | EFI_STATUS\r | |
886 | EFIAPI\r | |
887 | InitializeS3SaveState (\r | |
888 | IN EFI_HANDLE ImageHandle,\r | |
889 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
890 | )\r | |
891 | {\r | |
892 | \r | |
893 | \r | |
894 | return gBS->InstallProtocolInterface (\r | |
895 | &mHandle,\r | |
896 | &gEfiS3SaveStateProtocolGuid,\r | |
897 | EFI_NATIVE_INTERFACE,\r | |
898 | &mS3SaveState\r | |
899 | );\r | |
900 | \r | |
901 | }\r | |
902 | \r | |
903 | \r |