2 Implementation for S3 SMM Boot Script Saver state driver.
4 Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions
8 of the BSD License which accompanies this distribution. The
9 full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "InternalSmmSaveState.h"
18 EFI_S3_SMM_SAVE_STATE_PROTOCOL mS3SmmSaveState
= {
25 Internal function to add IO write opcode to the table.
27 @param Marker The variable argument list to get the opcode
28 and associated attributes.
30 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
31 @retval EFI_SUCCESS Opcode is added.
35 BootScriptWriteIoWrite (
39 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
44 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
45 Address
= VA_ARG (Marker
, UINT64
);
46 Count
= VA_ARG (Marker
, UINTN
);
47 Buffer
= VA_ARG (Marker
, UINT8
*);
49 return S3BootScriptSaveIoWrite (Width
, Address
, Count
, Buffer
);
52 Internal function to add IO read/write opcode to the table.
54 @param Marker The variable argument list to get the opcode
55 and associated attributes.
57 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
58 @retval EFI_SUCCESS Opcode is added.
62 BootScriptWriteIoReadWrite (
66 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
71 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
72 Address
= VA_ARG (Marker
, UINT64
);
73 Data
= VA_ARG (Marker
, UINT8
*);
74 DataMask
= VA_ARG (Marker
, UINT8
*);
76 return S3BootScriptSaveIoReadWrite (Width
, Address
, Data
, DataMask
);
80 Internal function to add memory write opcode to the table.
82 @param Marker The variable argument list to get the opcode
83 and associated attributes.
85 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
86 @retval EFI_SUCCESS Opcode is added.
90 BootScriptWriteMemWrite (
94 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
99 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
100 Address
= VA_ARG (Marker
, UINT64
);
101 Count
= VA_ARG (Marker
, UINTN
);
102 Buffer
= VA_ARG (Marker
, UINT8
*);
104 return S3BootScriptSaveMemWrite (Width
, Address
, Count
, Buffer
);
108 Internal function to add memory read/write opcode to the table.
110 @param Marker The variable argument list to get the opcode
111 and associated attributes.
113 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
114 @retval EFI_SUCCESS Opcode is added.
118 BootScriptWriteMemReadWrite (
122 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
127 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
128 Address
= VA_ARG (Marker
, UINT64
);
129 Data
= VA_ARG (Marker
, UINT8
*);
130 DataMask
= VA_ARG (Marker
, UINT8
*);
132 return S3BootScriptSaveMemReadWrite (Width
, Address
, Data
, DataMask
);
136 Internal function to add PciCfg write opcode to the table.
138 @param Marker The variable argument list to get the opcode
139 and associated attributes.
141 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
142 @retval EFI_SUCCESS Opcode is added.
146 BootScriptWritePciCfgWrite (
150 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
155 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
156 Address
= VA_ARG (Marker
, UINT64
);
157 Count
= VA_ARG (Marker
, UINTN
);
158 Buffer
= VA_ARG (Marker
, UINT8
*);
160 return S3BootScriptSavePciCfgWrite (Width
, Address
, Count
, Buffer
);
164 Internal function to PciCfg read/write opcode to the table.
166 @param Marker The variable argument list to get the opcode
167 and associated attributes.
169 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
170 @retval EFI_SUCCESS Opcode is added.
174 BootScriptWritePciCfgReadWrite (
178 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
183 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
184 Address
= VA_ARG (Marker
, UINT64
);
185 Data
= VA_ARG (Marker
, UINT8
*);
186 DataMask
= VA_ARG (Marker
, UINT8
*);
188 return S3BootScriptSavePciCfgReadWrite (Width
, Address
, Data
, DataMask
);
191 Internal function to add PciCfg2 write opcode to the table.
193 @param Marker The variable argument list to get the opcode
194 and associated attributes.
196 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
197 @retval EFI_SUCCESS Opcode is added.
201 BootScriptWritePciCfg2Write (
205 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
211 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
212 Address
= VA_ARG (Marker
, UINT64
);
213 Count
= VA_ARG (Marker
, UINTN
);
214 Buffer
= VA_ARG (Marker
, UINT8
*);
215 Segment
= VA_ARG (Marker
, UINT16
);
217 return S3BootScriptSavePciCfg2Write (Width
, Segment
, Address
, Count
, Buffer
);
221 Internal function to PciCfg2 read/write opcode to the table.
223 @param Marker The variable argument list to get the opcode
224 and associated attributes.
226 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
227 @retval EFI_SUCCESS Opcode is added.
231 BootScriptWritePciCfg2ReadWrite (
235 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
241 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
242 Address
= VA_ARG (Marker
, UINT64
);
243 Segment
= VA_ARG (Marker
, UINT16
);
244 Data
= VA_ARG (Marker
, UINT8
*);
245 DataMask
= VA_ARG (Marker
, UINT8
*);
247 return S3BootScriptSavePciCfg2ReadWrite (Width
, Segment
, Address
, Data
, DataMask
);
250 Internal function to add smbus execute opcode to the table.
252 @param Marker The variable argument list to get the opcode
253 and associated attributes.
255 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
256 @retval EFI_SUCCESS Opcode is added.
260 BootScriptWriteSmbusExecute (
264 EFI_SMBUS_DEVICE_ADDRESS SlaveAddress
;
265 EFI_SMBUS_DEVICE_COMMAND Command
;
266 EFI_SMBUS_OPERATION Operation
;
272 SlaveAddress
.SmbusDeviceAddress
= VA_ARG (Marker
, UINTN
);
273 Command
= VA_ARG (Marker
, EFI_SMBUS_DEVICE_COMMAND
);
274 Operation
= VA_ARG (Marker
, EFI_SMBUS_OPERATION
);
275 PecCheck
= VA_ARG (Marker
, BOOLEAN
);
276 SmBusAddress
= SMBUS_LIB_ADDRESS (SlaveAddress
.SmbusDeviceAddress
,Command
,0,PecCheck
);
277 DataSize
= VA_ARG (Marker
, UINTN
*);
278 Buffer
= VA_ARG (Marker
, VOID
*);
280 return S3BootScriptSaveSmbusExecute (SmBusAddress
, Operation
, DataSize
, Buffer
);
283 Internal function to add stall opcode to the table.
285 @param Marker The variable argument list to get the opcode
286 and associated attributes.
288 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
289 @retval EFI_SUCCESS Opcode is added.
293 BootScriptWriteStall (
299 Duration
= VA_ARG (Marker
, UINT32
);
301 return S3BootScriptSaveStall (Duration
);
305 Internal function to add Save jmp address according to DISPATCH_OPCODE.
306 We ignore "Context" parameter
308 @param Marker The variable argument list to get the opcode
309 and associated attributes.
311 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
312 @retval EFI_SUCCESS Opcode is added.
316 BootScriptWriteDispatch (
322 EntryPoint
= (VOID
*)(UINTN
)VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
323 return S3BootScriptSaveDispatch (EntryPoint
);
327 Internal function to add memory pool operation to the table.
329 @param Marker The variable argument list to get the opcode
330 and associated attributes.
332 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
333 @retval EFI_SUCCESS Opcode is added.
337 BootScriptWriteMemPoll (
341 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
349 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
350 Address
= VA_ARG (Marker
, UINT64
);
351 Data
= VA_ARG (Marker
, VOID
*);
352 DataMask
= VA_ARG (Marker
, VOID
*);
353 Delay
= VA_ARG (Marker
, UINT64
);
355 // According to the spec, the interval between 2 polls is 100ns,
356 // but the unit of Duration for S3BootScriptSaveMemPoll() is microsecond(1000ns).
357 // Duration * 1000ns * LoopTimes = Delay * 100ns
358 // Duration will be minimum 1(microsecond) to be minimum deviation,
359 // so LoopTimes = Delay / 10.
361 LoopTimes
= DivU64x32Remainder (
366 if (Remainder
!= 0) {
368 // If Remainder is not zero, LoopTimes will be rounded up by 1.
372 return S3BootScriptSaveMemPoll (Width
, Address
, DataMask
, Data
, 1, LoopTimes
);
377 Internal function to add Save jmp address according to DISPATCH_OPCODE2.
378 The "Context" parameter is not ignored.
380 @param Marker The variable argument list to get the opcode
381 and associated attributes.
383 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
384 @retval EFI_SUCCESS Opcode is added.
388 BootScriptWriteDispatch2 (
395 EntryPoint
= (VOID
*)(UINTN
)VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
396 Context
= (VOID
*)(UINTN
)VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
398 return S3BootScriptSaveDispatch2 (EntryPoint
, Context
);
401 Internal function to add INFORAMTION opcode node to the table
403 @param Marker The variable argument list to get the opcode
404 and associated attributes.
406 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
407 @retval EFI_SUCCESS The opcode entry is added to the table
411 BootScriptWriteInformation (
415 UINT32 InformationLength
;
416 EFI_PHYSICAL_ADDRESS Information
;
418 InformationLength
= VA_ARG (Marker
, UINT32
);
419 Information
= VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
420 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
);
451 Internal function to add PCI config poll opcode node to the table
453 @param Marker The variable argument list to get the opcode
454 and associated attributes.
456 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
457 @retval EFI_SUCCESS The opcode entry is added to the table
461 BootScriptWritePciConfigPoll (
465 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
);
481 Internal function to add PCI config 2 poll opcode node to the table
483 @param Marker The variable argument list to get the opcode
484 and associated attributes.
486 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
487 @retval EFI_SUCCESS The opcode entry is added to the table
491 BootScriptWritePciConfig2Poll (
495 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
502 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
503 Segment
= VA_ARG (Marker
, UINT16
);
504 Address
= VA_ARG (Marker
, UINT64
);
505 Data
= VA_ARG (Marker
, VOID
*);
506 DataMask
= VA_ARG (Marker
, VOID
*);
507 Delay
= (UINT64
)VA_ARG (Marker
, UINT64
);
509 return S3BootScriptSavePci2Poll (Width
, Segment
, Address
, Data
, DataMask
, Delay
);
513 Adds a record into S3 boot script table.
515 This function is used to store a boot script record into a given boot
516 script table. If the table specified by TableName is nonexistent in the
517 system, a new table will automatically be created and then the script record
518 will be added into the new table. This function is responsible for allocating
519 necessary memory for the script.
521 This function has a variable parameter list. The exact parameter list depends on
522 the OpCode that is passed into the function. If an unsupported OpCode or illegal
523 parameter list is passed in, this function returns EFI_INVALID_PARAMETER.
524 If there are not enough resources available for storing more scripts, this function returns
525 EFI_OUT_OF_RESOURCES.
527 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
528 @param OpCode The operation code (opcode) number.
529 @param ... Argument list that is specific to each opcode.
531 @retval EFI_SUCCESS The operation succeeded. A record was added into the
532 specified script table.
533 @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.
534 If the opcode is unknow or not supported because of the PCD
536 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
542 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
550 // Build script according to opcode
554 case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE
:
555 VA_START (Marker
, OpCode
);
556 Status
= BootScriptWriteIoWrite (Marker
);
560 case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE
:
561 VA_START (Marker
, OpCode
);
562 Status
= BootScriptWriteIoReadWrite (Marker
);
566 case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE
:
567 VA_START (Marker
, OpCode
);
568 Status
= BootScriptWriteMemWrite (Marker
);
572 case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE
:
573 VA_START (Marker
, OpCode
);
574 Status
= BootScriptWriteMemReadWrite (Marker
);
578 case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE
:
579 VA_START (Marker
, OpCode
);
580 Status
= BootScriptWritePciCfgWrite (Marker
);
584 case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE
:
585 VA_START (Marker
, OpCode
);
586 Status
= BootScriptWritePciCfgReadWrite (Marker
);
590 case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE
:
591 VA_START (Marker
, OpCode
);
592 Status
= BootScriptWriteSmbusExecute (Marker
);
596 case EFI_BOOT_SCRIPT_STALL_OPCODE
:
597 VA_START (Marker
, OpCode
);
598 Status
= BootScriptWriteStall (Marker
);
603 case EFI_BOOT_SCRIPT_DISPATCH_OPCODE
:
604 VA_START (Marker
, OpCode
);
605 Status
= BootScriptWriteDispatch (Marker
);
609 case EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE
:
610 VA_START (Marker
, OpCode
);
611 Status
= BootScriptWriteDispatch2 (Marker
);
615 case EFI_BOOT_SCRIPT_INFORMATION_OPCODE
:
616 VA_START (Marker
, OpCode
);
617 Status
= BootScriptWriteInformation (Marker
);
621 case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE
:
622 VA_START (Marker
, OpCode
);
623 Status
= BootScriptWriteMemPoll (Marker
);
627 case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE
:
628 VA_START (Marker
, OpCode
);
629 Status
= BootScriptWritePciCfg2Write (Marker
);
633 case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE
:
634 VA_START (Marker
, OpCode
);
635 Status
= BootScriptWritePciCfg2ReadWrite (Marker
);
639 case EFI_BOOT_SCRIPT_IO_POLL_OPCODE
:
640 VA_START (Marker
, OpCode
);
641 Status
= BootScriptWriteIoPoll (Marker
);
645 case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE
:
646 VA_START (Marker
, OpCode
);
647 Status
= BootScriptWritePciConfigPoll (Marker
);
651 case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE
:
652 VA_START (Marker
, OpCode
);
653 Status
= BootScriptWritePciConfig2Poll (Marker
);
658 Status
= EFI_INVALID_PARAMETER
;
665 Insert a record into a specified Framework boot script table.
667 This function is used to store an OpCode to be replayed as part of the S3 resume boot path. It is
668 assumed this protocol has platform specific mechanism to store the OpCode set and replay them
669 during the S3 resume.
670 The opcode is inserted before or after the specified position in the boot script table. If Position is
671 NULL then that position is after the last opcode in the table (BeforeOrAfter is FALSE) or before
672 the first opcode in the table (BeforeOrAfter is TRUE). The position which is pointed to by
673 Position upon return can be used for subsequent insertions.
675 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
676 @param BeforeOrAfter Specifies whether the opcode is stored before (TRUE) or after (FALSE) the position
677 in the boot script table specified by Position. If Position is NULL or points to
678 NULL then the new opcode is inserted at the beginning of the table (if TRUE) or end
679 of the table (if FALSE).
680 @param Position On entry, specifies the position in the boot script table where the opcode will be
681 inserted, either before or after, depending on BeforeOrAfter. On exit, specifies
682 the position of the inserted opcode in the boot script table.
683 @param OpCode The operation code (opcode) number.
684 @param ... Argument list that is specific to each opcode.
686 @retval EFI_SUCCESS The operation succeeded. A record was added into the
687 specified script table.
688 @retval EFI_INVALID_PARAMETER The Opcode is an invalid opcode value or the Position is not a valid position in the boot script table..
689 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
695 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
696 IN BOOLEAN BeforeOrAfter
,
697 IN OUT EFI_S3_BOOT_SCRIPT_POSITION
*Position OPTIONAL
,
705 // Build script according to opcode
709 case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE
:
710 VA_START (Marker
, OpCode
);
711 Status
= BootScriptWriteIoWrite (Marker
);
715 case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE
:
716 VA_START (Marker
, OpCode
);
717 Status
= BootScriptWriteIoReadWrite (Marker
);
721 case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE
:
722 VA_START (Marker
, OpCode
);
723 Status
= BootScriptWriteMemWrite (Marker
);
727 case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE
:
728 VA_START (Marker
, OpCode
);
729 Status
= BootScriptWriteMemReadWrite (Marker
);
733 case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE
:
734 VA_START (Marker
, OpCode
);
735 Status
= BootScriptWritePciCfgWrite (Marker
);
739 case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE
:
740 VA_START (Marker
, OpCode
);
741 Status
= BootScriptWritePciCfgReadWrite (Marker
);
745 case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE
:
746 VA_START (Marker
, OpCode
);
747 Status
= BootScriptWriteSmbusExecute (Marker
);
751 case EFI_BOOT_SCRIPT_STALL_OPCODE
:
752 VA_START (Marker
, OpCode
);
753 Status
= BootScriptWriteStall (Marker
);
758 case EFI_BOOT_SCRIPT_DISPATCH_OPCODE
:
759 VA_START (Marker
, OpCode
);
760 Status
= BootScriptWriteDispatch (Marker
);
764 case EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE
:
765 VA_START (Marker
, OpCode
);
766 Status
= BootScriptWriteDispatch2 (Marker
);
770 case EFI_BOOT_SCRIPT_INFORMATION_OPCODE
:
771 VA_START (Marker
, OpCode
);
772 Status
= BootScriptWriteInformation (Marker
);
776 case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE
:
777 VA_START (Marker
, OpCode
);
778 Status
= BootScriptWriteMemPoll (Marker
);
782 case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE
:
783 VA_START (Marker
, OpCode
);
784 Status
= BootScriptWritePciCfg2Write (Marker
);
788 case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE
:
789 VA_START (Marker
, OpCode
);
790 Status
= BootScriptWritePciCfg2ReadWrite (Marker
);
794 case EFI_BOOT_SCRIPT_IO_POLL_OPCODE
:
795 VA_START (Marker
, OpCode
);
796 Status
= BootScriptWriteIoPoll (Marker
);
800 case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE
:
801 VA_START (Marker
, OpCode
);
802 Status
= BootScriptWritePciConfigPoll (Marker
);
806 case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE
:
807 VA_START (Marker
, OpCode
);
808 Status
= BootScriptWritePciConfig2Poll (Marker
);
813 Status
= EFI_INVALID_PARAMETER
;
817 if (!EFI_ERROR (Status
)) {
818 Status
= S3BootScriptMoveLastOpcode (BeforeOrAfter
, Position
);
823 Find a label within the boot script table and, if not present, optionally create it.
825 If the label Label is already exists in the boot script table, then no new label is created, the
826 position of the Label is returned in *Position and EFI_SUCCESS is returned.
827 If the label Label does not already exist and CreateIfNotFound is TRUE, then it will be
828 created before or after the specified position and EFI_SUCCESS is returned.
829 If the label Label does not already exist and CreateIfNotFound is FALSE, then
830 EFI_NOT_FOUND is returned.
832 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
833 @param BeforeOrAfter Specifies whether the label is stored before (TRUE) or after (FALSE) the position in
834 the boot script table specified by Position. If Position is NULL or points to
835 NULL then the new label is inserted at the beginning of the table (if TRUE) or end of
836 the table (if FALSE).
837 @param CreateIfNotFound Specifies whether the label will be created if the label does not exists (TRUE) or not
839 @param Position On entry, specifies the position in the boot script table where the label will be inserted,
840 either before or after, depending on BeforeOrAfter. On exit, specifies the position
841 of the inserted label in the boot script table.
842 @param Label Points to the label which will be inserted in the boot script table.
844 @retval EFI_SUCCESS The label already exists or was inserted.
845 @retval EFI_INVALID_PARAMETER The Label is NULL or points to an empty string.
846 @retval EFI_INVALID_PARAMETER The Position is not a valid position in the boot script table.
852 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
853 IN BOOLEAN BeforeOrAfter
,
854 IN BOOLEAN CreateIfNotFound
,
855 IN OUT EFI_S3_BOOT_SCRIPT_POSITION
*Position OPTIONAL
,
856 IN CONST CHAR8
*Label
859 return S3BootScriptLabel (BeforeOrAfter
, CreateIfNotFound
, Position
, Label
);
862 Compare two positions in the boot script table and return their relative position.
864 This function compares two positions in the boot script table and returns their relative positions. If
865 Position1 is before Position2, then -1 is returned. If Position1 is equal to Position2,
866 then 0 is returned. If Position1 is after Position2, then 1 is returned.
868 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
869 @param Position1 The positions in the boot script table to compare
870 @param Position2 The positions in the boot script table to compare
871 @param RelativePosition On return, points to the result of the comparison
873 @retval EFI_SUCCESS The operation succeeded.
874 @retval EFI_INVALID_PARAMETER The Position1 or Position2 is not a valid position in the boot script table.
875 @retval EFI_INVALID_PARAMETER The RelativePosition is NULL.
881 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
882 IN EFI_S3_BOOT_SCRIPT_POSITION Position1
,
883 IN EFI_S3_BOOT_SCRIPT_POSITION Position2
,
884 OUT UINTN
*RelativePosition
887 return S3BootScriptCompare (Position1
, Position2
, RelativePosition
);
890 This routine is entry point of ScriptSave driver.
892 @param ImageHandle Handle for this drivers loaded image protocol.
893 @param SystemTable EFI system table.
895 @retval EFI_OUT_OF_RESOURCES No enough resource
896 @retval EFI_SUCCESS Succesfully installed the ScriptSave driver.
897 @retval other Errors occured.
902 InitializeSmmS3SaveState (
903 IN EFI_HANDLE ImageHandle
,
904 IN EFI_SYSTEM_TABLE
*SystemTable
909 if (!PcdGetBool (PcdAcpiS3Enable
)) {
910 return EFI_UNSUPPORTED
;
914 return gSmst
->SmmInstallProtocolInterface (
916 &gEfiS3SmmSaveStateProtocolGuid
,
917 EFI_NATIVE_INTERFACE
,