2 Internal file explorer functions for SecureBoot configuration module.
4 Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "SecureBootConfigImpl.h"
11 VOID
*mStartOpCodeHandle
= NULL
;
12 VOID
*mEndOpCodeHandle
= NULL
;
13 EFI_IFR_GUID_LABEL
*mStartLabel
= NULL
;
14 EFI_IFR_GUID_LABEL
*mEndLabel
= NULL
;
17 Refresh the global UpdateData structure.
26 // Free current updated date
28 if (mStartOpCodeHandle
!= NULL
) {
29 HiiFreeOpCodeHandle (mStartOpCodeHandle
);
33 // Create new OpCode Handle
35 mStartOpCodeHandle
= HiiAllocateOpCodeHandle ();
38 // Create Hii Extend Label OpCode as the start opcode
40 mStartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (
44 sizeof (EFI_IFR_GUID_LABEL
)
46 mStartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
50 Clean up the dynamic opcode at label and form specified by both LabelId.
52 @param[in] LabelId It is both the Form ID and Label ID for opcode deletion.
53 @param[in] PrivateData Module private data.
59 IN SECUREBOOT_CONFIG_PRIVATE_DATA
*PrivateData
65 // Remove all op-codes from dynamic page
67 mStartLabel
->Number
= LabelId
;
69 PrivateData
->HiiHandle
,
70 &gSecureBootConfigFormSetGuid
,
72 mStartOpCodeHandle
, // Label LabelId
73 mEndOpCodeHandle
// LABEL_END
78 Extract filename from device path. The returned buffer is allocated using AllocateCopyPool.
79 The caller is responsible for freeing the allocated buffer using FreePool(). If return NULL
80 means not enough memory resource.
82 @param DevicePath Device path.
84 @retval NULL Not enough memory resource for AllocateCopyPool.
85 @retval Other A new allocated string that represents the file name.
89 ExtractFileNameFromDevicePath (
90 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
99 ASSERT(DevicePath
!= NULL
);
101 String
= DevicePathToStr(DevicePath
);
102 MatchString
= String
;
106 while(MatchString
!= NULL
){
107 LastMatch
= MatchString
+ 1;
108 MatchString
= StrStr(LastMatch
,L
"\\");
111 Length
= StrLen(LastMatch
);
112 FileName
= AllocateCopyPool ((Length
+ 1) * sizeof(CHAR16
), LastMatch
);
113 if (FileName
!= NULL
) {
114 *(FileName
+ Length
) = 0;
124 Update the form base on the selected file.
126 @param FilePath Point to the file path.
127 @param FormId The form need to display.
129 @retval TRUE Exit caller function.
130 @retval FALSE Not exit caller function.
135 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
136 IN EFI_FORM_ID FormId
140 EFI_STRING_ID StringToken
;
144 if (FilePath
!= NULL
) {
145 FileName
= ExtractFileNameFromDevicePath(FilePath
);
147 if (FileName
== NULL
) {
149 // FileName = NULL has two case:
150 // 1. FilePath == NULL, not select file.
151 // 2. FilePath != NULL, but ExtractFileNameFromDevicePath return NULL not enough memory resource.
152 // In these two case, no need to update the form, and exit the caller function.
156 StringToken
= HiiSetString (gSecureBootPrivateData
->HiiHandle
, 0, FileName
, NULL
);
158 gSecureBootPrivateData
->FileContext
->FileName
= FileName
;
160 EfiOpenFileByDevicePath (
162 &gSecureBootPrivateData
->FileContext
->FHandle
,
167 // Create Subtitle op-code for the display string of the option.
169 RefreshUpdateData ();
170 mStartLabel
->Number
= FormId
;
172 HiiCreateSubTitleOpCode (
181 gSecureBootPrivateData
->HiiHandle
,
182 &gSecureBootConfigFormSetGuid
,
184 mStartOpCodeHandle
, // Label FormId
185 mEndOpCodeHandle
// LABEL_END
192 Update the PK form base on the input file path info.
194 @param FilePath Point to the file path.
196 @retval TRUE Exit caller function.
197 @retval FALSE Not exit caller function.
202 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
205 return UpdatePage(FilePath
, FORMID_ENROLL_PK_FORM
);
210 Update the KEK form base on the input file path info.
212 @param FilePath Point to the file path.
214 @retval TRUE Exit caller function.
215 @retval FALSE Not exit caller function.
220 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
223 return UpdatePage(FilePath
, FORMID_ENROLL_KEK_FORM
);
227 Update the DB form base on the input file path info.
229 @param FilePath Point to the file path.
231 @retval TRUE Exit caller function.
232 @retval FALSE Not exit caller function.
237 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
240 return UpdatePage(FilePath
, SECUREBOOT_ENROLL_SIGNATURE_TO_DB
);
244 Update the DBX form base on the input file path info.
246 @param FilePath Point to the file path.
248 @retval TRUE Exit caller function.
249 @retval FALSE Not exit caller function.
254 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
257 return UpdatePage(FilePath
, SECUREBOOT_ENROLL_SIGNATURE_TO_DBX
);
261 Update the DBT form base on the input file path info.
263 @param FilePath Point to the file path.
265 @retval TRUE Exit caller function.
266 @retval FALSE Not exit caller function.
271 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
274 return UpdatePage(FilePath
, SECUREBOOT_ENROLL_SIGNATURE_TO_DBT
);