forked from systemd/systemd
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
systemd-boot: load addons from type 1 and expose them via EFI protocol
This make it possible to attach addons to any Type systemd#1 entry and get them back in the next bootable stage via an EFI protocol.
- Loading branch information
1 parent
8b9ad17
commit 48ffc70
Showing
4 changed files
with
89 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* SPDX-License-Identifier: LGPL-2.1-or-later */ | ||
|
||
#include "addon-util.h" | ||
#include "proto/device-path.h" | ||
#include "util.h" | ||
#include "log.h" | ||
|
||
EFI_STATUS addons_install_proto(EFI_LOADED_IMAGE_PROTOCOL *stub_image, char16_t * const *addons) { | ||
EFI_STATUS err; | ||
EFI_DEVICE_PATH **dps; | ||
|
||
assert(stub_image); | ||
|
||
err = make_multiple_file_device_path(stub_image->DeviceHandle, addons, &dps); | ||
if (err != EFI_SUCCESS || dps == NULL) | ||
return err; | ||
|
||
return BS->InstallMultipleProtocolInterfaces(&stub_image->DeviceHandle, | ||
MAKE_GUID_PTR(SYSTEMD_ADDON_MEDIA), | ||
dps, NULL); | ||
} | ||
|
||
EFI_STATUS addons_unload_proto(EFI_HANDLE *addons) | ||
{ | ||
EFI_STATUS err; | ||
EFI_DEVICE_PATH *dps; | ||
|
||
assert(addons); | ||
|
||
if (!*addons) | ||
return EFI_SUCCESS; | ||
|
||
/* get the EFI_DEVICE_PATH* interface that we allocated earlier */ | ||
err = BS->HandleProtocol(*addons, MAKE_GUID_PTR(SYSTEMD_ADDON_MEDIA), | ||
(void **) &dps); | ||
if (err != EFI_SUCCESS) | ||
return err; | ||
|
||
err = BS->UninstallMultipleProtocolInterfaces(*addons, | ||
MAKE_GUID_PTR(SYSTEMD_ADDON_MEDIA), | ||
&dps, NULL); | ||
|
||
if (err != EFI_SUCCESS) | ||
return err; | ||
|
||
*addons = NULL; | ||
return EFI_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* SPDX-License-Identifier: LGPL-2.1-or-later */ | ||
#pragma once | ||
|
||
#include "proto/loaded-image.h" | ||
#include "device-path-util.h" | ||
#include "util.h" | ||
|
||
#define SYSTEMD_ADDON_MEDIA_GUID \ | ||
GUID_DEF(0x97ac68bf, 0xc741, 0x4bbb, 0xb7, 0xbf, 0x7f, 0x6c, 0xcc, 0x00, 0x8a, 0x7e) | ||
|
||
EFI_STATUS addons_install_proto(EFI_LOADED_IMAGE_PROTOCOL *loaded_image, char16_t * const *addons); | ||
EFI_STATUS addons_unload_proto(EFI_HANDLE *addons); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters