From patchwork Tue Jul 11 20:06:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 786844 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3x6YCc3zsvz9s81 for ; Wed, 12 Jul 2017 06:12:28 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 4337EC21F30; Tue, 11 Jul 2017 20:09:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2575CC21F15; Tue, 11 Jul 2017 20:07:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0DF5DC21F09; Tue, 11 Jul 2017 20:07:35 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lists.denx.de (Postfix) with ESMTPS id A51FFC21EDB for ; Tue, 11 Jul 2017 20:07:31 +0000 (UTC) Received: from workstation4.fritz.box ([88.152.145.149]) by mail.gmx.com (mrgmx001 [212.227.17.184]) with ESMTPSA (Nemesis) id 0MAQXq-1dOvZC11D8-00BfTs; Tue, 11 Jul 2017 22:06:40 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Tue, 11 Jul 2017 22:06:25 +0200 Message-Id: <20170711200625.7108-13-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170711200625.7108-1-xypron.glpk@gmx.de> References: <20170711200625.7108-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:UWyAY57mjUCBamCOSqqVTeH1OEdhslkg6ukhXiPMZ95TTBShisK qzYLEsT3t6q4gLd3PFumiSFIsapJHZWnP1ohgCaeCl69+y6MOT1X17P3XUtzSSqGEUt0JuL rR12p0ljjlulDIrekhH89hPaf9e3jy7hlrH8tA/ccXFYhNtaOu7bIWMhI78QNi5gxSPlxw9 nSbyH16STrYAYMpD4fvwQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:g5JIhGluMCc=:zOGX0Rsm/5escofMWqjqRp tgDupNOe+6kTRWzfiGbPCuKKMwEuMYnocabYCDEOCyaU4Ybma/vlUhOmVgUyQCD+SRYR9QutD exRL3obxvM92ecxDUE93LteUtu3eCE/ySWyCb/xOyg7IFPZr5kskt7yKzGwaJAASjP3aw4EOt pn3GcADbOQq7W0pirRxEzvI9dLBUJRjV0FTHnwqo6qBvIQH1+gYRyYPysXqOyczzqKPEWovMR MtpuCkzdAetujuH2EhMHxsHpQmsZXapbkTcVsx6k/4ssEKMBa4bg55xJOke9yKnQMIdHvzjKF qUAV4KGnaDuLqbHwCadRFmoppSuAETrsOnhwi4UALpeU/4e6DBvEGhuYnzp+pUQo0jadONYxU mZYW5RLx9wgsy40ld719J2WpqIs7vWS+3c+JAxo4g+PwoDViWRDU4lnyg12lRxyYRy5+FXKzE aIQX31vUTUc9Sk4DJHAH7pvOsVDQgutGZaUwFBLjUAvy+KX9nSpIJH8OfMkDmB0BXuBZ4B9Yy qELiP9QzvUNoXP/WNzfwIx0tjan6N1ppeuiVtpYSwGt2DkJ8gF6NnGUzpdsNgj97civxQnah1 HRXEtNS/fRj+559Z87CGl9qvnCAsIHZ4IqwXQeARi8yWfKsfh4bXHAgvByfxOU3P+gc/mVsj3 8i1uyEniep8n4Y8rwz3F7A5lYgGV6NnQ3Yujr3mHd852cm/h6RRQIaRIGY4oqqnrplxPIdpk+ q00Nj1BlkeO2h5VEU/eo76gShvkG2TgXPy7yzq5Kn3zNXJB4o0bKBVuYl7k= Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 12/12] efi_loader: implement EFI_DEVICE_PATH_TO_TEXT_PROTOCOL X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 --- v2 new patch --- cmd/bootefi.c | 4 ++ include/efi_api.h | 24 +++++++++++ include/efi_loader.h | 2 + lib/efi_loader/Makefile | 2 +- lib/efi_loader/efi_device_path_to_text.c | 68 ++++++++++++++++++++++++++++++++ 5 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 lib/efi_loader/efi_device_path_to_text.c diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 4e73059cb3..d1e782cfe9 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -84,6 +84,10 @@ static struct efi_object loaded_image_info_obj = { .guid = &efi_guid_console_control, .protocol_interface = (void *) &efi_console_control }, + { + .guid = &efi_guid_device_path_to_text_protocol, + .protocol_interface = (void *) &efi_device_path_to_text + }, }, }; diff --git a/include/efi_api.h b/include/efi_api.h index 42cd47ff08..ea63e80b47 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -395,6 +395,30 @@ struct efi_console_control_protocol uint16_t *password); }; +#define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \ + EFI_GUID(0x8b843e20, 0x8132, 0x4852, \ + 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c) + +struct efi_device_path_protocol +{ + uint8_t type; + uint8_t sub_type; + uint16_t length; + uint8_t data[]; +}; + +struct efi_device_path_to_text_protocol +{ + uint16_t *(EFIAPI *convert_device_node_to_text)( + struct efi_device_path_protocol *device_node, + bool display_only, + bool allow_shortcuts); + uint16_t *(EFIAPI *convert_device_path_to_text)( + struct efi_device_path_protocol *device_path, + bool display_only, + bool allow_shortcuts); +}; + #define EFI_GOP_GUID \ EFI_GUID(0x9042a9de, 0x23dc, 0x4a38, \ 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a) diff --git a/include/efi_loader.h b/include/efi_loader.h index 6ea6e9ee4d..d7847d23e5 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -28,10 +28,12 @@ extern struct efi_system_table systab; extern const struct efi_simple_text_output_protocol efi_con_out; extern const struct efi_simple_input_interface efi_con_in; extern const struct efi_console_control_protocol efi_console_control; +extern const struct efi_device_path_to_text_protocol efi_device_path_to_text; extern const efi_guid_t efi_guid_console_control; extern const efi_guid_t efi_guid_device_path; extern const efi_guid_t efi_guid_loaded_image; +extern const efi_guid_t efi_guid_device_path_to_text_protocol; extern unsigned int __efi_runtime_start, __efi_runtime_stop; extern unsigned int __efi_runtime_rel_start, __efi_runtime_rel_stop; 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..d6d2e3c35f --- /dev/null +++ b/lib/efi_loader/efi_device_path_to_text.c @@ -0,0 +1,68 @@ +/* + * EFI device path interface + * + * Copyright (c) 2017 Heinrich Schuchardt + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include + +#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, +};