From patchwork Fri Mar 9 16:43:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 131163 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1200744lja; Fri, 9 Mar 2018 08:43:54 -0800 (PST) X-Google-Smtp-Source: AG47ELvaWKCPyLDyYvju5HjvJjh8gpRcU8cI6BawWvbGo4h7/ja3NL/D1Cmll2AbtDDdkVJqzPjQ X-Received: by 10.80.181.24 with SMTP id y24mr5124436edd.166.1520613834755; Fri, 09 Mar 2018 08:43:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520613834; cv=none; d=google.com; s=arc-20160816; b=KNDOgSXnbBHfLzVuIWAKQz5ZQuIBQ8WtuizfJ5Q58V3hFU849obscTuhdRRL9Y6vTY lJJnsnOIQIX/oyHVhTahnFIdyigI8zSBqTGyBfy/QWqyz5FB9xGqy9a3y9pj3mE4q4kr GVJ0EGe3Xp8Lj6APA1wFSe3642UAYCkt3aE9Bfx8FWgNdjIdDAwtuo0u7X3xUW8qtKHg tW8jxzMamPGfW+iGCS1PWXKwd7KWPRd81JiREOf8MsZ1XOIC11DQDSBwk3jCvHs6U8pZ vkvtxuxl1Xfk7FjpTJtZcD/9hTl7Bwd7eqtZJpjbpvP/Z1pWz0H+uduHUdDQkFsX6XDk v/pQ== 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:message-id:date:to:from :arc-authentication-results; bh=/KZx6YudELbbUGMTH+txgXaFAx4jMMOUxjG7bHeVwqw=; b=hcqUJQrBwmmbAFVGw+zhGDe2SlPvaJ3l59YfPqufSGhAHVdsIEDK4wxl6g5wXetuac 8Fjdwr3tFqcHbIyhzQ5u/3NDKXBa0QgTVNM6hApQRWFtwcL0aq77NZYEsoDKaahZnsHN ym5EP/dwqnPYRSiYKOBD6IihyCzbOQ5QQk72WcriGmdNYX33acn9T+gbqqUHIHjetEj/ jEGcxjBJQPvBzGrviPZmS8JC0g6Vi1B7EPhjctO8bSDq6g95hnXYW4NGi/DMHzmqLVEN bGUXRYJiA6pu5Ug4gSGtYZ0ghv357FfAFhIMtt00PxlYUdUY7MHg1e/HJeL93aNglK8h xQJQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id 35si1354930edh.523.2018.03.09.08.43.54; Fri, 09 Mar 2018 08:43:54 -0800 (PST) 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; 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 Received: by lists.denx.de (Postfix, from userid 105) id 39607C21DD4; Fri, 9 Mar 2018 16:43:53 +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 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 505EBC21C93; Fri, 9 Mar 2018 16:43:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 39AF8C21C93; Fri, 9 Mar 2018 16:43:48 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id 20E29C21C27 for ; Fri, 9 Mar 2018 16:43:47 +0000 (UTC) Received: from workstation4.fritz.box ([84.118.156.34]) by mail.gmx.com (mrgmx101 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MUUWN-1f2tpC2Z7r-00RLTO; Fri, 09 Mar 2018 17:43:45 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Fri, 9 Mar 2018 17:43:21 +0100 Message-Id: <20180309164321.22575-1-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 X-Provags-ID: V03:K0:MwDO6o+ZGcQBggWUkZNtQsRWR32chB1MY1AMrFiCTik4y29E2Fb 2m1tL0xvw9dadzyVQmNHqomL5UxH1ckL1G9rApy+ma86t0NdwQMKPsta1FIGI6cuyjQ61Rg wU4joTuMY8cnKtuT4w364qgWGjENwF714RhsBOWvVqVCEni8ZtuTw96RT4z/+E5rPbwJ9Hz WNGmr3dylyGXmqEpNnrlw== X-UI-Out-Filterresults: notjunk:1; V01:K0:z8unjJHlCz0=:ACsHDZNf8rlMphnqyNfogZ Kv09TP8zhSgBE6y1dyHqoosvhXlUEKwKGZpKm2RXggdpMHWH4cuf7EBalwMeoi9QwctGLcem5 bByDFtgrFkB0Muj8kxDcQseeg/UMcXuh00uKuBj0KmGuycfbv95Cjxk+Uiexk/96TMCYBZpJP aXJKWerkcNIbBmdE8fbV/CKD4b65Q/DWS3rVS0ifdNQx4MHpGviz5UyALCnMjNhPFFp9ujSzd rlmVFM+RNPy8moQAhN46fgCGrzbzkdJMpxCD+VYzcdepf4eYqLJrSdj+4NUzZGAfR/xU6nQD+ FdxxOxQeE1IEbThRSuF+CXNuSPRCeNm5w+iiQZdhH7gIX91loPRQREL0sHhmeqk9SXWUAUvIl Lx7D3/oWx4K6+oZFH/vhnRevqEsvQoLpLtfwVmZZ4gHy3BmTVB3aD9v/+p6nmc5SdPukHHkCH YUSKP/Iob8WvKl+FHGfd26yhLi8nhJr3dadx1FqnR2b5nO8AEfzJeTvzed5QMdzNmX8vN0LxX et9JfQHx4/Wo/0iZddzaKBxhO5x+qdr762Y0e12aInHQ3alkZ+Hkj8DJwNFD3/oP5tjBKyoYf ytg5KW/NLjfLaDFaLg8FJcwf6eKsssWpTGbAToWT+ncnYja1l1Ay3lbtRoeZsz934Sni/Eqd9 92k7TBzlPV1HkrR/6uCeC2g6THjhtjyyx/1CI9dfEPEZytSVmLKbvYZaZuNU1c+3SUwWaRjtv jAXlmFRTbhj90pT0u9pIAatueAOQ6cnsaxpJbNVm4/ROYvomuGlCPxkHoSrYOtdrQAYk322gp 4ihMgl6DLMHUcE+1nXaHZhuszM+YQ== Cc: u-boot@lists.denx.de, Leif Lindholm , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 1/1] 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 Rob. Signed-off-by: Leif Lindholm [Fill initial skeleton] Signed-off-by: Rob Clark [Rebase on v2018.03-rc1] Signed-off-by: Heinrich Schuchardt --- v3 Rebase on v2018.03-rc1 v2 Fill initial skeleton https://lists.denx.de/pipermail/u-boot/2017-October/308997.html v1 Initial patch by Leif https://lists.denx.de/pipermail/u-boot/2017-September/305230.html --- include/efi_api.h | 29 ++++++++++ include/efi_loader.h | 4 ++ lib/efi_loader/Makefile | 3 +- lib/efi_loader/efi_boottime.c | 6 ++ lib/efi_loader/efi_device_path_utilities.c | 89 ++++++++++++++++++++++++++++++ 5 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 lib/efi_loader/efi_device_path_utilities.c diff --git a/include/efi_api.h b/include/efi_api.h index 559e58e5501..993e8231fca 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -588,6 +588,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 7caae97ea70..0937b47e4bf 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -83,6 +83,9 @@ extern struct efi_simple_text_output_protocol efi_con_out; extern struct efi_simple_input_interface efi_con_in; extern struct efi_console_control_protocol efi_console_control; extern const struct efi_device_path_to_text_protocol efi_device_path_to_text; +/* implementation of the EFI_DEVICE_PATH_UTILITIES_PROTOCOL */ +extern const struct efi_device_path_utilities_protocol + efi_device_path_utilities; uint16_t *efi_dp_str(struct efi_device_path *dp); @@ -97,6 +100,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 2722265ee3d..55c97c04766 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -17,7 +17,8 @@ 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_file.o efi_variable.o efi_bootmgr.o efi_watchdog.o +obj-y += efi_device_path_utilities.o efi_file.o efi_variable.o efi_bootmgr.o +obj-y += efi_watchdog.o obj-$(CONFIG_LCD) += efi_gop.o obj-$(CONFIG_DM_VIDEO) += efi_gop.o obj-$(CONFIG_PARTITIONS) += efi_disk.o diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 013e0353c3a..0fd272253d2 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1426,6 +1426,12 @@ efi_status_t efi_setup_loaded_image( if (ret != EFI_SUCCESS) goto failure; + ret = efi_add_protocol(obj->handle, + &efi_guid_device_path_utilities_protocol, + (void *)&efi_device_path_utilities); + if (ret != EFI_SUCCESS) + goto failure; + return ret; failure: printf("ERROR: Failure to install protocols for loaded image\n"); 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 00000000000..bc97eeee31b --- /dev/null +++ b/lib/efi_loader/efi_device_path_utilities.c @@ -0,0 +1,89 @@ +/* + * 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, +};