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;
123 Update the form base on the selected file.
125 @param FilePath Point to the file path.
126 @param FormId The form need to display.
128 @retval TRUE Exit caller function.
129 @retval FALSE Not exit caller function.
134 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
135 IN EFI_FORM_ID FormId
139 EFI_STRING_ID StringToken
;
143 if (FilePath
!= NULL
) {
144 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.
157 StringToken
= HiiSetString (gSecureBootPrivateData
->HiiHandle
, 0, FileName
, NULL
);
159 gSecureBootPrivateData
->FileContext
->FileName
= FileName
;
161 EfiOpenFileByDevicePath (
163 &gSecureBootPrivateData
->FileContext
->FHandle
,
168 // Create Subtitle op-code for the display string of the option.
170 RefreshUpdateData ();
171 mStartLabel
->Number
= FormId
;
173 HiiCreateSubTitleOpCode (
182 gSecureBootPrivateData
->HiiHandle
,
183 &gSecureBootConfigFormSetGuid
,
185 mStartOpCodeHandle
, // Label FormId
186 mEndOpCodeHandle
// LABEL_END
193 Update the PK form base on the input file path info.
195 @param FilePath Point to the file path.
197 @retval TRUE Exit caller function.
198 @retval FALSE Not exit caller function.
203 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
206 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
);