From patchwork Tue Oct 10 12:22:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 115400 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3690623qgn; Tue, 10 Oct 2017 05:24:42 -0700 (PDT) X-Received: by 10.80.163.140 with SMTP id s12mr7573369edb.22.1507638282572; Tue, 10 Oct 2017 05:24:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507638282; cv=none; d=google.com; s=arc-20160816; b=T/eXk8uKvjudh6hnobw0zyGKByZtx57heyAGytb0KxBV3znY0ikh6w666nagXYVYWP AiNXlWko83UZzs3B2tLeRZFdZVuNvgCmKHwMw8Gb49Zvqrae5m8v2cKioj1ZAN1DVmtA s84yMVps7/kVqyp0WmCNCZuWlctW/XpBGP1m4uTHR9oly41Rh/qOFAsXLFKFXP2Sl6pE svRsdrebKZ2WgHaDDI9XGJfKN7UMYz8s0FUbLmjT9CkMWRG9Jkgv9x7drCOiRNkODq+M yboFmwnM05QH0u8PJUNLXOeHMJDC3OUWt34tJliQQWhpPdNeq8yRS8bzQo3o8vbI00FG KRUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:arc-authentication-results; bh=ixy5ox/j5pubVourDilENkCbEIoGwgmLZXPMb9vbHx4=; b=DFYD8lyxYYteFHI0/VC0Sls0/lcBc8fmR9cv8iPED/F8JJZppuP198PbEgYK62DwL7 wPDFKMf3xcdrM/2YBuWwj2/2rgBFIsUUz8BfYY8OwYA09uTPBC4MSjUSEVCGyuIpIOC1 yMFTxI3FTg56JEPO+dXyAEGdSOuKZwVhIUjJ3iznYYWO4aLckM/W5s3Ir6fc8NPwXA71 Wc/78MUUeJW7A7O9WCMtDIb8k/6aKTT2OPtSZFNJkNsGGDP9sA/v1hucQHx/DooAQKty QDbXbymxvZmeoZ/6PVInu9kPi8x2uSbqVdsSswWmDoVzWxib6b41KW8eTmyl9VGPlcTo RGYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=ndBKiVbh; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id j4si537409edd.462.2017.10.10.05.24.42; Tue, 10 Oct 2017 05:24:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=ndBKiVbh; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: by lists.denx.de (Postfix, from userid 105) id 0C9BFC21E0C; Tue, 10 Oct 2017 12:23:37 +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_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID 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 90FE3C21D90; Tue, 10 Oct 2017 12:23:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8F2ECC21D5F; Tue, 10 Oct 2017 12:23:26 +0000 (UTC) Received: from mail-qt0-f196.google.com (mail-qt0-f196.google.com [209.85.216.196]) by lists.denx.de (Postfix) with ESMTPS id 62131C21D80 for ; Tue, 10 Oct 2017 12:23:22 +0000 (UTC) Received: by mail-qt0-f196.google.com with SMTP id 32so15984674qtp.4 for ; Tue, 10 Oct 2017 05:23:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BtvilWVDYXj9Vw8it6dRHeAawXAdfsv7YYF77N/nQLQ=; b=ndBKiVbhkU/A1cSOqyr47k0O7hQVd0lNpNrXYlqWyoADPxOYE3G3NJtBIoeuusBrPJ fefriAWcO6Nd1fCfDjGhmaAm4RksykalaxWGTNahtytPR9aGU/P7zCjrIKTmAq0Dlvhr KqNzWItFxbV+BypqAdoslTMJOdCFeFsWhMRmsRQYLcLsv4zjByyc3z+v6s3VpWgLUkTP CzqC8QgCpmuzzrnMA8jFNr+npb/J2VyS06ElcsLbTG1b/AK4YeOL2N0HZ0FPXE6y2HI9 u6EYE5DNAn8BieOdxfU6qOD54EvTpCa9Jf5XoK1HjfuvahLwfJaqDht/seXMNb7wYs3R FtOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BtvilWVDYXj9Vw8it6dRHeAawXAdfsv7YYF77N/nQLQ=; b=CpKrnljhqEcNbX6AOBZCec7S++nauBrf9PCcngiZTH7869fk6wROfv04rgVtpo3MQJ U2IgYjK6KhB5MV4aJnjp+XukVjhtIDyhRW8+3Dbga4JfFp2wYdrMmot0J1TrhJnJyXaE ZW+jZhcxKloIsPRZbXJSCXt2w4oGC1WRjM2D94iuwp4Y7me0vQYDdu/N7MBbG9g2ryrv R4w2eY+gYfdW7lRCwsY43SssDZ98510moF30/JM0vdqqtf0+yT1eT6zOr/JHxGeuoPwL 6FEeBx/GiyGiCqGgrOcfx2bQbieBv2jhlh95P2lE5br2aQzaU0WHSYkutxh7V5y1fHjb KRtw== X-Gm-Message-State: AMCzsaXH1mvCy1vTpKKe6LlYkHtPdfpWHDKKFHlCYSeZW3UiouQK2/CO ILHxm02WMTXq3K7ILHMZ3FkMjkCX X-Google-Smtp-Source: AOwi7QCDVl2QKK1MMAptTIaZxiwV/MyDDpo+CSvKr382Vnpp4INaNCXd4KFwWrD4qLlvA0V7pQT2QA== X-Received: by 10.55.59.131 with SMTP id i125mr13274321qka.93.1507638200984; Tue, 10 Oct 2017 05:23:20 -0700 (PDT) Received: from localhost ([144.121.20.162]) by smtp.gmail.com with ESMTPSA id m65sm6283535qkl.87.2017.10.10.05.23.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Oct 2017 05:23:19 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Tue, 10 Oct 2017 08:22:57 -0400 Message-Id: <20171010122309.25313-2-robdclark@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171010122309.25313-1-robdclark@gmail.com> References: <20171010122309.25313-1-robdclark@gmail.com> Cc: Heinrich Schuchardt , Leif Lindholm Subject: [U-Boot] [PATCH 01/11] efi_loader: Initial EFI_DEVICE_PATH_UTILITIES_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" From: Leif Lindholm Not complete, but enough for Shell.efi and SCT.efi. We'll implement the rest as needed or once we have SCT running properly so there is a way to validate the interface against the conformance test suite. Initial skeleton written by Leif, and then implementation by myself. Cc: Leif Lindholm Signed-off-by: Rob Clark --- include/efi_api.h | 34 +++++++++++- include/efi_loader.h | 2 + lib/efi_loader/Makefile | 1 + lib/efi_loader/efi_boottime.c | 4 ++ lib/efi_loader/efi_device_path_utilities.c | 88 ++++++++++++++++++++++++++++++ 5 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 lib/efi_loader/efi_device_path_utilities.c diff --git a/include/efi_api.h b/include/efi_api.h index a9a6494afe..ffdba7fe1a 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -28,8 +28,9 @@ enum efi_timer_delay { EFI_TIMER_RELATIVE = 2 }; -#define UINTN size_t -typedef long INTN; +#define UINTN size_t /* TODO this should be removed in a future patch */ +typedef size_t efi_uintn_t; +typedef ssize_t efi_intn_t; typedef uint16_t *efi_string_t; #define EVT_TIMER 0x80000000 @@ -506,6 +507,35 @@ struct efi_device_path_to_text_protocol bool allow_shortcuts); }; +#define EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \ + EFI_GUID(0x0379be4e, 0xd706, 0x437d, \ + 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4) + +struct efi_device_path_utilities_protocol { + efi_uintn_t (EFIAPI *get_device_path_size)( + const struct efi_device_path *device_path); + struct efi_device_path *(EFIAPI *duplicate_device_path)( + const struct efi_device_path *device_path); + struct efi_device_path *(EFIAPI *append_device_path)( + const struct efi_device_path *src1, + const struct efi_device_path *src2); + struct efi_device_path *(EFIAPI *append_device_node)( + const struct efi_device_path *device_path, + const struct efi_device_path *device_node); + struct efi_device_path *(EFIAPI *append_device_path_instance)( + const struct efi_device_path *device_path, + const struct efi_device_path *device_path_instance); + struct efi_device_path *(EFIAPI *get_next_device_path_instance)( + struct efi_device_path **device_path_instance, + efi_uintn_t *device_path_instance_size); + bool (EFIAPI *is_device_path_multi_instance)( + const struct efi_device_path *device_path); + struct efi_device_path *(EFIAPI *create_device_node)( + uint8_t node_type, + uint8_t node_sub_type, + uint16_t node_length); +}; + #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 e1179b7dcd..5d37c1d75f 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -79,6 +79,7 @@ extern const struct efi_simple_text_output_protocol efi_con_out; extern 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 struct efi_device_path_utilities_protocol efi_device_path_utilities; uint16_t *efi_dp_str(struct efi_device_path *dp); @@ -89,6 +90,7 @@ extern const efi_guid_t efi_guid_loaded_image; extern const efi_guid_t efi_guid_device_path_to_text_protocol; extern const efi_guid_t efi_simple_file_system_protocol_guid; extern const efi_guid_t efi_file_info_guid; +extern const efi_guid_t efi_guid_device_path_utilities_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 ddb978f650..b6927b3b84 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -17,6 +17,7 @@ endif 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 efi_device_path_to_text.o efi_device_path.o +obj-y += efi_device_path_utilities.o obj-y += efi_file.o efi_variable.o efi_bootmgr.o obj-$(CONFIG_LCD) += efi_gop.o obj-$(CONFIG_DM_VIDEO) += efi_gop.o diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 976d5822f7..92c778fcca 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1153,6 +1153,10 @@ void efi_setup_loaded_image(struct efi_loaded_image *info, struct efi_object *ob obj->protocols[3].protocol_interface = (void *)&efi_device_path_to_text; + obj->protocols[4].guid = &efi_guid_device_path_utilities_protocol; + obj->protocols[4].protocol_interface = + (void *)&efi_device_path_utilities; + info->file_path = file_path; info->device_handle = efi_dp_find_obj(device_path, NULL); diff --git a/lib/efi_loader/efi_device_path_utilities.c b/lib/efi_loader/efi_device_path_utilities.c new file mode 100644 index 0000000000..9d90f14ee4 --- /dev/null +++ b/lib/efi_loader/efi_device_path_utilities.c @@ -0,0 +1,88 @@ +/* + * EFI device path interface + * + * Copyright (c) 2017 Leif Lindholm + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include + +const efi_guid_t efi_guid_device_path_utilities_protocol = + EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID; + +static efi_uintn_t EFIAPI get_device_path_size( + const struct efi_device_path *device_path) +{ + efi_uintn_t sz = 0; + EFI_ENTRY("%p", device_path); + /* size includes the END node: */ + if (device_path) + sz = efi_dp_size(device_path) + sizeof(struct efi_device_path); + return EFI_EXIT(sz); +} + +static struct efi_device_path * EFIAPI duplicate_device_path( + const struct efi_device_path *device_path) +{ + EFI_ENTRY("%p", device_path); + return EFI_EXIT(efi_dp_dup(device_path)); +} + +static struct efi_device_path * EFIAPI append_device_path( + const struct efi_device_path *src1, + const struct efi_device_path *src2) +{ + EFI_ENTRY("%p, %p", src1, src2); + return EFI_EXIT(efi_dp_append(src1, src2)); +} + +static struct efi_device_path * EFIAPI append_device_node( + const struct efi_device_path *device_path, + const struct efi_device_path *device_node) +{ + EFI_ENTRY("%p, %p", device_path, device_node); + return EFI_EXIT(efi_dp_append_node(device_path, device_node)); +} + +static struct efi_device_path * EFIAPI append_device_path_instance( + const struct efi_device_path *device_path, + const struct efi_device_path *device_path_instance) +{ + EFI_ENTRY("%p, %p", device_path, device_path_instance); + return EFI_EXIT(NULL); +} + +static struct efi_device_path * EFIAPI get_next_device_path_instance( + struct efi_device_path **device_path_instance, + efi_uintn_t *device_path_instance_size) +{ + EFI_ENTRY("%p, %p", device_path_instance, device_path_instance_size); + return EFI_EXIT(NULL); +} + +static bool EFIAPI is_device_path_multi_instance( + const struct efi_device_path *device_path) +{ + EFI_ENTRY("%p", device_path); + return EFI_EXIT(false); +} + +static struct efi_device_path * EFIAPI create_device_node( + uint8_t node_type, uint8_t node_sub_type, uint16_t node_length) +{ + EFI_ENTRY("%u, %u, %u", node_type, node_sub_type, node_length); + return EFI_EXIT(NULL); +} + +const struct efi_device_path_utilities_protocol efi_device_path_utilities = { + .get_device_path_size = get_device_path_size, + .duplicate_device_path = duplicate_device_path, + .append_device_path = append_device_path, + .append_device_node = append_device_node, + .append_device_path_instance = append_device_path_instance, + .get_next_device_path_instance = get_next_device_path_instance, + .is_device_path_multi_instance = is_device_path_multi_instance, + .create_device_node = create_device_node, +};