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