TianoCore EDK2 master
Loading...
Searching...
No Matches
SecureBootConfigFileExplorer.c
Go to the documentation of this file.
1
10
11VOID *mStartOpCodeHandle = NULL;
12VOID *mEndOpCodeHandle = NULL;
13EFI_IFR_GUID_LABEL *mStartLabel = NULL;
14EFI_IFR_GUID_LABEL *mEndLabel = NULL;
15
20VOID
22 VOID
23 )
24{
25 //
26 // Free current updated date
27 //
28 if (mStartOpCodeHandle != NULL) {
29 HiiFreeOpCodeHandle (mStartOpCodeHandle);
30 }
31
32 //
33 // Create new OpCode Handle
34 //
35 mStartOpCodeHandle = HiiAllocateOpCodeHandle ();
36
37 //
38 // Create Hii Extend Label OpCode as the start opcode
39 //
41 mStartOpCodeHandle,
42 &gEfiIfrTianoGuid,
43 NULL,
44 sizeof (EFI_IFR_GUID_LABEL)
45 );
47}
48
56VOID
58 IN UINT16 LabelId,
60 )
61{
63
64 //
65 // Remove all op-codes from dynamic page
66 //
67 mStartLabel->Number = LabelId;
69 PrivateData->HiiHandle,
70 &gSecureBootConfigFormSetGuid,
71 LabelId,
72 mStartOpCodeHandle, // Label LabelId
73 mEndOpCodeHandle // LABEL_END
74 );
75}
76
88CHAR16 *
91 )
92{
93 CHAR16 *String;
94 CHAR16 *MatchString;
95 CHAR16 *LastMatch;
96 CHAR16 *FileName;
97 UINTN Length;
98
99 ASSERT (DevicePath != NULL);
100
101 String = DevicePathToStr (DevicePath);
102 MatchString = String;
103 LastMatch = String;
104 FileName = NULL;
105
106 while (MatchString != NULL) {
107 LastMatch = MatchString + 1;
108 MatchString = StrStr (LastMatch, L"\\");
109 }
110
111 Length = StrLen (LastMatch);
112 FileName = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), LastMatch);
113 if (FileName != NULL) {
114 *(FileName + Length) = 0;
115 }
116
117 FreePool (String);
118
119 return FileName;
120}
121
132BOOLEAN
135 IN EFI_FORM_ID FormId
136 )
137{
138 CHAR16 *FileName;
139 EFI_STRING_ID StringToken;
140
141 FileName = NULL;
142
143 if (FilePath != NULL) {
144 FileName = ExtractFileNameFromDevicePath (FilePath);
145 }
146
147 if (FileName == NULL) {
148 //
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.
153 //
154 return TRUE;
155 }
156
157 StringToken = HiiSetString (gSecureBootPrivateData->HiiHandle, 0, FileName, NULL);
158
159 gSecureBootPrivateData->FileContext->FileName = FileName;
160
162 &FilePath,
163 &gSecureBootPrivateData->FileContext->FHandle,
164 EFI_FILE_MODE_READ,
165 0
166 );
167 //
168 // Create Subtitle op-code for the display string of the option.
169 //
171 mStartLabel->Number = FormId;
172
174 mStartOpCodeHandle,
175 StringToken,
176 0,
177 0,
178 0
179 );
180
182 gSecureBootPrivateData->HiiHandle,
183 &gSecureBootConfigFormSetGuid,
184 FormId,
185 mStartOpCodeHandle, // Label FormId
186 mEndOpCodeHandle // LABEL_END
187 );
188
189 return TRUE;
190}
191
200BOOLEAN
201EFIAPI
204 )
205{
206 return UpdatePage (FilePath, FORMID_ENROLL_PK_FORM);
207}
208
217BOOLEAN
218EFIAPI
221 )
222{
223 return UpdatePage (FilePath, FORMID_ENROLL_KEK_FORM);
224}
225
234BOOLEAN
235EFIAPI
238 )
239{
240 return UpdatePage (FilePath, SECUREBOOT_ENROLL_SIGNATURE_TO_DB);
241}
242
251BOOLEAN
252EFIAPI
255 )
256{
257 return UpdatePage (FilePath, SECUREBOOT_ENROLL_SIGNATURE_TO_DBX);
258}
259
268BOOLEAN
269EFIAPI
272 )
273{
274 return UpdatePage (FilePath, SECUREBOOT_ENROLL_SIGNATURE_TO_DBT);
275}
UINT64 UINTN
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
Definition: String.c:30
CHAR16 *EFIAPI StrStr(IN CONST CHAR16 *String, IN CONST CHAR16 *SearchString)
Definition: String.c:224
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
UINT8 *EFIAPI HiiCreateSubTitleOpCode(IN VOID *OpCodeHandle, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 Flags, IN UINT8 Scope)
Definition: HiiLib.c:3504
VOID *EFIAPI HiiAllocateOpCodeHandle(VOID)
Definition: HiiLib.c:3051
VOID EFIAPI HiiFreeOpCodeHandle(VOID *OpCodeHandle)
Definition: HiiLib.c:3085
UINT8 *EFIAPI HiiCreateGuidOpCode(IN VOID *OpCodeHandle, IN CONST EFI_GUID *Guid, IN CONST VOID *GuidOpCode OPTIONAL, IN UINTN OpCodeSize)
Definition: HiiLib.c:3411
EFI_STATUS EFIAPI HiiUpdateForm(IN EFI_HII_HANDLE HiiHandle, IN EFI_GUID *FormSetGuid OPTIONAL, IN EFI_FORM_ID FormId, IN VOID *StartOpCodeHandle, IN VOID *EndOpCodeHandle OPTIONAL)
Definition: HiiLib.c:4410
EFI_STRING_ID EFIAPI HiiSetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId OPTIONAL, IN CONST EFI_STRING String, IN CONST CHAR8 *SupportedLanguages OPTIONAL)
Definition: HiiString.c:52
#define EFI_IFR_EXTEND_OP_LABEL
Definition: MdeModuleHii.h:33
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define IN
Definition: Base.h:279
CHAR16 * DevicePathToStr(IN EFI_DEVICE_PATH_PROTOCOL *DevPath)
BOOLEAN EFIAPI UpdatePKFromFile(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
BOOLEAN EFIAPI UpdateDBTFromFile(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
VOID RefreshUpdateData(VOID)
VOID CleanUpPage(IN UINT16 LabelId, IN SECUREBOOT_CONFIG_PRIVATE_DATA *PrivateData)
BOOLEAN EFIAPI UpdateDBXFromFile(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
BOOLEAN EFIAPI UpdateKEKFromFile(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
BOOLEAN UpdatePage(IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN EFI_FORM_ID FormId)
CHAR16 * ExtractFileNameFromDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
BOOLEAN EFIAPI UpdateDBFromFile(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
EFI_STATUS EFIAPI EfiOpenFileByDevicePath(IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath, OUT EFI_FILE_PROTOCOL **File, IN UINT64 OpenMode, IN UINT64 Attributes)
Definition: UefiLib.c:1806