]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.c
fix the typo error for the name of BootScriptSaveOnS3SaveStateThunk thunk driver
[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
5 Copyright (c) 2010 Intel Corporation\r
6 All rights reserved. This program and the accompanying materials\r
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
519\r
520 @retval EFI_SUCCESS The operation succeeded. A record was added into the\r
521 specified script table.\r
522 @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.\r
523 If the opcode is unknow or not supported because of the PCD \r
524 Feature Flags.\r
525 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.\r
526\r
527**/\r
528EFI_STATUS\r
529EFIAPI\r
530BootScriptWrite (\r
531 IN EFI_BOOT_SCRIPT_SAVE_PROTOCOL *This,\r
532 IN UINT16 TableName,\r
533 IN UINT16 OpCode,\r
534 ...\r
535 )\r
536{\r
537 EFI_STATUS Status;\r
538 VA_LIST Marker;\r
539 \r
540 if (TableName != FRAMEWORK_EFI_ACPI_S3_RESUME_SCRIPT_TABLE) {\r
541 //\r
542 // Only S3 boot script is supported for now\r
543 //\r
544 return EFI_OUT_OF_RESOURCES;\r
545 }\r
546 //\r
547 // Build script according to opcode\r
548 //\r
549 switch (OpCode) {\r
550\r
551 case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE:\r
552 VA_START (Marker, OpCode);\r
553 Status = BootScriptIoWrite (Marker);\r
554 VA_END (Marker);\r
555 break;\r
556\r
557 case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE:\r
558 VA_START (Marker, OpCode);\r
559 Status = BootScriptIoReadWrite (Marker);\r
560 VA_END (Marker);\r
561 break;\r
562\r
563 case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE:\r
564 VA_START (Marker, OpCode);\r
565 Status = BootScriptMemWrite (Marker);\r
566 VA_END (Marker); \r
567 break;\r
568\r
569 case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE:\r
570 VA_START (Marker, OpCode);\r
571 Status = BootScriptMemReadWrite (Marker);\r
572 VA_END (Marker);\r
573 break;\r
574\r
575 case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE:\r
576 VA_START (Marker, OpCode);\r
577 Status = BootScriptPciCfgWrite (Marker);\r
578 VA_END (Marker);\r
579 break;\r
580\r
581 case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE:\r
582 VA_START (Marker, OpCode);\r
583 Status = BootScriptPciCfgReadWrite (Marker);\r
584 VA_END (Marker);\r
585 break;\r
586\r
587 case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE:\r
588 VA_START (Marker, OpCode);\r
589 Status = BootScriptSmbusExecute (Marker);\r
590 VA_END (Marker);\r
591 break;\r
592\r
593 case EFI_BOOT_SCRIPT_STALL_OPCODE:\r
594 VA_START (Marker, OpCode);\r
595 Status = BootScriptStall (Marker);\r
596 VA_END (Marker);\r
597 \r
598 break;\r
599\r
600 case EFI_BOOT_SCRIPT_DISPATCH_OPCODE:\r
601 VA_START (Marker, OpCode);\r
602 Status = BootScriptDispatch (Marker);\r
603 VA_END (Marker);\r
604 break;\r
605\r
606 case FRAMEWORK_EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE:\r
607 VA_START (Marker, OpCode);\r
608 Status = BootScriptDispatch2 (Marker);\r
609 VA_END (Marker);\r
610 break;\r
611\r
612 case EFI_BOOT_SCRIPT_INFORMATION_OPCODE:\r
613 VA_START (Marker, OpCode);\r
614 Status = BootScriptInformation (Marker);\r
615 VA_END (Marker);\r
616 break;\r
617\r
618 case FRAMEWORK_EFI_BOOT_SCRIPT_MEM_POLL_OPCODE:\r
619 VA_START (Marker, OpCode);\r
620 Status = BootScriptMemPoll (Marker);\r
621 VA_END (Marker);\r
622 break;\r
623\r
624 case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE:\r
625 VA_START (Marker, OpCode);\r
626 Status = BootScriptPciCfg2Write (Marker);\r
627 VA_END (Marker);\r
628 break;\r
629\r
630 case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE:\r
631 VA_START (Marker, OpCode);\r
632 Status = BootScriptPciCfg2ReadWrite (Marker);\r
633 VA_END (Marker);\r
634 break;\r
635\r
636 default:\r
637 Status = EFI_INVALID_PARAMETER;\r
638 break;\r
639 }\r
640\r
641 return Status;\r
642}\r
643\r
644/**\r
645 Closes the specified script table.\r
646\r
647 This function closes the specified boot script table and returns the base address \r
648 of the table. It allocates a new pool to duplicate all the boot scripts in the specified \r
649 table. Once this function is called, the specified table will be destroyed after it is \r
650 copied into the allocated pool. As a result, any attempts to add a script record into a \r
651 closed table will cause a new table to be created. The base address of the allocated pool \r
652 will be returned in Address. After using the boot script table, the caller is responsible \r
653 for freeing the pool that is allocated by this function. If the boot script table,\r
654 such as EFI_ACPI_S3_RESUME_SCRIPT_TABLE, is required to be stored in a nonperturbed\r
655 memory region, the caller should copy the table into the nonperturbed memory region by itself.\r
656\r
657 @param This A pointer to the EFI_BOOT_SCRIPT_SAVE_PROTOCOL instance.\r
658 @param TableName Name of the script table. Currently, the only meaningful value is\r
659 EFI_ACPI_S3_RESUME_SCRIPT_TABLE.\r
660 @param Address A pointer to the physical address where the table begins. \r
661 \r
662 @retval EFI_SUCCESS The table was successfully returned.\r
663 @retval EFI_NOT_FOUND The specified table was not created previously.\r
664 @retval EFI_OUT_OF_RESOURCE Memory is insufficient to hold the reorganized boot script table.\r
665 @retval EFI_UNSUPPORTED the table type is not EFI_ACPI_S3_RESUME_SCRIPT_TABLE\r
666 \r
667**/\r
668EFI_STATUS\r
669EFIAPI\r
670BootScriptCloseTable (\r
671 IN EFI_BOOT_SCRIPT_SAVE_PROTOCOL *This,\r
672 IN UINT16 TableName,\r
673 OUT EFI_PHYSICAL_ADDRESS *Address\r
674 )\r
675{ \r
676 if (TableName != FRAMEWORK_EFI_ACPI_S3_RESUME_SCRIPT_TABLE) {\r
677 //\r
678 // Only S3 boot script is supported for now\r
679 //\r
680 return EFI_NOT_FOUND;\r
681 }\r
682 //\r
683 // Here the close table is not implemented. \r
684 // \r
685 \r
686 return EFI_UNSUPPORTED;\r
687}\r
688\r
689/**\r
690 This routine is entry point of ScriptSave driver.\r
691\r
692 @param Imagehandle Handle for this drivers loaded image protocol.\r
693 @param SystemTable EFI system table.\r
694\r
695 @retval EFI_OUT_OF_RESOURCES No enough resource\r
696 @retval EFI_SUCCESS Succesfully installed the ScriptSave driver.\r
697 @retval other Errors occured.\r
698\r
699**/\r
700EFI_STATUS\r
701EFIAPI\r
702InitializeScriptSaveOnS3SaveState (\r
703 IN EFI_HANDLE ImageHandle,\r
704 IN EFI_SYSTEM_TABLE *SystemTable\r
705 )\r
706{\r
707 EFI_STATUS Status;\r
708 //\r
709 // Locate and cache PI S3 Save State Protocol.\r
710 //\r
711 Status = gBS->LocateProtocol (\r
712 &gEfiS3SaveStateProtocolGuid, \r
713 NULL, \r
714 (VOID **) &mS3SaveState\r
715 );\r
716 ASSERT_EFI_ERROR (Status);\r
717\r
718 return gBS->InstallProtocolInterface (\r
719 &mHandle,\r
720 &gEfiBootScriptSaveProtocolGuid,\r
721 EFI_NATIVE_INTERFACE,\r
722 &mS3ScriptSave\r
723 );\r
724\r
725}\r
726\r
727\r