2 Implementation for S3 Boot Script Saver state driver.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "InternalS3SaveState.h"
11 EFI_HANDLE mHandle
= NULL
;
12 EFI_S3_SAVE_STATE_PROTOCOL mS3SaveState
= {
19 Internal function to add IO write opcode to the table.
21 @param Marker The variable argument list to get the opcode
22 and associated attributes.
24 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
25 @retval EFI_SUCCESS Opcode is added.
29 BootScriptWriteIoWrite (
33 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
38 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
39 Address
= VA_ARG (Marker
, UINT64
);
40 Count
= VA_ARG (Marker
, UINTN
);
41 Buffer
= VA_ARG (Marker
, UINT8
*);
43 return S3BootScriptSaveIoWrite (Width
, Address
, Count
, Buffer
);
46 Internal function to add IO read/write opcode to the table.
48 @param Marker The variable argument list to get the opcode
49 and associated attributes.
51 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
52 @retval EFI_SUCCESS Opcode is added.
56 BootScriptWriteIoReadWrite (
60 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
65 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
66 Address
= VA_ARG (Marker
, UINT64
);
67 Data
= VA_ARG (Marker
, UINT8
*);
68 DataMask
= VA_ARG (Marker
, UINT8
*);
70 return S3BootScriptSaveIoReadWrite (Width
, Address
, Data
, DataMask
);
74 Internal function to add memory write opcode to the table.
76 @param Marker The variable argument list to get the opcode
77 and associated attributes.
79 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
80 @retval EFI_SUCCESS Opcode is added.
84 BootScriptWriteMemWrite (
88 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
93 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
94 Address
= VA_ARG (Marker
, UINT64
);
95 Count
= VA_ARG (Marker
, UINTN
);
96 Buffer
= VA_ARG (Marker
, UINT8
*);
98 return S3BootScriptSaveMemWrite (Width
, Address
, Count
, Buffer
);
102 Internal function to add memory read/write opcode to the table.
104 @param Marker The variable argument list to get the opcode
105 and associated attributes.
107 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
108 @retval EFI_SUCCESS Opcode is added.
112 BootScriptWriteMemReadWrite (
116 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
121 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
122 Address
= VA_ARG (Marker
, UINT64
);
123 Data
= VA_ARG (Marker
, UINT8
*);
124 DataMask
= VA_ARG (Marker
, UINT8
*);
126 return S3BootScriptSaveMemReadWrite (Width
, Address
, Data
, DataMask
);
130 Internal function to add PciCfg write opcode to the table.
132 @param Marker The variable argument list to get the opcode
133 and associated attributes.
135 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
136 @retval EFI_SUCCESS Opcode is added.
140 BootScriptWritePciCfgWrite (
144 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
149 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
150 Address
= VA_ARG (Marker
, UINT64
);
151 Count
= VA_ARG (Marker
, UINTN
);
152 Buffer
= VA_ARG (Marker
, UINT8
*);
154 return S3BootScriptSavePciCfgWrite (Width
, Address
, Count
, Buffer
);
158 Internal function to PciCfg read/write opcode to the table.
160 @param Marker The variable argument list to get the opcode
161 and associated attributes.
163 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
164 @retval EFI_SUCCESS Opcode is added.
168 BootScriptWritePciCfgReadWrite (
172 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
177 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
178 Address
= VA_ARG (Marker
, UINT64
);
179 Data
= VA_ARG (Marker
, UINT8
*);
180 DataMask
= VA_ARG (Marker
, UINT8
*);
182 return S3BootScriptSavePciCfgReadWrite (Width
, Address
, Data
, DataMask
);
185 Internal function to add PciCfg2 write opcode to the table.
187 @param Marker The variable argument list to get the opcode
188 and associated attributes.
190 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
191 @retval EFI_SUCCESS Opcode is added.
195 BootScriptWritePciCfg2Write (
199 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
205 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
206 Segment
= VA_ARG (Marker
, UINT16
);
207 Address
= VA_ARG (Marker
, UINT64
);
208 Count
= VA_ARG (Marker
, UINTN
);
209 Buffer
= VA_ARG (Marker
, UINT8
*);
211 return S3BootScriptSavePciCfg2Write (Width
, Segment
, Address
, Count
, Buffer
);
215 Internal function to PciCfg2 read/write opcode to the table.
217 @param Marker The variable argument list to get the opcode
218 and associated attributes.
220 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
221 @retval EFI_SUCCESS Opcode is added.
225 BootScriptWritePciCfg2ReadWrite (
229 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
235 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
236 Segment
= VA_ARG (Marker
, UINT16
);
237 Address
= VA_ARG (Marker
, UINT64
);
238 Data
= VA_ARG (Marker
, UINT8
*);
239 DataMask
= VA_ARG (Marker
, UINT8
*);
241 return S3BootScriptSavePciCfg2ReadWrite (Width
, Segment
, Address
, Data
, DataMask
);
244 Internal function to add smbus execute opcode to the table.
246 @param Marker The variable argument list to get the opcode
247 and associated attributes.
249 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
250 @retval EFI_SUCCESS Opcode is added.
254 BootScriptWriteSmbusExecute (
258 EFI_SMBUS_DEVICE_ADDRESS SlaveAddress
;
259 EFI_SMBUS_DEVICE_COMMAND Command
;
260 EFI_SMBUS_OPERATION Operation
;
266 SlaveAddress
.SmbusDeviceAddress
= VA_ARG (Marker
, UINTN
);
267 Command
= VA_ARG (Marker
, EFI_SMBUS_DEVICE_COMMAND
);
268 Operation
= VA_ARG (Marker
, EFI_SMBUS_OPERATION
);
269 PecCheck
= VA_ARG (Marker
, BOOLEAN
);
270 SmBusAddress
= SMBUS_LIB_ADDRESS (SlaveAddress
.SmbusDeviceAddress
,Command
,0,PecCheck
);
271 DataSize
= VA_ARG (Marker
, UINTN
*);
272 Buffer
= VA_ARG (Marker
, VOID
*);
274 return S3BootScriptSaveSmbusExecute (SmBusAddress
, Operation
, DataSize
, Buffer
);
277 Internal function to add stall opcode to the table.
279 @param Marker The variable argument list to get the opcode
280 and associated attributes.
282 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
283 @retval EFI_SUCCESS Opcode is added.
287 BootScriptWriteStall (
293 Duration
= VA_ARG (Marker
, UINT32
);
295 return S3BootScriptSaveStall (Duration
);
299 Internal function to add Save jmp address according to DISPATCH_OPCODE.
300 We ignore "Context" parameter
302 @param Marker The variable argument list to get the opcode
303 and associated attributes.
305 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
306 @retval EFI_SUCCESS Opcode is added.
310 BootScriptWriteDispatch (
316 EntryPoint
= (VOID
*)(UINTN
)VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
317 return S3BootScriptSaveDispatch (EntryPoint
);
321 Internal function to add memory pool operation to the table.
323 @param Marker The variable argument list to get the opcode
324 and associated attributes.
326 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
327 @retval EFI_SUCCESS Opcode is added.
331 BootScriptWriteMemPoll (
335 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
343 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
344 Address
= VA_ARG (Marker
, UINT64
);
345 Data
= VA_ARG (Marker
, VOID
*);
346 DataMask
= VA_ARG (Marker
, VOID
*);
347 Delay
= VA_ARG (Marker
, UINT64
);
349 // According to the spec, the interval between 2 polls is 100ns,
350 // but the unit of Duration for S3BootScriptSaveMemPoll() is microsecond(1000ns).
351 // Duration * 1000ns * LoopTimes = Delay * 100ns
352 // Duration will be minimum 1(microsecond) to be minimum deviation,
353 // so LoopTimes = Delay / 10.
355 LoopTimes
= DivU64x32Remainder (
360 if (Remainder
!= 0) {
362 // If Remainder is not zero, LoopTimes will be rounded up by 1.
366 return S3BootScriptSaveMemPoll (Width
, Address
, DataMask
, Data
, 1, LoopTimes
);
371 Internal function to add Save jmp address according to DISPATCH_OPCODE2.
372 The "Context" parameter is not ignored.
374 @param Marker The variable argument list to get the opcode
375 and associated attributes.
377 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
378 @retval EFI_SUCCESS Opcode is added.
382 BootScriptWriteDispatch2 (
389 EntryPoint
= (VOID
*)(UINTN
)VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
390 Context
= (VOID
*)(UINTN
)VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
392 return S3BootScriptSaveDispatch2 (EntryPoint
, Context
);
395 Internal function to add INFORAMTION opcode node to the table
397 @param Marker The variable argument list to get the opcode
398 and associated attributes.
400 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
401 @retval EFI_SUCCESS The opcode entry is added to the table
405 BootScriptWriteInformation (
409 UINT32 InformationLength
;
410 EFI_PHYSICAL_ADDRESS Information
;
412 InformationLength
= VA_ARG (Marker
, UINT32
);
413 Information
= VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
414 return S3BootScriptSaveInformation (InformationLength
, (VOID
*)(UINTN
)Information
);
417 Internal function to add IO poll opcode node to the table
418 @param Marker The variable argument list to get the opcode
419 and associated attributes.
421 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
422 @retval EFI_SUCCESS The opcode entry is added to the table
426 BootScriptWriteIoPoll (
430 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
436 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
437 Address
= VA_ARG (Marker
, UINT64
);
438 Data
= VA_ARG (Marker
, VOID
*);
439 DataMask
= VA_ARG (Marker
, VOID
*);
440 Delay
= (UINT64
)VA_ARG (Marker
, UINT64
);
442 return S3BootScriptSaveIoPoll (Width
, Address
, Data
, DataMask
, Delay
);
445 Internal function to add PCI config poll opcode node to the table
447 @param Marker The variable argument list to get the opcode
448 and associated attributes.
450 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
451 @retval EFI_SUCCESS The opcode entry is added to the table
455 BootScriptWritePciConfigPoll (
459 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
466 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
467 Address
= VA_ARG (Marker
, UINT64
);
468 Data
= VA_ARG (Marker
, VOID
*);
469 DataMask
= VA_ARG (Marker
, VOID
*);
470 Delay
= (UINT64
)VA_ARG (Marker
, UINT64
);
472 return S3BootScriptSavePciPoll (Width
, Address
, Data
, DataMask
, Delay
);
475 Internal function to add PCI config 2 poll opcode node to the table
477 @param Marker The variable argument list to get the opcode
478 and associated attributes.
480 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
481 @retval EFI_SUCCESS The opcode entry is added to the table
485 BootScriptWritePciConfig2Poll (
489 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
496 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
497 Segment
= VA_ARG (Marker
, UINT16
);
498 Address
= VA_ARG (Marker
, UINT64
);
499 Data
= VA_ARG (Marker
, VOID
*);
500 DataMask
= VA_ARG (Marker
, VOID
*);
501 Delay
= (UINT64
)VA_ARG (Marker
, UINT64
);
503 return S3BootScriptSavePci2Poll (Width
, Segment
, Address
, Data
, DataMask
, Delay
);
508 Adds a record into S3 boot script table.
510 This function is used to store a boot script record into a given boot
511 script table. If the table specified by TableName is nonexistent in the
512 system, a new table will automatically be created and then the script record
513 will be added into the new table. This function is responsible for allocating
514 necessary memory for the script.
516 This function has a variable parameter list. The exact parameter list depends on
517 the OpCode that is passed into the function. If an unsupported OpCode or illegal
518 parameter list is passed in, this function returns EFI_INVALID_PARAMETER.
519 If there are not enough resources available for storing more scripts, this function returns
520 EFI_OUT_OF_RESOURCES.
522 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
523 @param OpCode The operation code (opcode) number.
524 @param ... Argument list that is specific to each opcode.
526 @retval EFI_SUCCESS The operation succeeded. A record was added into the
527 specified script table.
528 @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.
529 If the opcode is unknow or not supported because of the PCD
531 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
537 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
545 // Build script according to opcode
549 case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE
:
550 VA_START (Marker
, OpCode
);
551 Status
= BootScriptWriteIoWrite (Marker
);
555 case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE
:
556 VA_START (Marker
, OpCode
);
557 Status
= BootScriptWriteIoReadWrite (Marker
);
561 case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE
:
562 VA_START (Marker
, OpCode
);
563 Status
= BootScriptWriteMemWrite (Marker
);
567 case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE
:
568 VA_START (Marker
, OpCode
);
569 Status
= BootScriptWriteMemReadWrite (Marker
);
573 case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE
:
574 VA_START (Marker
, OpCode
);
575 Status
= BootScriptWritePciCfgWrite (Marker
);
579 case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE
:
580 VA_START (Marker
, OpCode
);
581 Status
= BootScriptWritePciCfgReadWrite (Marker
);
585 case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE
:
586 VA_START (Marker
, OpCode
);
587 Status
= BootScriptWriteSmbusExecute (Marker
);
591 case EFI_BOOT_SCRIPT_STALL_OPCODE
:
592 VA_START (Marker
, OpCode
);
593 Status
= BootScriptWriteStall (Marker
);
598 case EFI_BOOT_SCRIPT_DISPATCH_OPCODE
:
599 VA_START (Marker
, OpCode
);
600 Status
= BootScriptWriteDispatch (Marker
);
604 case EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE
:
605 VA_START (Marker
, OpCode
);
606 Status
= BootScriptWriteDispatch2 (Marker
);
610 case EFI_BOOT_SCRIPT_INFORMATION_OPCODE
:
611 VA_START (Marker
, OpCode
);
612 Status
= BootScriptWriteInformation (Marker
);
616 case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE
:
617 VA_START (Marker
, OpCode
);
618 Status
= BootScriptWriteMemPoll (Marker
);
622 case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE
:
623 VA_START (Marker
, OpCode
);
624 Status
= BootScriptWritePciCfg2Write (Marker
);
628 case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE
:
629 VA_START (Marker
, OpCode
);
630 Status
= BootScriptWritePciCfg2ReadWrite (Marker
);
634 case EFI_BOOT_SCRIPT_IO_POLL_OPCODE
:
635 VA_START (Marker
, OpCode
);
636 Status
= BootScriptWriteIoPoll (Marker
);
640 case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE
:
641 VA_START (Marker
, OpCode
);
642 Status
= BootScriptWritePciConfigPoll (Marker
);
646 case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE
:
647 VA_START (Marker
, OpCode
);
648 Status
= BootScriptWritePciConfig2Poll (Marker
);
653 Status
= EFI_INVALID_PARAMETER
;
660 Insert a record into a specified Framework boot script table.
662 This function is used to store an OpCode to be replayed as part of the S3 resume boot path. It is
663 assumed this protocol has platform specific mechanism to store the OpCode set and replay them
664 during the S3 resume.
665 The opcode is inserted before or after the specified position in the boot script table. If Position is
666 NULL then that position is after the last opcode in the table (BeforeOrAfter is FALSE) or before
667 the first opcode in the table (BeforeOrAfter is TRUE). The position which is pointed to by
668 Position upon return can be used for subsequent insertions.
670 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
671 @param BeforeOrAfter Specifies whether the opcode is stored before (TRUE) or after (FALSE) the position
672 in the boot script table specified by Position. If Position is NULL or points to
673 NULL then the new opcode is inserted at the beginning of the table (if TRUE) or end
674 of the table (if FALSE).
675 @param Position On entry, specifies the position in the boot script table where the opcode will be
676 inserted, either before or after, depending on BeforeOrAfter. On exit, specifies
677 the position of the inserted opcode in the boot script table.
678 @param OpCode The operation code (opcode) number.
679 @param ... Argument list that is specific to each opcode.
681 @retval EFI_SUCCESS The operation succeeded. A record was added into the
682 specified script table.
683 @retval EFI_INVALID_PARAMETER The Opcode is an invalid opcode value or the Position is not a valid position in the boot script table..
684 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
690 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
691 IN BOOLEAN BeforeOrAfter
,
692 IN OUT EFI_S3_BOOT_SCRIPT_POSITION
*Position OPTIONAL
,
700 // Build script according to opcode
704 case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE
:
705 VA_START (Marker
, OpCode
);
706 Status
= BootScriptWriteIoWrite (Marker
);
710 case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE
:
711 VA_START (Marker
, OpCode
);
712 Status
= BootScriptWriteIoReadWrite (Marker
);
716 case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE
:
717 VA_START (Marker
, OpCode
);
718 Status
= BootScriptWriteMemWrite (Marker
);
722 case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE
:
723 VA_START (Marker
, OpCode
);
724 Status
= BootScriptWriteMemReadWrite (Marker
);
728 case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE
:
729 VA_START (Marker
, OpCode
);
730 Status
= BootScriptWritePciCfgWrite (Marker
);
734 case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE
:
735 VA_START (Marker
, OpCode
);
736 Status
= BootScriptWritePciCfgReadWrite (Marker
);
740 case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE
:
741 VA_START (Marker
, OpCode
);
742 Status
= BootScriptWriteSmbusExecute (Marker
);
746 case EFI_BOOT_SCRIPT_STALL_OPCODE
:
747 VA_START (Marker
, OpCode
);
748 Status
= BootScriptWriteStall (Marker
);
753 case EFI_BOOT_SCRIPT_DISPATCH_OPCODE
:
754 VA_START (Marker
, OpCode
);
755 Status
= BootScriptWriteDispatch (Marker
);
759 case EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE
:
760 VA_START (Marker
, OpCode
);
761 Status
= BootScriptWriteDispatch2 (Marker
);
765 case EFI_BOOT_SCRIPT_INFORMATION_OPCODE
:
766 VA_START (Marker
, OpCode
);
767 Status
= BootScriptWriteInformation (Marker
);
771 case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE
:
772 VA_START (Marker
, OpCode
);
773 Status
= BootScriptWriteMemPoll (Marker
);
777 case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE
:
778 VA_START (Marker
, OpCode
);
779 Status
= BootScriptWritePciCfg2Write (Marker
);
783 case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE
:
784 VA_START (Marker
, OpCode
);
785 Status
= BootScriptWritePciCfg2ReadWrite (Marker
);
789 case EFI_BOOT_SCRIPT_IO_POLL_OPCODE
:
790 VA_START (Marker
, OpCode
);
791 Status
= BootScriptWriteIoPoll (Marker
);
795 case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE
:
796 VA_START (Marker
, OpCode
);
797 Status
= BootScriptWritePciConfigPoll (Marker
);
801 case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE
:
802 VA_START (Marker
, OpCode
);
803 Status
= BootScriptWritePciConfig2Poll (Marker
);
808 Status
= EFI_INVALID_PARAMETER
;
812 if (!EFI_ERROR (Status
)) {
813 Status
= S3BootScriptMoveLastOpcode (BeforeOrAfter
, (VOID
**)Position
);
818 Find a label within the boot script table and, if not present, optionally create it.
820 If the label Label is already exists in the boot script table, then no new label is created, the
821 position of the Label is returned in *Position and EFI_SUCCESS is returned.
822 If the label Label does not already exist and CreateIfNotFound is TRUE, then it will be
823 created before or after the specified position and EFI_SUCCESS is returned.
824 If the label Label does not already exist and CreateIfNotFound is FALSE, then
825 EFI_NOT_FOUND is returned.
827 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
828 @param BeforeOrAfter Specifies whether the label is stored before (TRUE) or after (FALSE) the position in
829 the boot script table specified by Position. If Position is NULL or points to
830 NULL then the new label is inserted at the beginning of the table (if TRUE) or end of
831 the table (if FALSE).
832 @param CreateIfNotFound Specifies whether the label will be created if the label does not exists (TRUE) or not
834 @param Position On entry, specifies the position in the boot script table where the label will be inserted,
835 either before or after, depending on BeforeOrAfter. On exit, specifies the position
836 of the inserted label in the boot script table.
837 @param Label Points to the label which will be inserted in the boot script table.
839 @retval EFI_SUCCESS The label already exists or was inserted.
840 @retval EFI_INVALID_PARAMETER The Label is NULL or points to an empty string.
841 @retval EFI_INVALID_PARAMETER The Position is not a valid position in the boot script table.
847 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
848 IN BOOLEAN BeforeOrAfter
,
849 IN BOOLEAN CreateIfNotFound
,
850 IN OUT EFI_S3_BOOT_SCRIPT_POSITION
*Position OPTIONAL
,
851 IN CONST CHAR8
*Label
854 return S3BootScriptLabel (BeforeOrAfter
, CreateIfNotFound
, (VOID
**)Position
, Label
);
857 Compare two positions in the boot script table and return their relative position.
859 This function compares two positions in the boot script table and returns their relative positions. If
860 Position1 is before Position2, then -1 is returned. If Position1 is equal to Position2,
861 then 0 is returned. If Position1 is after Position2, then 1 is returned.
863 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
864 @param Position1 The positions in the boot script table to compare
865 @param Position2 The positions in the boot script table to compare
866 @param RelativePosition On return, points to the result of the comparison
868 @retval EFI_SUCCESS The operation succeeded.
869 @retval EFI_INVALID_PARAMETER The Position1 or Position2 is not a valid position in the boot script table.
870 @retval EFI_INVALID_PARAMETER The RelativePosition is NULL.
876 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
877 IN EFI_S3_BOOT_SCRIPT_POSITION Position1
,
878 IN EFI_S3_BOOT_SCRIPT_POSITION Position2
,
879 OUT UINTN
*RelativePosition
882 return S3BootScriptCompare (Position1
, Position2
, RelativePosition
);
885 This routine is entry point of ScriptSave driver.
887 @param ImageHandle Handle for this drivers loaded image protocol.
888 @param SystemTable EFI system table.
890 @retval EFI_OUT_OF_RESOURCES No enough resource
891 @retval EFI_SUCCESS Succesfully installed the ScriptSave driver.
892 @retval other Errors occurred.
897 InitializeS3SaveState (
898 IN EFI_HANDLE ImageHandle
,
899 IN EFI_SYSTEM_TABLE
*SystemTable
903 EFI_EVENT EndOfDxeEvent
;
905 if (!PcdGetBool (PcdAcpiS3Enable
)) {
906 return EFI_UNSUPPORTED
;
909 Status
= gBS
->CreateEventEx (
912 AcpiS3ContextSaveOnEndOfDxe
,
914 &gEfiEndOfDxeEventGroupGuid
,
917 ASSERT_EFI_ERROR (Status
);
919 return gBS
->InstallProtocolInterface (
921 &gEfiS3SaveStateProtocolGuid
,
922 EFI_NATIVE_INTERFACE
,