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 | /**
|
---|
66 | Find Esrt Entry stored in ESRT repository.
|
---|
67 |
|
---|
68 | @param[in] FwClass Firmware class guid in Esrt entry
|
---|
69 | @param[in] Attribute Esrt from Non FMP or FMP instance
|
---|
70 | @param[out] Entry Esrt entry returned
|
---|
71 |
|
---|
72 | @retval EFI_SUCCESS Successfully find an Esrt entry
|
---|
73 | @retval EF_NOT_FOUND No Esrt entry found
|
---|
74 |
|
---|
75 | **/
|
---|
76 | EFI_STATUS
|
---|
77 | GetEsrtEntry (
|
---|
78 | IN EFI_GUID *FwClass,
|
---|
79 | IN UINTN Attribute,
|
---|
80 | OUT EFI_SYSTEM_RESOURCE_ENTRY *Entry
|
---|
81 | );
|
---|
82 |
|
---|
83 | /**
|
---|
84 | Insert a new ESRT entry into ESRT Cache repository.
|
---|
85 |
|
---|
86 | @param[in] Entry Esrt entry to be set
|
---|
87 | @param[in] Attribute Esrt from Esrt private protocol or FMP instance
|
---|
88 |
|
---|
89 | @retval EFI_SUCCESS Successfully set a variable.
|
---|
90 |
|
---|
91 | **/
|
---|
92 | EFI_STATUS
|
---|
93 | InsertEsrtEntry(
|
---|
94 | IN EFI_SYSTEM_RESOURCE_ENTRY *Entry,
|
---|
95 | UINTN Attribute
|
---|
96 | );
|
---|
97 |
|
---|
98 | /**
|
---|
99 | Delete ESRT Entry from ESRT repository.
|
---|
100 |
|
---|
101 | @param[in] FwClass FwClass of Esrt entry to delete
|
---|
102 | @param[in] Attribute Esrt from Esrt private protocol or FMP instance
|
---|
103 |
|
---|
104 | @retval EFI_SUCCESS Insert all entries Successfully
|
---|
105 | @retval EFI_NOT_FOUND ESRT entry with FwClass doesn't exsit
|
---|
106 |
|
---|
107 | **/
|
---|
108 | EFI_STATUS
|
---|
109 | DeleteEsrtEntry(
|
---|
110 | IN EFI_GUID *FwClass,
|
---|
111 | IN UINTN Attribute
|
---|
112 | );
|
---|
113 |
|
---|
114 | /**
|
---|
115 | Update one ESRT entry in ESRT repository
|
---|
116 |
|
---|
117 | @param[in] Entry Esrt entry to be set
|
---|
118 | @param[in] Attribute Esrt from Non Esrt or FMP instance
|
---|
119 |
|
---|
120 | @retval EFI_SUCCESS Successfully Update a variable.
|
---|
121 | @retval EFI_NOT_FOUND The Esrt enry doesn't exist
|
---|
122 |
|
---|
123 | **/
|
---|
124 | EFI_STATUS
|
---|
125 | UpdateEsrtEntry(
|
---|
126 | IN EFI_SYSTEM_RESOURCE_ENTRY *Entry,
|
---|
127 | UINTN Attribute
|
---|
128 | );
|
---|
129 |
|
---|
130 | /**
|
---|
131 | Init one ESRT entry according to input FmpImageInfo (V1, V2, V3) .
|
---|
132 |
|
---|
133 | @param[in, out] EsrtEntry Esrt entry to be Init
|
---|
134 | @param[in] FmpImageInfo FMP image info descriptor
|
---|
135 | @param[in] DescriptorVersion FMP Image info descriptor version
|
---|
136 |
|
---|
137 | **/
|
---|
138 | VOID
|
---|
139 | SetEsrtEntryFromFmpInfo (
|
---|
140 | IN OUT EFI_SYSTEM_RESOURCE_ENTRY *EsrtEntry,
|
---|
141 | IN EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfo,
|
---|
142 | IN UINT32 DescriptorVersion
|
---|
143 | );
|
---|
144 |
|
---|
145 | /**
|
---|
146 | Get ESRT entry from ESRT Cache by FwClass Guid
|
---|
147 |
|
---|
148 | @param[in] FwClass FwClass of Esrt entry to get
|
---|
149 | @param[in, out] Entry Esrt entry returned
|
---|
150 |
|
---|
151 | @retval EFI_SUCCESS The variable saving this Esrt Entry exists.
|
---|
152 | @retval EF_NOT_FOUND No correct variable found.
|
---|
153 | @retval EFI_WRITE_PROTECTED ESRT Cache repository is locked
|
---|
154 |
|
---|
155 | **/
|
---|
156 | EFI_STATUS
|
---|
157 | EFIAPI
|
---|
158 | EsrtDxeGetEsrtEntry(
|
---|
159 | IN EFI_GUID *FwClass,
|
---|
160 | IN OUT EFI_SYSTEM_RESOURCE_ENTRY *Entry
|
---|
161 | );
|
---|
162 |
|
---|
163 | /**
|
---|
164 | Update one ESRT entry in ESRT Cache.
|
---|
165 |
|
---|
166 | @param[in] Entry Esrt entry to be updated
|
---|
167 |
|
---|
168 | @retval EFI_SUCCESS Successfully update an ESRT entry in cache.
|
---|
169 | @retval EFI_INVALID_PARAMETER Entry does't exist in ESRT Cache
|
---|
170 | @retval EFI_WRITE_PROTECTED ESRT Cache is locked
|
---|
171 |
|
---|
172 | **/
|
---|
173 | EFI_STATUS
|
---|
174 | EFIAPI
|
---|
175 | EsrtDxeUpdateEsrtEntry(
|
---|
176 | IN EFI_SYSTEM_RESOURCE_ENTRY *Entry
|
---|
177 | );
|
---|
178 |
|
---|
179 | /**
|
---|
180 | Non-FMP instance to unregister Esrt Entry from ESRT Cache.
|
---|
181 |
|
---|
182 | @param[in] FwClass FwClass of Esrt entry to Unregister
|
---|
183 |
|
---|
184 | @retval EFI_SUCCESS Insert all entries Successfully
|
---|
185 | @retval EFI_NOT_FOUND Entry of FwClass does not exsit
|
---|
186 |
|
---|
187 | **/
|
---|
188 | EFI_STATUS
|
---|
189 | EFIAPI
|
---|
190 | EsrtDxeUnRegisterEsrtEntry(
|
---|
191 | IN EFI_GUID *FwClass
|
---|
192 | );
|
---|
193 |
|
---|
194 | /**
|
---|
195 | Non-FMP instance to register one ESRT entry into ESRT Cache.
|
---|
196 |
|
---|
197 | @param[in] Entry Esrt entry to be set
|
---|
198 |
|
---|
199 | @retval EFI_SUCCESS Successfully set a variable.
|
---|
200 | @retval EFI_INVALID_PARAMETER ESRT Entry is already exist
|
---|
201 | **/
|
---|
202 | EFI_STATUS
|
---|
203 | EFIAPI
|
---|
204 | EsrtDxeRegisterEsrtEntry(
|
---|
205 | IN EFI_SYSTEM_RESOURCE_ENTRY *Entry
|
---|
206 | );
|
---|
207 |
|
---|
208 | /**
|
---|
209 | This function syn up Cached ESRT with data from FMP instances
|
---|
210 | Function should be called after Connect All in order to locate all FMP protocols
|
---|
211 | installed.
|
---|
212 |
|
---|
213 | @retval EFI_SUCCESS Successfully sync cache repository from FMP instances
|
---|
214 | @retval EFI_NOT_FOUND No FMP Instance are found
|
---|
215 | @retval EFI_OUT_OF_RESOURCES Resource allocaton fail
|
---|
216 |
|
---|
217 | **/
|
---|
218 | EFI_STATUS
|
---|
219 | EFIAPI
|
---|
220 | EsrtDxeSyncFmp(
|
---|
221 | VOID
|
---|
222 | );
|
---|
223 |
|
---|
224 | /**
|
---|
225 | This function locks up Esrt repository to be readonly. It should be called
|
---|
226 | before gEfiEndOfDxeEventGroupGuid event signaled
|
---|
227 |
|
---|
228 | @retval EFI_SUCCESS Locks up FMP Non-FMP repository successfully
|
---|
229 |
|
---|
230 | **/
|
---|
231 | EFI_STATUS
|
---|
232 | EFIAPI
|
---|
233 | EsrtDxeLockEsrtRepository(
|
---|
234 | VOID
|
---|
235 | );
|
---|
236 |
|
---|
237 | #endif // #ifndef _EFI_ESRT_IMPL_H_
|
---|
238 |
|
---|