]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.c
Document the inconsistency of EFI_SMM_CPU_SAVE_STATE between the EDK2 code base and...
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / BootScriptSaveOnS3SaveStateThunk / ScriptSave.c
CommitLineData
ba9978cf 1/** @file\r
2 Implementation for S3 Boot Script Save thunk driver.\r
3 This thunk driver consumes PI S3SaveState protocol to produce framework S3BootScriptSave Protocol \r
4 \r
584d5652
HT
5 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
6 This program and the accompanying materials\r
ba9978cf 7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15#include "ScriptSave.h"\r
16\r
17EFI_HANDLE mHandle;\r
18EFI_BOOT_SCRIPT_SAVE_PROTOCOL mS3ScriptSave = {\r
19 BootScriptWrite,\r
20 BootScriptCloseTable\r
21 };\r
22EFI_S3_SAVE_STATE_PROTOCOL *mS3SaveState;\r
23/**\r
24 Internal function to add IO write opcode to the table.\r
25\r
26 @param Marker The variable argument list to get the opcode\r
27 and associated attributes.\r
28\r
29 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r
30 @retval EFI_SUCCESS Opcode is added.\r
31\r
32**/\r
33EFI_STATUS\r
34BootScriptIoWrite (\r
35 IN VA_LIST Marker\r
36 )\r
37{\r
38 EFI_BOOT_SCRIPT_WIDTH Width;\r
39 UINT64 Address;\r
40 UINTN Count;\r
41 UINT8 *Buffer;\r
42\r
43 Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);\r
44 Address = VA_ARG (Marker, UINT64);\r
45 Count = VA_ARG (Marker, UINTN);\r
46 Buffer = VA_ARG (Marker, UINT8 *);\r
47 \r
48 return mS3SaveState->Write (\r
49 mS3SaveState,\r
50 EFI_BOOT_SCRIPT_IO_WRITE_OPCODE,\r
51 Width, \r
52 Address, \r
53 Count, \r
54 Buffer\r
55 );\r
56}\r
57/**\r
58 Internal function to add IO read/write opcode to the table.\r
59\r
60 @param Marker The variable argument list to get the opcode\r
61 and associated attributes.\r
62\r
63 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r
64 @retval EFI_SUCCESS Opcode is added.\r
65\r
66**/\r
67EFI_STATUS\r
68BootScriptIoReadWrite (\r
69 IN VA_LIST Marker\r
70 )\r
71{\r
72 EFI_BOOT_SCRIPT_WIDTH Width;\r
73 UINT64 Address;\r
74 UINT8 *Data;\r
75 UINT8 *DataMask;\r
76 \r
77 Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);\r
78 Address = VA_ARG (Marker, UINT64);\r
79 Data = VA_ARG (Marker, UINT8 *);\r
80 DataMask = VA_ARG (Marker, UINT8 *);\r
81 \r
82 return mS3SaveState->Write (\r
83 mS3SaveState,\r
84 EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE,\r
85 Width, \r
86 Address, \r
87 Data, \r
88 DataMask\r
89 );\r
90}\r
91\r
92/**\r
93 Internal function to add memory write opcode to the table.\r
94\r
95 @param Marker The variable argument list to get the opcode\r
96 and associated attributes.\r
97\r
98 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r
99 @retval EFI_SUCCESS Opcode is added.\r
100\r
101**/\r
102EFI_STATUS\r
103BootScriptMemWrite (\r
104 IN VA_LIST Marker\r
105 )\r
106{\r
107 EFI_BOOT_SCRIPT_WIDTH Width;\r
108 UINT64 Address;\r
109 UINTN Count;\r
110 UINT8 *Buffer;\r
111 \r
112 Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);\r
113 Address = VA_ARG (Marker, UINT64);\r
114 Count = VA_ARG (Marker, UINTN);\r
115 Buffer = VA_ARG (Marker, UINT8 *);\r
116\r
117 return mS3SaveState->Write (\r
118 mS3SaveState,\r
119 EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE,\r
120 Width, \r
121 Address, \r
122 Count, \r
123 Buffer\r
124 );\r
125}\r
126\r
127/**\r
128 Internal function to add memory read/write opcode to the table.\r
129\r
130 @param Marker The variable argument list to get the opcode\r
131 and associated attributes.\r
132\r
133 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r
134 @retval EFI_SUCCESS Opcode is added.\r
135\r
136**/\r
137EFI_STATUS\r
138BootScriptMemReadWrite (\r
139 IN VA_LIST Marker\r
140 )\r
141{\r
142 EFI_BOOT_SCRIPT_WIDTH Width;\r
143 UINT64 Address;\r
144 UINT8 *Data;\r
145 UINT8 *DataMask;\r
146 \r
147 Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);\r
148 Address = VA_ARG (Marker, UINT64);\r
149 Data = VA_ARG (Marker, UINT8 *);\r
150 DataMask = VA_ARG (Marker, UINT8 *);\r
151\r
152 return mS3SaveState->Write (\r
153 mS3SaveState,\r
154 EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE,\r
155 Width, \r
156 Address, \r
157 Data, \r
158 DataMask\r
159 );\r
160}\r
161\r
162/**\r
163 Internal function to add PciCfg write opcode to the table.\r
164\r
165 @param Marker The variable argument list to get the opcode\r
166 and associated attributes.\r
167\r
168 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r
169 @retval EFI_SUCCESS Opcode is added.\r
170\r
171**/\r
172EFI_STATUS\r
173BootScriptPciCfgWrite (\r
174 IN VA_LIST Marker\r
175 )\r
176{\r
177 EFI_BOOT_SCRIPT_WIDTH Width;\r
178 UINT64 Address;\r
179 UINTN Count;\r
180 UINT8 *Buffer;\r
181\r
182 Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);\r
183 Address = VA_ARG (Marker, UINT64);\r
184 Count = VA_ARG (Marker, UINTN);\r
185 Buffer = VA_ARG (Marker, UINT8 *);\r
186\r
187 return mS3SaveState->Write (\r
188 mS3SaveState,\r
189 EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE,\r
190 Width, \r
191 Address, \r
192 Count, \r
193 Buffer\r
194 );\r
195}\r
196\r
197/**\r
198 Internal function to PciCfg read/write opcode to the table.\r
199\r
200 @param Marker The variable argument list to get the opcode\r
201 and associated attributes.\r
202\r
203 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r
204 @retval EFI_SUCCESS Opcode is added.\r
205\r
206**/\r
207EFI_STATUS\r
208BootScriptPciCfgReadWrite (\r
209 IN VA_LIST Marker\r
210 )\r
211{\r
212 EFI_BOOT_SCRIPT_WIDTH Width;\r
213 UINT64 Address;\r
214 UINT8 *Data;\r
215 UINT8 *DataMask;\r
216\r
217 Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);\r
218 Address = VA_ARG (Marker, UINT64);\r
219 Data = VA_ARG (Marker, UINT8 *);\r
220 DataMask = VA_ARG (Marker, UINT8 *);\r
221\r
222 return mS3SaveState->Write (\r
223 mS3SaveState,\r
224 EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE,\r
225 Width,\r
226 Address,\r
227 Data,\r
228 DataMask\r
229 );\r
230}\r
231/**\r
232 Internal function to add PciCfg2 write opcode to the table.\r
233\r
234 @param Marker The variable argument list to get the opcode\r
235 and associated attributes.\r
236\r
237 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r
238 @retval EFI_SUCCESS Opcode is added.\r
239\r
240**/\r
241EFI_STATUS\r
242BootScriptPciCfg2Write (\r
243 IN VA_LIST Marker\r
244 )\r
245{\r
246 EFI_BOOT_SCRIPT_WIDTH Width;\r
247 UINT64 Address;\r
248 UINTN Count;\r
249 UINT8 *Buffer;\r
250 UINT16 Segment;\r
251\r
252 Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);\r
253 Address = VA_ARG (Marker, UINT64);\r
254 Count = VA_ARG (Marker, UINTN);\r
255 Buffer = VA_ARG (Marker, UINT8 *);\r
256 Segment = VA_ARG (Marker, UINT16);\r
257\r
258 return mS3SaveState->Write (\r
259 mS3SaveState,\r
260 EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE,\r
261 Width, \r
262 Segment, \r
263 Address, \r
264 Count, \r
265 Buffer\r
266 );\r
267}\r
268\r
269/**\r
270 Internal function to PciCfg2 read/write opcode to the table.\r
271\r
272 @param Marker The variable argument list to get the opcode\r
273 and associated attributes.\r
274\r
275 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r
276 @retval EFI_SUCCESS Opcode is added.\r
277\r
278**/\r
279EFI_STATUS\r
280BootScriptPciCfg2ReadWrite (\r
281 IN VA_LIST Marker\r
282 )\r
283{\r
284 EFI_BOOT_SCRIPT_WIDTH Width;\r
285 UINT16 Segment;\r
286 UINT64 Address;\r
287 UINT8 *Data;\r
288 UINT8 *DataMask;\r
289 \r
290 Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);\r
291 Address = VA_ARG (Marker, UINT64);\r
292 Segment = VA_ARG (Marker, UINT16);\r
293 Data = VA_ARG (Marker, UINT8 *);\r
294 DataMask = VA_ARG (Marker, UINT8 *);\r
295 \r
296 return mS3SaveState->Write (\r
297 mS3SaveState,\r
298 EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE,\r
299 Width, \r
300 Segment,\r
301 Address,\r
302 Data,\r
303 DataMask\r
304 );\r
305}\r
306/**\r
307 Internal function to add smbus excute opcode to the table.\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
316EFI_STATUS\r
317BootScriptSmbusExecute (\r
318 IN VA_LIST Marker\r
319 )\r
320{\r
321 EFI_SMBUS_DEVICE_ADDRESS SlaveAddress;\r
322 EFI_SMBUS_DEVICE_COMMAND Command;\r
323 EFI_SMBUS_OPERATION Operation;\r
324 BOOLEAN PecCheck;\r
325 VOID *Buffer;\r
326 UINTN *DataSize;\r
327 \r
328 SlaveAddress.SmbusDeviceAddress = VA_ARG (Marker, UINTN);\r
329 Command = VA_ARG (Marker, EFI_SMBUS_DEVICE_COMMAND);\r
330 Operation = VA_ARG (Marker, EFI_SMBUS_OPERATION);\r
331 PecCheck = VA_ARG (Marker, BOOLEAN);\r
332 DataSize = VA_ARG (Marker, UINTN *); \r
333 Buffer = VA_ARG (Marker, VOID *);\r
334 \r
335 return mS3SaveState->Write (\r
336 mS3SaveState,\r
337 EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE,\r
338 SlaveAddress,\r
339 Command, \r
340 Operation, \r
341 PecCheck,\r
342 DataSize, \r
343 Buffer\r
344 );\r
345}\r
346/**\r
347 Internal function to add stall opcode to the table.\r
348\r
349 @param Marker The variable argument list to get the opcode\r
350 and associated attributes.\r
351\r
352 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r
353 @retval EFI_SUCCESS Opcode is added.\r
354\r
355**/\r
356EFI_STATUS\r
357BootScriptStall (\r
358 IN VA_LIST Marker\r
359 )\r
360{\r
361 UINT32 Duration;\r
362\r
363 Duration = VA_ARG (Marker, UINT32);\r
364\r
365 return mS3SaveState->Write (\r
366 mS3SaveState,\r
367 EFI_BOOT_SCRIPT_STALL_OPCODE,\r
368 Duration\r
369 );\r
370}\r
371\r
372/**\r
373 Internal function to add Save jmp address according to DISPATCH_OPCODE. \r
374 We ignore "Context" parameter\r
375\r
376 @param Marker The variable argument list to get the opcode\r
377 and associated attributes.\r
378\r
379 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r
380 @retval EFI_SUCCESS Opcode is added.\r
381\r
382**/\r
383EFI_STATUS\r
384BootScriptDispatch (\r
385 IN VA_LIST Marker\r
386 )\r
387{\r
388 VOID *EntryPoint;\r
389\r
390 EntryPoint = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);\r
391 return mS3SaveState->Write (\r
392 mS3SaveState,\r
393 EFI_BOOT_SCRIPT_DISPATCH_OPCODE,\r
394 EntryPoint\r
395 );\r
396}\r
397\r
398/**\r
399 Internal function to add memory pool operation to the table. \r
400 \r
401 @param Marker The variable argument list to get the opcode\r
402 and associated attributes.\r
403\r
404 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r
405 @retval EFI_SUCCESS Opcode is added.\r
406\r
407**/\r
408EFI_STATUS\r
409BootScriptMemPoll (\r
410 IN VA_LIST Marker\r
411 )\r
412{\r
413 EFI_BOOT_SCRIPT_WIDTH Width;\r
414 UINT64 Address;\r
415 UINT8 *BitMask;\r
416 UINT8 *BitValue;\r
417 UINT64 Duration;\r
418 UINT64 LoopTimes;\r
419 UINT64 Delay;\r
420\r
421 Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);\r
422 Address = VA_ARG (Marker, UINT64);\r
423 BitMask = VA_ARG (Marker, UINT8 *);\r
424 BitValue = VA_ARG (Marker, UINT8 *);\r
425 Duration = (UINT64)VA_ARG (Marker, UINT64);\r
426 LoopTimes = (UINT64)VA_ARG (Marker, UINT64);\r
427 Delay = MultU64x64 (DivU64x32(Duration, 100), LoopTimes);\r
428 \r
429 return mS3SaveState->Write (\r
430 mS3SaveState,\r
431 EFI_BOOT_SCRIPT_MEM_POLL_OPCODE,\r
432 Width, \r
433 Address, \r
434 BitMask, \r
435 BitValue, \r
436 Delay\r
437 );\r
438}\r
439\r
440/**\r
441 Internal function to add Save jmp address according to DISPATCH_OPCODE2. \r
442 The "Context" parameter is not ignored.\r
443\r
444 @param Marker The variable argument list to get the opcode\r
445 and associated attributes.\r
446\r
447 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.\r
448 @retval EFI_SUCCESS Opcode is added.\r
449\r
450**/\r
451EFI_STATUS\r
452BootScriptDispatch2 (\r
453 IN VA_LIST Marker\r
454 )\r
455{\r
456 VOID *EntryPoint;\r
457 VOID *Context; \r
458\r
459 EntryPoint = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);\r
460 Context = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);\r
461\r
462 return mS3SaveState->Write (\r
463 mS3SaveState,\r
464 EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE,\r
465 EntryPoint, \r
466 Context\r
467 );\r
468}\r
469/**\r
470 Internal function to add the opcode link node to the link\r
471 list.\r
472 @param Marker The variable argument list to get the opcode\r
473 and associated attributes.\r
474\r
475 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.\r
476 @retval EFI_SUCCESS The opcode entry is added to the link list\r
477 successfully.\r
478**/\r
479EFI_STATUS\r
480BootScriptInformation (\r
481 IN VA_LIST Marker\r
482 )\r
483{\r
484 UINT32 InformationLength;\r
485 EFI_PHYSICAL_ADDRESS Information; \r
486\r
487 InformationLength = VA_ARG (Marker, UINT32);\r
488 Information = VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);\r
489 \r
490 return mS3SaveState->Write (\r
491 mS3SaveState,\r
492 EFI_BOOT_SCRIPT_INFORMATION_OPCODE,\r
493 InformationLength, \r
494 (VOID*)(UINTN)Information\r
495 );\r
496}\r
497\r
498/**\r
499 Adds a record into a specified Framework boot script table.\r
500\r
501 This function is used to store a boot script record into a given boot\r
502 script table. If the table specified by TableName is nonexistent in the \r
503 system, a new table will automatically be created and then the script record \r
504 will be added into the new table. A boot script table can add new script records\r
505 until EFI_BOOT_SCRIPT_SAVE_PROTOCOL.CloseTable() is called. Currently, the only \r
506 meaningful table name is EFI_ACPI_S3_RESUME_SCRIPT_TABLE. This function is\r
507 responsible for allocating necessary memory for the script.\r
508\r
509 This function has a variable parameter list. The exact parameter list depends on \r
510 the OpCode that is passed into the function. If an unsupported OpCode or illegal \r
511 parameter list is passed in, this function returns EFI_INVALID_PARAMETER.\r
512 If there are not enough resources available for storing more scripts, this function returns\r
513 EFI_OUT_OF_RESOURCES.\r
514\r
515 @param This A pointer to the EFI_BOOT_SCRIPT_SAVE_PROTOCOL instance.\r
516 @param TableName Name of the script table. Currently, the only meaningful value is\r
517 EFI_ACPI_S3_RESUME_SCRIPT_TABLE.\r
518 @param OpCode The operation code (opcode) number.\r
26a76fbc 519 @param ... Argument list that is specific to each opcode. \r
ba9978cf 520\r
521 @retval EFI_SUCCESS The operation succeeded. A record was added into the\r
522 specified script table.\r
523 @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.\r
524 If the opcode is unknow or not supported because of the PCD \r
525 Feature Flags.\r
526 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.\r
527\r
528**/\r
529EFI_STATUS\r
530EFIAPI\r
531BootScriptWrite (\r
532 IN EFI_BOOT_SCRIPT_SAVE_PROTOCOL *This,\r
533 IN UINT16 TableName,\r
534 IN UINT16 OpCode,\r
535 ...\r
536 )\r
537{\r
538 EFI_STATUS Status;\r
539 VA_LIST Marker;\r
540 \r
541 if (TableName != FRAMEWORK_EFI_ACPI_S3_RESUME_SCRIPT_TABLE) {\r
542 //\r
543 // Only S3 boot script is supported for now\r
544 //\r
545 return EFI_OUT_OF_RESOURCES;\r
546 }\r
547 //\r
548 // Build script according to opcode\r
549 //\r
550 switch (OpCode) {\r
551\r
552 case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE:\r
553 VA_START (Marker, OpCode);\r
554 Status = BootScriptIoWrite (Marker);\r
555 VA_END (Marker);\r
556 break;\r
557\r
558 case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE:\r
559 VA_START (Marker, OpCode);\r
560 Status = BootScriptIoReadWrite (Marker);\r
561 VA_END (Marker);\r
562 break;\r
563\r
564 case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE:\r
565 VA_START (Marker, OpCode);\r
566 Status = BootScriptMemWrite (Marker);\r
567 VA_END (Marker); \r
568 break;\r
569\r
570 case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE:\r
571 VA_START (Marker, OpCode);\r
572 Status = BootScriptMemReadWrite (Marker);\r
573 VA_END (Marker);\r
574 break;\r
575\r
576 case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE:\r
577 VA_START (Marker, OpCode);\r
578 Status = BootScriptPciCfgWrite (Marker);\r
579 VA_END (Marker);\r
580 break;\r
581\r
582 case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE:\r
583 VA_START (Marker, OpCode);\r
584 Status = BootScriptPciCfgReadWrite (Marker);\r
585 VA_END (Marker);\r
586 break;\r
587\r
588 case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE:\r
589 VA_START (Marker, OpCode);\r
590 Status = BootScriptSmbusExecute (Marker);\r
591 VA_END (Marker);\r
592 break;\r
593\r
594 case EFI_BOOT_SCRIPT_STALL_OPCODE:\r
595 VA_START (Marker, OpCode);\r
596 Status = BootScriptStall (Marker);\r
597 VA_END (Marker);\r
598 \r
599 break;\r
600\r
601 case EFI_BOOT_SCRIPT_DISPATCH_OPCODE:\r
602 VA_START (Marker, OpCode);\r
603 Status = BootScriptDispatch (Marker);\r
604 VA_END (Marker);\r
605 break;\r
606\r
607 case FRAMEWORK_EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE:\r
608 VA_START (Marker, OpCode);\r
609 Status = BootScriptDispatch2 (Marker);\r
610 VA_END (Marker);\r
611 break;\r
612\r
613 case EFI_BOOT_SCRIPT_INFORMATION_OPCODE:\r
614 VA_START (Marker, OpCode);\r
615 Status = BootScriptInformation (Marker);\r
616 VA_END (Marker);\r
617 break;\r
618\r
619 case FRAMEWORK_EFI_BOOT_SCRIPT_MEM_POLL_OPCODE:\r
620 VA_START (Marker, OpCode);\r
621 Status = BootScriptMemPoll (Marker);\r
622 VA_END (Marker);\r
623 break;\r
624\r
625 case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE:\r
626 VA_START (Marker, OpCode);\r
627 Status = BootScriptPciCfg2Write (Marker);\r
628 VA_END (Marker);\r
629 break;\r
630\r
631 case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE:\r
632 VA_START (Marker, OpCode);\r
633 Status = BootScriptPciCfg2ReadWrite (Marker);\r
634 VA_END (Marker);\r
635 break;\r
636\r
637 default:\r
638 Status = EFI_INVALID_PARAMETER;\r
639 break;\r
640 }\r
641\r
642 return Status;\r
643}\r
644\r
645/**\r
646 Closes the specified script table.\r
647\r
648 This function closes the specified boot script table and returns the base address \r
649 of the table. It allocates a new pool to duplicate all the boot scripts in the specified \r
650 table. Once this function is called, the specified table will be destroyed after it is \r
651 copied into the allocated pool. As a result, any attempts to add a script record into a \r
652 closed table will cause a new table to be created. The base address of the allocated pool \r
653 will be returned in Address. After using the boot script table, the caller is responsible \r
654 for freeing the pool that is allocated by this function. If the boot script table,\r
655 such as EFI_ACPI_S3_RESUME_SCRIPT_TABLE, is required to be stored in a nonperturbed\r
656 memory region, the caller should copy the table into the nonperturbed memory region by itself.\r
657\r
658 @param This A pointer to the EFI_BOOT_SCRIPT_SAVE_PROTOCOL instance.\r
659 @param TableName Name of the script table. Currently, the only meaningful value is\r
660 EFI_ACPI_S3_RESUME_SCRIPT_TABLE.\r
661 @param Address A pointer to the physical address where the table begins. \r
662 \r
663 @retval EFI_SUCCESS The table was successfully returned.\r
664 @retval EFI_NOT_FOUND The specified table was not created previously.\r
665 @retval EFI_OUT_OF_RESOURCE Memory is insufficient to hold the reorganized boot script table.\r
666 @retval EFI_UNSUPPORTED the table type is not EFI_ACPI_S3_RESUME_SCRIPT_TABLE\r
667 \r
668**/\r
669EFI_STATUS\r
670EFIAPI\r
671BootScriptCloseTable (\r
672 IN EFI_BOOT_SCRIPT_SAVE_PROTOCOL *This,\r
673 IN UINT16 TableName,\r
674 OUT EFI_PHYSICAL_ADDRESS *Address\r
675 )\r
676{ \r
677 if (TableName != FRAMEWORK_EFI_ACPI_S3_RESUME_SCRIPT_TABLE) {\r
678 //\r
679 // Only S3 boot script is supported for now\r
680 //\r
681 return EFI_NOT_FOUND;\r
682 }\r
683 //\r
684 // Here the close table is not implemented. \r
685 // \r
686 \r
687 return EFI_UNSUPPORTED;\r
688}\r
689\r
690/**\r
691 This routine is entry point of ScriptSave driver.\r
692\r
26a76fbc 693 @param ImageHandle Handle for this drivers loaded image protocol.\r
ba9978cf 694 @param SystemTable EFI system table.\r
695\r
696 @retval EFI_OUT_OF_RESOURCES No enough resource\r
697 @retval EFI_SUCCESS Succesfully installed the ScriptSave driver.\r
698 @retval other Errors occured.\r
699\r
700**/\r
701EFI_STATUS\r
702EFIAPI\r
703InitializeScriptSaveOnS3SaveState (\r
704 IN EFI_HANDLE ImageHandle,\r
705 IN EFI_SYSTEM_TABLE *SystemTable\r
706 )\r
707{\r
708 EFI_STATUS Status;\r
709 //\r
710 // Locate and cache PI S3 Save State Protocol.\r
711 //\r
712 Status = gBS->LocateProtocol (\r
713 &gEfiS3SaveStateProtocolGuid, \r
714 NULL, \r
715 (VOID **) &mS3SaveState\r
716 );\r
717 ASSERT_EFI_ERROR (Status);\r
718\r
719 return gBS->InstallProtocolInterface (\r
720 &mHandle,\r
721 &gEfiBootScriptSaveProtocolGuid,\r
722 EFI_NATIVE_INTERFACE,\r
723 &mS3ScriptSave\r
724 );\r
725\r
726}\r
727\r
728\r