]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/EsrtDxe/EsrtImpl.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Universal / EsrtDxe / EsrtImpl.h
1 /** @file
2 Esrt management implementation head file.
3
4 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef _DXE_ESRT_IMPL_H_
10 #define _DXE_ESRT_IMPL_H_
11
12 #include <Guid/EventGroup.h>
13 #include <Guid/SystemResourceTable.h>
14
15 #include <Library/UefiLib.h>
16 #include <Library/UefiRuntimeServicesTableLib.h>
17 #include <Library/UefiLib.h>
18 #include <Library/PcdLib.h>
19 #include <Library/BaseLib.h>
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/MemoryAllocationLib.h>
22 #include <Library/UefiBootServicesTableLib.h>
23 #include <Library/DebugLib.h>
24 #include <Library/CapsuleLib.h>
25
26 #include <Protocol/FirmwareManagement.h>
27 #include <Protocol/EsrtManagement.h>
28 #include <Protocol/VariableLock.h>
29
30 //
31 // Name of Variable for Non-FMP ESRT Repository
32 //
33 #define EFI_ESRT_NONFMP_VARIABLE_NAME L"EsrtNonFmp"
34
35 //
36 // Name of Variable for FMP
37 //
38 #define EFI_ESRT_FMP_VARIABLE_NAME L"EsrtFmp"
39
40 //
41 // Attribute of Cached ESRT entry
42 //
43 #define ESRT_FROM_FMP 0x00000001
44 #define ESRT_FROM_NONFMP 0x00000002
45
46 typedef struct {
47 EFI_HANDLE Handle;
48 //
49 // Ready to boot event
50 //
51 EFI_EVENT Event;
52
53 //
54 // Updates to Fmp storage must be locked.
55 //
56 EFI_LOCK FmpLock;
57
58 //
59 // Update to Non-Fmp storage must be locked
60 //
61 EFI_LOCK NonFmpLock;
62 } ESRT_PRIVATE_DATA;
63
64 /**
65 Find Esrt Entry stored in ESRT repository.
66
67 @param[in] FwClass Firmware class guid in Esrt entry
68 @param[in] Attribute Esrt from Non FMP or FMP instance
69 @param[out] Entry Esrt entry returned
70
71 @retval EFI_SUCCESS Successfully find an Esrt entry
72 @retval EF_NOT_FOUND No Esrt entry found
73
74 **/
75 EFI_STATUS
76 GetEsrtEntry (
77 IN EFI_GUID *FwClass,
78 IN UINTN Attribute,
79 OUT EFI_SYSTEM_RESOURCE_ENTRY *Entry
80 );
81
82 /**
83 Insert a new ESRT entry into ESRT Cache repository.
84
85 @param[in] Entry Esrt entry to be set
86 @param[in] Attribute Esrt from Esrt private protocol or FMP instance
87
88 @retval EFI_SUCCESS Successfully set a variable.
89
90 **/
91 EFI_STATUS
92 InsertEsrtEntry (
93 IN EFI_SYSTEM_RESOURCE_ENTRY *Entry,
94 UINTN Attribute
95 );
96
97 /**
98 Delete ESRT Entry from ESRT repository.
99
100 @param[in] FwClass FwClass of Esrt entry to delete
101 @param[in] Attribute Esrt from Esrt private protocol or FMP instance
102
103 @retval EFI_SUCCESS Insert all entries Successfully
104 @retval EFI_NOT_FOUND ESRT entry with FwClass doesn't exsit
105
106 **/
107 EFI_STATUS
108 DeleteEsrtEntry (
109 IN EFI_GUID *FwClass,
110 IN UINTN Attribute
111 );
112
113 /**
114 Update one ESRT entry in ESRT repository
115
116 @param[in] Entry Esrt entry to be set
117 @param[in] Attribute Esrt from Non Esrt or FMP instance
118
119 @retval EFI_SUCCESS Successfully Update a variable.
120 @retval EFI_NOT_FOUND The Esrt enry doesn't exist
121
122 **/
123 EFI_STATUS
124 UpdateEsrtEntry (
125 IN EFI_SYSTEM_RESOURCE_ENTRY *Entry,
126 UINTN Attribute
127 );
128
129 /**
130 Init one ESRT entry according to input FmpImageInfo (V1, V2, V3) .
131
132 @param[in, out] EsrtEntry Esrt entry to be Init
133 @param[in] FmpImageInfo FMP image info descriptor
134 @param[in] DescriptorVersion FMP Image info descriptor version
135
136 **/
137 VOID
138 SetEsrtEntryFromFmpInfo (
139 IN OUT EFI_SYSTEM_RESOURCE_ENTRY *EsrtEntry,
140 IN EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfo,
141 IN UINT32 DescriptorVersion
142 );
143
144 /**
145 Get ESRT entry from ESRT Cache by FwClass Guid
146
147 @param[in] FwClass FwClass of Esrt entry to get
148 @param[in, out] Entry Esrt entry returned
149
150 @retval EFI_SUCCESS The variable saving this Esrt Entry exists.
151 @retval EF_NOT_FOUND No correct variable found.
152 @retval EFI_WRITE_PROTECTED ESRT Cache repository is locked
153
154 **/
155 EFI_STATUS
156 EFIAPI
157 EsrtDxeGetEsrtEntry (
158 IN EFI_GUID *FwClass,
159 IN OUT EFI_SYSTEM_RESOURCE_ENTRY *Entry
160 );
161
162 /**
163 Update one ESRT entry in ESRT Cache.
164
165 @param[in] Entry Esrt entry to be updated
166
167 @retval EFI_SUCCESS Successfully update an ESRT entry in cache.
168 @retval EFI_INVALID_PARAMETER Entry does't exist in ESRT Cache
169 @retval EFI_WRITE_PROTECTED ESRT Cache is locked
170
171 **/
172 EFI_STATUS
173 EFIAPI
174 EsrtDxeUpdateEsrtEntry (
175 IN EFI_SYSTEM_RESOURCE_ENTRY *Entry
176 );
177
178 /**
179 Non-FMP instance to unregister Esrt Entry from ESRT Cache.
180
181 @param[in] FwClass FwClass of Esrt entry to Unregister
182
183 @retval EFI_SUCCESS Insert all entries Successfully
184 @retval EFI_NOT_FOUND Entry of FwClass does not exsit
185
186 **/
187 EFI_STATUS
188 EFIAPI
189 EsrtDxeUnRegisterEsrtEntry (
190 IN EFI_GUID *FwClass
191 );
192
193 /**
194 Non-FMP instance to register one ESRT entry into ESRT Cache.
195
196 @param[in] Entry Esrt entry to be set
197
198 @retval EFI_SUCCESS Successfully set a variable.
199 @retval EFI_INVALID_PARAMETER ESRT Entry is already exist
200 **/
201 EFI_STATUS
202 EFIAPI
203 EsrtDxeRegisterEsrtEntry (
204 IN EFI_SYSTEM_RESOURCE_ENTRY *Entry
205 );
206
207 /**
208 This function syn up Cached ESRT with data from FMP instances
209 Function should be called after Connect All in order to locate all FMP protocols
210 installed.
211
212 @retval EFI_SUCCESS Successfully sync cache repository from FMP instances
213 @retval EFI_NOT_FOUND No FMP Instance are found
214 @retval EFI_OUT_OF_RESOURCES Resource allocaton fail
215
216 **/
217 EFI_STATUS
218 EFIAPI
219 EsrtDxeSyncFmp (
220 VOID
221 );
222
223 /**
224 This function locks up Esrt repository to be readonly. It should be called
225 before gEfiEndOfDxeEventGroupGuid event signaled
226
227 @retval EFI_SUCCESS Locks up FMP Non-FMP repository successfully
228
229 **/
230 EFI_STATUS
231 EFIAPI
232 EsrtDxeLockEsrtRepository (
233 VOID
234 );
235
236 #endif // #ifndef _EFI_ESRT_IMPL_H_