summaryrefslogtreecommitdiff
path: root/lib/efi_loader
diff options
context:
space:
mode:
authorxypron.glpk@gmx.de <xypron.glpk@gmx.de>2017-07-11 22:06:25 +0200
committerAlexander Graf <agraf@suse.de>2017-07-19 14:14:40 +0200
commitcc5b70812f5e3b13ea9072c2dacc939818ef8e66 (patch)
tree122757ca40162ca3b81b02ad56e2031a20ff30d7 /lib/efi_loader
parent88adae5ef057845f6bc69c63123df4332fe835b1 (diff)
efi_loader: implement EFI_DEVICE_PATH_TO_TEXT_PROTOCOL
ConvertPathToText is implemented for * type 4 - media device path * subtype 4 - file path This is the kind of device path we hand out for block devices. All other cases may be implemented later. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> [agraf: fix whitespace] Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'lib/efi_loader')
-rw-r--r--lib/efi_loader/Makefile2
-rw-r--r--lib/efi_loader/efi_device_path_to_text.c67
2 files changed, 68 insertions, 1 deletions
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index fa8b91a526..3fc2371896 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -15,7 +15,7 @@ always := $(efiprogs-y)
obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o
obj-y += efi_image_loader.o efi_boottime.o efi_runtime.o efi_console.o
-obj-y += efi_memory.o
+obj-y += efi_memory.o efi_device_path_to_text.o
obj-$(CONFIG_LCD) += efi_gop.o
obj-$(CONFIG_PARTITIONS) += efi_disk.o
obj-$(CONFIG_NET) += efi_net.o
diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c
new file mode 100644
index 0000000000..a7a513047f
--- /dev/null
+++ b/lib/efi_loader/efi_device_path_to_text.c
@@ -0,0 +1,67 @@
+/*
+ * EFI device path interface
+ *
+ * Copyright (c) 2017 Heinrich Schuchardt
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <efi_loader.h>
+
+#define MEDIA_DEVICE_PATH 4
+#define FILE_PATH_MEDIA_DEVICE_PATH 4
+
+const efi_guid_t efi_guid_device_path_to_text_protocol =
+ EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID;
+
+uint16_t *efi_convert_device_node_to_text(
+ struct efi_device_path_protocol *device_node,
+ bool display_only,
+ bool allow_shortcuts)
+{
+ EFI_ENTRY("%p, %d, %d", device_node, display_only, allow_shortcuts);
+
+ EFI_EXIT(EFI_UNSUPPORTED);
+ return NULL;
+}
+
+uint16_t *efi_convert_device_path_to_text(
+ struct efi_device_path_protocol *device_path,
+ bool display_only,
+ bool allow_shortcuts)
+{
+ EFI_ENTRY("%p, %d, %d", device_path, display_only, allow_shortcuts);
+
+ unsigned long buffer_size;
+ efi_status_t r;
+ uint16_t *buffer = NULL;
+
+ switch (device_path->type) {
+ case MEDIA_DEVICE_PATH:
+ switch (device_path->sub_type) {
+ case FILE_PATH_MEDIA_DEVICE_PATH:
+ buffer_size = device_path->length - 4;
+ r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES,
+ buffer_size, (void **) &buffer);
+ if (r == EFI_SUCCESS)
+ memcpy(buffer, device_path->data, buffer_size);
+ break;
+ }
+ }
+
+ if (buffer) {
+ EFI_EXIT(EFI_SUCCESS);
+ } else {
+ debug("type %d, subtype %d\n",
+ device_path->type, device_path->sub_type);
+ EFI_EXIT(EFI_UNSUPPORTED);
+ }
+
+ return buffer;
+}
+
+const struct efi_device_path_to_text_protocol efi_device_path_to_text = {
+ .convert_device_node_to_text = efi_convert_device_node_to_text,
+ .convert_device_path_to_text = efi_convert_device_path_to_text,
+};