2 Implementation for S3 SMM Boot Script Saver state driver.
4 Copyright (c) 2010, 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 excute 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
;
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
= (UINTN
)VA_ARG (Marker
, UINT64
);
353 // According to the spec, the interval between 2 pools is 100ns
355 return S3BootScriptSaveMemPoll (Width
, Address
, DataMask
, Data
, 100, Delay
);
360 Internal function to add Save jmp address according to DISPATCH_OPCODE2.
361 The "Context" parameter is not ignored.
363 @param Marker The variable argument list to get the opcode
364 and associated attributes.
366 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
367 @retval EFI_SUCCESS Opcode is added.
371 BootScriptWriteDispatch2 (
378 EntryPoint
= (VOID
*)(UINTN
)VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
379 Context
= (VOID
*)(UINTN
)VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
381 return S3BootScriptSaveDispatch2 (EntryPoint
, Context
);
384 Internal function to add INFORAMTION opcode node to the table
386 @param Marker The variable argument list to get the opcode
387 and associated attributes.
389 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
390 @retval EFI_SUCCESS The opcode entry is added to the table
394 BootScriptWriteInformation (
398 UINT32 InformationLength
;
399 EFI_PHYSICAL_ADDRESS Information
;
401 InformationLength
= VA_ARG (Marker
, UINT32
);
402 Information
= VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
403 return S3BootScriptSaveInformation (InformationLength
, (VOID
*)(UINTN
)Information
);
406 Internal function to add IO poll opcode node to the table
407 @param Marker The variable argument list to get the opcode
408 and associated attributes.
410 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
411 @retval EFI_SUCCESS The opcode entry is added to the table
415 BootScriptWriteIoPoll (
419 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
425 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
426 Address
= VA_ARG (Marker
, UINT64
);
427 Data
= VA_ARG (Marker
, VOID
*);
428 DataMask
= VA_ARG (Marker
, VOID
*);
429 Delay
= (UINT64
)VA_ARG (Marker
, UINT64
);
431 return S3BootScriptSaveIoPoll (Width
, Address
, Data
, DataMask
, Delay
);
434 Internal function to add PCI config poll opcode node to the table
436 @param Marker The variable argument list to get the opcode
437 and associated attributes.
439 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
440 @retval EFI_SUCCESS The opcode entry is added to the table
444 BootScriptWritePciConfigPoll (
448 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
455 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
456 Address
= VA_ARG (Marker
, UINT64
);
457 Data
= VA_ARG (Marker
, VOID
*);
458 DataMask
= VA_ARG (Marker
, VOID
*);
459 Delay
= (UINT64
)VA_ARG (Marker
, UINT64
);
461 return S3BootScriptSavePciPoll (Width
, Address
, Data
, DataMask
, Delay
);
464 Internal function to add PCI config 2 poll opcode node to the table
466 @param Marker The variable argument list to get the opcode
467 and associated attributes.
469 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
470 @retval EFI_SUCCESS The opcode entry is added to the table
474 BootScriptWritePciConfig2Poll (
478 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
485 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
486 Segment
= VA_ARG (Marker
, UINT16
);
487 Address
= VA_ARG (Marker
, UINT64
);
488 Data
= VA_ARG (Marker
, VOID
*);
489 DataMask
= VA_ARG (Marker
, VOID
*);
490 Delay
= (UINT64
)VA_ARG (Marker
, UINT64
);
492 return S3BootScriptSavePci2Poll (Width
, Segment
, Address
, Data
, DataMask
, Delay
);
496 Adds a record into S3 boot script table.
498 This function is used to store a boot script record into a given boot
499 script table. If the table specified by TableName is nonexistent in the
500 system, a new table will automatically be created and then the script record
501 will be added into the new table. This function is responsible for allocating
502 necessary memory for the script.
504 This function has a variable parameter list. The exact parameter list depends on
505 the OpCode that is passed into the function. If an unsupported OpCode or illegal
506 parameter list is passed in, this function returns EFI_INVALID_PARAMETER.
507 If there are not enough resources available for storing more scripts, this function returns
508 EFI_OUT_OF_RESOURCES.
510 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
511 @param OpCode The operation code (opcode) number.
512 @param ... Argument list that is specific to each opcode.
514 @retval EFI_SUCCESS The operation succeeded. A record was added into the
515 specified script table.
516 @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.
517 If the opcode is unknow or not supported because of the PCD
519 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
525 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
533 // Build script according to opcode
537 case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE
:
538 VA_START (Marker
, OpCode
);
539 Status
= BootScriptWriteIoWrite (Marker
);
543 case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE
:
544 VA_START (Marker
, OpCode
);
545 Status
= BootScriptWriteIoReadWrite (Marker
);
549 case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE
:
550 VA_START (Marker
, OpCode
);
551 Status
= BootScriptWriteMemWrite (Marker
);
555 case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE
:
556 VA_START (Marker
, OpCode
);
557 Status
= BootScriptWriteMemReadWrite (Marker
);
561 case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE
:
562 VA_START (Marker
, OpCode
);
563 Status
= BootScriptWritePciCfgWrite (Marker
);
567 case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE
:
568 VA_START (Marker
, OpCode
);
569 Status
= BootScriptWritePciCfgReadWrite (Marker
);
573 case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE
:
574 VA_START (Marker
, OpCode
);
575 Status
= BootScriptWriteSmbusExecute (Marker
);
579 case EFI_BOOT_SCRIPT_STALL_OPCODE
:
580 VA_START (Marker
, OpCode
);
581 Status
= BootScriptWriteStall (Marker
);
586 case EFI_BOOT_SCRIPT_DISPATCH_OPCODE
:
587 VA_START (Marker
, OpCode
);
588 Status
= BootScriptWriteDispatch (Marker
);
592 case EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE
:
593 VA_START (Marker
, OpCode
);
594 Status
= BootScriptWriteDispatch2 (Marker
);
598 case EFI_BOOT_SCRIPT_INFORMATION_OPCODE
:
599 VA_START (Marker
, OpCode
);
600 Status
= BootScriptWriteInformation (Marker
);
604 case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE
:
605 VA_START (Marker
, OpCode
);
606 Status
= BootScriptWriteMemPoll (Marker
);
610 case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE
:
611 VA_START (Marker
, OpCode
);
612 Status
= BootScriptWritePciCfg2Write (Marker
);
616 case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE
:
617 VA_START (Marker
, OpCode
);
618 Status
= BootScriptWritePciCfg2ReadWrite (Marker
);
622 case EFI_BOOT_SCRIPT_IO_POLL_OPCODE
:
623 VA_START (Marker
, OpCode
);
624 Status
= BootScriptWriteIoPoll (Marker
);
628 case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE
:
629 VA_START (Marker
, OpCode
);
630 Status
= BootScriptWritePciConfigPoll (Marker
);
634 case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE
:
635 VA_START (Marker
, OpCode
);
636 Status
= BootScriptWritePciConfig2Poll (Marker
);
641 Status
= EFI_INVALID_PARAMETER
;
648 Insert a record into a specified Framework boot script table.
650 This function is used to store an OpCode to be replayed as part of the S3 resume boot path. It is
651 assumed this protocol has platform specific mechanism to store the OpCode set and replay them
652 during the S3 resume.
653 The opcode is inserted before or after the specified position in the boot script table. If Position is
654 NULL then that position is after the last opcode in the table (BeforeOrAfter is FALSE) or before
655 the first opcode in the table (BeforeOrAfter is TRUE). The position which is pointed to by
656 Position upon return can be used for subsequent insertions.
658 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
659 @param BeforeOrAfter Specifies whether the opcode is stored before (TRUE) or after (FALSE) the position
660 in the boot script table specified by Position. If Position is NULL or points to
661 NULL then the new opcode is inserted at the beginning of the table (if TRUE) or end
662 of the table (if FALSE).
663 @param Position On entry, specifies the position in the boot script table where the opcode will be
664 inserted, either before or after, depending on BeforeOrAfter. On exit, specifies
665 the position of the inserted opcode in the boot script table.
666 @param OpCode The operation code (opcode) number.
667 @param ... Argument list that is specific to each opcode.
669 @retval EFI_SUCCESS The operation succeeded. A record was added into the
670 specified script table.
671 @retval EFI_INVALID_PARAMETER The Opcode is an invalid opcode value or the Position is not a valid position in the boot script table..
672 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
678 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
679 IN BOOLEAN BeforeOrAfter
,
680 IN OUT EFI_S3_BOOT_SCRIPT_POSITION
*Position OPTIONAL
,
688 // Build script according to opcode
692 case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE
:
693 VA_START (Marker
, OpCode
);
694 Status
= BootScriptWriteIoWrite (Marker
);
698 case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE
:
699 VA_START (Marker
, OpCode
);
700 Status
= BootScriptWriteIoReadWrite (Marker
);
704 case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE
:
705 VA_START (Marker
, OpCode
);
706 Status
= BootScriptWriteMemWrite (Marker
);
710 case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE
:
711 VA_START (Marker
, OpCode
);
712 Status
= BootScriptWriteMemReadWrite (Marker
);
716 case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE
:
717 VA_START (Marker
, OpCode
);
718 Status
= BootScriptWritePciCfgWrite (Marker
);
722 case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE
:
723 VA_START (Marker
, OpCode
);
724 Status
= BootScriptWritePciCfgReadWrite (Marker
);
728 case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE
:
729 VA_START (Marker
, OpCode
);
730 Status
= BootScriptWriteSmbusExecute (Marker
);
734 case EFI_BOOT_SCRIPT_STALL_OPCODE
:
735 VA_START (Marker
, OpCode
);
736 Status
= BootScriptWriteStall (Marker
);
741 case EFI_BOOT_SCRIPT_DISPATCH_OPCODE
:
742 VA_START (Marker
, OpCode
);
743 Status
= BootScriptWriteDispatch (Marker
);
747 case EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE
:
748 VA_START (Marker
, OpCode
);
749 Status
= BootScriptWriteDispatch2 (Marker
);
753 case EFI_BOOT_SCRIPT_INFORMATION_OPCODE
:
754 VA_START (Marker
, OpCode
);
755 Status
= BootScriptWriteInformation (Marker
);
759 case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE
:
760 VA_START (Marker
, OpCode
);
761 Status
= BootScriptWriteMemPoll (Marker
);
765 case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE
:
766 VA_START (Marker
, OpCode
);
767 Status
= BootScriptWritePciCfg2Write (Marker
);
771 case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE
:
772 VA_START (Marker
, OpCode
);
773 Status
= BootScriptWritePciCfg2ReadWrite (Marker
);
777 case EFI_BOOT_SCRIPT_IO_POLL_OPCODE
:
778 VA_START (Marker
, OpCode
);
779 Status
= BootScriptWriteIoPoll (Marker
);
783 case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE
:
784 VA_START (Marker
, OpCode
);
785 Status
= BootScriptWritePciConfigPoll (Marker
);
789 case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE
:
790 VA_START (Marker
, OpCode
);
791 Status
= BootScriptWritePciConfig2Poll (Marker
);
796 Status
= EFI_INVALID_PARAMETER
;
800 if (!EFI_ERROR (Status
)) {
801 Status
= S3BootScriptMoveLastOpcode (BeforeOrAfter
, Position
);
806 Find a label within the boot script table and, if not present, optionally create it.
808 If the label Label is already exists in the boot script table, then no new label is created, the
809 position of the Label is returned in *Position and EFI_SUCCESS is returned.
810 If the label Label does not already exist and CreateIfNotFound is TRUE, then it will be
811 created before or after the specified position and EFI_SUCCESS is returned.
812 If the label Label does not already exist and CreateIfNotFound is FALSE, then
813 EFI_NOT_FOUND is returned.
815 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
816 @param BeforeOrAfter Specifies whether the label is stored before (TRUE) or after (FALSE) the position in
817 the boot script table specified by Position. If Position is NULL or points to
818 NULL then the new label is inserted at the beginning of the table (if TRUE) or end of
819 the table (if FALSE).
820 @param CreateIfNotFound Specifies whether the label will be created if the label does not exists (TRUE) or not
822 @param Position On entry, specifies the position in the boot script table where the label will be inserted,
823 either before or after, depending on BeforeOrAfter. On exit, specifies the position
824 of the inserted label in the boot script table.
825 @param Label Points to the label which will be inserted in the boot script table.
827 @retval EFI_SUCCESS The label already exists or was inserted.
828 @retval EFI_INVALID_PARAMETER The Opcode is an invalid opcode value or the Position is not a valid position in the boot script table..
834 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
835 IN BOOLEAN BeforeOrAfter
,
836 IN BOOLEAN CreateIfNotFound
,
837 IN OUT EFI_S3_BOOT_SCRIPT_POSITION
*Position OPTIONAL
,
838 IN CONST CHAR8
*Label
841 return S3BootScriptLabel (BeforeOrAfter
, CreateIfNotFound
, Position
, Label
);
844 Compare two positions in the boot script table and return their relative position.
846 This function compares two positions in the boot script table and returns their relative positions. If
847 Position1 is before Position2, then -1 is returned. If Position1 is equal to Position2,
848 then 0 is returned. If Position1 is after Position2, then 1 is returned.
850 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
851 @param Position1 The positions in the boot script table to compare
852 @param Position2 The positions in the boot script table to compare
853 @param RelativePosition On return, points to the result of the comparison
855 @retval EFI_SUCCESS The operation succeeded.
856 @retval EFI_INVALID_PARAMETER The Position1 or Position2 is not a valid position in the boot script table.
862 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
863 IN EFI_S3_BOOT_SCRIPT_POSITION Position1
,
864 IN EFI_S3_BOOT_SCRIPT_POSITION Position2
,
865 OUT UINTN
*RelativePosition
868 return S3BootScriptCompare (Position1
, Position2
, RelativePosition
);
871 This routine is entry point of ScriptSave driver.
873 @param ImageHandle Handle for this drivers loaded image protocol.
874 @param SystemTable EFI system table.
876 @retval EFI_OUT_OF_RESOURCES No enough resource
877 @retval EFI_SUCCESS Succesfully installed the ScriptSave driver.
878 @retval other Errors occured.
883 InitializeSmmS3SaveState (
884 IN EFI_HANDLE ImageHandle
,
885 IN EFI_SYSTEM_TABLE
*SystemTable
892 return gSmst
->SmmInstallProtocolInterface (
894 &gEfiS3SmmSaveStateProtocolGuid
,
895 EFI_NATIVE_INTERFACE
,