2 Implementation for S3 Boot Script Saver state driver.
4 Copyright (c) 2006 - 2018, 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 "InternalS3SaveState.h"
18 EFI_HANDLE mHandle
= NULL
;
19 EFI_S3_SAVE_STATE_PROTOCOL mS3SaveState
= {
26 Internal function to add IO write opcode to the table.
28 @param Marker The variable argument list to get the opcode
29 and associated attributes.
31 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
32 @retval EFI_SUCCESS Opcode is added.
36 BootScriptWriteIoWrite (
40 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
45 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
46 Address
= VA_ARG (Marker
, UINT64
);
47 Count
= VA_ARG (Marker
, UINTN
);
48 Buffer
= VA_ARG (Marker
, UINT8
*);
50 return S3BootScriptSaveIoWrite (Width
, Address
, Count
, Buffer
);
53 Internal function to add IO read/write opcode to the table.
55 @param Marker The variable argument list to get the opcode
56 and associated attributes.
58 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
59 @retval EFI_SUCCESS Opcode is added.
63 BootScriptWriteIoReadWrite (
67 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
72 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
73 Address
= VA_ARG (Marker
, UINT64
);
74 Data
= VA_ARG (Marker
, UINT8
*);
75 DataMask
= VA_ARG (Marker
, UINT8
*);
77 return S3BootScriptSaveIoReadWrite (Width
, Address
, Data
, DataMask
);
81 Internal function to add memory write opcode to the table.
83 @param Marker The variable argument list to get the opcode
84 and associated attributes.
86 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
87 @retval EFI_SUCCESS Opcode is added.
91 BootScriptWriteMemWrite (
95 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
100 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
101 Address
= VA_ARG (Marker
, UINT64
);
102 Count
= VA_ARG (Marker
, UINTN
);
103 Buffer
= VA_ARG (Marker
, UINT8
*);
105 return S3BootScriptSaveMemWrite (Width
, Address
, Count
, Buffer
);
109 Internal function to add memory read/write opcode to the table.
111 @param Marker The variable argument list to get the opcode
112 and associated attributes.
114 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
115 @retval EFI_SUCCESS Opcode is added.
119 BootScriptWriteMemReadWrite (
123 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
128 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
129 Address
= VA_ARG (Marker
, UINT64
);
130 Data
= VA_ARG (Marker
, UINT8
*);
131 DataMask
= VA_ARG (Marker
, UINT8
*);
133 return S3BootScriptSaveMemReadWrite (Width
, Address
, Data
, DataMask
);
137 Internal function to add PciCfg write opcode to the table.
139 @param Marker The variable argument list to get the opcode
140 and associated attributes.
142 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
143 @retval EFI_SUCCESS Opcode is added.
147 BootScriptWritePciCfgWrite (
151 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
156 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
157 Address
= VA_ARG (Marker
, UINT64
);
158 Count
= VA_ARG (Marker
, UINTN
);
159 Buffer
= VA_ARG (Marker
, UINT8
*);
161 return S3BootScriptSavePciCfgWrite (Width
, Address
, Count
, Buffer
);
165 Internal function to PciCfg read/write opcode to the table.
167 @param Marker The variable argument list to get the opcode
168 and associated attributes.
170 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
171 @retval EFI_SUCCESS Opcode is added.
175 BootScriptWritePciCfgReadWrite (
179 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
184 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
185 Address
= VA_ARG (Marker
, UINT64
);
186 Data
= VA_ARG (Marker
, UINT8
*);
187 DataMask
= VA_ARG (Marker
, UINT8
*);
189 return S3BootScriptSavePciCfgReadWrite (Width
, Address
, Data
, DataMask
);
192 Internal function to add PciCfg2 write opcode to the table.
194 @param Marker The variable argument list to get the opcode
195 and associated attributes.
197 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
198 @retval EFI_SUCCESS Opcode is added.
202 BootScriptWritePciCfg2Write (
206 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
212 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
213 Segment
= VA_ARG (Marker
, UINT16
);
214 Address
= VA_ARG (Marker
, UINT64
);
215 Count
= VA_ARG (Marker
, UINTN
);
216 Buffer
= VA_ARG (Marker
, UINT8
*);
218 return S3BootScriptSavePciCfg2Write (Width
, Segment
, Address
, Count
, Buffer
);
222 Internal function to PciCfg2 read/write opcode to the table.
224 @param Marker The variable argument list to get the opcode
225 and associated attributes.
227 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
228 @retval EFI_SUCCESS Opcode is added.
232 BootScriptWritePciCfg2ReadWrite (
236 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
242 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
243 Segment
= VA_ARG (Marker
, UINT16
);
244 Address
= VA_ARG (Marker
, UINT64
);
245 Data
= VA_ARG (Marker
, UINT8
*);
246 DataMask
= VA_ARG (Marker
, UINT8
*);
248 return S3BootScriptSavePciCfg2ReadWrite (Width
, Segment
, Address
, Data
, DataMask
);
251 Internal function to add smbus execute opcode to the table.
253 @param Marker The variable argument list to get the opcode
254 and associated attributes.
256 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
257 @retval EFI_SUCCESS Opcode is added.
261 BootScriptWriteSmbusExecute (
265 EFI_SMBUS_DEVICE_ADDRESS SlaveAddress
;
266 EFI_SMBUS_DEVICE_COMMAND Command
;
267 EFI_SMBUS_OPERATION Operation
;
273 SlaveAddress
.SmbusDeviceAddress
= VA_ARG (Marker
, UINTN
);
274 Command
= VA_ARG (Marker
, EFI_SMBUS_DEVICE_COMMAND
);
275 Operation
= VA_ARG (Marker
, EFI_SMBUS_OPERATION
);
276 PecCheck
= VA_ARG (Marker
, BOOLEAN
);
277 SmBusAddress
= SMBUS_LIB_ADDRESS (SlaveAddress
.SmbusDeviceAddress
,Command
,0,PecCheck
);
278 DataSize
= VA_ARG (Marker
, UINTN
*);
279 Buffer
= VA_ARG (Marker
, VOID
*);
281 return S3BootScriptSaveSmbusExecute (SmBusAddress
, Operation
, DataSize
, Buffer
);
284 Internal function to add stall opcode to the table.
286 @param Marker The variable argument list to get the opcode
287 and associated attributes.
289 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
290 @retval EFI_SUCCESS Opcode is added.
294 BootScriptWriteStall (
300 Duration
= VA_ARG (Marker
, UINT32
);
302 return S3BootScriptSaveStall (Duration
);
306 Internal function to add Save jmp address according to DISPATCH_OPCODE.
307 We ignore "Context" parameter
309 @param Marker The variable argument list to get the opcode
310 and associated attributes.
312 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
313 @retval EFI_SUCCESS Opcode is added.
317 BootScriptWriteDispatch (
323 EntryPoint
= (VOID
*)(UINTN
)VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
324 return S3BootScriptSaveDispatch (EntryPoint
);
328 Internal function to add memory pool operation to the table.
330 @param Marker The variable argument list to get the opcode
331 and associated attributes.
333 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
334 @retval EFI_SUCCESS Opcode is added.
338 BootScriptWriteMemPoll (
342 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
350 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
351 Address
= VA_ARG (Marker
, UINT64
);
352 Data
= VA_ARG (Marker
, VOID
*);
353 DataMask
= VA_ARG (Marker
, VOID
*);
354 Delay
= VA_ARG (Marker
, UINT64
);
356 // According to the spec, the interval between 2 polls is 100ns,
357 // but the unit of Duration for S3BootScriptSaveMemPoll() is microsecond(1000ns).
358 // Duration * 1000ns * LoopTimes = Delay * 100ns
359 // Duration will be minimum 1(microsecond) to be minimum deviation,
360 // so LoopTimes = Delay / 10.
362 LoopTimes
= DivU64x32Remainder (
367 if (Remainder
!= 0) {
369 // If Remainder is not zero, LoopTimes will be rounded up by 1.
373 return S3BootScriptSaveMemPoll (Width
, Address
, DataMask
, Data
, 1, LoopTimes
);
378 Internal function to add Save jmp address according to DISPATCH_OPCODE2.
379 The "Context" parameter is not ignored.
381 @param Marker The variable argument list to get the opcode
382 and associated attributes.
384 @retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
385 @retval EFI_SUCCESS Opcode is added.
389 BootScriptWriteDispatch2 (
396 EntryPoint
= (VOID
*)(UINTN
)VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
397 Context
= (VOID
*)(UINTN
)VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
399 return S3BootScriptSaveDispatch2 (EntryPoint
, Context
);
402 Internal function to add INFORAMTION opcode node to the table
404 @param Marker The variable argument list to get the opcode
405 and associated attributes.
407 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
408 @retval EFI_SUCCESS The opcode entry is added to the table
412 BootScriptWriteInformation (
416 UINT32 InformationLength
;
417 EFI_PHYSICAL_ADDRESS Information
;
419 InformationLength
= VA_ARG (Marker
, UINT32
);
420 Information
= VA_ARG (Marker
, EFI_PHYSICAL_ADDRESS
);
421 return S3BootScriptSaveInformation (InformationLength
, (VOID
*)(UINTN
)Information
);
424 Internal function to add IO poll opcode node to the table
425 @param Marker The variable argument list to get the opcode
426 and associated attributes.
428 @retval EFI_OUT_OF_RESOURCES Not enought resource to complete the operations.
429 @retval EFI_SUCCESS The opcode entry is added to the table
433 BootScriptWriteIoPoll (
437 S3_BOOT_SCRIPT_LIB_WIDTH Width
;
443 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
444 Address
= VA_ARG (Marker
, UINT64
);
445 Data
= VA_ARG (Marker
, VOID
*);
446 DataMask
= VA_ARG (Marker
, VOID
*);
447 Delay
= (UINT64
)VA_ARG (Marker
, UINT64
);
449 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
;
473 Width
= VA_ARG (Marker
, S3_BOOT_SCRIPT_LIB_WIDTH
);
474 Address
= VA_ARG (Marker
, UINT64
);
475 Data
= VA_ARG (Marker
, VOID
*);
476 DataMask
= VA_ARG (Marker
, VOID
*);
477 Delay
= (UINT64
)VA_ARG (Marker
, UINT64
);
479 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
);
515 Adds a record into S3 boot script table.
517 This function is used to store a boot script record into a given boot
518 script table. If the table specified by TableName is nonexistent in the
519 system, a new table will automatically be created and then the script record
520 will be added into the new table. This function is responsible for allocating
521 necessary memory for the script.
523 This function has a variable parameter list. The exact parameter list depends on
524 the OpCode that is passed into the function. If an unsupported OpCode or illegal
525 parameter list is passed in, this function returns EFI_INVALID_PARAMETER.
526 If there are not enough resources available for storing more scripts, this function returns
527 EFI_OUT_OF_RESOURCES.
529 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
530 @param OpCode The operation code (opcode) number.
531 @param ... Argument list that is specific to each opcode.
533 @retval EFI_SUCCESS The operation succeeded. A record was added into the
534 specified script table.
535 @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.
536 If the opcode is unknow or not supported because of the PCD
538 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
544 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
552 // Build script according to opcode
556 case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE
:
557 VA_START (Marker
, OpCode
);
558 Status
= BootScriptWriteIoWrite (Marker
);
562 case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE
:
563 VA_START (Marker
, OpCode
);
564 Status
= BootScriptWriteIoReadWrite (Marker
);
568 case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE
:
569 VA_START (Marker
, OpCode
);
570 Status
= BootScriptWriteMemWrite (Marker
);
574 case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE
:
575 VA_START (Marker
, OpCode
);
576 Status
= BootScriptWriteMemReadWrite (Marker
);
580 case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE
:
581 VA_START (Marker
, OpCode
);
582 Status
= BootScriptWritePciCfgWrite (Marker
);
586 case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE
:
587 VA_START (Marker
, OpCode
);
588 Status
= BootScriptWritePciCfgReadWrite (Marker
);
592 case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE
:
593 VA_START (Marker
, OpCode
);
594 Status
= BootScriptWriteSmbusExecute (Marker
);
598 case EFI_BOOT_SCRIPT_STALL_OPCODE
:
599 VA_START (Marker
, OpCode
);
600 Status
= BootScriptWriteStall (Marker
);
605 case EFI_BOOT_SCRIPT_DISPATCH_OPCODE
:
606 VA_START (Marker
, OpCode
);
607 Status
= BootScriptWriteDispatch (Marker
);
611 case EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE
:
612 VA_START (Marker
, OpCode
);
613 Status
= BootScriptWriteDispatch2 (Marker
);
617 case EFI_BOOT_SCRIPT_INFORMATION_OPCODE
:
618 VA_START (Marker
, OpCode
);
619 Status
= BootScriptWriteInformation (Marker
);
623 case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE
:
624 VA_START (Marker
, OpCode
);
625 Status
= BootScriptWriteMemPoll (Marker
);
629 case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE
:
630 VA_START (Marker
, OpCode
);
631 Status
= BootScriptWritePciCfg2Write (Marker
);
635 case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE
:
636 VA_START (Marker
, OpCode
);
637 Status
= BootScriptWritePciCfg2ReadWrite (Marker
);
641 case EFI_BOOT_SCRIPT_IO_POLL_OPCODE
:
642 VA_START (Marker
, OpCode
);
643 Status
= BootScriptWriteIoPoll (Marker
);
647 case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE
:
648 VA_START (Marker
, OpCode
);
649 Status
= BootScriptWritePciConfigPoll (Marker
);
653 case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE
:
654 VA_START (Marker
, OpCode
);
655 Status
= BootScriptWritePciConfig2Poll (Marker
);
660 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
,
707 // 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
, Position
);
825 Find a label within the boot script table and, if not present, optionally create it.
827 If the label Label is already exists in the boot script table, then no new label is created, the
828 position of the Label is returned in *Position and EFI_SUCCESS is returned.
829 If the label Label does not already exist and CreateIfNotFound is TRUE, then it will be
830 created before or after the specified position and EFI_SUCCESS is returned.
831 If the label Label does not already exist and CreateIfNotFound is FALSE, then
832 EFI_NOT_FOUND is returned.
834 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
835 @param BeforeOrAfter Specifies whether the label is stored before (TRUE) or after (FALSE) the position in
836 the boot script table specified by Position. If Position is NULL or points to
837 NULL then the new label is inserted at the beginning of the table (if TRUE) or end of
838 the table (if FALSE).
839 @param CreateIfNotFound Specifies whether the label will be created if the label does not exists (TRUE) or not
841 @param Position On entry, specifies the position in the boot script table where the label will be inserted,
842 either before or after, depending on BeforeOrAfter. On exit, specifies the position
843 of the inserted label in the boot script table.
844 @param Label Points to the label which will be inserted in the boot script table.
846 @retval EFI_SUCCESS The label already exists or was inserted.
847 @retval EFI_INVALID_PARAMETER The Label is NULL or points to an empty string.
848 @retval EFI_INVALID_PARAMETER The Position is not a valid position in the boot script table.
854 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
855 IN BOOLEAN BeforeOrAfter
,
856 IN BOOLEAN CreateIfNotFound
,
857 IN OUT EFI_S3_BOOT_SCRIPT_POSITION
*Position OPTIONAL
,
858 IN CONST CHAR8
*Label
861 return S3BootScriptLabel (BeforeOrAfter
, CreateIfNotFound
, Position
, Label
);
864 Compare two positions in the boot script table and return their relative position.
866 This function compares two positions in the boot script table and returns their relative positions. If
867 Position1 is before Position2, then -1 is returned. If Position1 is equal to Position2,
868 then 0 is returned. If Position1 is after Position2, then 1 is returned.
870 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
871 @param Position1 The positions in the boot script table to compare
872 @param Position2 The positions in the boot script table to compare
873 @param RelativePosition On return, points to the result of the comparison
875 @retval EFI_SUCCESS The operation succeeded.
876 @retval EFI_INVALID_PARAMETER The Position1 or Position2 is not a valid position in the boot script table.
877 @retval EFI_INVALID_PARAMETER The RelativePosition is NULL.
883 IN CONST EFI_S3_SAVE_STATE_PROTOCOL
*This
,
884 IN EFI_S3_BOOT_SCRIPT_POSITION Position1
,
885 IN EFI_S3_BOOT_SCRIPT_POSITION Position2
,
886 OUT UINTN
*RelativePosition
889 return S3BootScriptCompare (Position1
, Position2
, RelativePosition
);
892 This routine is entry point of ScriptSave driver.
894 @param ImageHandle Handle for this drivers loaded image protocol.
895 @param SystemTable EFI system table.
897 @retval EFI_OUT_OF_RESOURCES No enough resource
898 @retval EFI_SUCCESS Succesfully installed the ScriptSave driver.
899 @retval other Errors occured.
904 InitializeS3SaveState (
905 IN EFI_HANDLE ImageHandle
,
906 IN EFI_SYSTEM_TABLE
*SystemTable
910 EFI_EVENT EndOfDxeEvent
;
912 if (!PcdGetBool (PcdAcpiS3Enable
)) {
913 return EFI_UNSUPPORTED
;
916 Status
= gBS
->CreateEventEx (
919 AcpiS3ContextSaveOnEndOfDxe
,
921 &gEfiEndOfDxeEventGroupGuid
,
924 ASSERT_EFI_ERROR (Status
);
926 return gBS
->InstallProtocolInterface (
928 &gEfiS3SaveStateProtocolGuid
,
929 EFI_NATIVE_INTERFACE
,