Skip to content

Commit

Permalink
Loader: continue booting if the driver is already loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattiwatti committed Sep 25, 2023
1 parent 41b1731 commit bb77cca
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions Application/Loader/Loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,20 +266,19 @@ StartAndConfigureDriver(
Print(L"[LOADER] StartImage failed: %llx (%r).\r\n", Status, Status);
goto Exit;
}

Status = gBS->LocateProtocol(&gEfiGuardDriverProtocolGuid,
NULL,
(VOID**)&EfiGuardDriverProtocol);
if (EFI_ERROR(Status))
{
Print(L"[LOADER] LocateProtocol failed: %llx (%r).\r\n", Status, Status);
goto Exit;
}
}
else
{
ASSERT_EFI_ERROR(Status);
Print(L"[LOADER] The driver is already loaded.\r\n");
Status = EFI_ALREADY_STARTED;
}

Status = gBS->LocateProtocol(&gEfiGuardDriverProtocolGuid,
NULL,
(VOID**)&EfiGuardDriverProtocol);
if (EFI_ERROR(Status))
{
Print(L"[LOADER] LocateProtocol failed: %llx (%r).\r\n", Status, Status);
goto Exit;
}

Expand Down Expand Up @@ -424,7 +423,9 @@ TryBootOptionsInOrder(
// Print what we're booting
if (ConvertedPath != NULL)
{
Print(L"Booting %Sdevice path %S...\r\n", IsLegacy ? L"legacy " : L"", ConvertedPath);
Print(L"Booting \"%S\"...\r\n -> %S = %S\r\n",
(BootOptions[Index].Description != NULL ? BootOptions[Index].Description : L"<null description>"),
IsLegacy ? L"Legacy path" : L"Path", ConvertedPath);
FreePool(ConvertedPath);
}

Expand Down Expand Up @@ -580,9 +581,6 @@ UefiMain(
// Locate, load, start and configure the driver
//
CONST EFI_STATUS DriverStatus = StartAndConfigureDriver(ImageHandle, SystemTable);
if (DriverStatus == EFI_ALREADY_STARTED)
return EFI_SUCCESS;

if (EFI_ERROR(DriverStatus))
{
Print(L"\r\nERROR: driver load failed with status %llx (%r).\r\n"
Expand Down

0 comments on commit bb77cca

Please sign in to comment.