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