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