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
= {
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
);
47 Internal function to add IO read/write opcode to the table.
49 @param Marker The variable argument list to get the opcode
50 and associated attributes.
52 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
53 @retval EFI_SUCCESS Opcode is added.
57 BootScriptWriteIoReadWrite (
61 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
66 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
67 Address
= VA_ARG (Marker
, UINT64
);
68 Data
= VA_ARG (Marker
, UINT8
*);
69 DataMask
= VA_ARG (Marker
, UINT8
*);
71 return S3BootScriptSaveIoReadWrite (Width
, Address
, Data
, DataMask
);
75 Internal function to add memory write opcode to the table.
77 @param Marker The variable argument list to get the opcode
78 and associated attributes.
80 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
81 @retval EFI_SUCCESS Opcode is added.
85 BootScriptWriteMemWrite (
89 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
94 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
95 Address
= VA_ARG (Marker
, UINT64
);
96 Count
= VA_ARG (Marker
, UINTN
);
97 Buffer
= VA_ARG (Marker
, UINT8
*);
99 return S3BootScriptSaveMemWrite (Width
, Address
, Count
, Buffer
);
103 Internal function to add memory read/write opcode to the table.
105 @param Marker The variable argument list to get the opcode
106 and associated attributes.
108 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
109 @retval EFI_SUCCESS Opcode is added.
113 BootScriptWriteMemReadWrite (
117 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
122 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
123 Address
= VA_ARG (Marker
, UINT64
);
124 Data
= VA_ARG (Marker
, UINT8
*);
125 DataMask
= VA_ARG (Marker
, UINT8
*);
127 return S3BootScriptSaveMemReadWrite (Width
, Address
, Data
, DataMask
);
131 Internal function to add PciCfg write opcode to the table.
133 @param Marker The variable argument list to get the opcode
134 and associated attributes.
136 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
137 @retval EFI_SUCCESS Opcode is added.
141 BootScriptWritePciCfgWrite (
145 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
150 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
151 Address
= VA_ARG (Marker
, UINT64
);
152 Count
= VA_ARG (Marker
, UINTN
);
153 Buffer
= VA_ARG (Marker
, UINT8
*);
155 return S3BootScriptSavePciCfgWrite (Width
, Address
, Count
, Buffer
);
159 Internal function to PciCfg read/write opcode to the table.
161 @param Marker The variable argument list to get the opcode
162 and associated attributes.
164 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
165 @retval EFI_SUCCESS Opcode is added.
169 BootScriptWritePciCfgReadWrite (
173 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
178 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
179 Address
= VA_ARG (Marker
, UINT64
);
180 Data
= VA_ARG (Marker
, UINT8
*);
181 DataMask
= VA_ARG (Marker
, UINT8
*);
183 return S3BootScriptSavePciCfgReadWrite (Width
, Address
, Data
, DataMask
);
187 Internal function to add PciCfg2 write opcode to the table.
189 @param Marker The variable argument list to get the opcode
190 and associated attributes.
192 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
193 @retval EFI_SUCCESS Opcode is added.
197 BootScriptWritePciCfg2Write (
201 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
207 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
208 Segment
= VA_ARG (Marker
, UINT16
);
209 Address
= VA_ARG (Marker
, UINT64
);
210 Count
= VA_ARG (Marker
, UINTN
);
211 Buffer
= VA_ARG (Marker
, UINT8
*);
213 return S3BootScriptSavePciCfg2Write (Width
, Segment
, Address
, Count
, Buffer
);
217 Internal function to PciCfg2 read/write opcode to the table.
219 @param Marker The variable argument list to get the opcode
220 and associated attributes.
222 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
223 @retval EFI_SUCCESS Opcode is added.
227 BootScriptWritePciCfg2ReadWrite (
231 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
237 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
238 Segment
= VA_ARG (Marker
, UINT16
);
239 Address
= VA_ARG (Marker
, UINT64
);
240 Data
= VA_ARG (Marker
, UINT8
*);
241 DataMask
= VA_ARG (Marker
, UINT8
*);
243 return S3BootScriptSavePciCfg2ReadWrite (Width
, Segment
, Address
, Data
, DataMask
);
247 Internal function to add smbus execute opcode to the table.
249 @param Marker The variable argument list to get the opcode
250 and associated attributes.
252 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
253 @retval EFI_SUCCESS Opcode is added.
257 BootScriptWriteSmbusExecute (
261 EFI_SMBUS_DEVICE_ADDRESS SlaveAddress
;
262 EFI_SMBUS_DEVICE_COMMAND Command
;
263 EFI_SMBUS_OPERATION Operation
;
269 SlaveAddress
.SmbusDeviceAddress
= VA_ARG (Marker
, UINTN
);
270 Command
= VA_ARG (Marker
, EFI_SMBUS_DEVICE_COMMAND
);
271 Operation
= VA_ARG (Marker
, EFI_SMBUS_OPERATION
);
272 PecCheck
= VA_ARG (Marker
, BOOLEAN
);
273 SmBusAddress
= SMBUS_LIB_ADDRESS (SlaveAddress
.SmbusDeviceAddress
, Command
, 0, PecCheck
);
274 DataSize
= VA_ARG (Marker
, UINTN
*);
275 Buffer
= VA_ARG (Marker
, VOID
*);
277 return S3BootScriptSaveSmbusExecute (SmBusAddress
, Operation
, DataSize
, Buffer
);
281 Internal function to add stall opcode to the table.
283 @param Marker The variable argument list to get the opcode
284 and associated attributes.
286 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
287 @retval EFI_SUCCESS Opcode is added.
291 BootScriptWriteStall (
297 Duration
= VA_ARG (Marker
, UINT32
);
299 return S3BootScriptSaveStall (Duration
);
303 Internal function to add Save jmp address according to DISPATCH_OPCODE.
304 We ignore "Context" parameter
306 @param Marker The variable argument list to get the opcode
307 and associated attributes.
309 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
310 @retval EFI_SUCCESS Opcode is added.
314 BootScriptWriteDispatch (
320 EntryPoint
= (VOID
*)(UINTN
)VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
321 return S3BootScriptSaveDispatch (EntryPoint
);
325 Internal function to add memory pool operation to the table.
327 @param Marker The variable argument list to get the opcode
328 and associated attributes.
330 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
331 @retval EFI_SUCCESS Opcode is added.
335 BootScriptWriteMemPoll (
339 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
347 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
348 Address
= VA_ARG (Marker
, UINT64
);
349 Data
= VA_ARG (Marker
, VOID
*);
350 DataMask
= VA_ARG (Marker
, VOID
*);
351 Delay
= VA_ARG (Marker
, UINT64
);
353 // According to the spec, the interval between 2 polls is 100ns,
354 // but the unit of Duration for S3BootScriptSaveMemPoll() is microsecond(1000ns).
355 // Duration * 1000ns * LoopTimes = Delay * 100ns
356 // Duration will be minimum 1(microsecond) to be minimum deviation,
357 // so LoopTimes = Delay / 10.
359 LoopTimes
= DivU64x32Remainder (
364 if (Remainder
!= 0) {
366 // If Remainder is not zero, LoopTimes will be rounded up by 1.
371 return S3BootScriptSaveMemPoll (Width
, Address
, DataMask
, Data
, 1, LoopTimes
);
375 Internal function to add Save jmp address according to DISPATCH_OPCODE2.
376 The "Context" parameter is not ignored.
378 @param Marker The variable argument list to get the opcode
379 and associated attributes.
381 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
382 @retval EFI_SUCCESS Opcode is added.
386 BootScriptWriteDispatch2 (
393 EntryPoint
= (VOID
*)(UINTN
)VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
394 Context
= (VOID
*)(UINTN
)VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
396 return S3BootScriptSaveDispatch2 (EntryPoint
, Context
);
400 Internal function to add INFORAMTION opcode node to the table
402 @param Marker The variable argument list to get the opcode
403 and associated attributes.
405 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
406 @retval EFI_SUCCESS The opcode entry is added to the table
410 BootScriptWriteInformation (
414 UINT32 InformationLength
;
415 EFI_PHYSICAL_ADDRESS Information
;
417 InformationLength
= VA_ARG (Marker
, UINT32
);
418 Information
= VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
419 return S3BootScriptSaveInformation (InformationLength
, (VOID
*)(UINTN
)Information
);
423 Internal function to add IO poll opcode node to the table
424 @param Marker The variable argument list to get the opcode
425 and associated attributes.
427 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
428 @retval EFI_SUCCESS The opcode entry is added to the table
432 BootScriptWriteIoPoll (
436 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
442 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
443 Address
= VA_ARG (Marker
, UINT64
);
444 Data
= VA_ARG (Marker
, VOID
*);
445 DataMask
= VA_ARG (Marker
, VOID
*);
446 Delay
= (UINT64
)VA_ARG (Marker
, UINT64
);
448 return S3BootScriptSaveIoPoll (Width
, Address
, Data
, DataMask
, Delay
);
452 Internal function to add PCI config poll opcode node to the table
454 @param Marker The variable argument list to get the opcode
455 and associated attributes.
457 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
458 @retval EFI_SUCCESS The opcode entry is added to the table
462 BootScriptWritePciConfigPoll (
466 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
472 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
473 Address
= VA_ARG (Marker
, UINT64
);
474 Data
= VA_ARG (Marker
, VOID
*);
475 DataMask
= VA_ARG (Marker
, VOID
*);
476 Delay
= (UINT64
)VA_ARG (Marker
, UINT64
);
478 return S3BootScriptSavePciPoll (Width
, Address
, Data
, DataMask
, Delay
);
482 Internal function to add PCI config 2 poll opcode node to the table
484 @param Marker The variable argument list to get the opcode
485 and associated attributes.
487 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
488 @retval EFI_SUCCESS The opcode entry is added to the table
492 BootScriptWritePciConfig2Poll (
496 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
503 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
504 Segment
= VA_ARG (Marker
, UINT16
);
505 Address
= VA_ARG (Marker
, UINT64
);
506 Data
= VA_ARG (Marker
, VOID
*);
507 DataMask
= VA_ARG (Marker
, VOID
*);
508 Delay
= (UINT64
)VA_ARG (Marker
, UINT64
);
510 return S3BootScriptSavePci2Poll (Width
, Segment
, Address
, Data
, DataMask
, Delay
);
514 Adds a record into S3 boot script table.
516 This function is used to store a boot script record into a given boot
517 script table. If the table specified by TableName is nonexistent in the
518 system, a new table will automatically be created and then the script record
519 will be added into the new table. This function is responsible for allocating
520 necessary memory for the script.
522 This function has a variable parameter list. The exact parameter list depends on
523 the OpCode that is passed into the function. If an unsupported OpCode or illegal
524 parameter list is passed in, this function returns EFI_INVALID_PARAMETER.
525 If there are not enough resources available for storing more scripts, this function returns
526 EFI_OUT_OF_RESOURCES.
528 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
529 @param OpCode The operation code (opcode) number.
530 @param ... Argument list that is specific to each opcode.
532 @retval EFI_SUCCESS The operation succeeded. A record was added into the
533 specified script table.
534 @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.
535 If the opcode is unknow or not supported because of the PCD
537 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
543 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
552 // Build script according to opcode
555 case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE
:
556 VA_START (Marker
, OpCode
);
557 Status
= BootScriptWriteIoWrite (Marker
);
561 case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE
:
562 VA_START (Marker
, OpCode
);
563 Status
= BootScriptWriteIoReadWrite (Marker
);
567 case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE
:
568 VA_START (Marker
, OpCode
);
569 Status
= BootScriptWriteMemWrite (Marker
);
573 case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE
:
574 VA_START (Marker
, OpCode
);
575 Status
= BootScriptWriteMemReadWrite (Marker
);
579 case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE
:
580 VA_START (Marker
, OpCode
);
581 Status
= BootScriptWritePciCfgWrite (Marker
);
585 case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE
:
586 VA_START (Marker
, OpCode
);
587 Status
= BootScriptWritePciCfgReadWrite (Marker
);
591 case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE
:
592 VA_START (Marker
, OpCode
);
593 Status
= BootScriptWriteSmbusExecute (Marker
);
597 case EFI_BOOT_SCRIPT_STALL_OPCODE
:
598 VA_START (Marker
, OpCode
);
599 Status
= BootScriptWriteStall (Marker
);
604 case EFI_BOOT_SCRIPT_DISPATCH_OPCODE
:
605 VA_START (Marker
, OpCode
);
606 Status
= BootScriptWriteDispatch (Marker
);
610 case EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE
:
611 VA_START (Marker
, OpCode
);
612 Status
= BootScriptWriteDispatch2 (Marker
);
616 case EFI_BOOT_SCRIPT_INFORMATION_OPCODE
:
617 VA_START (Marker
, OpCode
);
618 Status
= BootScriptWriteInformation (Marker
);
622 case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE
:
623 VA_START (Marker
, OpCode
);
624 Status
= BootScriptWriteMemPoll (Marker
);
628 case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE
:
629 VA_START (Marker
, OpCode
);
630 Status
= BootScriptWritePciCfg2Write (Marker
);
634 case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE
:
635 VA_START (Marker
, OpCode
);
636 Status
= BootScriptWritePciCfg2ReadWrite (Marker
);
640 case EFI_BOOT_SCRIPT_IO_POLL_OPCODE
:
641 VA_START (Marker
, OpCode
);
642 Status
= BootScriptWriteIoPoll (Marker
);
646 case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE
:
647 VA_START (Marker
, OpCode
);
648 Status
= BootScriptWritePciConfigPoll (Marker
);
652 case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE
:
653 VA_START (Marker
, OpCode
);
654 Status
= BootScriptWritePciConfig2Poll (Marker
);
659 Status
= EFI_INVALID_PARAMETER
;
667 Insert a record into a specified Framework boot script table.
669 This function is used to store an OpCode to be replayed as part of the S3 resume boot path. It is
670 assumed this protocol has platform specific mechanism to store the OpCode set and replay them
671 during the S3 resume.
672 The opcode is inserted before or after the specified position in the boot script table. If Position is
673 NULL then that position is after the last opcode in the table (BeforeOrAfter is FALSE) or before
674 the first opcode in the table (BeforeOrAfter is TRUE). The position which is pointed to by
675 Position upon return can be used for subsequent insertions.
677 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
678 @param BeforeOrAfter Specifies whether the opcode is stored before (TRUE) or after (FALSE) the position
679 in the boot script table specified by Position. If Position is NULL or points to
680 NULL then the new opcode is inserted at the beginning of the table (if TRUE) or end
681 of the table (if FALSE).
682 @param Position On entry, specifies the position in the boot script table where the opcode will be
683 inserted, either before or after, depending on BeforeOrAfter. On exit, specifies
684 the position of the inserted opcode in the boot script table.
685 @param OpCode The operation code (opcode) number.
686 @param ... Argument list that is specific to each opcode.
688 @retval EFI_SUCCESS The operation succeeded. A record was added into the
689 specified script table.
690 @retval EFI_INVALID_PARAMETER The Opcode is an invalid opcode value or the Position is not a valid position in the boot script table..
691 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
697 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
698 IN BOOLEAN BeforeOrAfter
,
699 IN OUT EFI_S3_BOOT_SCRIPT_POSITION
*Position OPTIONAL
,
708 // Build script according to opcode
711 case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE
:
712 VA_START (Marker
, OpCode
);
713 Status
= BootScriptWriteIoWrite (Marker
);
717 case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE
:
718 VA_START (Marker
, OpCode
);
719 Status
= BootScriptWriteIoReadWrite (Marker
);
723 case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE
:
724 VA_START (Marker
, OpCode
);
725 Status
= BootScriptWriteMemWrite (Marker
);
729 case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE
:
730 VA_START (Marker
, OpCode
);
731 Status
= BootScriptWriteMemReadWrite (Marker
);
735 case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE
:
736 VA_START (Marker
, OpCode
);
737 Status
= BootScriptWritePciCfgWrite (Marker
);
741 case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE
:
742 VA_START (Marker
, OpCode
);
743 Status
= BootScriptWritePciCfgReadWrite (Marker
);
747 case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE
:
748 VA_START (Marker
, OpCode
);
749 Status
= BootScriptWriteSmbusExecute (Marker
);
753 case EFI_BOOT_SCRIPT_STALL_OPCODE
:
754 VA_START (Marker
, OpCode
);
755 Status
= BootScriptWriteStall (Marker
);
760 case EFI_BOOT_SCRIPT_DISPATCH_OPCODE
:
761 VA_START (Marker
, OpCode
);
762 Status
= BootScriptWriteDispatch (Marker
);
766 case EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE
:
767 VA_START (Marker
, OpCode
);
768 Status
= BootScriptWriteDispatch2 (Marker
);
772 case EFI_BOOT_SCRIPT_INFORMATION_OPCODE
:
773 VA_START (Marker
, OpCode
);
774 Status
= BootScriptWriteInformation (Marker
);
778 case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE
:
779 VA_START (Marker
, OpCode
);
780 Status
= BootScriptWriteMemPoll (Marker
);
784 case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE
:
785 VA_START (Marker
, OpCode
);
786 Status
= BootScriptWritePciCfg2Write (Marker
);
790 case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE
:
791 VA_START (Marker
, OpCode
);
792 Status
= BootScriptWritePciCfg2ReadWrite (Marker
);
796 case EFI_BOOT_SCRIPT_IO_POLL_OPCODE
:
797 VA_START (Marker
, OpCode
);
798 Status
= BootScriptWriteIoPoll (Marker
);
802 case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE
:
803 VA_START (Marker
, OpCode
);
804 Status
= BootScriptWritePciConfigPoll (Marker
);
808 case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE
:
809 VA_START (Marker
, OpCode
);
810 Status
= BootScriptWritePciConfig2Poll (Marker
);
815 Status
= EFI_INVALID_PARAMETER
;
819 if (!EFI_ERROR (Status
)) {
820 Status
= S3BootScriptMoveLastOpcode (BeforeOrAfter
, (VOID
**)Position
);
827 Find a label within the boot script table and, if not present, optionally create it.
829 If the label Label is already exists in the boot script table, then no new label is created, the
830 position of the Label is returned in *Position and EFI_SUCCESS is returned.
831 If the label Label does not already exist and CreateIfNotFound is TRUE, then it will be
832 created before or after the specified position and EFI_SUCCESS is returned.
833 If the label Label does not already exist and CreateIfNotFound is FALSE, then
834 EFI_NOT_FOUND is returned.
836 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
837 @param BeforeOrAfter Specifies whether the label is stored before (TRUE) or after (FALSE) the position in
838 the boot script table specified by Position. If Position is NULL or points to
839 NULL then the new label is inserted at the beginning of the table (if TRUE) or end of
840 the table (if FALSE).
841 @param CreateIfNotFound Specifies whether the label will be created if the label does not exists (TRUE) or not
843 @param Position On entry, specifies the position in the boot script table where the label will be inserted,
844 either before or after, depending on BeforeOrAfter. On exit, specifies the position
845 of the inserted label in the boot script table.
846 @param Label Points to the label which will be inserted in the boot script table.
848 @retval EFI_SUCCESS The label already exists or was inserted.
849 @retval EFI_INVALID_PARAMETER The Label is NULL or points to an empty string.
850 @retval EFI_INVALID_PARAMETER The Position is not a valid position in the boot script table.
856 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
857 IN BOOLEAN BeforeOrAfter
,
858 IN BOOLEAN CreateIfNotFound
,
859 IN OUT EFI_S3_BOOT_SCRIPT_POSITION
*Position OPTIONAL
,
860 IN CONST CHAR8
*Label
863 return S3BootScriptLabel (BeforeOrAfter
, CreateIfNotFound
, (VOID
**)Position
, Label
);
867 Compare two positions in the boot script table and return their relative position.
869 This function compares two positions in the boot script table and returns their relative positions. If
870 Position1 is before Position2, then -1 is returned. If Position1 is equal to Position2,
871 then 0 is returned. If Position1 is after Position2, then 1 is returned.
873 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
874 @param Position1 The positions in the boot script table to compare
875 @param Position2 The positions in the boot script table to compare
876 @param RelativePosition On return, points to the result of the comparison
878 @retval EFI_SUCCESS The operation succeeded.
879 @retval EFI_INVALID_PARAMETER The Position1 or Position2 is not a valid position in the boot script table.
880 @retval EFI_INVALID_PARAMETER The RelativePosition is NULL.
886 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
887 IN EFI_S3_BOOT_SCRIPT_POSITION Position1
,
888 IN EFI_S3_BOOT_SCRIPT_POSITION Position2
,
889 OUT UINTN
*RelativePosition
892 return S3BootScriptCompare (Position1
, Position2
, RelativePosition
);
896 This routine is entry point of ScriptSave driver.
898 @param ImageHandle Handle for this drivers loaded image protocol.
899 @param SystemTable EFI system table.
901 @retval EFI_OUT_OF_RESOURCES No enough resource
902 @retval EFI_SUCCESS Succesfully installed the ScriptSave driver.
903 @retval other Errors occurred.
908 InitializeSmmS3SaveState (
909 IN EFI_HANDLE ImageHandle
,
910 IN EFI_SYSTEM_TABLE
*SystemTable
915 if (!PcdGetBool (PcdAcpiS3Enable
)) {
916 return EFI_UNSUPPORTED
;
920 return gSmst
->SmmInstallProtocolInterface (
922 &gEfiS3SmmSaveStateProtocolGuid
,
923 EFI_NATIVE_INTERFACE
,