summaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authorJan Janssen <medhefgo@web.de>2022-06-05 15:31:01 +0200
committerJan Janssen <medhefgo@web.de>2022-10-12 13:19:34 +0200
commit3b3eb196a2480b2671dcd6c14792fefc48f1abb1 (patch)
tree6933f7a1fa7d9e815215e74baa9c05c03f23a883 /src/boot
parent6c65a9e1d6b84fec4ff01d0794607377e600b353 (diff)
downloadsystemd-3b3eb196a2480b2671dcd6c14792fefc48f1abb1.tar.gz
boot: Add device_path_to_str
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/efi/util.c19
-rw-r--r--src/boot/efi/util.h1
2 files changed, 20 insertions, 0 deletions
diff --git a/src/boot/efi/util.c b/src/boot/efi/util.c
index e17a8e18a4..5547d288de 100644
--- a/src/boot/efi/util.c
+++ b/src/boot/efi/util.c
@@ -769,6 +769,25 @@ EFI_STATUS make_file_device_path(EFI_HANDLE device, const char16_t *file, EFI_DE
return EFI_SUCCESS;
}
+EFI_STATUS device_path_to_str(const EFI_DEVICE_PATH *dp, char16_t **ret) {
+ EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *dp_to_text;
+ EFI_STATUS err;
+
+ assert(dp);
+ assert(ret);
+
+ err = BS->LocateProtocol(&(EFI_GUID) EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID, NULL, (void **) &dp_to_text);
+ if (err != EFI_SUCCESS)
+ return err;
+
+ char16_t *str = dp_to_text->ConvertDevicePathToText(dp, false, false);
+ if (!str)
+ return EFI_OUT_OF_RESOURCES;
+
+ *ret = str;
+ return EFI_SUCCESS;
+}
+
#if defined(__i386__) || defined(__x86_64__)
bool in_hypervisor(void) {
uint32_t eax, ebx, ecx, edx;
diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h
index be79b205a4..b33c50f9fc 100644
--- a/src/boot/efi/util.h
+++ b/src/boot/efi/util.h
@@ -207,6 +207,7 @@ static inline void beep(UINTN beep_count) {}
EFI_STATUS open_volume(EFI_HANDLE device, EFI_FILE **ret_file);
EFI_STATUS make_file_device_path(EFI_HANDLE device, const char16_t *file, EFI_DEVICE_PATH **ret_dp);
+EFI_STATUS device_path_to_str(const EFI_DEVICE_PATH *dp, char16_t **ret);
#if defined(__i386__) || defined(__x86_64__)
bool in_hypervisor(void);