Skip to content

Commit 345ebdf

Browse files
committed
System76PayloadPkg: UiApp: Link to SecureBootConfig
Shoehorn in logic from Device Manager to show only the Secure Boot Config entry on the front page. Signed-off-by: Tim Crawford <tcrawford@system76.com>
1 parent 4af2f9b commit 345ebdf

2 files changed

Lines changed: 121 additions & 0 deletions

File tree

System76PayloadPkg/Application/UiApp/FrontPage.c

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,124 @@ UpdateFrontPageForm (
249249
HiiFreeOpCodeHandle (EndOpCodeHandle);
250250
}
251251

252+
// FIXME: Copied from Device Manager; clean up
253+
void ShowSecureBootConfig(void)
254+
{
255+
void *StartHandle;
256+
void *EndHandle;
257+
EFI_IFR_GUID_LABEL *StartLabel;
258+
EFI_IFR_GUID_LABEL *EndLabel;
259+
EFI_HII_HANDLE *HiiHandles;
260+
EFI_HII_HANDLE HiiHandle = gFrontPagePrivate.HiiHandle;
261+
UINTN Index;
262+
EFI_STRING String;
263+
EFI_STRING_ID Token;
264+
EFI_STRING_ID TokenHelp;
265+
EFI_IFR_FORM_SET *Buffer = NULL;
266+
UINTN BufferSize = 0;
267+
UINT8 ClassGuidNum;
268+
EFI_GUID *ClassGuid;
269+
UINTN TempSize = 0;
270+
UINT8 *Ptr;
271+
EFI_STATUS Status;
272+
// XXX: Copied from SecureBootConfigDxe
273+
EFI_GUID SecureBootConfigGuid = { 0x5daf50a5, 0xea81, 0x4de2, {0x8f, 0x9b, 0xca, 0xbd, 0xa9, 0xcf, 0x5c, 0x14}};
274+
275+
StartHandle = HiiAllocateOpCodeHandle();
276+
ASSERT(StartHandle != NULL);
277+
278+
EndHandle = HiiAllocateOpCodeHandle();
279+
ASSERT(EndHandle != NULL);
280+
281+
StartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode(StartHandle, &gEfiIfrTianoGuid, NULL, sizeof(*StartLabel));
282+
StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
283+
StartLabel->Number = LABEL_DEVICES_LIST;
284+
285+
EndLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode(EndHandle, &gEfiIfrTianoGuid, NULL, sizeof(*EndLabel));
286+
EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
287+
EndLabel->Number = LABEL_END;
288+
289+
// Get SecureBootConfig handle
290+
HiiHandles = HiiGetHiiHandles(&SecureBootConfigGuid);
291+
ASSERT(HiiHandles != NULL);
292+
293+
// Search for formset of each class type
294+
for (Index = 0; HiiHandles[Index] != NULL; Index++) {
295+
Status = HiiGetFormSetFromHiiHandle(HiiHandles[Index], &Buffer, &BufferSize);
296+
if (EFI_ERROR(Status)) {
297+
continue;
298+
}
299+
300+
Ptr = (UINT8 *)Buffer;
301+
while (TempSize < BufferSize) {
302+
TempSize += ((EFI_IFR_OP_HEADER *)Ptr)->Length;
303+
if (((EFI_IFR_OP_HEADER *)Ptr)->Length <= OFFSET_OF (EFI_IFR_FORM_SET, Flags)) {
304+
Ptr += ((EFI_IFR_OP_HEADER *)Ptr)->Length;
305+
continue;
306+
}
307+
308+
ClassGuidNum = (UINT8)(((EFI_IFR_FORM_SET *)Ptr)->Flags & 0x3);
309+
ClassGuid = (EFI_GUID *)(VOID *)(Ptr + sizeof(EFI_IFR_FORM_SET));
310+
while (ClassGuidNum-- > 0) {
311+
if (CompareGuid(&gEfiHiiPlatformSetupFormsetGuid, ClassGuid) == 0) {
312+
ClassGuid++;
313+
continue;
314+
}
315+
316+
String = HiiGetString(HiiHandles[Index], ((EFI_IFR_FORM_SET *)Ptr)->FormSetTitle, NULL);
317+
if (String == NULL) {
318+
String = HiiGetString(HiiHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);
319+
ASSERT (String != NULL);
320+
}
321+
322+
Token = HiiSetString(HiiHandle, 0, String, NULL);
323+
FreePool(String);
324+
325+
String = HiiGetString(HiiHandles[Index], ((EFI_IFR_FORM_SET *)Ptr)->Help, NULL);
326+
if (String == NULL) {
327+
String = HiiGetString(HiiHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);
328+
ASSERT(String != NULL);
329+
}
330+
331+
TokenHelp = HiiSetString(HiiHandle, 0, String, NULL);
332+
FreePool(String);
333+
334+
HiiCreateGotoExOpCode(
335+
StartHandle,
336+
0,
337+
Token,
338+
TokenHelp,
339+
0,
340+
0,
341+
0,
342+
&SecureBootConfigGuid,
343+
0
344+
);
345+
346+
break;
347+
}
348+
349+
Ptr += ((EFI_IFR_OP_HEADER *)Ptr)->Length;
350+
}
351+
352+
FreePool (Buffer);
353+
Buffer = NULL;
354+
TempSize = 0;
355+
BufferSize = 0;
356+
}
357+
358+
HiiUpdateForm(
359+
HiiHandle,
360+
&mFrontPageGuid,
361+
FRONT_PAGE_FORM_ID,
362+
StartHandle,
363+
EndHandle
364+
);
365+
366+
HiiFreeOpCodeHandle(StartHandle);
367+
HiiFreeOpCodeHandle(EndHandle);
368+
}
369+
252370
/**
253371
Initialize HII information for the FrontPage
254372
@@ -308,6 +426,8 @@ InitializeFrontPage (
308426
//
309427
UpdateFrontPageForm ();
310428

429+
ShowSecureBootConfig ();
430+
311431
return Status;
312432
}
313433

System76PayloadPkg/Application/UiApp/UiApp.inf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
gEfiAcpiTableGuid ## COMSUMES ## GUID
6060
gEfiIfrTianoGuid ## CONSUMES ## GUID (Extended IFR Guid Opcode)
6161
gEfiIfrFrontPageGuid ## CONSUMES ## GUID
62+
gEfiHiiPlatformSetupFormsetGuid ## CONSUMES ## GUID
6263

6364
[Protocols]
6465
gEfiSmbiosProtocolGuid ## CONSUMES

0 commit comments

Comments
 (0)