Skip to content

Commit

Permalink
OcBootManagementLib: Allow launching any app via GUID
Browse files Browse the repository at this point in the history
  • Loading branch information
vit9696 committed Dec 3, 2020
1 parent 27dcb28 commit 1f2982b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Application/BootKicker/BootKicker.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ UefiMain (
return Status;
}

Status = OcRunAppleBootPicker ();
Status = OcRunFirmwareApplication (&gAppleBootPickerFileGuid, TRUE);

Pixel.Raw = 0x0;
if (Status == EFI_NOT_FOUND) {
Expand Down
10 changes: 7 additions & 3 deletions Include/Acidanthera/Library/OcBootManagementLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -1210,13 +1210,17 @@ OcDeleteVariables (
);

/**
Launch Apple BootPicker.
Launch firmware application.
@param[in] ApplicationGuid Application GUID identifier in the firmware.
@param[in] SetReason Pass enter reason (specific to Apple BootPicker).
@retval error code, should not return.
**/
EFI_STATUS
OcRunAppleBootPicker (
VOID
OcRunFirmwareApplication (
IN EFI_GUID *ApplicationGuid,
IN BOOLEAN SetReason
);

/**
Expand Down
41 changes: 25 additions & 16 deletions Library/OcBootManagementLib/OcBootManagementLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ RunShowMenu (

if (!BootContext->PickerContext->ApplePickerUnsupported
&& BootContext->PickerContext->PickerMode == OcPickerModeApple) {
Status = OcRunAppleBootPicker ();
Status = OcRunFirmwareApplication (&gAppleBootPickerFileGuid, TRUE);
//
// This should not return on success.
//
Expand Down Expand Up @@ -540,7 +540,7 @@ OcRunBootPicker (
}

if (Context->PickerCommand == OcPickerShowPicker && Context->PickerMode == OcPickerModeApple) {
Status = OcRunAppleBootPicker ();
Status = OcRunFirmwareApplication (&gAppleBootPickerFileGuid, TRUE);
DEBUG ((DEBUG_INFO, "OCB: Apple BootPicker failed - %r, fallback to builtin\n", Status));
Context->ApplePickerUnsupported = TRUE;
}
Expand Down Expand Up @@ -707,20 +707,21 @@ OcRunBootPicker (
}

EFI_STATUS
OcRunAppleBootPicker (
VOID
OcRunFirmwareApplication (
IN EFI_GUID *ApplicationGuid,
IN BOOLEAN SetReason
)
{
EFI_STATUS Status;
EFI_HANDLE NewHandle;
EFI_DEVICE_PATH_PROTOCOL *Dp;
APPLE_PICKER_ENTRY_REASON PickerEntryReason;

DEBUG ((DEBUG_INFO, "OCB: OcRunAppleBootPicker attempting to find...\n"));
DEBUG ((DEBUG_INFO, "OCB: run fw app attempting to find %g...\n", ApplicationGuid));

Dp = CreateFvFileDevicePath (&gAppleBootPickerFileGuid);
Dp = CreateFvFileDevicePath (ApplicationGuid);
if (Dp != NULL) {
DEBUG ((DEBUG_INFO, "OCB: OcRunAppleBootPicker attempting to load...\n"));
DEBUG ((DEBUG_INFO, "OCB: run fw app attempting to load %g...\n", ApplicationGuid));
NewHandle = NULL;
Status = gBS->LoadImage (
FALSE,
Expand All @@ -738,16 +739,24 @@ OcRunAppleBootPicker (
}

if (!EFI_ERROR (Status)) {
PickerEntryReason = ApplePickerEntryReasonUnknown;
Status = gRT->SetVariable (
APPLE_PICKER_ENTRY_REASON_VARIABLE_NAME,
&gAppleVendorVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS,
sizeof (PickerEntryReason),
&PickerEntryReason
);
if (SetReason) {
PickerEntryReason = ApplePickerEntryReasonUnknown;
Status = gRT->SetVariable (
APPLE_PICKER_ENTRY_REASON_VARIABLE_NAME,
&gAppleVendorVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS,
sizeof (PickerEntryReason),
&PickerEntryReason
);
}

DEBUG ((DEBUG_INFO, "OCB: OcRunAppleBootPicker attempting to start with var %r...\n", Status));
DEBUG ((
DEBUG_INFO,
"OCB: run fw app attempting to start %g (%d) %r...\n",
ApplicationGuid,
SetReason,
Status
));
Status = gBS->StartImage (
NewHandle,
NULL,
Expand Down

0 comments on commit 1f2982b

Please sign in to comment.