2 Internal file explorer functions for SecureBoot configuration module.
4 Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "SecureBootConfigImpl.h"
17 VOID
*mStartOpCodeHandle
= NULL
;
18 VOID
*mEndOpCodeHandle
= NULL
;
19 EFI_IFR_GUID_LABEL
*mStartLabel
= NULL
;
20 EFI_IFR_GUID_LABEL
*mEndLabel
= NULL
;
23 Refresh the global UpdateData structure.
32 // Free current updated date
34 if (mStartOpCodeHandle
!= NULL
) {
35 HiiFreeOpCodeHandle (mStartOpCodeHandle
);
39 // Create new OpCode Handle
41 mStartOpCodeHandle
= HiiAllocateOpCodeHandle ();
44 // Create Hii Extend Label OpCode as the start opcode
46 mStartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (
50 sizeof (EFI_IFR_GUID_LABEL
)
52 mStartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
56 Clean up the dynamic opcode at label and form specified by both LabelId.
58 @param[in] LabelId It is both the Form ID and Label ID for opcode deletion.
59 @param[in] PrivateData Module private data.
65 IN SECUREBOOT_CONFIG_PRIVATE_DATA
*PrivateData
71 // Remove all op-codes from dynamic page
73 mStartLabel
->Number
= LabelId
;
75 PrivateData
->HiiHandle
,
76 &gSecureBootConfigFormSetGuid
,
78 mStartOpCodeHandle
, // Label LabelId
79 mEndOpCodeHandle
// LABEL_END
84 Extract filename from device path. The returned buffer is allocated using AllocateCopyPool.
85 The caller is responsible for freeing the allocated buffer using FreePool(). If return NULL
86 means not enough memory resource.
88 @param DevicePath Device path.
90 @retval NULL Not enough memory resourece for AllocateCopyPool.
91 @retval Other A new allocated string that represents the file name.
95 ExtractFileNameFromDevicePath (
96 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
105 ASSERT(DevicePath
!= NULL
);
107 String
= DevicePathToStr(DevicePath
);
108 MatchString
= String
;
112 while(MatchString
!= NULL
){
113 LastMatch
= MatchString
+ 1;
114 MatchString
= StrStr(LastMatch
,L
"\\");
117 Length
= StrLen(LastMatch
);
118 FileName
= AllocateCopyPool ((Length
+ 1) * sizeof(CHAR16
), LastMatch
);
119 if (FileName
!= NULL
) {
120 *(FileName
+ Length
) = 0;
130 Update the form base on the selected file.
132 @param FilePath Point to the file path.
133 @param FormId The form need to display.
135 @retval TRUE Exit caller function.
136 @retval FALSE Not exit caller function.
141 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
142 IN EFI_FORM_ID FormId
146 EFI_STRING_ID StringToken
;
150 if (FilePath
!= NULL
) {
151 FileName
= ExtractFileNameFromDevicePath(FilePath
);
153 if (FileName
== NULL
) {
155 // FileName = NULL has two case:
156 // 1. FilePath == NULL, not select file.
157 // 2. FilePath != NULL, but ExtractFileNameFromDevicePath return NULL not enough memory resource.
158 // In these two case, no need to update the form, and exit the caller function.
162 StringToken
= HiiSetString (gSecureBootPrivateData
->HiiHandle
, 0, FileName
, NULL
);
164 gSecureBootPrivateData
->FileContext
->FileName
= FileName
;
166 EfiOpenFileByDevicePath (
168 &gSecureBootPrivateData
->FileContext
->FHandle
,
173 // Create Subtitle op-code for the display string of the option.
175 RefreshUpdateData ();
176 mStartLabel
->Number
= FormId
;
178 HiiCreateSubTitleOpCode (
187 gSecureBootPrivateData
->HiiHandle
,
188 &gSecureBootConfigFormSetGuid
,
190 mStartOpCodeHandle
, // Label FormId
191 mEndOpCodeHandle
// LABEL_END
198 Update the PK form base on the input file path info.
200 @param FilePath Point to the file path.
202 @retval TRUE Exit caller function.
203 @retval FALSE Not exit caller function.
208 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
211 return UpdatePage(FilePath
, FORMID_ENROLL_PK_FORM
);
216 Update the KEK form base on the input file path info.
218 @param FilePath Point to the file path.
220 @retval TRUE Exit caller function.
221 @retval FALSE Not exit caller function.
226 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
229 return UpdatePage(FilePath
, FORMID_ENROLL_KEK_FORM
);
233 Update the DB form base on the input file path info.
235 @param FilePath Point to the file path.
237 @retval TRUE Exit caller function.
238 @retval FALSE Not exit caller function.
243 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
246 return UpdatePage(FilePath
, SECUREBOOT_ENROLL_SIGNATURE_TO_DB
);
250 Update the DBX form base on the input file path info.
252 @param FilePath Point to the file path.
254 @retval TRUE Exit caller function.
255 @retval FALSE Not exit caller function.
260 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
263 return UpdatePage(FilePath
, SECUREBOOT_ENROLL_SIGNATURE_TO_DBX
);
267 Update the DBT form base on the input file path info.
269 @param FilePath Point to the file path.
271 @retval TRUE Exit caller function.
272 @retval FALSE Not exit caller function.
277 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
280 return UpdatePage(FilePath
, SECUREBOOT_ENROLL_SIGNATURE_TO_DBT
);