]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Acpi/S3SaveStateDxe/InternalS3SaveState.h
MdeModulePkg S3SaveStateDxe: Consume PcdAcpiS3Enable to control the code
[mirror_edk2.git] / MdeModulePkg / Universal / Acpi / S3SaveStateDxe / InternalS3SaveState.h
1 /** @file
2 Internal header file for S3 Boot Script Saver state driver.
3
4 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
5
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
11
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.
14
15 **/
16 #ifndef _INTERNAL_S3_SAVE_STATE_H_
17 #define _INTERNAL_S3_SAVE_STATE_H_
18 #include <PiDxe.h>
19
20 #include <Protocol/S3SaveState.h>
21
22 #include <Library/BaseLib.h>
23 #include <Library/DebugLib.h>
24 #include <Library/UefiDriverEntryPoint.h>
25 #include <Library/UefiBootServicesTableLib.h>
26 #include <Library/UefiRuntimeServicesTableLib.h>
27 #include <Library/S3BootScriptLib.h>
28 #include <Library/SmbusLib.h>
29 #include <Library/PcdLib.h>
30 #include <IndustryStandard/SmBus.h>
31 /**
32 Adds a record into S3 boot script table.
33
34 This function is used to store a boot script record into a given boot
35 script table. If the table specified by TableName is nonexistent in the
36 system, a new table will automatically be created and then the script record
37 will be added into the new table. This function is responsible for allocating
38 necessary memory for the script.
39
40 This function has a variable parameter list. The exact parameter list depends on
41 the OpCode that is passed into the function. If an unsupported OpCode or illegal
42 parameter list is passed in, this function returns EFI_INVALID_PARAMETER.
43 If there are not enough resources available for storing more scripts, this function returns
44 EFI_OUT_OF_RESOURCES.
45
46 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
47 @param OpCode The operation code (opcode) number.
48 @param ... Argument list that is specific to each opcode.
49
50 @retval EFI_SUCCESS The operation succeeded. A record was added into the
51 specified script table.
52 @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.
53 If the opcode is unknow or not supported because of the PCD
54 Feature Flags.
55 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
56
57 **/
58 EFI_STATUS
59 EFIAPI
60 BootScriptWrite (
61 IN CONST EFI_S3_SAVE_STATE_PROTOCOL *This,
62 IN UINT16 OpCode,
63 ...
64 );
65 /**
66 Insert a record into a specified Framework boot script table.
67
68 This function is used to store an OpCode to be replayed as part of the S3 resume boot path. It is
69 assumed this protocol has platform specific mechanism to store the OpCode set and replay them
70 during the S3 resume.
71 The opcode is inserted before or after the specified position in the boot script table. If Position is
72 NULL then that position is after the last opcode in the table (BeforeOrAfter is FALSE) or before
73 the first opcode in the table (BeforeOrAfter is TRUE). The position which is pointed to by
74 Position upon return can be used for subsequent insertions.
75
76 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
77 @param BeforeOrAfter Specifies whether the opcode is stored before (TRUE) or after (FALSE) the position
78 in the boot script table specified by Position. If Position is NULL or points to
79 NULL then the new opcode is inserted at the beginning of the table (if TRUE) or end
80 of the table (if FALSE).
81 @param Position On entry, specifies the position in the boot script table where the opcode will be
82 inserted, either before or after, depending on BeforeOrAfter. On exit, specifies
83 the position of the inserted opcode in the boot script table.
84 @param OpCode The operation code (opcode) number.
85 @param ... Argument list that is specific to each opcode.
86
87 @retval EFI_SUCCESS The operation succeeded. A record was added into the
88 specified script table.
89 @retval EFI_INVALID_PARAMETER The Opcode is an invalid opcode value or the Position is not a valid position in the boot script table..
90 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
91
92 **/
93 EFI_STATUS
94 EFIAPI
95 BootScriptInsert (
96 IN CONST EFI_S3_SAVE_STATE_PROTOCOL *This,
97 IN BOOLEAN BeforeOrAfter,
98 IN OUT EFI_S3_BOOT_SCRIPT_POSITION *Position OPTIONAL,
99 IN UINT16 OpCode,
100 ...
101 );
102 /**
103 Find a label within the boot script table and, if not present, optionally create it.
104
105 If the label Label is already exists in the boot script table, then no new label is created, the
106 position of the Label is returned in *Position and EFI_SUCCESS is returned.
107 If the label Label does not already exist and CreateIfNotFound is TRUE, then it will be
108 created before or after the specified position and EFI_SUCCESS is returned.
109 If the label Label does not already exist and CreateIfNotFound is FALSE, then
110 EFI_NOT_FOUND is returned.
111
112 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
113 @param BeforeOrAfter Specifies whether the label is stored before (TRUE) or after (FALSE) the position in
114 the boot script table specified by Position. If Position is NULL or points to
115 NULL then the new label is inserted at the beginning of the table (if TRUE) or end of
116 the table (if FALSE).
117 @param CreateIfNotFound Specifies whether the label will be created if the label does not exists (TRUE) or not
118 (FALSE).
119 @param Position On entry, specifies the position in the boot script table where the label will be inserted,
120 either before or after, depending on BeforeOrAfter. On exit, specifies the position
121 of the inserted label in the boot script table.
122 @param Label Points to the label which will be inserted in the boot script table.
123
124 @retval EFI_SUCCESS The label already exists or was inserted.
125 @retval EFI_INVALID_PARAMETER The Opcode is an invalid opcode value or the Position is not a valid position in the boot script table..
126
127 **/
128 EFI_STATUS
129 EFIAPI
130 BootScriptLabel (
131 IN CONST EFI_S3_SAVE_STATE_PROTOCOL *This,
132 IN BOOLEAN BeforeOrAfter,
133 IN BOOLEAN CreateIfNotFound,
134 IN OUT EFI_S3_BOOT_SCRIPT_POSITION *Position OPTIONAL,
135 IN CONST CHAR8 *Label
136 );
137 /**
138 Compare two positions in the boot script table and return their relative position.
139
140 This function compares two positions in the boot script table and returns their relative positions. If
141 Position1 is before Position2, then -1 is returned. If Position1 is equal to Position2,
142 then 0 is returned. If Position1 is after Position2, then 1 is returned.
143
144 @param This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
145 @param Position1 The positions in the boot script table to compare
146 @param Position2 The positions in the boot script table to compare
147 @param RelativePosition On return, points to the result of the comparison
148
149 @retval EFI_SUCCESS The operation succeeded.
150 @retval EFI_INVALID_PARAMETER The Position1 or Position2 is not a valid position in the boot script table.
151
152 **/
153 EFI_STATUS
154 EFIAPI
155 BootScriptCompare (
156 IN CONST EFI_S3_SAVE_STATE_PROTOCOL *This,
157 IN EFI_S3_BOOT_SCRIPT_POSITION Position1,
158 IN EFI_S3_BOOT_SCRIPT_POSITION Position2,
159 OUT UINTN *RelativePosition
160 );
161
162 #endif //_INTERNAL_S3_SAVE_STATE_H_