]>
Commit | Line | Data |
---|---|---|
beda2356 | 1 | /** @file\r |
2 | The header file of HII Config Access protocol implementation of SecureBoot\r | |
3 | configuration module.\r | |
4 | \r | |
20333c6d | 5 | Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r |
bc0c99b3 | 6 | This program and the accompanying materials\r |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
beda2356 | 9 | http://opensource.org/licenses/bsd-license.php\r |
10 | \r | |
bc0c99b3 | 11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
beda2356 | 12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #ifndef __SECUREBOOT_CONFIG_IMPL_H__\r | |
17 | #define __SECUREBOOT_CONFIG_IMPL_H__\r | |
18 | \r | |
19 | #include <Uefi.h>\r | |
20 | \r | |
21 | #include <Protocol/HiiConfigAccess.h>\r | |
22 | #include <Protocol/HiiConfigRouting.h>\r | |
ecc722ad | 23 | #include <Protocol/SimpleFileSystem.h>\r |
24 | #include <Protocol/BlockIo.h>\r | |
25 | #include <Protocol/DevicePath.h>\r | |
ecc722ad | 26 | #include <Protocol/DebugPort.h>\r |
27 | #include <Protocol/LoadFile.h>\r | |
beda2356 | 28 | \r |
29 | #include <Library/BaseLib.h>\r | |
30 | #include <Library/BaseMemoryLib.h>\r | |
31 | #include <Library/DebugLib.h>\r | |
32 | #include <Library/MemoryAllocationLib.h>\r | |
33 | #include <Library/UefiBootServicesTableLib.h>\r | |
34 | #include <Library/UefiRuntimeServicesTableLib.h>\r | |
35 | #include <Library/UefiHiiServicesLib.h>\r | |
36 | #include <Library/UefiLib.h>\r | |
37 | #include <Library/HiiLib.h>\r | |
38 | #include <Library/DevicePathLib.h>\r | |
bc0c99b3 | 39 | #include <Library/PrintLib.h>\r |
ecc722ad | 40 | #include <Library/PlatformSecureLib.h>\r |
41 | #include <Library/BaseCryptLib.h>\r | |
beda2356 | 42 | #include <Guid/MdeModuleHii.h>\r |
43 | #include <Guid/AuthenticatedVariableFormat.h>\r | |
ecc722ad | 44 | #include <Guid/FileSystemVolumeLabelInfo.h>\r |
45 | #include <Guid/ImageAuthentication.h>\r | |
46 | #include <Guid/FileInfo.h>\r | |
beda2356 | 47 | \r |
48 | #include "SecureBootConfigNvData.h"\r | |
49 | \r | |
50 | //\r | |
51 | // Tool generated IFR binary data and String package data\r | |
52 | //\r | |
ecc722ad | 53 | extern UINT8 SecureBootConfigBin[];\r |
54 | extern UINT8 SecureBootConfigDxeStrings[];\r | |
55 | \r | |
56 | //\r | |
57 | // Shared IFR form update data\r | |
58 | //\r | |
59 | extern VOID *mStartOpCodeHandle;\r | |
60 | extern VOID *mEndOpCodeHandle;\r | |
61 | extern EFI_IFR_GUID_LABEL *mStartLabel;\r | |
62 | extern EFI_IFR_GUID_LABEL *mEndLabel;\r | |
63 | \r | |
64 | #define MAX_CHAR 480\r | |
65 | #define TWO_BYTE_ENCODE 0x82\r | |
66 | \r | |
67 | //\r | |
68 | // SHA-1 digest size in bytes.\r | |
69 | //\r | |
70 | #define SHA1_DIGEST_SIZE 20\r | |
71 | //\r | |
72 | // SHA-256 digest size in bytes\r | |
73 | //\r | |
74 | #define SHA256_DIGEST_SIZE 32\r | |
75 | //\r | |
20333c6d | 76 | // SHA-384 digest size in bytes\r |
ecc722ad | 77 | //\r |
20333c6d QL |
78 | #define SHA384_DIGEST_SIZE 48\r |
79 | //\r | |
80 | // SHA-512 digest size in bytes\r | |
81 | //\r | |
82 | #define SHA512_DIGEST_SIZE 64\r | |
83 | \r | |
84 | //\r | |
85 | // Set max digest size as SHA512 Output (64 bytes) by far\r | |
86 | //\r | |
87 | #define MAX_DIGEST_SIZE SHA512_DIGEST_SIZE\r | |
ecc722ad | 88 | \r |
89 | #define WIN_CERT_UEFI_RSA2048_SIZE 256\r | |
90 | \r | |
91 | //\r | |
92 | // Support hash types\r | |
93 | //\r | |
94 | #define HASHALG_SHA1 0x00000000\r | |
95 | #define HASHALG_SHA224 0x00000001\r | |
96 | #define HASHALG_SHA256 0x00000002\r | |
97 | #define HASHALG_SHA384 0x00000003\r | |
98 | #define HASHALG_SHA512 0x00000004\r | |
20333c6d | 99 | #define HASHALG_RAW 0x00000005\r |
ecc722ad | 100 | #define HASHALG_MAX 0x00000005\r |
101 | \r | |
102 | \r | |
103 | #define SECUREBOOT_MENU_OPTION_SIGNATURE SIGNATURE_32 ('S', 'b', 'M', 'u')\r | |
104 | #define SECUREBOOT_MENU_ENTRY_SIGNATURE SIGNATURE_32 ('S', 'b', 'M', 'r')\r | |
105 | \r | |
106 | typedef struct {\r | |
107 | EFI_DEVICE_PATH_PROTOCOL Header;\r | |
108 | EFI_GUID Guid;\r | |
109 | UINT8 VendorDefinedData[1];\r | |
110 | } VENDOR_DEVICE_PATH_WITH_DATA;\r | |
111 | \r | |
112 | typedef struct {\r | |
113 | EFI_DEVICE_PATH_PROTOCOL Header;\r | |
114 | UINT16 NetworkProtocol;\r | |
115 | UINT16 LoginOption;\r | |
116 | UINT64 Lun;\r | |
117 | UINT16 TargetPortalGroupTag;\r | |
118 | CHAR16 TargetName[1];\r | |
119 | } ISCSI_DEVICE_PATH_WITH_NAME;\r | |
120 | \r | |
121 | typedef enum _FILE_EXPLORER_DISPLAY_CONTEXT {\r | |
122 | FileExplorerDisplayFileSystem,\r | |
123 | FileExplorerDisplayDirectory,\r | |
124 | FileExplorerDisplayUnknown\r | |
125 | } FILE_EXPLORER_DISPLAY_CONTEXT;\r | |
126 | \r | |
127 | typedef enum _FILE_EXPLORER_STATE {\r | |
128 | FileExplorerStateInActive = 0,\r | |
129 | FileExplorerStateEnrollPkFile,\r | |
130 | FileExplorerStateEnrollKekFile,\r | |
131 | FileExplorerStateEnrollSignatureFileToDb,\r | |
132 | FileExplorerStateEnrollSignatureFileToDbx,\r | |
20333c6d | 133 | FileExplorerStateEnrollSignatureFileToDbt,\r |
ecc722ad | 134 | FileExplorerStateUnknown\r |
135 | } FILE_EXPLORER_STATE;\r | |
136 | \r | |
137 | typedef struct {\r | |
138 | CHAR16 *Str;\r | |
139 | UINTN Len;\r | |
140 | UINTN Maxlen;\r | |
141 | } POOL_PRINT;\r | |
142 | \r | |
143 | typedef\r | |
144 | VOID\r | |
145 | (*DEV_PATH_FUNCTION) (\r | |
146 | IN OUT POOL_PRINT *Str,\r | |
147 | IN VOID *DevPath\r | |
148 | );\r | |
149 | \r | |
150 | typedef struct {\r | |
151 | UINT8 Type;\r | |
152 | UINT8 SubType;\r | |
153 | DEV_PATH_FUNCTION Function;\r | |
154 | } DEVICE_PATH_STRING_TABLE;\r | |
155 | \r | |
156 | typedef struct {\r | |
157 | UINTN Signature;\r | |
158 | LIST_ENTRY Head;\r | |
159 | UINTN MenuNumber;\r | |
160 | } SECUREBOOT_MENU_OPTION;\r | |
161 | \r | |
162 | extern SECUREBOOT_MENU_OPTION FsOptionMenu;\r | |
163 | extern SECUREBOOT_MENU_OPTION DirectoryMenu;\r | |
164 | \r | |
165 | typedef struct {\r | |
166 | UINTN Signature;\r | |
167 | LIST_ENTRY Link;\r | |
168 | UINTN OptionNumber;\r | |
169 | UINT16 *DisplayString;\r | |
170 | UINT16 *HelpString;\r | |
171 | EFI_STRING_ID DisplayStringToken;\r | |
172 | EFI_STRING_ID HelpStringToken;\r | |
173 | VOID *FileContext;\r | |
174 | } SECUREBOOT_MENU_ENTRY;\r | |
175 | \r | |
176 | typedef struct {\r | |
177 | EFI_HANDLE Handle;\r | |
178 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
179 | EFI_FILE_HANDLE FHandle;\r | |
180 | UINT16 *FileName;\r | |
181 | EFI_FILE_SYSTEM_VOLUME_LABEL *Info;\r | |
182 | \r | |
183 | BOOLEAN IsRoot;\r | |
184 | BOOLEAN IsDir;\r | |
185 | BOOLEAN IsRemovableMedia;\r | |
186 | BOOLEAN IsLoadFile;\r | |
187 | BOOLEAN IsBootLegacy;\r | |
188 | } SECUREBOOT_FILE_CONTEXT;\r | |
189 | \r | |
190 | \r | |
191 | //\r | |
192 | // We define another format of 5th directory entry: security directory\r | |
193 | //\r | |
194 | typedef struct {\r | |
195 | UINT32 Offset; // Offset of certificate\r | |
196 | UINT32 SizeOfCert; // size of certificate appended\r | |
197 | } EFI_IMAGE_SECURITY_DATA_DIRECTORY;\r | |
198 | \r | |
199 | typedef enum{\r | |
200 | ImageType_IA32,\r | |
201 | ImageType_X64\r | |
202 | } IMAGE_TYPE;\r | |
beda2356 | 203 | \r |
204 | ///\r | |
205 | /// HII specific Vendor Device Path definition.\r | |
206 | ///\r | |
207 | typedef struct {\r | |
208 | VENDOR_DEVICE_PATH VendorDevicePath;\r | |
209 | EFI_DEVICE_PATH_PROTOCOL End;\r | |
210 | } HII_VENDOR_DEVICE_PATH;\r | |
211 | \r | |
212 | typedef struct {\r | |
213 | UINTN Signature;\r | |
214 | \r | |
215 | EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;\r | |
216 | EFI_HII_HANDLE HiiHandle;\r | |
217 | EFI_HANDLE DriverHandle;\r | |
218 | \r | |
ecc722ad | 219 | FILE_EXPLORER_STATE FeCurrentState;\r |
220 | FILE_EXPLORER_DISPLAY_CONTEXT FeDisplayContext;\r | |
221 | \r | |
222 | SECUREBOOT_MENU_ENTRY *MenuEntry;\r | |
223 | SECUREBOOT_FILE_CONTEXT *FileContext;\r | |
224 | \r | |
225 | EFI_GUID *SignatureGUID;\r | |
beda2356 | 226 | } SECUREBOOT_CONFIG_PRIVATE_DATA;\r |
227 | \r | |
228 | extern SECUREBOOT_CONFIG_PRIVATE_DATA mSecureBootConfigPrivateDateTemplate;\r | |
229 | \r | |
230 | #define SECUREBOOT_CONFIG_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('S', 'E', 'C', 'B')\r | |
bc0c99b3 | 231 | #define SECUREBOOT_CONFIG_PRIVATE_FROM_THIS(a) CR (a, SECUREBOOT_CONFIG_PRIVATE_DATA, ConfigAccess, SECUREBOOT_CONFIG_PRIVATE_DATA_SIGNATURE)\r |
232 | \r | |
ecc722ad | 233 | //\r |
234 | // Cryptograhpic Key Information\r | |
235 | //\r | |
1413b8e9 | 236 | #pragma pack(1)\r |
ecc722ad | 237 | typedef struct _CPL_KEY_INFO {\r |
238 | UINT32 KeyLengthInBits; // Key Length In Bits\r | |
239 | UINT32 BlockSize; // Operation Block Size in Bytes\r | |
240 | UINT32 CipherBlockSize; // Output Cipher Block Size in Bytes\r | |
241 | UINT32 KeyType; // Key Type\r | |
242 | UINT32 CipherMode; // Cipher Mode for Symmetric Algorithm\r | |
243 | UINT32 Flags; // Additional Key Property Flags\r | |
244 | } CPL_KEY_INFO;\r | |
1413b8e9 | 245 | #pragma pack()\r |
ecc722ad | 246 | \r |
247 | \r | |
248 | /**\r | |
249 | Retrieves the size, in bytes, of the context buffer required for hash operations.\r | |
250 | \r | |
251 | @return The size, in bytes, of the context buffer required for hash operations.\r | |
252 | \r | |
253 | **/\r | |
254 | typedef\r | |
255 | EFI_STATUS\r | |
256 | (EFIAPI *HASH_GET_CONTEXT_SIZE)(\r | |
257 | VOID\r | |
258 | );\r | |
259 | \r | |
260 | /**\r | |
261 | Initializes user-supplied memory pointed by HashContext as hash context for\r | |
262 | subsequent use.\r | |
263 | \r | |
264 | If HashContext is NULL, then ASSERT().\r | |
265 | \r | |
266 | @param[in, out] HashContext Pointer to Context being initialized.\r | |
267 | \r | |
268 | @retval TRUE HASH context initialization succeeded.\r | |
269 | @retval FALSE HASH context initialization failed.\r | |
270 | \r | |
271 | **/\r | |
272 | typedef\r | |
273 | BOOLEAN\r | |
274 | (EFIAPI *HASH_INIT)(\r | |
275 | IN OUT VOID *HashContext\r | |
276 | );\r | |
277 | \r | |
278 | \r | |
279 | /**\r | |
280 | Performs digest on a data buffer of the specified length. This function can\r | |
281 | be called multiple times to compute the digest of long or discontinuous data streams.\r | |
282 | \r | |
283 | If HashContext is NULL, then ASSERT().\r | |
284 | \r | |
285 | @param[in, out] HashContext Pointer to the MD5 context.\r | |
286 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
287 | @param[in] DataLength Length of Data buffer in bytes.\r | |
288 | \r | |
289 | @retval TRUE HASH data digest succeeded.\r | |
290 | @retval FALSE Invalid HASH context. After HashFinal function has been called, the\r | |
291 | HASH context cannot be reused.\r | |
292 | \r | |
293 | **/\r | |
294 | typedef\r | |
295 | BOOLEAN\r | |
296 | (EFIAPI *HASH_UPDATE)(\r | |
297 | IN OUT VOID *HashContext,\r | |
298 | IN CONST VOID *Data,\r | |
299 | IN UINTN DataLength\r | |
300 | );\r | |
301 | \r | |
302 | /**\r | |
303 | Completes hash computation and retrieves the digest value into the specified\r | |
304 | memory. After this function has been called, the context cannot be used again.\r | |
305 | \r | |
306 | If HashContext is NULL, then ASSERT().\r | |
307 | If HashValue is NULL, then ASSERT().\r | |
308 | \r | |
309 | @param[in, out] HashContext Pointer to the MD5 context\r | |
310 | @param[out] HashValue Pointer to a buffer that receives the HASH digest\r | |
311 | value (16 bytes).\r | |
312 | \r | |
313 | @retval TRUE HASH digest computation succeeded.\r | |
314 | @retval FALSE HASH digest computation failed.\r | |
315 | \r | |
316 | **/\r | |
317 | typedef\r | |
318 | BOOLEAN\r | |
319 | (EFIAPI *HASH_FINAL)(\r | |
320 | IN OUT VOID *HashContext,\r | |
321 | OUT UINT8 *HashValue\r | |
322 | );\r | |
323 | \r | |
324 | //\r | |
325 | // Hash Algorithm Table\r | |
326 | //\r | |
327 | typedef struct {\r | |
328 | CHAR16 *Name; ///< Name for Hash Algorithm\r | |
329 | UINTN DigestLength; ///< Digest Length\r | |
20333c6d | 330 | UINT8 *OidValue; ///< Hash Algorithm OID ASN.1 Value\r |
ecc722ad | 331 | UINTN OidLength; ///< Length of Hash OID Value\r |
332 | HASH_GET_CONTEXT_SIZE GetContextSize; ///< Pointer to Hash GetContentSize function\r | |
333 | HASH_INIT HashInit; ///< Pointer to Hash Init function\r | |
334 | HASH_UPDATE HashUpdate; ///< Pointer to Hash Update function\r | |
335 | HASH_FINAL HashFinal; ///< Pointer to Hash Final function\r | |
336 | } HASH_TABLE;\r | |
337 | \r | |
338 | typedef struct {\r | |
339 | WIN_CERTIFICATE Hdr;\r | |
340 | UINT8 CertData[1];\r | |
341 | } WIN_CERTIFICATE_EFI_PKCS;\r | |
342 | \r | |
beda2356 | 343 | \r |
344 | /**\r | |
345 | This function publish the SecureBoot configuration Form.\r | |
346 | \r | |
347 | @param[in, out] PrivateData Points to SecureBoot configuration private data.\r | |
348 | \r | |
ecc722ad | 349 | @retval EFI_SUCCESS HII Form is installed successfully.\r |
beda2356 | 350 | @retval EFI_OUT_OF_RESOURCES Not enough resource for HII Form installation.\r |
351 | @retval Others Other errors as indicated.\r | |
352 | \r | |
353 | **/\r | |
354 | EFI_STATUS\r | |
355 | InstallSecureBootConfigForm (\r | |
356 | IN OUT SECUREBOOT_CONFIG_PRIVATE_DATA *PrivateData\r | |
357 | );\r | |
358 | \r | |
ecc722ad | 359 | \r |
beda2356 | 360 | /**\r |
361 | This function removes SecureBoot configuration Form.\r | |
362 | \r | |
363 | @param[in, out] PrivateData Points to SecureBoot configuration private data.\r | |
364 | \r | |
365 | **/\r | |
beda2356 | 366 | VOID\r |
367 | UninstallSecureBootConfigForm (\r | |
368 | IN OUT SECUREBOOT_CONFIG_PRIVATE_DATA *PrivateData\r | |
369 | );\r | |
370 | \r | |
ecc722ad | 371 | \r |
beda2356 | 372 | /**\r |
373 | This function allows a caller to extract the current configuration for one\r | |
374 | or more named elements from the target driver.\r | |
375 | \r | |
376 | @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
377 | @param[in] Request A null-terminated Unicode string in\r | |
378 | <ConfigRequest> format.\r | |
379 | @param[out] Progress On return, points to a character in the Request\r | |
380 | string. Points to the string's null terminator if\r | |
381 | request was successful. Points to the most recent\r | |
382 | '&' before the first failing name/value pair (or\r | |
383 | the beginning of the string if the failure is in\r | |
384 | the first name/value pair) if the request was not\r | |
385 | successful.\r | |
386 | @param[out] Results A null-terminated Unicode string in\r | |
387 | <ConfigAltResp> format which has all values filled\r | |
388 | in for the names in the Request string. String to\r | |
389 | be allocated by the called function.\r | |
390 | \r | |
391 | @retval EFI_SUCCESS The Results is filled with the requested values.\r | |
392 | @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.\r | |
393 | @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.\r | |
394 | @retval EFI_NOT_FOUND Routing data doesn't match any storage in this\r | |
395 | driver.\r | |
396 | \r | |
397 | **/\r | |
398 | EFI_STATUS\r | |
399 | EFIAPI\r | |
400 | SecureBootExtractConfig (\r | |
401 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
402 | IN CONST EFI_STRING Request,\r | |
403 | OUT EFI_STRING *Progress,\r | |
404 | OUT EFI_STRING *Results\r | |
405 | );\r | |
406 | \r | |
ecc722ad | 407 | \r |
beda2356 | 408 | /**\r |
409 | This function processes the results of changes in configuration.\r | |
410 | \r | |
411 | @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
412 | @param[in] Configuration A null-terminated Unicode string in <ConfigResp>\r | |
413 | format.\r | |
414 | @param[out] Progress A pointer to a string filled in with the offset of\r | |
415 | the most recent '&' before the first failing\r | |
416 | name/value pair (or the beginning of the string if\r | |
417 | the failure is in the first name/value pair) or\r | |
418 | the terminating NULL if all was successful.\r | |
419 | \r | |
420 | @retval EFI_SUCCESS The Results is processed successfully.\r | |
421 | @retval EFI_INVALID_PARAMETER Configuration is NULL.\r | |
422 | @retval EFI_NOT_FOUND Routing data doesn't match any storage in this\r | |
423 | driver.\r | |
424 | \r | |
425 | **/\r | |
426 | EFI_STATUS\r | |
427 | EFIAPI\r | |
428 | SecureBootRouteConfig (\r | |
429 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
430 | IN CONST EFI_STRING Configuration,\r | |
431 | OUT EFI_STRING *Progress\r | |
432 | );\r | |
433 | \r | |
ecc722ad | 434 | \r |
beda2356 | 435 | /**\r |
436 | This function processes the results of changes in configuration.\r | |
437 | \r | |
438 | @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
439 | @param[in] Action Specifies the type of action taken by the browser.\r | |
440 | @param[in] QuestionId A unique value which is sent to the original\r | |
441 | exporting driver so that it can identify the type\r | |
442 | of data to expect.\r | |
443 | @param[in] Type The type of value for the question.\r | |
444 | @param[in] Value A pointer to the data being sent to the original\r | |
445 | exporting driver.\r | |
446 | @param[out] ActionRequest On return, points to the action requested by the\r | |
447 | callback function.\r | |
448 | \r | |
449 | @retval EFI_SUCCESS The callback successfully handled the action.\r | |
450 | @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the\r | |
451 | variable and its data.\r | |
452 | @retval EFI_DEVICE_ERROR The variable could not be saved.\r | |
453 | @retval EFI_UNSUPPORTED The specified Action is not supported by the\r | |
454 | callback.\r | |
455 | \r | |
456 | **/\r | |
457 | EFI_STATUS\r | |
458 | EFIAPI\r | |
459 | SecureBootCallback (\r | |
460 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
461 | IN EFI_BROWSER_ACTION Action,\r | |
462 | IN EFI_QUESTION_ID QuestionId,\r | |
463 | IN UINT8 Type,\r | |
464 | IN EFI_IFR_TYPE_VALUE *Value,\r | |
465 | OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r | |
466 | );\r | |
467 | \r | |
ecc722ad | 468 | \r |
469 | /**\r | |
470 | This function converts an input device structure to a Unicode string.\r | |
471 | \r | |
472 | @param[in] DevPath A pointer to the device path structure.\r | |
473 | \r | |
474 | @return A new allocated Unicode string that represents the device path.\r | |
475 | \r | |
476 | **/\r | |
477 | CHAR16 *\r | |
478 | EFIAPI\r | |
479 | DevicePathToStr (\r | |
480 | IN EFI_DEVICE_PATH_PROTOCOL *DevPath\r | |
481 | );\r | |
482 | \r | |
483 | \r | |
484 | /**\r | |
20333c6d | 485 | Clean up the dynamic opcode at label and form specified by both LabelId.\r |
ecc722ad | 486 | \r |
487 | @param[in] LabelId It is both the Form ID and Label ID for opcode deletion.\r | |
488 | @param[in] PrivateData Module private data.\r | |
489 | \r | |
490 | **/\r | |
491 | VOID\r | |
492 | CleanUpPage (\r | |
493 | IN UINT16 LabelId,\r | |
494 | IN SECUREBOOT_CONFIG_PRIVATE_DATA *PrivateData\r | |
495 | );\r | |
496 | \r | |
497 | \r | |
498 | /**\r | |
499 | Update the file explorer page with the refreshed file system.\r | |
500 | \r | |
501 | @param[in] PrivateData Module private data.\r | |
502 | @param[in] KeyValue Key value to identify the type of data to expect.\r | |
503 | \r | |
504 | @retval TRUE Inform the caller to create a callback packet to exit file explorer.\r | |
505 | @retval FALSE Indicate that there is no need to exit file explorer.\r | |
506 | \r | |
507 | **/\r | |
508 | BOOLEAN\r | |
509 | UpdateFileExplorer (\r | |
510 | IN SECUREBOOT_CONFIG_PRIVATE_DATA *PrivateData,\r | |
511 | IN UINT16 KeyValue\r | |
512 | );\r | |
513 | \r | |
514 | \r | |
515 | /**\r | |
516 | Free resources allocated in Allocate Rountine.\r | |
517 | \r | |
518 | @param[in, out] MenuOption Menu to be freed\r | |
20333c6d | 519 | \r |
ecc722ad | 520 | **/\r |
521 | VOID\r | |
522 | FreeMenu (\r | |
523 | IN OUT SECUREBOOT_MENU_OPTION *MenuOption\r | |
524 | );\r | |
525 | \r | |
526 | \r | |
527 | /**\r | |
20333c6d | 528 | Read file content into BufferPtr, the size of the allocate buffer\r |
ecc722ad | 529 | is *FileSize plus AddtionAllocateSize.\r |
530 | \r | |
531 | @param[in] FileHandle The file to be read.\r | |
532 | @param[in, out] BufferPtr Pointers to the pointer of allocated buffer.\r | |
533 | @param[out] FileSize Size of input file\r | |
20333c6d | 534 | @param[in] AddtionAllocateSize Addtion size the buffer need to be allocated.\r |
ecc722ad | 535 | In case the buffer need to contain others besides the file content.\r |
20333c6d | 536 | \r |
ecc722ad | 537 | @retval EFI_SUCCESS The file was read into the buffer.\r |
538 | @retval EFI_INVALID_PARAMETER A parameter was invalid.\r | |
539 | @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r | |
540 | @retval others Unexpected error.\r | |
541 | \r | |
542 | **/\r | |
543 | EFI_STATUS\r | |
544 | ReadFileContent (\r | |
545 | IN EFI_FILE_HANDLE FileHandle,\r | |
546 | IN OUT VOID **BufferPtr,\r | |
547 | OUT UINTN *FileSize,\r | |
548 | IN UINTN AddtionAllocateSize\r | |
549 | );\r | |
550 | \r | |
551 | \r | |
552 | /**\r | |
553 | Close an open file handle.\r | |
554 | \r | |
555 | @param[in] FileHandle The file handle to close.\r | |
20333c6d | 556 | \r |
ecc722ad | 557 | **/\r |
558 | VOID\r | |
559 | CloseFile (\r | |
560 | IN EFI_FILE_HANDLE FileHandle\r | |
561 | );\r | |
562 | \r | |
563 | \r | |
564 | /**\r | |
565 | Converts a nonnegative integer to an octet string of a specified length.\r | |
566 | \r | |
567 | @param[in] Integer Pointer to the nonnegative integer to be converted\r | |
568 | @param[in] IntSizeInWords Length of integer buffer in words\r | |
20333c6d | 569 | @param[out] OctetString Converted octet string of the specified length\r |
ecc722ad | 570 | @param[in] OSSizeInBytes Intended length of resulting octet string in bytes\r |
571 | \r | |
572 | Returns:\r | |
573 | \r | |
574 | @retval EFI_SUCCESS Data conversion successfully\r | |
575 | @retval EFI_BUFFER_TOOL_SMALL Buffer is too small for output string\r | |
576 | \r | |
577 | **/\r | |
578 | EFI_STATUS\r | |
579 | EFIAPI\r | |
580 | Int2OctStr (\r | |
581 | IN CONST UINTN *Integer,\r | |
582 | IN UINTN IntSizeInWords,\r | |
583 | OUT UINT8 *OctetString,\r | |
584 | IN UINTN OSSizeInBytes\r | |
585 | );\r | |
586 | \r | |
587 | \r | |
588 | /**\r | |
589 | Convert a String to Guid Value.\r | |
590 | \r | |
591 | @param[in] Str Specifies the String to be converted.\r | |
592 | @param[in] StrLen Number of Unicode Characters of String (exclusive \0)\r | |
593 | @param[out] Guid Return the result Guid value.\r | |
594 | \r | |
595 | @retval EFI_SUCCESS The operation is finished successfully.\r | |
596 | @retval EFI_NOT_FOUND Invalid string.\r | |
597 | \r | |
598 | **/\r | |
599 | EFI_STATUS\r | |
600 | StringToGuid (\r | |
20333c6d QL |
601 | IN CHAR16 *Str,\r |
602 | IN UINTN StrLen,\r | |
ecc722ad | 603 | OUT EFI_GUID *Guid\r |
604 | );\r | |
605 | \r | |
606 | \r | |
607 | /**\r | |
608 | Worker function that prints an EFI_GUID into specified Buffer.\r | |
609 | \r | |
610 | @param[in] Guid Pointer to GUID to print.\r | |
611 | @param[in] Buffer Buffer to print Guid into.\r | |
612 | @param[in] BufferSize Size of Buffer.\r | |
20333c6d | 613 | \r |
ecc722ad | 614 | @retval Number of characters printed.\r |
615 | \r | |
616 | **/\r | |
617 | UINTN\r | |
618 | GuidToString (\r | |
619 | IN EFI_GUID *Guid,\r | |
620 | IN CHAR16 *Buffer,\r | |
621 | IN UINTN BufferSize\r | |
622 | );\r | |
623 | \r | |
20333c6d | 624 | #endif |