2 Implementation for S3 SMM Boot Script Saver state driver.
4 Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "InternalSmmSaveState.h"
11 EFI_S3_SMM_SAVE_STATE_PROTOCOL mS3SmmSaveState
= {
18 Internal function to add IO write opcode to the table.
20 @param Marker The variable argument list to get the opcode
21 and associated attributes.
23 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
24 @retval EFI_SUCCESS Opcode is added.
28 BootScriptWriteIoWrite (
32 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
37 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
38 Address
= VA_ARG (Marker
, UINT64
);
39 Count
= VA_ARG (Marker
, UINTN
);
40 Buffer
= VA_ARG (Marker
, UINT8
*);
42 return S3BootScriptSaveIoWrite (Width
, Address
, Count
, Buffer
);
45 Internal function to add IO read/write opcode to the table.
47 @param Marker The variable argument list to get the opcode
48 and associated attributes.
50 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
51 @retval EFI_SUCCESS Opcode is added.
55 BootScriptWriteIoReadWrite (
59 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
64 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
65 Address
= VA_ARG (Marker
, UINT64
);
66 Data
= VA_ARG (Marker
, UINT8
*);
67 DataMask
= VA_ARG (Marker
, UINT8
*);
69 return S3BootScriptSaveIoReadWrite (Width
, Address
, Data
, DataMask
);
73 Internal function to add memory write opcode to the table.
75 @param Marker The variable argument list to get the opcode
76 and associated attributes.
78 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
79 @retval EFI_SUCCESS Opcode is added.
83 BootScriptWriteMemWrite (
87 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
92 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
93 Address
= VA_ARG (Marker
, UINT64
);
94 Count
= VA_ARG (Marker
, UINTN
);
95 Buffer
= VA_ARG (Marker
, UINT8
*);
97 return S3BootScriptSaveMemWrite (Width
, Address
, Count
, Buffer
);
101 Internal function to add memory read/write opcode to the table.
103 @param Marker The variable argument list to get the opcode
104 and associated attributes.
106 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
107 @retval EFI_SUCCESS Opcode is added.
111 BootScriptWriteMemReadWrite (
115 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
120 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
121 Address
= VA_ARG (Marker
, UINT64
);
122 Data
= VA_ARG (Marker
, UINT8
*);
123 DataMask
= VA_ARG (Marker
, UINT8
*);
125 return S3BootScriptSaveMemReadWrite (Width
, Address
, Data
, DataMask
);
129 Internal function to add PciCfg write opcode to the table.
131 @param Marker The variable argument list to get the opcode
132 and associated attributes.
134 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
135 @retval EFI_SUCCESS Opcode is added.
139 BootScriptWritePciCfgWrite (
143 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
148 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
149 Address
= VA_ARG (Marker
, UINT64
);
150 Count
= VA_ARG (Marker
, UINTN
);
151 Buffer
= VA_ARG (Marker
, UINT8
*);
153 return S3BootScriptSavePciCfgWrite (Width
, Address
, Count
, Buffer
);
157 Internal function to PciCfg read/write opcode to the table.
159 @param Marker The variable argument list to get the opcode
160 and associated attributes.
162 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
163 @retval EFI_SUCCESS Opcode is added.
167 BootScriptWritePciCfgReadWrite (
171 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
176 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
177 Address
= VA_ARG (Marker
, UINT64
);
178 Data
= VA_ARG (Marker
, UINT8
*);
179 DataMask
= VA_ARG (Marker
, UINT8
*);
181 return S3BootScriptSavePciCfgReadWrite (Width
, Address
, Data
, DataMask
);
184 Internal function to add PciCfg2 write opcode to the table.
186 @param Marker The variable argument list to get the opcode
187 and associated attributes.
189 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
190 @retval EFI_SUCCESS Opcode is added.
194 BootScriptWritePciCfg2Write (
198 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
204 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
205 Segment
= VA_ARG (Marker
, UINT16
);
206 Address
= VA_ARG (Marker
, UINT64
);
207 Count
= VA_ARG (Marker
, UINTN
);
208 Buffer
= VA_ARG (Marker
, UINT8
*);
210 return S3BootScriptSavePciCfg2Write (Width
, Segment
, Address
, Count
, Buffer
);
214 Internal function to PciCfg2 read/write opcode to the table.
216 @param Marker The variable argument list to get the opcode
217 and associated attributes.
219 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
220 @retval EFI_SUCCESS Opcode is added.
224 BootScriptWritePciCfg2ReadWrite (
228 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
234 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
235 Segment
= VA_ARG (Marker
, UINT16
);
236 Address
= VA_ARG (Marker
, UINT64
);
237 Data
= VA_ARG (Marker
, UINT8
*);
238 DataMask
= VA_ARG (Marker
, UINT8
*);
240 return S3BootScriptSavePciCfg2ReadWrite (Width
, Segment
, Address
, Data
, DataMask
);
243 Internal function to add smbus execute opcode to the table.
245 @param Marker The variable argument list to get the opcode
246 and associated attributes.
248 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
249 @retval EFI_SUCCESS Opcode is added.
253 BootScriptWriteSmbusExecute (
257 EFI_SMBUS_DEVICE_ADDRESS SlaveAddress
;
258 EFI_SMBUS_DEVICE_COMMAND Command
;
259 EFI_SMBUS_OPERATION Operation
;
265 SlaveAddress
.SmbusDeviceAddress
= VA_ARG (Marker
, UINTN
);
266 Command
= VA_ARG (Marker
, EFI_SMBUS_DEVICE_COMMAND
);
267 Operation
= VA_ARG (Marker
, EFI_SMBUS_OPERATION
);
268 PecCheck
= VA_ARG (Marker
, BOOLEAN
);
269 SmBusAddress
= SMBUS_LIB_ADDRESS (SlaveAddress
.SmbusDeviceAddress
,Command
,0,PecCheck
);
270 DataSize
= VA_ARG (Marker
, UINTN
*);
271 Buffer
= VA_ARG (Marker
, VOID
*);
273 return S3BootScriptSaveSmbusExecute (SmBusAddress
, Operation
, DataSize
, Buffer
);
276 Internal function to add stall opcode to the table.
278 @param Marker The variable argument list to get the opcode
279 and associated attributes.
281 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
282 @retval EFI_SUCCESS Opcode is added.
286 BootScriptWriteStall (
292 Duration
= VA_ARG (Marker
, UINT32
);
294 return S3BootScriptSaveStall (Duration
);
298 Internal function to add Save jmp address according to DISPATCH_OPCODE.
299 We ignore "Context" parameter
301 @param Marker The variable argument list to get the opcode
302 and associated attributes.
304 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
305 @retval EFI_SUCCESS Opcode is added.
309 BootScriptWriteDispatch (
315 EntryPoint
= (VOID
*)(UINTN
)VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
316 return S3BootScriptSaveDispatch (EntryPoint
);
320 Internal function to add memory pool operation to the table.
322 @param Marker The variable argument list to get the opcode
323 and associated attributes.
325 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
326 @retval EFI_SUCCESS Opcode is added.
330 BootScriptWriteMemPoll (
334 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
342 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
343 Address
= VA_ARG (Marker
, UINT64
);
344 Data
= VA_ARG (Marker
, VOID
*);
345 DataMask
= VA_ARG (Marker
, VOID
*);
346 Delay
= VA_ARG (Marker
, UINT64
);
348 // According to the spec, the interval between 2 polls is 100ns,
349 // but the unit of Duration for S3BootScriptSaveMemPoll() is microsecond(1000ns).
350 // Duration * 1000ns * LoopTimes = Delay * 100ns
351 // Duration will be minimum 1(microsecond) to be minimum deviation,
352 // so LoopTimes = Delay / 10.
354 LoopTimes
= DivU64x32Remainder (
359 if (Remainder
!= 0) {
361 // If Remainder is not zero, LoopTimes will be rounded up by 1.
365 return S3BootScriptSaveMemPoll (Width
, Address
, DataMask
, Data
, 1, LoopTimes
);
370 Internal function to add Save jmp address according to DISPATCH_OPCODE2.
371 The "Context" parameter is not ignored.
373 @param Marker The variable argument list to get the opcode
374 and associated attributes.
376 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
377 @retval EFI_SUCCESS Opcode is added.
381 BootScriptWriteDispatch2 (
388 EntryPoint
= (VOID
*)(UINTN
)VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
389 Context
= (VOID
*)(UINTN
)VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
391 return S3BootScriptSaveDispatch2 (EntryPoint
, Context
);
394 Internal function to add INFORAMTION opcode node to the table
396 @param Marker The variable argument list to get the opcode
397 and associated attributes.
399 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
400 @retval EFI_SUCCESS The opcode entry is added to the table
404 BootScriptWriteInformation (
408 UINT32 InformationLength
;
409 EFI_PHYSICAL_ADDRESS Information
;
411 InformationLength
= VA_ARG (Marker
, UINT32
);
412 Information
= VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
413 return S3BootScriptSaveInformation (InformationLength
, (VOID
*)(UINTN
)Information
);
416 Internal function to add IO poll opcode node to the table
417 @param Marker The variable argument list to get the opcode
418 and associated attributes.
420 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
421 @retval EFI_SUCCESS The opcode entry is added to the table
425 BootScriptWriteIoPoll (
429 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
435 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
436 Address
= VA_ARG (Marker
, UINT64
);
437 Data
= VA_ARG (Marker
, VOID
*);
438 DataMask
= VA_ARG (Marker
, VOID
*);
439 Delay
= (UINT64
)VA_ARG (Marker
, UINT64
);
441 return S3BootScriptSaveIoPoll (Width
, Address
, Data
, DataMask
, Delay
);
444 Internal function to add PCI config poll opcode node to the table
446 @param Marker The variable argument list to get the opcode
447 and associated attributes.
449 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
450 @retval EFI_SUCCESS The opcode entry is added to the table
454 BootScriptWritePciConfigPoll (
458 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
465 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
466 Address
= VA_ARG (Marker
, UINT64
);
467 Data
= VA_ARG (Marker
, VOID
*);
468 DataMask
= VA_ARG (Marker
, VOID
*);
469 Delay
= (UINT64
)VA_ARG (Marker
, UINT64
);
471 return S3BootScriptSavePciPoll (Width
, Address
, Data
, DataMask
, Delay
);
474 Internal function to add PCI config 2 poll opcode node to the table
476 @param Marker The variable argument list to get the opcode
477 and associated attributes.
479 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
480 @retval EFI_SUCCESS The opcode entry is added to the table
484 BootScriptWritePciConfig2Poll (
488 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
495 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
496 Segment
= VA_ARG (Marker
, UINT16
);
497 Address
= VA_ARG (Marker
, UINT64
);
498 Data
= VA_ARG (Marker
, VOID
*);
499 DataMask
= VA_ARG (Marker
, VOID
*);
500 Delay
= (UINT64
)VA_ARG (Marker
, UINT64
);
502 return S3BootScriptSavePci2Poll (Width
, Segment
, Address
, Data
, DataMask
, Delay
);
506 Adds a record into S3 boot script table.
508 This function is used to store a boot script record into a given boot
509 script table. If the table specified by TableName is nonexistent in the
510 system, a new table will automatically be created and then the script record
511 will be added into the new table. This function is responsible for allocating
512 necessary memory for the script.
514 This function has a variable parameter list. The exact parameter list depends on
515 the OpCode that is passed into the function. If an unsupported OpCode or illegal
516 parameter list is passed in, this function returns EFI_INVALID_PARAMETER.
517 If there are not enough resources available for storing more scripts, this function returns
518 EFI_OUT_OF_RESOURCES.
520 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
521 @param OpCode The operation code (opcode) number.
522 @param ... Argument list that is specific to each opcode.
524 @retval EFI_SUCCESS The operation succeeded. A record was added into the
525 specified script table.
526 @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.
527 If the opcode is unknow or not supported because of the PCD
529 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
535 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
543 // Build script according to opcode
547 case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE
:
548 VA_START (Marker
, OpCode
);
549 Status
= BootScriptWriteIoWrite (Marker
);
553 case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE
:
554 VA_START (Marker
, OpCode
);
555 Status
= BootScriptWriteIoReadWrite (Marker
);
559 case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE
:
560 VA_START (Marker
, OpCode
);
561 Status
= BootScriptWriteMemWrite (Marker
);
565 case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE
:
566 VA_START (Marker
, OpCode
);
567 Status
= BootScriptWriteMemReadWrite (Marker
);
571 case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE
:
572 VA_START (Marker
, OpCode
);
573 Status
= BootScriptWritePciCfgWrite (Marker
);
577 case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE
:
578 VA_START (Marker
, OpCode
);
579 Status
= BootScriptWritePciCfgReadWrite (Marker
);
583 case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE
:
584 VA_START (Marker
, OpCode
);
585 Status
= BootScriptWriteSmbusExecute (Marker
);
589 case EFI_BOOT_SCRIPT_STALL_OPCODE
:
590 VA_START (Marker
, OpCode
);
591 Status
= BootScriptWriteStall (Marker
);
596 case EFI_BOOT_SCRIPT_DISPATCH_OPCODE
:
597 VA_START (Marker
, OpCode
);
598 Status
= BootScriptWriteDispatch (Marker
);
602 case EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE
:
603 VA_START (Marker
, OpCode
);
604 Status
= BootScriptWriteDispatch2 (Marker
);
608 case EFI_BOOT_SCRIPT_INFORMATION_OPCODE
:
609 VA_START (Marker
, OpCode
);
610 Status
= BootScriptWriteInformation (Marker
);
614 case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE
:
615 VA_START (Marker
, OpCode
);
616 Status
= BootScriptWriteMemPoll (Marker
);
620 case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE
:
621 VA_START (Marker
, OpCode
);
622 Status
= BootScriptWritePciCfg2Write (Marker
);
626 case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE
:
627 VA_START (Marker
, OpCode
);
628 Status
= BootScriptWritePciCfg2ReadWrite (Marker
);
632 case EFI_BOOT_SCRIPT_IO_POLL_OPCODE
:
633 VA_START (Marker
, OpCode
);
634 Status
= BootScriptWriteIoPoll (Marker
);
638 case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE
:
639 VA_START (Marker
, OpCode
);
640 Status
= BootScriptWritePciConfigPoll (Marker
);
644 case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE
:
645 VA_START (Marker
, OpCode
);
646 Status
= BootScriptWritePciConfig2Poll (Marker
);
651 Status
= EFI_INVALID_PARAMETER
;
658 Insert a record into a specified Framework boot script table.
660 This function is used to store an OpCode to be replayed as part of the S3 resume boot path. It is
661 assumed this protocol has platform specific mechanism to store the OpCode set and replay them
662 during the S3 resume.
663 The opcode is inserted before or after the specified position in the boot script table. If Position is
664 NULL then that position is after the last opcode in the table (BeforeOrAfter is FALSE) or before
665 the first opcode in the table (BeforeOrAfter is TRUE). The position which is pointed to by
666 Position upon return can be used for subsequent insertions.
668 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
669 @param BeforeOrAfter Specifies whether the opcode is stored before (TRUE) or after (FALSE) the position
670 in the boot script table specified by Position. If Position is NULL or points to
671 NULL then the new opcode is inserted at the beginning of the table (if TRUE) or end
672 of the table (if FALSE).
673 @param Position On entry, specifies the position in the boot script table where the opcode will be
674 inserted, either before or after, depending on BeforeOrAfter. On exit, specifies
675 the position of the inserted opcode in the boot script table.
676 @param OpCode The operation code (opcode) number.
677 @param ... Argument list that is specific to each opcode.
679 @retval EFI_SUCCESS The operation succeeded. A record was added into the
680 specified script table.
681 @retval EFI_INVALID_PARAMETER The Opcode is an invalid opcode value or the Position is not a valid position in the boot script table..
682 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
688 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
689 IN BOOLEAN BeforeOrAfter
,
690 IN OUT EFI_S3_BOOT_SCRIPT_POSITION
*Position OPTIONAL
,
698 // Build script according to opcode
702 case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE
:
703 VA_START (Marker
, OpCode
);
704 Status
= BootScriptWriteIoWrite (Marker
);
708 case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE
:
709 VA_START (Marker
, OpCode
);
710 Status
= BootScriptWriteIoReadWrite (Marker
);
714 case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE
:
715 VA_START (Marker
, OpCode
);
716 Status
= BootScriptWriteMemWrite (Marker
);
720 case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE
:
721 VA_START (Marker
, OpCode
);
722 Status
= BootScriptWriteMemReadWrite (Marker
);
726 case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE
:
727 VA_START (Marker
, OpCode
);
728 Status
= BootScriptWritePciCfgWrite (Marker
);
732 case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE
:
733 VA_START (Marker
, OpCode
);
734 Status
= BootScriptWritePciCfgReadWrite (Marker
);
738 case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE
:
739 VA_START (Marker
, OpCode
);
740 Status
= BootScriptWriteSmbusExecute (Marker
);
744 case EFI_BOOT_SCRIPT_STALL_OPCODE
:
745 VA_START (Marker
, OpCode
);
746 Status
= BootScriptWriteStall (Marker
);
751 case EFI_BOOT_SCRIPT_DISPATCH_OPCODE
:
752 VA_START (Marker
, OpCode
);
753 Status
= BootScriptWriteDispatch (Marker
);
757 case EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE
:
758 VA_START (Marker
, OpCode
);
759 Status
= BootScriptWriteDispatch2 (Marker
);
763 case EFI_BOOT_SCRIPT_INFORMATION_OPCODE
:
764 VA_START (Marker
, OpCode
);
765 Status
= BootScriptWriteInformation (Marker
);
769 case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE
:
770 VA_START (Marker
, OpCode
);
771 Status
= BootScriptWriteMemPoll (Marker
);
775 case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE
:
776 VA_START (Marker
, OpCode
);
777 Status
= BootScriptWritePciCfg2Write (Marker
);
781 case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE
:
782 VA_START (Marker
, OpCode
);
783 Status
= BootScriptWritePciCfg2ReadWrite (Marker
);
787 case EFI_BOOT_SCRIPT_IO_POLL_OPCODE
:
788 VA_START (Marker
, OpCode
);
789 Status
= BootScriptWriteIoPoll (Marker
);
793 case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE
:
794 VA_START (Marker
, OpCode
);
795 Status
= BootScriptWritePciConfigPoll (Marker
);
799 case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE
:
800 VA_START (Marker
, OpCode
);
801 Status
= BootScriptWritePciConfig2Poll (Marker
);
806 Status
= EFI_INVALID_PARAMETER
;
810 if (!EFI_ERROR (Status
)) {
811 Status
= S3BootScriptMoveLastOpcode (BeforeOrAfter
, (VOID
**)Position
);
816 Find a label within the boot script table and, if not present, optionally create it.
818 If the label Label is already exists in the boot script table, then no new label is created, the
819 position of the Label is returned in *Position and EFI_SUCCESS is returned.
820 If the label Label does not already exist and CreateIfNotFound is TRUE, then it will be
821 created before or after the specified position and EFI_SUCCESS is returned.
822 If the label Label does not already exist and CreateIfNotFound is FALSE, then
823 EFI_NOT_FOUND is returned.
825 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
826 @param BeforeOrAfter Specifies whether the label is stored before (TRUE) or after (FALSE) the position in
827 the boot script table specified by Position. If Position is NULL or points to
828 NULL then the new label is inserted at the beginning of the table (if TRUE) or end of
829 the table (if FALSE).
830 @param CreateIfNotFound Specifies whether the label will be created if the label does not exists (TRUE) or not
832 @param Position On entry, specifies the position in the boot script table where the label will be inserted,
833 either before or after, depending on BeforeOrAfter. On exit, specifies the position
834 of the inserted label in the boot script table.
835 @param Label Points to the label which will be inserted in the boot script table.
837 @retval EFI_SUCCESS The label already exists or was inserted.
838 @retval EFI_INVALID_PARAMETER The Label is NULL or points to an empty string.
839 @retval EFI_INVALID_PARAMETER The Position is not a valid position in the boot script table.
845 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
846 IN BOOLEAN BeforeOrAfter
,
847 IN BOOLEAN CreateIfNotFound
,
848 IN OUT EFI_S3_BOOT_SCRIPT_POSITION
*Position OPTIONAL
,
849 IN CONST CHAR8
*Label
852 return S3BootScriptLabel (BeforeOrAfter
, CreateIfNotFound
, (VOID
**)Position
, Label
);
855 Compare two positions in the boot script table and return their relative position.
857 This function compares two positions in the boot script table and returns their relative positions. If
858 Position1 is before Position2, then -1 is returned. If Position1 is equal to Position2,
859 then 0 is returned. If Position1 is after Position2, then 1 is returned.
861 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
862 @param Position1 The positions in the boot script table to compare
863 @param Position2 The positions in the boot script table to compare
864 @param RelativePosition On return, points to the result of the comparison
866 @retval EFI_SUCCESS The operation succeeded.
867 @retval EFI_INVALID_PARAMETER The Position1 or Position2 is not a valid position in the boot script table.
868 @retval EFI_INVALID_PARAMETER The RelativePosition is NULL.
874 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
875 IN EFI_S3_BOOT_SCRIPT_POSITION Position1
,
876 IN EFI_S3_BOOT_SCRIPT_POSITION Position2
,
877 OUT UINTN
*RelativePosition
880 return S3BootScriptCompare (Position1
, Position2
, RelativePosition
);
883 This routine is entry point of ScriptSave driver.
885 @param ImageHandle Handle for this drivers loaded image protocol.
886 @param SystemTable EFI system table.
888 @retval EFI_OUT_OF_RESOURCES No enough resource
889 @retval EFI_SUCCESS Succesfully installed the ScriptSave driver.
890 @retval other Errors occurred.
895 InitializeSmmS3SaveState (
896 IN EFI_HANDLE ImageHandle
,
897 IN EFI_SYSTEM_TABLE
*SystemTable
902 if (!PcdGetBool (PcdAcpiS3Enable
)) {
903 return EFI_UNSUPPORTED
;
907 return gSmst
->SmmInstallProtocolInterface (
909 &gEfiS3SmmSaveStateProtocolGuid
,
910 EFI_NATIVE_INTERFACE
,