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