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