* By default, Shim uninstalls its protocol when calling StartImage(). */
shim_retain_protocol();
- err = BS->OpenProtocol(
- image,
- MAKE_GUID_PTR(EFI_LOADED_IMAGE_PROTOCOL),
- (void **) &loaded_image,
- image,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ err = BS->HandleProtocol(image, MAKE_GUID_PTR(EFI_LOADED_IMAGE_PROTOCOL), (void **) &loaded_image);
if (err != EFI_SUCCESS)
return log_error_status(err, "Error getting a LoadedImageProtocol handle: %m");
config_load_all_entries(&config, loaded_image, loaded_image_path, root_dir);
- if (config.entry_count == 0) {
- log_error("No loader found. Configuration files in \\loader\\entries\\*.conf are needed.");
- goto out;
- }
+ if (config.entry_count == 0)
+ return log_error_status(
+ EFI_NOT_FOUND,
+ "No loader found. Configuration files in \\loader\\entries\\*.conf are needed.");
/* select entry or show menu when key is pressed or timeout is set */
if (config.force_menu || config.timeout_sec > 0)
if (menu) {
efivar_set_time_usec(MAKE_GUID_PTR(LOADER), u"LoaderTimeMenuUSec", 0);
if (!menu_run(&config, &entry, loaded_image_path))
- break;
+ return EFI_SUCCESS;
}
/* if auto enrollment is activated, we try to load keys for the given entry. */
err = image_start(image, entry);
if (err != EFI_SUCCESS)
- goto out;
+ return err;
menu = true;
config.timeout_sec = 0;
}
- err = EFI_SUCCESS;
-out:
- BS->CloseProtocol(image, MAKE_GUID_PTR(EFI_LOADED_IMAGE_PROTOCOL), image, NULL);
- return err;
}
DEFINE_EFI_MAIN_FUNCTION(run, "systemd-boot", /*wait_for_debugger=*/false);
return EFI_SUCCESS;
/* get the LoadFile2 protocol that we allocated earlier */
- err = BS->OpenProtocol(
- initrd_handle,
- MAKE_GUID_PTR(EFI_LOAD_FILE2_PROTOCOL),
- (void **) &loader,
- NULL,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ err = BS->HandleProtocol(initrd_handle, MAKE_GUID_PTR(EFI_LOAD_FILE2_PROTOCOL), (void **) &loader);
if (err != EFI_SUCCESS)
return err;
- /* close the handle */
- (void) BS->CloseProtocol(initrd_handle, MAKE_GUID_PTR(EFI_LOAD_FILE2_PROTOCOL), NULL, NULL);
-
/* uninstall all protocols thus destroying the handle */
err = BS->UninstallMultipleProtocolInterfaces(
initrd_handle, MAKE_GUID_PTR(EFI_DEVICE_PATH_PROTOCOL),
uint64_t loader_features = 0;
EFI_STATUS err;
- err = BS->OpenProtocol(
- image,
- MAKE_GUID_PTR(EFI_LOADED_IMAGE_PROTOCOL),
- (void **) &loaded_image,
- image,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ err = BS->HandleProtocol(image, MAKE_GUID_PTR(EFI_LOADED_IMAGE_PROTOCOL), (void **) &loaded_image);
if (err != EFI_SUCCESS)
return log_error_status(err, "Error getting a LoadedImageProtocol handle: %m");