From patchwork Sun Sep 10 13:22:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 812139 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cnTj3IX4"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xqsHM66BYz9s83 for ; Sun, 10 Sep 2017 23:25:03 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 73560C21EE4; Sun, 10 Sep 2017 13:23:46 +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, 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 A5D56C21E40; Sun, 10 Sep 2017 13:23:01 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id F01B3C21DEB; Sun, 10 Sep 2017 13:22:50 +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 ECC63C21EA9 for ; Sun, 10 Sep 2017 13:22:45 +0000 (UTC) Received: by mail-qt0-f196.google.com with SMTP id 7so4190460qtz.3 for ; Sun, 10 Sep 2017 06:22:45 -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=LemN/4krNFCT7o7M65iutcrbnjNiKuB/STSObMRxCqM=; b=cnTj3IX4hrwrtvNfIAGaggGHWgL57KskJNjNFw6tD2rMUYAvkYmYQJ/MHydIuswxjo 805l3L3TWDovdwtNEadVuYAfmQa2D7ARHaM99kGyK4T0prGZXhHG9anHSU966XjA/nrr BX9t33iCz6isTFT1iZp5i/qh0UFi9L9QIM6KAdaVFR0WjJOomHbIdaZ7b28DnbwH9mzd dxRNFF7qiUNDZKwP6vKGq4efgrXcLRft+XBpt8HKZL8wmoB2yljY61EjR3QCmtC5lwws deukzAZ5vl7JW/qXi0578xwpPkYVk7bEpaII2ODzEnaIzW8l8oaSW8oqsTmOT9xhLGXt nwTA== 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=LemN/4krNFCT7o7M65iutcrbnjNiKuB/STSObMRxCqM=; b=qic6I8l79oHzX9w0iORMWKgqrQtZ0dVEr9fzqr6QzgK26R+BbV2gaAqHcDPIRGYK+Y SFrku7TxyDoI41+MajSc8bH/GN1Hig7NZIzHtnI7u+SRRX0mrS7ia2JNw8/c1A4UlneV //mzR0vcKkn9IgAHAzy/ti449+jWik8RRu0Ylve1nPpuOdAX8DPXUpW9S5p28/Qbp4ze wPm75eYsAMzDOO1ZBZJlnVNXPyHOwqBvNi47gzoxtt+0b1LppPmR6WP886zNVQWQplAF suIBi2yAz9LqXVpxoIZOP7xTp+qN13AW/8MBig8qdaUxGXEC1tqDFw5z9JaDB0vLZI/U Lnhg== X-Gm-Message-State: AHPjjUikqU4EMJsP3ON4dqghDsDuJrk8BRnbynhN9TQ4WtUrhcoAlCml /gC3UmUk48V4ZNugUG8= X-Google-Smtp-Source: AOwi7QDMnsT27AC7mRHS7S8ysEDWpXaou6B9ratYeOw2y9Lpr/PhaUDZcM8qibQhMX+7VZhXJPGVUg== X-Received: by 10.200.26.123 with SMTP id q56mr5514604qtk.130.1505049764657; Sun, 10 Sep 2017 06:22:44 -0700 (PDT) Received: from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a]) by smtp.gmail.com with ESMTPSA id h58sm4438932qta.82.2017.09.10.06.22.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Sep 2017 06:22:43 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Sun, 10 Sep 2017 09:22:22 -0400 Message-Id: <20170910132236.14318-2-robdclark@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170910132236.14318-1-robdclark@gmail.com> References: <20170910132236.14318-1-robdclark@gmail.com> Cc: Heinrich Schuchardt , Peter Jones , Leif Lindholm Subject: [U-Boot] [PATCH v1 01/12] efi_loader: add stub 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 Signed-off-by: Leif Lindholm --- include/efi_api.h | 30 +++++++++++ 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 | 83 ++++++++++++++++++++++++++++++ 5 files changed, 120 insertions(+) create mode 100644 lib/efi_loader/efi_device_path_utilities.c diff --git a/include/efi_api.h b/include/efi_api.h index c3b9032a48..57468dd972 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -506,6 +506,36 @@ 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 +{ + UINTN(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, + UINTN *device_path_instance_size); + struct efi_device_path *(EFIAPI *create_device_node)( + uint8_t node_type, + uint8_t node_sub_type, + uint16_t node_length); + bool(EFIAPI *is_device_path_multi_instance)( + const struct efi_device_path *device_path); +}; + #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 43b12b94fa..c009828db9 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -58,6 +58,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); @@ -68,6 +69,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 930c0e218e..f5e69dd078 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -16,6 +16,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 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 3860feb79b..8bb243d673 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -775,6 +775,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..4b97080f35 --- /dev/null +++ b/lib/efi_loader/efi_device_path_utilities.c @@ -0,0 +1,83 @@ +/* + * 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 UINTN get_device_path_size(const struct efi_device_path *device_path) +{ + EFI_ENTRY("%p", device_path); + return EFI_EXIT(0); +} + +static struct efi_device_path *duplicate_device_path( + const struct efi_device_path *device_path) +{ + EFI_ENTRY("%p", device_path); + return EFI_EXIT(NULL); +} + +static struct efi_device_path *append_device_path( + const struct efi_device_path *src1, + const struct efi_device_path *src2) +{ + EFI_ENTRY("%p, %p", src1, src2); + return EFI_EXIT(NULL); +} + +static struct efi_device_path *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(NULL); +} + +static struct efi_device_path *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 *get_next_device_path_instance( + struct efi_device_path **device_path_instance, + UINTN *device_path_instance_size) +{ + EFI_ENTRY("%p, %p", device_path_instance, device_path_instance_size); + return EFI_EXIT(NULL); +} + +static struct efi_device_path *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); +} + +static bool is_device_path_multi_instance( + const struct efi_device_path *device_path) +{ + EFI_ENTRY("%p", device_path); + return EFI_EXIT(false); +} + +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, + .create_device_node = create_device_node, + .is_device_path_multi_instance = is_device_path_multi_instance, +}; From patchwork Sun Sep 10 13:22:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 812138 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="c3sdRb3v"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xqsFS08WHz9s83 for ; Sun, 10 Sep 2017 23:23:23 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id BFDC3C21EA9; Sun, 10 Sep 2017 13:23:05 +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, 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 281EEC21E57; Sun, 10 Sep 2017 13:22:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0B39DC21F0A; Sun, 10 Sep 2017 13:22:53 +0000 (UTC) Received: from mail-qk0-f195.google.com (mail-qk0-f195.google.com [209.85.220.195]) by lists.denx.de (Postfix) with ESMTPS id A51C1C21E97 for ; Sun, 10 Sep 2017 13:22:49 +0000 (UTC) Received: by mail-qk0-f195.google.com with SMTP id r66so3910003qke.4 for ; Sun, 10 Sep 2017 06:22:49 -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=RtPQLWKaPJcVpsEQKBXFnRvuG0rJRVtnOnItYqmzEuQ=; b=c3sdRb3v9rYMrP+6AfuezFgaGOaHzCUybvDA75chpZuhSZP7ZVCaI+WUu0m2jO2J1/ kPCdj7+6g0FaJQV+/0OfiTM2nCgsXf69fM4TLhXEFuWi3DDXoOoAUYVWoyLrcNxKPX9d yzmwrpSItIcVKTlQf5FAl8A1AERLVSbauAST9XQLg2ToPWNSs6qIHYy5b1sbIBZebwDn oJLmac9A1iBpZITVohmM4GBeigQxrSg64Mrs8MlmgQBrKwYbnwNDI3sIZMnNn7r22u+z cazjVSc6n0sdZRzfwuRAN50Qx4Ak/EX+QlZ/DZuvMGgFyC0dKzA1Gxhwx6h/SDJKTNVU OpLA== 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=RtPQLWKaPJcVpsEQKBXFnRvuG0rJRVtnOnItYqmzEuQ=; b=dXGpTmgawxYustKmDjFvJBX2HU0o3a1Oit2wq3Xgf4R0chSVQD/EMJCGaJCanoT9I1 wfCjKiGJeNN0UPSLj9ptup9u4MnkvlM+aR6qjzkKOddrGpWk+zz0hygNyf2xh6yFaXVC A37i4qiaV9AAEo3o7DD6TX/qEWYehImKwpIjT5zz9u4QjeahmKgVj4LZoNMAGY+m9c47 VB+zFELs+g6jrR19MftCBhy4guEbZ6RWtu8ZpS1hY9JiYNaBH2PEnyGSt5rhhkOfP55d 1QMS81dzFwAHNQkYXPh+bJuUyjZsmOgs2u19urKYHFaWnquomLrD0u4n7YnWgj3Qw8fO AN+w== X-Gm-Message-State: AHPjjUgqECY8tz0VYlwHNIwgtyWaPXc3dExpd94zyZ5It+wq3Dg/gC61 G8W9tDYBw6volaB5FJk= X-Google-Smtp-Source: AOwi7QDLfvYIj7/SDKKyF8vryzQNiRpcjIulVnNqCU9q1+sPIH0V45elGjYknIh1ELMPyD5mk8qcjA== X-Received: by 10.55.104.138 with SMTP id d132mr12032680qkc.151.1505049768178; Sun, 10 Sep 2017 06:22:48 -0700 (PDT) Received: from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a]) by smtp.gmail.com with ESMTPSA id p7sm4422690qke.78.2017.09.10.06.22.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Sep 2017 06:22:47 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Sun, 10 Sep 2017 09:22:23 -0400 Message-Id: <20170910132236.14318-3-robdclark@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170910132236.14318-1-robdclark@gmail.com> References: <20170910132236.14318-1-robdclark@gmail.com> Cc: Heinrich Schuchardt , Peter Jones , Leif Lindholm Subject: [U-Boot] [PATCH v1 02/12] efi_loader: add stub HII protocols 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 EfiHiiConfigRoutingProtocolGuid EfiHiiDatabaseProtocol EfiHiiStringProtocol Signed-off-by: Leif Lindholm --- include/efi_api.h | 204 ++++++++++++++++++++++++++++ include/efi_loader.h | 6 + lib/efi_loader/Makefile | 2 +- lib/efi_loader/efi_boottime.c | 9 ++ lib/efi_loader/efi_hii.c | 303 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 523 insertions(+), 1 deletion(-) create mode 100644 lib/efi_loader/efi_hii.c diff --git a/include/efi_api.h b/include/efi_api.h index 57468dd972..932a3429a8 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -536,6 +536,210 @@ struct efi_device_path_utilities_protocol const struct efi_device_path *device_path); }; +#define EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID \ + EFI_GUID(0x587e72d7, 0xcc50, 0x4f79, \ + 0x82, 0x09, 0xca, 0x29, 0x1f, 0xc1, 0xa1, 0x0f) + +struct efi_hii_config_routing_protocol +{ + efi_status_t(EFIAPI *extract_config)( + const struct efi_hii_config_routing_protocol *this, + const efi_string_t request, + efi_string_t *progress, + efi_string_t *results); + efi_status_t(EFIAPI *export_config)( + const struct efi_hii_config_routing_protocol *this, + efi_string_t *results); + efi_status_t(EFIAPI *route_config)( + const struct efi_hii_config_routing_protocol *this, + const efi_string_t configuration, + efi_string_t *progress); + efi_status_t(EFIAPI *block_to_config)( + const struct efi_hii_config_routing_protocol *this, + const efi_string_t config_request, + const uint8_t *block, + const UINTN block_size, + efi_string_t *config, + efi_string_t *progress); + efi_status_t(EFIAPI *config_to_block)( + const struct efi_hii_config_routing_protocol *this, + const efi_string_t config_resp, + const uint8_t *block, + const UINTN *block_size, + efi_string_t *progress); + efi_status_t(EFIAPI *get_alt_config)( + const struct efi_hii_config_routing_protocol *this, + const efi_string_t config_resp, + const efi_guid_t *guid, + const efi_string_t name, + const struct efi_device_path *device_path, + const efi_string_t alt_cfg_id, + efi_string_t *alt_cfg_resp); +}; + +#define EFI_HII_DATABASE_PROTOCOL_GUID \ + EFI_GUID(0xef9fc172, 0xa1b2, 0x4693, \ + 0xb3, 0x27, 0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42) + +typedef enum { + EfiKeyLCtrl, EfiKeyA0, EfiKeyLAlt, EfiKeySpaceBar, + EfiKeyA2, EfiKeyA3, EfiKeyA4, EfiKeyRCtrl, EfiKeyLeftArrow, + EfiKeyDownArrow, EfiKeyRightArrow, EfiKeyZero, + EfiKeyPeriod, EfiKeyEnter, EfiKeyLShift, EfiKeyB0, + EfiKeyB1, EfiKeyB2, EfiKeyB3, EfiKeyB4, EfiKeyB5, EfiKeyB6, + EfiKeyB7, EfiKeyB8, EfiKeyB9, EfiKeyB10, EfiKeyRShift, + EfiKeyUpArrow, EfiKeyOne, EfiKeyTwo, EfiKeyThree, + EfiKeyCapsLock, EfiKeyC1, EfiKeyC2, EfiKeyC3, EfiKeyC4, + EfiKeyC5, EfiKeyC6, EfiKeyC7, EfiKeyC8, EfiKeyC9, + EfiKeyC10, EfiKeyC11, EfiKeyC12, EfiKeyFour, EfiKeyFive, + EfiKeySix, EfiKeyPlus, EfiKeyTab, EfiKeyD1, EfiKeyD2, + EfiKeyD3, EfiKeyD4, EfiKeyD5, EfiKeyD6, EfiKeyD7, EfiKeyD8, + EfiKeyD9, EfiKeyD10, EfiKeyD11, EfiKeyD12, EfiKeyD13, + EfiKeyDel, EfiKeyEnd, EfiKeyPgDn, EfiKeySeven, EfiKeyEight, + EfiKeyNine, EfiKeyE0, EfiKeyE1, EfiKeyE2, EfiKeyE3, + EfiKeyE4, EfiKeyE5, EfiKeyE6, EfiKeyE7, EfiKeyE8, EfiKeyE9, + EfiKeyE10, EfiKeyE11, EfiKeyE12, EfiKeyBackSpace, + EfiKeyIns, EfiKeyHome, EfiKeyPgUp, EfiKeyNLck, EfiKeySlash, + EfiKeyAsterisk, EfiKeyMinus, EfiKeyEsc, EfiKeyF1, EfiKeyF2, + EfiKeyF3, EfiKeyF4, EfiKeyF5, EfiKeyF6, EfiKeyF7, EfiKeyF8, + EfiKeyF9, EfiKeyF10, EfiKeyF11, EfiKeyF12, EfiKeyPrint, + EfiKeySLck, EfiKeyPause +} efi_key; + +struct efi_key_descriptor +{ + efi_key key; + uint16_t unicode; + uint16_t shifted_unicode; + uint16_t alt_gr_unicode; + uint16_t shifted_alt_gr_unicode; + uint16_t modifier; + uint16_t affected_attribute; +}; + +struct efi_hii_keyboard_layout +{ + uint16_t layout_length; + efi_guid_t guid; + uint32_t layout_descriptor_string_offset; + uint8_t descriptor_count; + struct efi_key_descriptor descriptors[]; +}; + +struct efi_hii_package_list_header +{ + efi_guid_t package_list_guid; + uint32_t package_length; +}; + +typedef void *efi_hii_handle_t; + +struct efi_hii_database_protocol +{ + efi_status_t(EFIAPI *new_package_list)( + const struct efi_hii_database_protocol *this, + const struct efi_hii_package_list_header *package_list, + const efi_handle_t driver_handle, + efi_hii_handle_t *handle); + efi_status_t(EFIAPI *remove_package_list)( + const struct efi_hii_database_protocol *this, + efi_hii_handle_t handle); + efi_status_t(EFIAPI *update_package_list)( + const struct efi_hii_database_protocol *this, + efi_hii_handle_t handle, + const struct efi_hii_package_list_header *package_list); + efi_status_t(EFIAPI *list_package_lists)( + const struct efi_hii_database_protocol *this, + uint8_t package_type, + const efi_guid_t *package_guid, + UINTN *handle_buffer_length, + efi_hii_handle_t *handle); + efi_status_t(EFIAPI *export_package_lists)( + const struct efi_hii_database_protocol *this, + efi_hii_handle_t handle, + UINTN *buffer_size, + struct efi_hii_package_list_header *buffer); + efi_status_t(EFIAPI *register_package_notify)( + const struct efi_hii_database_protocol *this, + uint8_t package_type, + const efi_guid_t *package_guid, + const void *package_notify_fn, + UINTN notify_type, + efi_handle_t *notify_handle); + efi_status_t(EFIAPI *unregister_package_notify)( + const struct efi_hii_database_protocol *this, + efi_handle_t notification_handle + ); + efi_status_t(EFIAPI *find_keyboard_layouts)( + const struct efi_hii_database_protocol *this, + uint16_t *key_guid_buffer_length, + efi_guid_t *key_guid_buffer); + efi_status_t(EFIAPI *get_keyboard_layout)( + const struct efi_hii_database_protocol *this, + efi_guid_t *key_guid, + uint16_t *keyboard_layout_length, + struct efi_hii_keyboard_layout *keyboard_layout); + efi_status_t(EFIAPI *set_keyboard_layout)( + const struct efi_hii_database_protocol *this, + efi_guid_t *key_guid); + efi_status_t(EFIAPI *get_package_list_handle)( + const struct efi_hii_database_protocol *this, + efi_hii_handle_t package_list_handle, + efi_handle_t *driver_handle); +}; + +#define EFI_HII_STRING_PROTOCOL_GUID \ + EFI_GUID(0x0fd96974, 0x23aa, 0x4cdc, \ + 0xb9, 0xcb, 0x98, 0xd1, 0x77, 0x50, 0x32, 0x2a) + +typedef uint32_t efi_hii_font_style_t; +typedef uint16_t efi_string_id_t; + +struct efi_font_info +{ + efi_hii_font_style_t font_style; + uint16_t font_size; + uint16_t font_name[1]; +}; + +struct efi_hii_string_protocol +{ + efi_status_t(EFIAPI *new_string)( + const struct efi_hii_string_protocol *this, + efi_hii_handle_t package_list, + efi_string_id_t *string_id, + const uint8_t *language, + const uint16_t *language_name, + const efi_string_t string, + const struct efi_font_info *string_font_info); + efi_status_t(EFIAPI *get_string)( + const struct efi_hii_string_protocol *this, + const uint8_t *language, + efi_hii_handle_t package_list, + efi_string_id_t string_id, + efi_string_t string, + UINTN *string_size, + struct efi_font_info **string_font_info); + efi_status_t(EFIAPI *set_string)( + const struct efi_hii_string_protocol *this, + efi_hii_handle_t package_list, + efi_string_id_t string_id, + const uint8_t *language, + const efi_string_t string, + const struct efi_font_info *string_font_info); + efi_status_t(EFIAPI *get_languages)( + const struct efi_hii_string_protocol *this, + efi_hii_handle_t package_list, + uint8_t *languages, + UINTN *languages_size); + efi_status_t(EFIAPI *get_secondary_languages)( + const struct efi_hii_string_protocol *this, + efi_hii_handle_t package_list, + const uint8_t *primary_language, + uint8_t *secondary_languages, + UINTN *secondary_languages_size); +}; + #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 c009828db9..a89bb2fcd9 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -59,6 +59,9 @@ 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; +extern const struct efi_hii_config_routing_protocol efi_hii_config_routing; +extern const struct efi_hii_database_protocol efi_hii_database; +extern const struct efi_hii_string_protocol efi_hii_string; uint16_t *efi_dp_str(struct efi_device_path *dp); @@ -70,6 +73,9 @@ 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 const efi_guid_t efi_guid_hii_config_routing_protocol; +extern const efi_guid_t efi_guid_hii_database_protocol; +extern const efi_guid_t efi_guid_hii_string_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 f5e69dd078..e8fd6823a3 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -16,7 +16,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 efi_device_path_to_text.o efi_device_path.o -obj-y += efi_device_path_utilities.o +obj-y += efi_device_path_utilities.o efi_hii.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 8bb243d673..4d1a16051b 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -779,6 +779,15 @@ void efi_setup_loaded_image(struct efi_loaded_image *info, struct efi_object *ob obj->protocols[4].protocol_interface = (void *)&efi_device_path_utilities; + obj->protocols[5].guid = &efi_guid_hii_string_protocol; + obj->protocols[5].protocol_interface = (void *)&efi_hii_string; + + obj->protocols[6].guid = &efi_guid_hii_database_protocol; + obj->protocols[6].protocol_interface = (void *)&efi_hii_database; + + obj->protocols[7].guid = &efi_guid_hii_config_routing_protocol; + obj->protocols[7].protocol_interface = (void *)&efi_hii_config_routing; + info->file_path = file_path; info->device_handle = efi_dp_find_obj(device_path, NULL); diff --git a/lib/efi_loader/efi_hii.c b/lib/efi_loader/efi_hii.c new file mode 100644 index 0000000000..cc68a28d2b --- /dev/null +++ b/lib/efi_loader/efi_hii.c @@ -0,0 +1,303 @@ +/* + * EFI Human Interface Infrastructure ... interface + * + * Copyright (c) 2017 Leif Lindholm + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include + +const efi_guid_t efi_guid_hii_config_routing_protocol = + EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID; +const efi_guid_t efi_guid_hii_database_protocol = EFI_HII_DATABASE_PROTOCOL_GUID; +const efi_guid_t efi_guid_hii_string_protocol = EFI_HII_STRING_PROTOCOL_GUID; + + +/* + * EFI_HII_CONFIG_ROUTING_PROTOCOL + */ + +static efi_status_t extract_config( + const struct efi_hii_config_routing_protocol *this, + const efi_string_t request, + efi_string_t *progress, + efi_string_t *results) +{ + EFI_ENTRY("%p, \"%ls\", %p, %p", this, request, progress, results); + return EFI_EXIT(EFI_OUT_OF_RESOURCES); +} + +static efi_status_t export_config( + const struct efi_hii_config_routing_protocol *this, + efi_string_t *results) +{ + EFI_ENTRY("%p, %p", this, results); + return EFI_EXIT(EFI_OUT_OF_RESOURCES); +} + +static efi_status_t route_config( + const struct efi_hii_config_routing_protocol *this, + const efi_string_t configuration, + efi_string_t *progress) +{ + EFI_ENTRY("%p, \"%ls\", %p", this, configuration, progress); + return EFI_EXIT(EFI_OUT_OF_RESOURCES); +} + +static efi_status_t block_to_config( + const struct efi_hii_config_routing_protocol *this, + const efi_string_t config_request, + const uint8_t *block, + const UINTN block_size, + efi_string_t *config, + efi_string_t *progress) +{ + EFI_ENTRY("%p, \"%ls\", %p, %lu, %p, %p", this, config_request, block, + block_size, config, progress); + return EFI_EXIT(EFI_OUT_OF_RESOURCES); +} + +static efi_status_t config_to_block( + const struct efi_hii_config_routing_protocol *this, + const efi_string_t config_resp, + const uint8_t *block, + const UINTN *block_size, + efi_string_t *progress) +{ + EFI_ENTRY("%p, \"%ls\", %p, %p, %p", this, config_resp, block, + block_size, progress); + return EFI_EXIT(EFI_OUT_OF_RESOURCES); +} + +static efi_status_t get_alt_config( + const struct efi_hii_config_routing_protocol *this, + const efi_string_t config_resp, + const efi_guid_t *guid, + const efi_string_t name, + const struct efi_device_path *device_path, + const efi_string_t alt_cfg_id, + efi_string_t *alt_cfg_resp) +{ + EFI_ENTRY("%p, \"%ls\", %pUl, \"%ls\", %p, \"%ls\", %p", this, + config_resp, guid, name, device_path, alt_cfg_id, + alt_cfg_resp); + return EFI_EXIT(EFI_OUT_OF_RESOURCES); +} + + +/* + * EFI_HII_DATABASE_PROTOCOL + */ + +static efi_status_t new_package_list( + const struct efi_hii_database_protocol *this, + const struct efi_hii_package_list_header *package_list, + const efi_handle_t driver_handle, + efi_hii_handle_t *handle) +{ + /* Current shell start failure. */ + /* Invoked from MdeModulePkg/Library/UefiHiiLib/HiiLib.c : HiiAddPackages */ + /* (Via autogenerated .c file.) */ + EFI_ENTRY("%p, %p, %p, %p", this, package_list, driver_handle, handle); + return EFI_EXIT(EFI_OUT_OF_RESOURCES); +} + +static efi_status_t remove_package_list( + const struct efi_hii_database_protocol *this, + efi_hii_handle_t handle) +{ + EFI_ENTRY("%p, %p", this, handle); + return EFI_EXIT(EFI_NOT_FOUND); +} + +static efi_status_t update_package_list( + const struct efi_hii_database_protocol *this, + efi_hii_handle_t handle, + const struct efi_hii_package_list_header *package_list) +{ + EFI_ENTRY("%p, %p, %p", this, handle, package_list); + return EFI_EXIT(EFI_NOT_FOUND); +} + +static efi_status_t list_package_lists( + const struct efi_hii_database_protocol *this, + uint8_t package_type, + const efi_guid_t *package_guid, + UINTN *handle_buffer_length, + efi_hii_handle_t *handle) +{ + EFI_ENTRY("%p, %u, %pUl, %p, %p", this, package_type, package_guid, + handle_buffer_length, handle); + return EFI_EXIT(EFI_NOT_FOUND); +} + +static efi_status_t export_package_lists( + const struct efi_hii_database_protocol *this, + efi_hii_handle_t handle, + UINTN *buffer_size, + struct efi_hii_package_list_header *buffer) +{ + EFI_ENTRY("%p, %p, %p, %p", this, handle, buffer_size, buffer); + return EFI_EXIT(EFI_NOT_FOUND); +} + +static efi_status_t register_package_notify( + const struct efi_hii_database_protocol *this, + uint8_t package_type, + const efi_guid_t *package_guid, + const void *package_notify_fn, + UINTN notify_type, + efi_handle_t *notify_handle) +{ + EFI_ENTRY("%p, %u, %pUl, %p, %lu, %p", this, package_type, + package_guid, package_notify_fn, notify_type, + notify_handle); + return EFI_EXIT(EFI_OUT_OF_RESOURCES); +} + +static efi_status_t unregister_package_notify( + const struct efi_hii_database_protocol *this, + efi_handle_t notification_handle) +{ + EFI_ENTRY("%p, %p", this, notification_handle); + return EFI_EXIT(EFI_NOT_FOUND); +} + +static efi_status_t find_keyboard_layouts( + const struct efi_hii_database_protocol *this, + uint16_t *key_guid_buffer_length, + efi_guid_t *key_guid_buffer) +{ + EFI_ENTRY("%p, %p, %p", this, key_guid_buffer_length, key_guid_buffer); + return EFI_EXIT(EFI_NOT_FOUND); /* Invalid */ +} + +static efi_status_t get_keyboard_layout( + const struct efi_hii_database_protocol *this, + efi_guid_t *key_guid, + uint16_t *keyboard_layout_length, + struct efi_hii_keyboard_layout *keyboard_layout) +{ + EFI_ENTRY("%p, %pUl, %p, %p", this, key_guid, keyboard_layout_length, + keyboard_layout); + return EFI_EXIT(EFI_NOT_FOUND); +} + +static efi_status_t set_keyboard_layout( + const struct efi_hii_database_protocol *this, + efi_guid_t *key_guid) +{ + EFI_ENTRY("%p, %pUl", this, key_guid); + return EFI_EXIT(EFI_NOT_FOUND); +} + +static efi_status_t get_package_list_handle( + const struct efi_hii_database_protocol *this, + efi_hii_handle_t package_list_handle, + efi_handle_t *driver_handle) +{ + EFI_ENTRY("%p, %p, %p", this, package_list_handle, driver_handle); + return EFI_EXIT(EFI_INVALID_PARAMETER); +} + + +/* + * EFI_HII_STRING_PROTOCOL + */ + +static efi_status_t new_string( + const struct efi_hii_string_protocol *this, + efi_hii_handle_t package_list, + efi_string_id_t *string_id, + const uint8_t *language, + const uint16_t *language_name, + const efi_string_t string, + const struct efi_font_info *string_font_info) +{ + EFI_ENTRY("%p, %p, %p, %p, %p, \"%ls\", %p", this, package_list, + string_id, language, language_name, string, + string_font_info); + return EFI_EXIT(EFI_NOT_FOUND); +} + +static efi_status_t get_string( + const struct efi_hii_string_protocol *this, + const uint8_t *language, + efi_hii_handle_t package_list, + efi_string_id_t string_id, + efi_string_t string, + UINTN *string_size, + struct efi_font_info **string_font_info) +{ + EFI_ENTRY("%p, %p, %p, %u, \"%ls\", %p, %p", this, language, + package_list, string_id, string, string_size, + string_font_info); + return EFI_EXIT(EFI_NOT_FOUND); +} + +static efi_status_t set_string( + const struct efi_hii_string_protocol *this, + efi_hii_handle_t package_list, + efi_string_id_t string_id, + const uint8_t *language, + const efi_string_t string, + const struct efi_font_info *string_font_info) +{ + EFI_ENTRY("%p, %p, %u, %p, \"%ls\", %p", this, package_list, string_id, + language, string, string_font_info); + return EFI_EXIT(EFI_NOT_FOUND); +} + +static efi_status_t get_languages( + const struct efi_hii_string_protocol *this, + efi_hii_handle_t package_list, + uint8_t *languages, + UINTN *languages_size) +{ + EFI_ENTRY("%p, %p, %p, %p", this, package_list, languages, + languages_size); + return EFI_EXIT(EFI_NOT_FOUND); +} + +static efi_status_t get_secondary_languages( + const struct efi_hii_string_protocol *this, + efi_hii_handle_t package_list, + const uint8_t *primary_language, + uint8_t *secondary_languages, + UINTN *secondary_languages_size) +{ + EFI_ENTRY("%p, %p, %p, %p, %p", this, package_list, primary_language, + secondary_languages, secondary_languages_size); + return EFI_EXIT(EFI_NOT_FOUND); +} + +const struct efi_hii_config_routing_protocol efi_hii_config_routing = { + .extract_config = extract_config, + .export_config = export_config, + .route_config = route_config, + .block_to_config = block_to_config, + .config_to_block = config_to_block, + .get_alt_config = get_alt_config +}; +const struct efi_hii_database_protocol efi_hii_database = { + .new_package_list = new_package_list, + .remove_package_list = remove_package_list, + .update_package_list = update_package_list, + .list_package_lists = list_package_lists, + .export_package_lists = export_package_lists, + .register_package_notify = register_package_notify, + .unregister_package_notify = unregister_package_notify, + .find_keyboard_layouts = find_keyboard_layouts, + .get_keyboard_layout = get_keyboard_layout, + .set_keyboard_layout = set_keyboard_layout, + .get_package_list_handle = get_package_list_handle +}; +const struct efi_hii_string_protocol efi_hii_string = { + .new_string = new_string, + .get_string = get_string, + .set_string = set_string, + .get_languages = get_languages, + .get_secondary_languages = get_secondary_languages +}; From patchwork Sun Sep 10 13:22:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 812143 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MqLl4sid"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xqsKk1XyBz9s8J for ; Sun, 10 Sep 2017 23:27:06 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id BA1C3C21F0A; Sun, 10 Sep 2017 13:24:11 +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, 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 08FB2C21F36; Sun, 10 Sep 2017 13:23:20 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 48AF5C21F26; Sun, 10 Sep 2017 13:22:56 +0000 (UTC) Received: from mail-qk0-f195.google.com (mail-qk0-f195.google.com [209.85.220.195]) by lists.denx.de (Postfix) with ESMTPS id D9C68C21F28 for ; Sun, 10 Sep 2017 13:22:52 +0000 (UTC) Received: by mail-qk0-f195.google.com with SMTP id o77so4071010qke.2 for ; Sun, 10 Sep 2017 06:22:52 -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=VLevONSjqVfJnJYbW80jG7Q8IPFI4445jP68p46tfd8=; b=MqLl4sidANuOu0wL+dSmtMfpAgkVsBfnyYwxwlRB2OvCfn6uYzB/+BXIoJSoK0scz+ o7oRjqngmajVnisRoWhmRxppbvdujY9hrpw8hXL9D223XzyJurp0oNtpOieXtkXg/yBR VGZJm6Z6Tp1SLYmOmmtkNVXeHZ+MeGvfbkvwfW8W9tP1+QUVsctJvU8H10hH2PDAUarO dVhTxWpvp0U2gvszi2lJ0NIqfgVRnT4vrFdfvHztGjnOTb2oiHgCXZFNn8j7V2AWgRTq I8vgRP7dMPwaJ0QeKhzhOQGdbEEc0Ux/2n+LFRc4HjeyLdR81ezEOGksRovC5KLXCSka PKpQ== 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=VLevONSjqVfJnJYbW80jG7Q8IPFI4445jP68p46tfd8=; b=DSn9bSzdCYkiUk/uD818Fa+ioHzIUxtv/z4liWYsxxxliANXdCM3J6gf322P99Sdqg k45vzdq4KikrPkCbYaiGdXkx/Hx/xYhz8EVdlC03vR/sniUvOkhukJRvQXnRTnBCWiZA uIfrwJFqwZOW9IH9JkG1GSokXGzFI2wZrp3LPfjBTcwgDC3FA6dyl6ySrD9jxZsUH+4Y l1DOH+vrmfHHF5sRvXA2U1VAkV3D5Brn/aABb9yek7ecnTE0Lm0aD+zbrWB7m2nflpZU q2Okq/dhzt9X4QkJx05tFgL8B39327eBYJQNJk3kEeZRnDdKH4wmoUKvM97SGa2J/SFx xz7g== X-Gm-Message-State: AHPjjUitKjnE38ZSM/hJzG0jNaspLny4EombCWz4ylGaKuQ0oNMOypH0 z6eUBGkoe3frWJL9rPI= X-Google-Smtp-Source: AOwi7QBUCPG9ToHMC0FUSwAAxiEloVwfStWv94EJ/s0ISrdNypi27I+h6WsRq72F78ln2/k6YadFSQ== X-Received: by 10.55.49.73 with SMTP id x70mr12162302qkx.238.1505049771587; Sun, 10 Sep 2017 06:22:51 -0700 (PDT) Received: from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a]) by smtp.gmail.com with ESMTPSA id 48sm4538925qty.29.2017.09.10.06.22.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Sep 2017 06:22:50 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Sun, 10 Sep 2017 09:22:24 -0400 Message-Id: <20170910132236.14318-4-robdclark@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170910132236.14318-1-robdclark@gmail.com> References: <20170910132236.14318-1-robdclark@gmail.com> Cc: Heinrich Schuchardt , Peter Jones , Leif Lindholm Subject: [U-Boot] [PATCH v1 03/12] efi_loader: add EFI_UNICODE_COLLATION_PROTOCOL stub 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 Signed-off-by: Leif Lindholm --- include/efi_api.h | 33 +++++++++++++++++++ include/efi_loader.h | 2 ++ lib/efi_loader/Makefile | 2 +- lib/efi_loader/efi_boottime.c | 3 ++ lib/efi_loader/efi_unicode.c | 73 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 lib/efi_loader/efi_unicode.c diff --git a/include/efi_api.h b/include/efi_api.h index 932a3429a8..25f774f253 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -740,6 +740,39 @@ struct efi_hii_string_protocol UINTN *secondary_languages_size); }; +#define EFI_UNICODE_COLLATION_PROTOCOL2_GUID \ + EFI_GUID(0xa4c751fc, 0x23ae, 0x4c3e, \ + 0x92, 0xe9, 0x49, 0x64, 0xcf, 0x63, 0xf3, 0x49) + +struct efi_unicode_collation_protocol +{ + INTN(EFIAPI *stri_coll)( + struct efi_unicode_collation_protocol *this, + efi_string_t s1, + efi_string_t s2); + bool(EFIAPI *metai_match)( + struct efi_unicode_collation_protocol *this, + efi_string_t string, + efi_string_t pattern); + void(EFIAPI *str_lwr)( + struct efi_unicode_collation_protocol *this, + efi_string_t string); + void(EFIAPI *str_upr)( + struct efi_unicode_collation_protocol *this, + efi_string_t string); + void(EFIAPI *fat_to_str)( + struct efi_unicode_collation_protocol *this, + UINTN fat_size, + uint8_t *fat, + efi_string_t string); + bool(EFIAPI *str_to_fat)( + struct efi_unicode_collation_protocol *this, + efi_string_t string, + UINTN fat_size, + uint8_t *fat); + uint8_t *supported_languages; +}; + #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 a89bb2fcd9..6668338d0b 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -62,6 +62,7 @@ extern const struct efi_device_path_utilities_protocol efi_device_path_utilities extern const struct efi_hii_config_routing_protocol efi_hii_config_routing; extern const struct efi_hii_database_protocol efi_hii_database; extern const struct efi_hii_string_protocol efi_hii_string; +extern const struct efi_unicode_collation_protocol efi_unicode_collation; uint16_t *efi_dp_str(struct efi_device_path *dp); @@ -76,6 +77,7 @@ extern const efi_guid_t efi_guid_device_path_utilities_protocol; extern const efi_guid_t efi_guid_hii_config_routing_protocol; extern const efi_guid_t efi_guid_hii_database_protocol; extern const efi_guid_t efi_guid_hii_string_protocol; +extern const efi_guid_t efi_guid_unicode_collation_protocol2; 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 e8fd6823a3..82b703bb39 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -16,7 +16,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 efi_device_path_to_text.o efi_device_path.o -obj-y += efi_device_path_utilities.o efi_hii.o +obj-y += efi_device_path_utilities.o efi_hii.o efi_unicode.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 4d1a16051b..04358e8aca 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -788,6 +788,9 @@ void efi_setup_loaded_image(struct efi_loaded_image *info, struct efi_object *ob obj->protocols[7].guid = &efi_guid_hii_config_routing_protocol; obj->protocols[7].protocol_interface = (void *)&efi_hii_config_routing; + obj->protocols[8].guid = &efi_guid_unicode_collation_protocol2; + obj->protocols[8].protocol_interface = (void *)&efi_unicode_collation; + info->file_path = file_path; info->device_handle = efi_dp_find_obj(device_path, NULL); diff --git a/lib/efi_loader/efi_unicode.c b/lib/efi_loader/efi_unicode.c new file mode 100644 index 0000000000..fdf1a99812 --- /dev/null +++ b/lib/efi_loader/efi_unicode.c @@ -0,0 +1,73 @@ +/* +* EFI Unicode interface + * + * Copyright (c) 2017 Leif Lindholm + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include + +const efi_guid_t efi_guid_unicode_collation_protocol2 = + EFI_UNICODE_COLLATION_PROTOCOL2_GUID; + +INTN stri_coll(struct efi_unicode_collation_protocol *this, + efi_string_t s1, + efi_string_t s2) +{ + EFI_ENTRY("%p, \"%ls\", \"%ls\"", this, s1, s2); + return EFI_EXIT(0); +} + +bool metai_match(struct efi_unicode_collation_protocol *this, + efi_string_t string, + efi_string_t pattern) +{ + EFI_ENTRY("%p, \"%ls\", \"%ls\"", this, string, pattern); + return EFI_EXIT(false); +} + +void str_lwr(struct efi_unicode_collation_protocol *this, + efi_string_t string) +{ + EFI_ENTRY("%p, \"%ls\"", this, string); + EFI_EXIT(0); + return; +} + +void str_upr(struct efi_unicode_collation_protocol *this, + efi_string_t string) +{ + EFI_ENTRY("%p, \"%ls\"", this, string); + EFI_EXIT(0); + return; +} + +void fat_to_str(struct efi_unicode_collation_protocol *this, + UINTN fat_size, + uint8_t *fat, + efi_string_t string) +{ + EFI_ENTRY("%p, %lu, \"%s\", %p", this, fat_size, fat, string); + EFI_EXIT(0); + return; +} + +bool str_to_fat(struct efi_unicode_collation_protocol *this, + efi_string_t string, + UINTN fat_size, + uint8_t *fat) +{ + EFI_ENTRY("%p, \"%ls\", %lu, %p", this, string, fat_size, fat); + return EFI_EXIT(false); +} + +const struct efi_unicode_collation_protocol efi_unicode_collation = { + .stri_coll = stri_coll, + .metai_match = metai_match, + .str_lwr = str_lwr, + .str_upr = str_upr, + .fat_to_str = fat_to_str, + .str_to_fat = str_to_fat +}; From patchwork Sun Sep 10 13:22:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 812141 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uGgEkTCZ"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xqsKD5jp4z9s7g for ; Sun, 10 Sep 2017 23:26:40 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 82567C21E54; Sun, 10 Sep 2017 13:24:49 +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, 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 ECAE2C21E9D; Sun, 10 Sep 2017 13:23:32 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AEC1DC21F70; Sun, 10 Sep 2017 13:22:58 +0000 (UTC) Received: from mail-qt0-f193.google.com (mail-qt0-f193.google.com [209.85.216.193]) by lists.denx.de (Postfix) with ESMTPS id 3C9FDC21F21 for ; Sun, 10 Sep 2017 13:22:56 +0000 (UTC) Received: by mail-qt0-f193.google.com with SMTP id u48so1297306qtc.4 for ; Sun, 10 Sep 2017 06:22:56 -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=5IFF6U5h3HI/ExkQAAxHlPYlx3w+z48LBx/kneAdp10=; b=uGgEkTCZixKi96CSFNy1kZt8h5+blbmkz5V2jSKgkwlJdrbVOnkDpGgGcGv1A7U1ml U732JkL7GqjCh+sdFC6+dYk5NCxIOODvE8fyCrXtZR+64bkPdeV4JdVLssGRi8PhFn0X 09SBU3aR/tPkoQkRA6tW2zf1LMz+lGiyoP4lzzVtIwg2iPl0MnW0EQSUuQfHdyh6F8Gn d39AdsvAxAwSTugWGhp2CcibVBEr0IvAJebW2MIRGoWIROyRUwcxBSW/v3HTeeMl4t/R KQ9EIjMK6pBYVy4QtNriHvsJTRwaC7c1KJJVV5qrHsyMjKZFbCY1Ax8eQX5THp3FACYf R27w== 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=5IFF6U5h3HI/ExkQAAxHlPYlx3w+z48LBx/kneAdp10=; b=QpLB13BZg1X343MXBAqH3o3dIQ26+bQYxp+QTtu3A7p0+THYG0LQQCrxLZOem0Ekqj 26mkic0o2lTToLmTUXoMP/rMplFyLH51rpjg+PM3eiZuARtyeTTiFxTAPJB1J/GFfqLY tfV+7CNSIvDR7RbYLsP29dMkIEiB/Gq+18Lat5Q/6uC8wDIKWI8pcgPo/n5DE32UXj83 /t+zpW+sgF3oGyTXcqW0zlkg5hcRAPWYHac7fv9jSCn0/OaCNesMPM+G50gBky0AnkXp UI2HYlyUsD0N3ngX6+TMn4D0rZhI1Lss2Nicvv1zVi57Kz7A7dZ5uFI9iNLHSeQh45gh wrfw== X-Gm-Message-State: AHPjjUiZ3plQeDWc2noLtg/FyS5IQ/XuUs9DYmxDuoOcL1X8QDhxU0XZ 188W9SAiYih6P2fp/70= X-Google-Smtp-Source: AOwi7QAfxCJENDMs9Pq6X8XOCFjZFTimn+vn+mg4N0GfWV0R1T4opOw/+1PMrXgzXt4XWut6nmvGjQ== X-Received: by 10.200.34.168 with SMTP id f37mr11797783qta.91.1505049774829; Sun, 10 Sep 2017 06:22:54 -0700 (PDT) Received: from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a]) by smtp.gmail.com with ESMTPSA id i39sm4644411qte.11.2017.09.10.06.22.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Sep 2017 06:22:53 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Sun, 10 Sep 2017 09:22:25 -0400 Message-Id: <20170910132236.14318-5-robdclark@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170910132236.14318-1-robdclark@gmail.com> References: <20170910132236.14318-1-robdclark@gmail.com> Cc: Heinrich Schuchardt , Peter Jones , Leif Lindholm Subject: [U-Boot] [PATCH v1 04/12] efi_loader: start fleshing out HII 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" Not complete but enough for Shell.efi and SCT.efi. Signed-off-by: Rob Clark --- include/efi_api.h | 68 +++++++++++- lib/efi_loader/efi_hii.c | 274 ++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 304 insertions(+), 38 deletions(-) diff --git a/include/efi_api.h b/include/efi_api.h index 25f774f253..4853b71497 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -16,6 +16,7 @@ #define _EFI_API_H #include +#include #ifdef CONFIG_EFI_LOADER #include @@ -540,6 +541,8 @@ struct efi_device_path_utilities_protocol EFI_GUID(0x587e72d7, 0xcc50, 0x4f79, \ 0x82, 0x09, 0xca, 0x29, 0x1f, 0xc1, 0xa1, 0x0f) +typedef uint16_t efi_string_id_t; + struct efi_hii_config_routing_protocol { efi_status_t(EFIAPI *extract_config)( @@ -630,7 +633,69 @@ struct efi_hii_package_list_header { efi_guid_t package_list_guid; uint32_t package_length; -}; +} __packed; + +struct efi_hii_package_header { + uint32_t length : 24; + uint32_t type : 8; +} __packed; + +#define EFI_HII_PACKAGE_TYPE_ALL 0x00 +#define EFI_HII_PACKAGE_TYPE_GUID 0x01 +#define EFI_HII_PACKAGE_FORMS 0x02 +#define EFI_HII_PACKAGE_STRINGS 0x04 +#define EFI_HII_PACKAGE_FONTS 0x05 +#define EFI_HII_PACKAGE_IMAGES 0x06 +#define EFI_HII_PACKAGE_SIMPLE_FONTS 0x07 +#define EFI_HII_PACKAGE_DEVICE_PATH 0x08 +#define EFI_HII_PACKAGE_KEYBOARD_LAYOUT 0x09 +#define EFI_HII_PACKAGE_ANIMATIONS 0x0A +#define EFI_HII_PACKAGE_END 0xDF +#define EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN 0xE0 +#define EFI_HII_PACKAGE_TYPE_SYSTEM_END 0xFF + +struct efi_hii_strings_package { + struct efi_hii_package_header header; + uint32_t header_size; + uint32_t string_info_offset; + uint16_t language_window[16]; + efi_string_id_t language_name; + uint8_t language[]; +} __packed; + +struct efi_hii_string_block { + uint8_t block_type; + /*uint8_t block_body[];*/ +} __packed; + +#define EFI_HII_SIBT_END 0x00 // The end of the string information. +#define EFI_HII_SIBT_STRING_SCSU 0x10 // Single string using default font information. +#define EFI_HII_SIBT_STRING_SCSU_FONT 0x11 // Single string with font information. +#define EFI_HII_SIBT_STRINGS_SCSU 0x12 // Multiple strings using default font information. +#define EFI_HII_SIBT_STRINGS_SCSU_FONT 0x13 // Multiple strings with font information. +#define EFI_HII_SIBT_STRING_UCS2 0x14 // Single UCS-2 string using default font information. +#define EFI_HII_SIBT_STRING_UCS2_FONT 0x15 // Single UCS-2 string with font information +#define EFI_HII_SIBT_STRINGS_UCS2 0x16 // Multiple UCS-2 strings using default font information. +#define EFI_HII_SIBT_STRINGS_UCS2_FONT 0x17 // Multiple UCS-2 strings with font information. +#define EFI_HII_SIBT_DUPLICATE 0x20 // Create a duplicate of an existing string. +#define EFI_HII_SIBT_SKIP2 0x21 // Skip a certain number of string identifiers. +#define EFI_HII_SIBT_SKIP1 0x22 // Skip a certain number of string identifiers. +#define EFI_HII_SIBT_EXT1 0x30 // For future expansion (one byte length field) +#define EFI_HII_SIBT_EXT2 0x31 // For future expansion (two byte length field) +#define EFI_HII_SIBT_EXT4 0x32 // For future expansion (four byte length field) +#define EFI_HII_SIBT_FONT 0x40 // Font information. + +struct efi_hii_sibt_string_ucs2_block { + struct efi_hii_string_block header; + uint16_t string_text[]; +} __packed; + +static inline struct efi_hii_string_block *efi_hii_sibt_string_ucs2_block_next( + struct efi_hii_sibt_string_ucs2_block *blk) +{ + return ((void *)blk) + sizeof(*blk) + + (utf16_strlen(blk->string_text) + 1) * 2; +} typedef void *efi_hii_handle_t; @@ -693,7 +758,6 @@ struct efi_hii_database_protocol 0xb9, 0xcb, 0x98, 0xd1, 0x77, 0x50, 0x32, 0x2a) typedef uint32_t efi_hii_font_style_t; -typedef uint16_t efi_string_id_t; struct efi_font_info { diff --git a/lib/efi_loader/efi_hii.c b/lib/efi_loader/efi_hii.c index cc68a28d2b..d818f409dc 100644 --- a/lib/efi_loader/efi_hii.c +++ b/lib/efi_loader/efi_hii.c @@ -7,6 +7,7 @@ */ #include +#include #include const efi_guid_t efi_guid_hii_config_routing_protocol = @@ -14,12 +15,128 @@ const efi_guid_t efi_guid_hii_config_routing_protocol = const efi_guid_t efi_guid_hii_database_protocol = EFI_HII_DATABASE_PROTOCOL_GUID; const efi_guid_t efi_guid_hii_string_protocol = EFI_HII_STRING_PROTOCOL_GUID; +struct hii_package { + // TODO should there be an associated efi_object? + struct list_head string_tables; /* list of string_table */ + /* we could also track fonts, images, etc */ +}; + +struct string_table { + struct list_head link; + efi_string_id_t language_name; + char *language; + uint32_t nstrings; + /* NOTE: string id starts at 1 so value is stbl->strings[id-1] */ + struct { + efi_string_t string; + /* we could also track font info, etc */ + } strings[]; +}; + +static void free_strings_table(struct string_table *stbl) +{ + for (int i = 0; i < stbl->nstrings; i++) + free(stbl->strings[i].string); + free(stbl->language); + free(stbl); +} + +static struct hii_package *new_package(void) +{ + struct hii_package *hii = malloc(sizeof(*hii)); + INIT_LIST_HEAD(&hii->string_tables); + return hii; +} + +static void free_package(struct hii_package *hii) +{ + + while (!list_empty(&hii->string_tables)) { + struct string_table *stbl; + + stbl = list_first_entry(&hii->string_tables, + struct string_table, link); + list_del(&stbl->link); + free_strings_table(stbl); + } + + free(hii); +} + +static efi_status_t add_strings_package(struct hii_package *hii, + struct efi_hii_strings_package *strings_package) +{ + struct efi_hii_string_block *block; + void *end = ((void *)strings_package) + strings_package->header.length; + uint32_t nstrings = 0; + unsigned id = 0; + + debug("header_size: %08x\n", strings_package->header_size); + debug("string_info_offset: %08x\n", strings_package->string_info_offset); + debug("language_name: %u\n", strings_package->language_name); + debug("language: %s\n", strings_package->language); + + /* count # of string entries: */ + block = ((void *)strings_package) + strings_package->string_info_offset; + while ((void *)block < end) { + switch (block->block_type) { + case EFI_HII_SIBT_STRING_UCS2: { + struct efi_hii_sibt_string_ucs2_block *ucs2 = + (void *)block; + nstrings++; + block = efi_hii_sibt_string_ucs2_block_next(ucs2); + break; + } + case EFI_HII_SIBT_END: + block = end; + break; + default: + debug("unknown HII string block type: %02x\n", + block->block_type); + return EFI_INVALID_PARAMETER; + } + } + + struct string_table *stbl = malloc(sizeof(*stbl) + + (nstrings * sizeof(stbl->strings[0]))); + stbl->language_name = strings_package->language_name; + stbl->language = strdup((char *)strings_package->language); + stbl->nstrings = nstrings; + + list_add(&stbl->link, &hii->string_tables); + + /* and now parse string entries and populate string_table */ + block = ((void *)strings_package) + strings_package->string_info_offset; + + while ((void *)block < end) { + switch (block->block_type) { + case EFI_HII_SIBT_STRING_UCS2: { + struct efi_hii_sibt_string_ucs2_block *ucs2 = + (void *)block; + id++; + debug("%4u: \"%ls\"\n", id, ucs2->string_text); + stbl->strings[id-1].string = + utf16_strdup(ucs2->string_text); + block = efi_hii_sibt_string_ucs2_block_next(ucs2); + break; + } + case EFI_HII_SIBT_END: + return EFI_SUCCESS; + default: + debug("unknown HII string block type: %02x\n", + block->block_type); + return EFI_INVALID_PARAMETER; + } + } + + return EFI_SUCCESS; +} /* * EFI_HII_CONFIG_ROUTING_PROTOCOL */ -static efi_status_t extract_config( +static efi_status_t EFIAPI extract_config( const struct efi_hii_config_routing_protocol *this, const efi_string_t request, efi_string_t *progress, @@ -29,7 +146,7 @@ static efi_status_t extract_config( return EFI_EXIT(EFI_OUT_OF_RESOURCES); } -static efi_status_t export_config( +static efi_status_t EFIAPI export_config( const struct efi_hii_config_routing_protocol *this, efi_string_t *results) { @@ -37,7 +154,7 @@ static efi_status_t export_config( return EFI_EXIT(EFI_OUT_OF_RESOURCES); } -static efi_status_t route_config( +static efi_status_t EFIAPI route_config( const struct efi_hii_config_routing_protocol *this, const efi_string_t configuration, efi_string_t *progress) @@ -46,7 +163,7 @@ static efi_status_t route_config( return EFI_EXIT(EFI_OUT_OF_RESOURCES); } -static efi_status_t block_to_config( +static efi_status_t EFIAPI block_to_config( const struct efi_hii_config_routing_protocol *this, const efi_string_t config_request, const uint8_t *block, @@ -54,12 +171,12 @@ static efi_status_t block_to_config( efi_string_t *config, efi_string_t *progress) { - EFI_ENTRY("%p, \"%ls\", %p, %lu, %p, %p", this, config_request, block, + EFI_ENTRY("%p, \"%ls\", %p, %zu, %p, %p", this, config_request, block, block_size, config, progress); return EFI_EXIT(EFI_OUT_OF_RESOURCES); } -static efi_status_t config_to_block( +static efi_status_t EFIAPI config_to_block( const struct efi_hii_config_routing_protocol *this, const efi_string_t config_resp, const uint8_t *block, @@ -71,7 +188,7 @@ static efi_status_t config_to_block( return EFI_EXIT(EFI_OUT_OF_RESOURCES); } -static efi_status_t get_alt_config( +static efi_status_t EFIAPI get_alt_config( const struct efi_hii_config_routing_protocol *this, const efi_string_t config_resp, const efi_guid_t *guid, @@ -91,28 +208,67 @@ static efi_status_t get_alt_config( * EFI_HII_DATABASE_PROTOCOL */ -static efi_status_t new_package_list( +static efi_status_t EFIAPI new_package_list( const struct efi_hii_database_protocol *this, const struct efi_hii_package_list_header *package_list, const efi_handle_t driver_handle, efi_hii_handle_t *handle) { - /* Current shell start failure. */ - /* Invoked from MdeModulePkg/Library/UefiHiiLib/HiiLib.c : HiiAddPackages */ - /* (Via autogenerated .c file.) */ + efi_status_t ret = EFI_SUCCESS; + EFI_ENTRY("%p, %p, %p, %p", this, package_list, driver_handle, handle); - return EFI_EXIT(EFI_OUT_OF_RESOURCES); + + if (!package_list || !driver_handle) + return EFI_EXIT(EFI_INVALID_PARAMETER); + + struct hii_package *hii = new_package(); + struct efi_hii_package_header *package; + void *end = ((void *)package_list) + package_list->package_length; + + debug("package_list: %pUl (%u)\n", &package_list->package_list_guid, + package_list->package_length); + + package = ((void *)package_list) + sizeof(*package_list); + while ((void *)package < end) { + debug("package=%p, package type=%x, length=%u\n", package, + package->type, package->length); + switch (package->type) { + case EFI_HII_PACKAGE_STRINGS: + ret = add_strings_package(hii, + (struct efi_hii_strings_package *)package); + break; + default: + break; + } + + if (ret != EFI_SUCCESS) + goto error; + + package = ((void *)package) + package->length; + } + + // TODO in theory there is some notifications that should be sent.. + + *handle = hii; + + return EFI_EXIT(EFI_SUCCESS); + +error: + free_package(hii); + return EFI_EXIT(ret); } -static efi_status_t remove_package_list( +static efi_status_t EFIAPI remove_package_list( const struct efi_hii_database_protocol *this, efi_hii_handle_t handle) { + struct hii_package *hii = handle; EFI_ENTRY("%p, %p", this, handle); - return EFI_EXIT(EFI_NOT_FOUND); + free_package(hii); + return EFI_EXIT(EFI_SUCCESS); } -static efi_status_t update_package_list( +static efi_status_t EFIAPI update_package_list( const struct efi_hii_database_protocol *this, efi_hii_handle_t handle, const struct efi_hii_package_list_header *package_list) @@ -121,7 +277,7 @@ static efi_status_t update_package_list( return EFI_EXIT(EFI_NOT_FOUND); } -static efi_status_t list_package_lists( +static efi_status_t EFIAPI list_package_lists( const struct efi_hii_database_protocol *this, uint8_t package_type, const efi_guid_t *package_guid, @@ -133,7 +289,7 @@ static efi_status_t list_package_lists( return EFI_EXIT(EFI_NOT_FOUND); } -static efi_status_t export_package_lists( +static efi_status_t EFIAPI export_package_lists( const struct efi_hii_database_protocol *this, efi_hii_handle_t handle, UINTN *buffer_size, @@ -143,7 +299,7 @@ static efi_status_t export_package_lists( return EFI_EXIT(EFI_NOT_FOUND); } -static efi_status_t register_package_notify( +static efi_status_t EFIAPI register_package_notify( const struct efi_hii_database_protocol *this, uint8_t package_type, const efi_guid_t *package_guid, @@ -151,13 +307,13 @@ static efi_status_t register_package_notify( UINTN notify_type, efi_handle_t *notify_handle) { - EFI_ENTRY("%p, %u, %pUl, %p, %lu, %p", this, package_type, + EFI_ENTRY("%p, %u, %pUl, %p, %zu, %p", this, package_type, package_guid, package_notify_fn, notify_type, notify_handle); return EFI_EXIT(EFI_OUT_OF_RESOURCES); } -static efi_status_t unregister_package_notify( +static efi_status_t EFIAPI unregister_package_notify( const struct efi_hii_database_protocol *this, efi_handle_t notification_handle) { @@ -165,7 +321,7 @@ static efi_status_t unregister_package_notify( return EFI_EXIT(EFI_NOT_FOUND); } -static efi_status_t find_keyboard_layouts( +static efi_status_t EFIAPI find_keyboard_layouts( const struct efi_hii_database_protocol *this, uint16_t *key_guid_buffer_length, efi_guid_t *key_guid_buffer) @@ -174,7 +330,7 @@ static efi_status_t find_keyboard_layouts( return EFI_EXIT(EFI_NOT_FOUND); /* Invalid */ } -static efi_status_t get_keyboard_layout( +static efi_status_t EFIAPI get_keyboard_layout( const struct efi_hii_database_protocol *this, efi_guid_t *key_guid, uint16_t *keyboard_layout_length, @@ -185,7 +341,7 @@ static efi_status_t get_keyboard_layout( return EFI_EXIT(EFI_NOT_FOUND); } -static efi_status_t set_keyboard_layout( +static efi_status_t EFIAPI set_keyboard_layout( const struct efi_hii_database_protocol *this, efi_guid_t *key_guid) { @@ -193,7 +349,7 @@ static efi_status_t set_keyboard_layout( return EFI_EXIT(EFI_NOT_FOUND); } -static efi_status_t get_package_list_handle( +static efi_status_t EFIAPI get_package_list_handle( const struct efi_hii_database_protocol *this, efi_hii_handle_t package_list_handle, efi_handle_t *driver_handle) @@ -207,7 +363,7 @@ static efi_status_t get_package_list_handle( * EFI_HII_STRING_PROTOCOL */ -static efi_status_t new_string( +static efi_status_t EFIAPI new_string( const struct efi_hii_string_protocol *this, efi_hii_handle_t package_list, efi_string_id_t *string_id, @@ -216,13 +372,13 @@ static efi_status_t new_string( const efi_string_t string, const struct efi_font_info *string_font_info) { - EFI_ENTRY("%p, %p, %p, %p, %p, \"%ls\", %p", this, package_list, + EFI_ENTRY("%p, %p, %p, \"%s\", %p, \"%ls\", %p", this, package_list, string_id, language, language_name, string, string_font_info); return EFI_EXIT(EFI_NOT_FOUND); } -static efi_status_t get_string( +static efi_status_t EFIAPI get_string( const struct efi_hii_string_protocol *this, const uint8_t *language, efi_hii_handle_t package_list, @@ -231,13 +387,34 @@ static efi_status_t get_string( UINTN *string_size, struct efi_font_info **string_font_info) { - EFI_ENTRY("%p, %p, %p, %u, \"%ls\", %p, %p", this, language, + struct hii_package *hii = package_list; + struct string_table *stbl; + + EFI_ENTRY("%p, \"%s\", %p, %u, %p, %p, %p", this, language, package_list, string_id, string, string_size, string_font_info); + + list_for_each_entry(stbl, &hii->string_tables, link) { + if (!strcmp((char *)language, (char *)stbl->language)) { + unsigned idx = string_id - 1; + if (idx > stbl->nstrings) + return EFI_EXIT(EFI_NOT_FOUND); + efi_string_t str = stbl->strings[idx].string; + size_t len = utf16_strlen(str) + 1; + if (*string_size < len * 2) { + *string_size = len * 2; + return EFI_EXIT(EFI_BUFFER_TOO_SMALL); + } + memcpy(string, str, len * 2); + *string_size = len * 2; + return EFI_EXIT(EFI_SUCCESS); + } + } + return EFI_EXIT(EFI_NOT_FOUND); } -static efi_status_t set_string( +static efi_status_t EFIAPI set_string( const struct efi_hii_string_protocol *this, efi_hii_handle_t package_list, efi_string_id_t string_id, @@ -245,31 +422,56 @@ static efi_status_t set_string( const efi_string_t string, const struct efi_font_info *string_font_info) { - EFI_ENTRY("%p, %p, %u, %p, \"%ls\", %p", this, package_list, string_id, - language, string, string_font_info); + EFI_ENTRY("%p, %p, %u, \"%s\", \"%ls\", %p", this, package_list, + string_id, language, string, string_font_info); return EFI_EXIT(EFI_NOT_FOUND); } -static efi_status_t get_languages( +static efi_status_t EFIAPI get_languages( const struct efi_hii_string_protocol *this, efi_hii_handle_t package_list, uint8_t *languages, UINTN *languages_size) { + struct hii_package *hii = package_list; + struct string_table *stbl; + size_t len = 0; + EFI_ENTRY("%p, %p, %p, %p", this, package_list, languages, languages_size); - return EFI_EXIT(EFI_NOT_FOUND); + + /* figure out required size: */ + list_for_each_entry(stbl, &hii->string_tables, link) { + len += strlen((char *)stbl->language) + 1; + } + + if (*languages_size < len) { + *languages_size = len; + return EFI_EXIT(EFI_BUFFER_TOO_SMALL); + } + + char *p = (char *)languages; + list_for_each_entry(stbl, &hii->string_tables, link) { + if (p != (char *)languages) + p += sprintf(p, ";"); + p += sprintf(p, "%s", stbl->language); + } + + debug("languages: %s\n", languages); + + return EFI_EXIT(EFI_SUCCESS); } -static efi_status_t get_secondary_languages( +static efi_status_t EFIAPI get_secondary_languages( const struct efi_hii_string_protocol *this, efi_hii_handle_t package_list, const uint8_t *primary_language, uint8_t *secondary_languages, UINTN *secondary_languages_size) { - EFI_ENTRY("%p, %p, %p, %p, %p", this, package_list, primary_language, - secondary_languages, secondary_languages_size); + EFI_ENTRY("%p, %p, \"%s\", %p, %p", this, package_list, + primary_language, secondary_languages, + secondary_languages_size); return EFI_EXIT(EFI_NOT_FOUND); } From patchwork Sun Sep 10 13:22:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 812149 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="KkTJEaTG"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xqsNS3tLCz9s7g for ; Sun, 10 Sep 2017 23:29:28 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 5070BC21E74; Sun, 10 Sep 2017 13:25:22 +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, 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 BBEB6C21F51; Sun, 10 Sep 2017 13:23:37 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C3D22C21EE4; Sun, 10 Sep 2017 13:23:08 +0000 (UTC) Received: from mail-qk0-f194.google.com (mail-qk0-f194.google.com [209.85.220.194]) by lists.denx.de (Postfix) with ESMTPS id 4B0CDC21F28 for ; Sun, 10 Sep 2017 13:22:59 +0000 (UTC) Received: by mail-qk0-f194.google.com with SMTP id o77so4071065qke.2 for ; Sun, 10 Sep 2017 06:22:59 -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=PzMhEq5X4ZXskTKlDOGsIWsSXJlR83KTYQp3klUDDsQ=; b=KkTJEaTGJBuC7KJI2A5xsjpMPvY3CK6cf2qm4iyKXdTn6VuuwfzQiSCLNZ92lOYcIW vYJk2SoYHtwNP7erP+9M0TDOz5iEucs52WNUntNmdroDGNDgIMdeBQcG6B1SCtAmT9CQ xIn9jkrdpdYYOCwbiXJ6vaWWNHtVPCKoRVJpXUgK5g2vCPT8xt1bSpCVpVo+6Awd7i9A wGPhD+q/s4lgFtiggFiE8h8gS0uQ4Ef+A/zBV8RiddxX2RN9cndWJfiZnYMxPiNpywNQ qc8c1FjQyWhCqJYCZUQbsJN8pTPOiakol4GaPTZlfhLz9DYKtepoNfdJoAbr7Ac/Ya+6 bfdA== 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=PzMhEq5X4ZXskTKlDOGsIWsSXJlR83KTYQp3klUDDsQ=; b=EeM/dy0TDN21pKF/KfcGbFsSBP9oRMjfAehPj6e+dAT+AgagTTK2c6osNiqVQ3xoIq PhqTR994PRKJ9I9Fzy6CGQaiLli+OIaBaxCUkM24CUIV/zTlV+XvEnTVJCVWQHYNHAqE ZAs/NGOd0ZqmfxnpefNxs+5s7SWyz9BBomtLlHwgym5RnuF0tdIvO1QNWdLooOjDMJba 2p3MqiR+g1uouFAnJ8BUxqPjiDDPifpYrfGWmQCYqmFVDSWPEtmw3kKHrmCZna2f/g8R 7JvaxQUKeseeLPPG3VbAN+kkJxa276tpWhGjbAgS2IZoWPmf9Qsa5icEcwSuH4v0XiRx /KyQ== X-Gm-Message-State: AHPjjUjUii3fUAVLG8nkh3Kzq7IAUuZMXU/5btgyxdQm/gNaUtWsVZYC FSctlU27cL5DeIpk3v8= X-Google-Smtp-Source: AOwi7QBug7XuUQuiZNyHHL6+k5fJh1V+sfXT3y88l+nSOVx+wxc5U6zHDGWNFkRka3tRnU3OSYMdrw== X-Received: by 10.55.167.144 with SMTP id q138mr11134617qke.74.1505049777992; Sun, 10 Sep 2017 06:22:57 -0700 (PDT) Received: from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a]) by smtp.gmail.com with ESMTPSA id s69sm4195296qka.95.2017.09.10.06.22.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Sep 2017 06:22:56 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Sun, 10 Sep 2017 09:22:26 -0400 Message-Id: <20170910132236.14318-6-robdclark@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170910132236.14318-1-robdclark@gmail.com> References: <20170910132236.14318-1-robdclark@gmail.com> Cc: Heinrich Schuchardt , Peter Jones , Leif Lindholm Subject: [U-Boot] [PATCH v1 05/12] efi_loader: flesh out unicode 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" Not complete, but enough for Shell.efi and SCT.efi. Signed-off-by: Rob Clark --- include/efi_api.h | 9 +++ include/efi_loader.h | 1 + lib/efi_loader/efi_boottime.c | 5 +- lib/efi_loader/efi_unicode.c | 143 +++++++++++++++++++++++++++++++++++------- 4 files changed, 134 insertions(+), 24 deletions(-) diff --git a/include/efi_api.h b/include/efi_api.h index 4853b71497..5612dfad49 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -804,6 +804,15 @@ struct efi_hii_string_protocol UINTN *secondary_languages_size); }; +/* + * Both UNICODE_COLLATION protocols seem to be the same thing, but + * advertised with two different GUID's because, why not? + */ + +#define EFI_UNICODE_COLLATION_PROTOCOL_GUID \ + EFI_GUID(0x1d85cd7f, 0xf43d, 0x11d2, \ + 0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) + #define EFI_UNICODE_COLLATION_PROTOCOL2_GUID \ EFI_GUID(0xa4c751fc, 0x23ae, 0x4c3e, \ 0x92, 0xe9, 0x49, 0x64, 0xcf, 0x63, 0xf3, 0x49) diff --git a/include/efi_loader.h b/include/efi_loader.h index 6668338d0b..4864b3ac77 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -77,6 +77,7 @@ extern const efi_guid_t efi_guid_device_path_utilities_protocol; extern const efi_guid_t efi_guid_hii_config_routing_protocol; extern const efi_guid_t efi_guid_hii_database_protocol; extern const efi_guid_t efi_guid_hii_string_protocol; +extern const efi_guid_t efi_guid_unicode_collation_protocol; extern const efi_guid_t efi_guid_unicode_collation_protocol2; extern unsigned int __efi_runtime_start, __efi_runtime_stop; diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 04358e8aca..7b53570354 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -788,9 +788,12 @@ void efi_setup_loaded_image(struct efi_loaded_image *info, struct efi_object *ob obj->protocols[7].guid = &efi_guid_hii_config_routing_protocol; obj->protocols[7].protocol_interface = (void *)&efi_hii_config_routing; - obj->protocols[8].guid = &efi_guid_unicode_collation_protocol2; + obj->protocols[8].guid = &efi_guid_unicode_collation_protocol; obj->protocols[8].protocol_interface = (void *)&efi_unicode_collation; + obj->protocols[9].guid = &efi_guid_unicode_collation_protocol2; + obj->protocols[9].protocol_interface = (void *)&efi_unicode_collation; + info->file_path = file_path; info->device_handle = efi_dp_find_obj(device_path, NULL); diff --git a/lib/efi_loader/efi_unicode.c b/lib/efi_loader/efi_unicode.c index fdf1a99812..8d8edfb45a 100644 --- a/lib/efi_loader/efi_unicode.c +++ b/lib/efi_loader/efi_unicode.c @@ -7,59 +7,155 @@ */ #include +#include +#include #include +const efi_guid_t efi_guid_unicode_collation_protocol = + EFI_UNICODE_COLLATION_PROTOCOL_GUID; + const efi_guid_t efi_guid_unicode_collation_protocol2 = EFI_UNICODE_COLLATION_PROTOCOL2_GUID; -INTN stri_coll(struct efi_unicode_collation_protocol *this, - efi_string_t s1, - efi_string_t s2) +static int matchn(efi_string_t s1, unsigned n1, efi_string_t s2, unsigned n2) +{ + char u1[MAX_UTF8_PER_UTF16 * n1 + 1]; + char u2[MAX_UTF8_PER_UTF16 * n2 + 1]; + + *utf16_to_utf8((u8 *)u1, s1, n1) = '\0'; + *utf16_to_utf8((u8 *)u2, s2, n2) = '\0'; + + return strcasecmp(u1, u2); +} + +static INTN EFIAPI stri_coll(struct efi_unicode_collation_protocol *this, + efi_string_t s1, + efi_string_t s2) { EFI_ENTRY("%p, \"%ls\", \"%ls\"", this, s1, s2); - return EFI_EXIT(0); + + unsigned n1 = utf16_strlen(s1); + unsigned n2 = utf16_strlen(s2); + + return EFI_EXIT(matchn(s1, n1, s2, n2)); } -bool metai_match(struct efi_unicode_collation_protocol *this, - efi_string_t string, - efi_string_t pattern) +static bool match(efi_string_t string, efi_string_t pattern) +{ + while (true) { + uint16_t p = *pattern++; + bool matches = false; + + if (p == '\0' || *string == '\0') { + /* + * End of pattern or string, succeed if + * end of both: + */ + return *string == p; + } + + switch (p) { + case '*': + /* Match zero or more chars: */ + while (*string != '\0') { + if (match(string, pattern)) + return true; + string++; + } + return match(string, pattern); + case '?': + /* Match any one char: */ + string++; + break; + case '[': + /* Match char set, either [abc] or [a-c]: */ + + if (pattern[0] == '\0' || pattern[0] == ']') { + /* invalid pattern */ + return false; + } + + if (pattern[1] == '-') { + uint16_t lo, hi, c; + + /* range: [a-c] */ + lo = pattern[0]; + hi = pattern[2]; + + if (hi == '\0' || hi == ']' || pattern[3] != ']') { + /* invalid pattern */ + return false; + } + + c = tolower(*string); + lo = tolower(lo); + hi = tolower(hi); + + if (lo <= c && c <= hi) + matches = true; + + pattern += 4; + } else { + /* set: [abc] */ + while ((p = *pattern++) && p != ']') + if (matchn(string, 1, &p, 1)) + matches = true; + } + + if (!matches) + return false; + + string++; + break; + default: + if (matchn(string, 1, &p, 1)) + return false; + string++; + break; + } + } +} + +static bool EFIAPI metai_match(struct efi_unicode_collation_protocol *this, + efi_string_t string, + efi_string_t pattern) { EFI_ENTRY("%p, \"%ls\", \"%ls\"", this, string, pattern); - return EFI_EXIT(false); + return EFI_EXIT(match(string, pattern)); } -void str_lwr(struct efi_unicode_collation_protocol *this, - efi_string_t string) +static void EFIAPI str_lwr(struct efi_unicode_collation_protocol *this, + efi_string_t string) { EFI_ENTRY("%p, \"%ls\"", this, string); EFI_EXIT(0); return; } -void str_upr(struct efi_unicode_collation_protocol *this, - efi_string_t string) +static void EFIAPI str_upr(struct efi_unicode_collation_protocol *this, + efi_string_t string) { EFI_ENTRY("%p, \"%ls\"", this, string); EFI_EXIT(0); return; } -void fat_to_str(struct efi_unicode_collation_protocol *this, - UINTN fat_size, - uint8_t *fat, - efi_string_t string) +static void EFIAPI fat_to_str(struct efi_unicode_collation_protocol *this, + UINTN fat_size, + uint8_t *fat, + efi_string_t string) { - EFI_ENTRY("%p, %lu, \"%s\", %p", this, fat_size, fat, string); + EFI_ENTRY("%p, %zu, \"%s\", %p", this, fat_size, fat, string); EFI_EXIT(0); return; } -bool str_to_fat(struct efi_unicode_collation_protocol *this, - efi_string_t string, - UINTN fat_size, - uint8_t *fat) +static bool EFIAPI str_to_fat(struct efi_unicode_collation_protocol *this, + efi_string_t string, + UINTN fat_size, + uint8_t *fat) { - EFI_ENTRY("%p, \"%ls\", %lu, %p", this, string, fat_size, fat); + EFI_ENTRY("%p, \"%ls\", %zu, %p", this, string, fat_size, fat); return EFI_EXIT(false); } @@ -69,5 +165,6 @@ const struct efi_unicode_collation_protocol efi_unicode_collation = { .str_lwr = str_lwr, .str_upr = str_upr, .fat_to_str = fat_to_str, - .str_to_fat = str_to_fat + .str_to_fat = str_to_fat, + .supported_languages = (uint8_t *)"eng", }; From patchwork Sun Sep 10 13:22:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 812140 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="qwOKDZx7"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xqsJG1rhpz9s7g for ; Sun, 10 Sep 2017 23:25:50 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id EDC05C21DEB; Sun, 10 Sep 2017 13:24:31 +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, 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 D085BC21F50; Sun, 10 Sep 2017 13:23:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4BC99C21E77; Sun, 10 Sep 2017 13:23:12 +0000 (UTC) Received: from mail-qt0-f193.google.com (mail-qt0-f193.google.com [209.85.216.193]) by lists.denx.de (Postfix) with ESMTPS id 12D8FC21E74 for ; Sun, 10 Sep 2017 13:23:03 +0000 (UTC) Received: by mail-qt0-f193.google.com with SMTP id 7so4190694qtz.3 for ; Sun, 10 Sep 2017 06:23:03 -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=HXdAp0zEVWe5zGXYEnjYmwjovDI2F9EsqoSyXMyoAsg=; b=qwOKDZx7bclzxNS+PAC3a8+AyoMki+pMAn9US8Uh/p2HKF3FUVorWmzEvlk0/4Dq2D 6wZd3n6WZTe6zEpLllJa7vGIbKPoJcPEEHQZ/La3Cjl75x6Eg/Q2WimJEikn68TTJ4Bd 2WyKBSNjzDnvLFM6QjtvOFuWjzB49wxwkB2xF9yocJoATQ4Bbq0Jq3eQu/ru0gc2BLRU w+ZaliqvYRS31WdmxQYrURXm86SMv2Ei90++XpR0K8hovNgIDH2M9bEmWnlh2LEOA/Gq 7fDUYytO0sKyWR1YPIY38J9hxXL6tSMRZuZvd8agSZO87G16Pdgs0WPjkK4QCM3/VPnr tLVw== 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=HXdAp0zEVWe5zGXYEnjYmwjovDI2F9EsqoSyXMyoAsg=; b=NAW/SdG2ndz8JGDTZNx5Cgq6MjkPiT3r0pZtNHhJoMFbX3IUlnT09FABI5fa+9weOs q/wz3a7jm5g653nDtulb4IXiWpcL+Bh1Jj97WAhyVUWiOM/9Xcdlnv10tDmXky3yvhw3 0qK+E1BeBakS3eLYLfzFAKdDJDVh4jUEPvjAAV1ZHB7sPsnVHAkCefoBxWTiNB6GWD7B Fbp3OVi9SQIu1CQI2oNoQtvmEd80UmWO2SvdgICmMYq27hx8EV3dtQe0fDa9AfqOO0QN AUk7frJVoV90hu5vnFlYoRHbYlpQm/tYMwYqCRwIL6DpOpUk8dPOWvE+ZaeNc5PgSJG0 cMQg== X-Gm-Message-State: AHPjjUiRRP8VVNpuFC2benvqLOUZFddaVOBRO9p2pmK0WiPfE7HExBxp LrRDKaCj9guwr5zZh8c= X-Google-Smtp-Source: AOwi7QATt6go53ntUUcBr21MSyQP85sstGzuYi9sMx6E0bC/sNyx5n7GN+3Y7lz9Ze5GzCWTwd3iaA== X-Received: by 10.200.2.141 with SMTP id p13mr4583429qtg.45.1505049781769; Sun, 10 Sep 2017 06:23:01 -0700 (PDT) Received: from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a]) by smtp.gmail.com with ESMTPSA id q52sm4543624qtc.12.2017.09.10.06.23.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Sep 2017 06:23:00 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Sun, 10 Sep 2017 09:22:27 -0400 Message-Id: <20170910132236.14318-7-robdclark@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170910132236.14318-1-robdclark@gmail.com> References: <20170910132236.14318-1-robdclark@gmail.com> Cc: Heinrich Schuchardt , Leif Lindholm Subject: [U-Boot] [PATCH v1 06/12] efi_loader: start fleshing out efi_device_path_utilities 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" Not complete, but enough for Shell.efi and SCT.efi. Signed-off-by: Rob Clark --- lib/efi_loader/efi_device_path_utilities.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/efi_loader/efi_device_path_utilities.c b/lib/efi_loader/efi_device_path_utilities.c index 4b97080f35..37b539e8ff 100644 --- a/lib/efi_loader/efi_device_path_utilities.c +++ b/lib/efi_loader/efi_device_path_utilities.c @@ -12,36 +12,40 @@ const efi_guid_t efi_guid_device_path_utilities_protocol = EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID; -static UINTN get_device_path_size(const struct efi_device_path *device_path) +static UINTN EFIAPI get_device_path_size(const struct efi_device_path *device_path) { + UINTN sz = 0; EFI_ENTRY("%p", device_path); - return EFI_EXIT(0); + /* 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 *duplicate_device_path( +static struct efi_device_path * EFIAPI duplicate_device_path( const struct efi_device_path *device_path) { EFI_ENTRY("%p", device_path); - return EFI_EXIT(NULL); + return EFI_EXIT(efi_dp_dup(device_path)); } -static struct efi_device_path *append_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(NULL); + return EFI_EXIT(efi_dp_append(src1, src2)); } -static struct efi_device_path *append_device_node( +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(NULL); + return EFI_EXIT(efi_dp_append_node(device_path, device_node)); } -static struct efi_device_path *append_device_path_instance( +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) { @@ -49,7 +53,7 @@ static struct efi_device_path *append_device_path_instance( return EFI_EXIT(NULL); } -static struct efi_device_path *get_next_device_path_instance( +static struct efi_device_path * EFIAPI get_next_device_path_instance( struct efi_device_path **device_path_instance, UINTN *device_path_instance_size) { @@ -57,14 +61,14 @@ static struct efi_device_path *get_next_device_path_instance( return EFI_EXIT(NULL); } -static struct efi_device_path *create_device_node( +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); } -static bool is_device_path_multi_instance( +static bool EFIAPI is_device_path_multi_instance( const struct efi_device_path *device_path) { EFI_ENTRY("%p", device_path); From patchwork Sun Sep 10 13:22:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 812144 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="F7lczsdj"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xqsLN5CCQz9s7g for ; Sun, 10 Sep 2017 23:27:40 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 79411C21F0D; Sun, 10 Sep 2017 13:26:31 +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, 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 237FCC21F74; Sun, 10 Sep 2017 13:24:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 939DFC21E40; Sun, 10 Sep 2017 13:23:16 +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 47904C21EE4 for ; Sun, 10 Sep 2017 13:23:07 +0000 (UTC) Received: by mail-qt0-f196.google.com with SMTP id u48so1297462qtc.4 for ; Sun, 10 Sep 2017 06:23:07 -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=r5ZC6/3pNXKFsf7NlBcHZ0Vu14dwXZhcZy36GpjGa6Y=; b=F7lczsdjBeFxI7OPnOg5/c7Tub9mQC2wEosD5Qg1uUcpa5MS11Y8T3jCQOcAQdi0cE LgGB9fl2Ol0ChPWFl90pPc8yZ2QKXih/mYT/4nWLD6uXwWK50a83veHwWKCXdzmHAdKh gCCAn6cEtKtN+1cPN1He7hKanxXVwgF1JbFB98V1G+YNwIp6jSQP0CyyDDRkHYRRQBUp g/zOJtj9yG15ylt1m2Lt+RO5YKqp0ubO0Mwa370OMNIo3/ta70h9Zq2qV2nFKfBqCILd Xt1kwQt3fvw2aBGp74tewLjnTCs3mrWb/yrAERAFSmVlBoq7VFZAGAiz++dTti+HcAZU eHpw== 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=r5ZC6/3pNXKFsf7NlBcHZ0Vu14dwXZhcZy36GpjGa6Y=; b=GML14R1zaXhKc9FkBN7hBA9PM4hjPiVEfEF8Rc4kkI4Cq5rK3q5wwSkZHvHxdI+Gup jp+tkCNmOAxmnjWFe1fh/tYlZG0NEB/0EAwJSNAAM2uoNIU1AMn1mQSfn82bKKkA78QS n2opIzF5jT1GeEg8Uv1/P/WWjPCvrD+L3YgO292nIP4hSzGewqBE0j/AbpNjTKCyPRvR GIVdCbMCFCA9oy/azS40C6UbA+clnjfO+BcnMoakuIVBJyY5l7zKbVt24jVRXGDqpwEo EoLtjvOBHhGIp3Vl40VKr7tIS6y8ihzNSHDaTHhugggqin2XGtlL+/gO9g0I/Bt6Trsb qC7A== X-Gm-Message-State: AHPjjUhLoe0+6+hn49WcuXuF+NcXoqP1aTqPrErE7oIsoHyFqH3spjGA kAO7RErq1RRWlJOmJ9U= X-Google-Smtp-Source: AOwi7QBUJpCpsdvi8sOdpO41hnmfAgp/NTPyIomsJlLU4pG5h3N1WeKp5xffNoF/+rbyu4YicW2kJA== X-Received: by 10.200.36.78 with SMTP id d14mr7744473qtd.136.1505049785822; Sun, 10 Sep 2017 06:23:05 -0700 (PDT) Received: from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a]) by smtp.gmail.com with ESMTPSA id l19sm5248416qkl.31.2017.09.10.06.23.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Sep 2017 06:23:04 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Sun, 10 Sep 2017 09:22:28 -0400 Message-Id: <20170910132236.14318-8-robdclark@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170910132236.14318-1-robdclark@gmail.com> References: <20170910132236.14318-1-robdclark@gmail.com> Cc: Heinrich Schuchardt , Peter Jones , Leif Lindholm Subject: [U-Boot] [PATCH v1 07/12] efi_loader: SIMPLE_TEXT_INPUT_EX plus wire up objects properly 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" I think we need the _EX version for SCT.. and either way we need to wire up the corresponding objects in the systab properly. This fixes some issues with SCT.efi. Signed-off-by: Rob Clark --- include/efi_api.h | 60 +++++++++++++++++++- include/efi_loader.h | 10 +--- lib/efi_loader/efi_boottime.c | 3 + lib/efi_loader/efi_console.c | 129 +++++++++++++++++++++++++++++++++++++----- 4 files changed, 177 insertions(+), 25 deletions(-) diff --git a/include/efi_api.h b/include/efi_api.h index 5612dfad49..87c8ffe68e 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -242,11 +242,11 @@ struct efi_system_table { struct efi_table_hdr hdr; unsigned long fw_vendor; /* physical addr of wchar_t vendor string */ u32 fw_revision; - unsigned long con_in_handle; + efi_handle_t con_in_handle; struct efi_simple_input_interface *con_in; - unsigned long con_out_handle; + efi_handle_t con_out_handle; struct efi_simple_text_output_protocol *con_out; - unsigned long stderr_handle; + efi_handle_t stderr_handle; struct efi_simple_text_output_protocol *std_err; struct efi_runtime_services *runtime; struct efi_boot_services *boottime; @@ -473,6 +473,60 @@ struct efi_simple_input_interface { struct efi_event *wait_for_key; }; + +#define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \ + EFI_GUID(0xdd9e7534, 0x7762, 0x4698, \ + 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa) + +/* key-shift state: */ +#define EFI_SHIFT_STATE_VALID 0x80000000 +#define EFI_RIGHT_SHIFT_PRESSED 0x00000001 +#define EFI_LEFT_SHIFT_PRESSED 0x00000002 +#define EFI_RIGHT_CONTROL_PRESSED 0x00000004 +#define EFI_LEFT_CONTROL_PRESSED 0x00000008 +#define EFI_RIGHT_ALT_PRESSED 0x00000010 +#define EFI_EFI_LEFT_ALT_PRESSED 0x00000020 +#define EFI_RIGHT_LOGO_PRESSED 0x00000040 +#define EFI_LEFT_LOGO_PRESSED 0x00000080 +#define EFI_MENU_KEY_PRESSED 0x00000100 +#define EFI_SYS_REQ_PRESSED 0x00000200 + +/* key-toggle state: */ +#define EFI_TOGGLE_STATE_VALID 0x80 +#define EFI_SCROLL_LOCK_ACTIVE 0x01 +#define EFI_NUM_LOCK_ACTIVE 0x02 +#define EFI_CAPS_LOCK_ACTIVE 0x04 + +struct efi_key_state { + uint32_t key_shift_state; + uint8_t key_toggle_state; +}; + +struct efi_key_data { + struct efi_input_key key; + struct efi_key_state key_state; +}; + +struct efi_simple_text_input_ex_interface { + efi_status_t (EFIAPI *reset)( + struct efi_simple_text_input_ex_interface *this, + bool ExtendedVerification); + efi_status_t (EFIAPI *read_key_stroke)( + struct efi_simple_text_input_ex_interface *this, + struct efi_key_data *key_data); + struct efi_event *wait_for_key; + efi_status_t (EFIAPI *set_state)( + struct efi_simple_text_input_ex_interface *this, + uint8_t key_toggle_state); + efi_status_t (EFIAPI *register_key_notify)( + struct efi_simple_text_input_ex_interface *this, + efi_status_t (EFIAPI *notify_fn)(struct efi_key_data *key_data), + efi_handle_t *notify_handle); + efi_status_t (EFIAPI *unregister_key_notify)( + struct efi_simple_text_input_ex_interface *this, + efi_handle_t notify_handle); +}; + #define CONSOLE_CONTROL_GUID \ EFI_GUID(0xf42f7782, 0x12e, 0x4c12, \ 0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21) diff --git a/include/efi_loader.h b/include/efi_loader.h index 4864b3ac77..72734b3a44 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -54,7 +54,9 @@ const char *__efi_nesting_dec(void); extern struct efi_runtime_services efi_runtime_services; extern struct efi_system_table systab; +extern struct efi_object efi_console_output_obj; extern const struct efi_simple_text_output_protocol efi_con_out; +extern struct efi_object efi_console_input_obj; 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; @@ -108,14 +110,6 @@ struct efi_object { void *handle; }; -#define EFI_PROTOCOL_OBJECT(_guid, _protocol) (struct efi_object){ \ - .protocols = {{ \ - .guid = &(_guid), \ - .protocol_interface = (void *)(_protocol), \ - }}, \ - .handle = (void *)(_protocol), \ -} - /** * struct efi_event * diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 7b53570354..9628bef474 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1394,8 +1394,11 @@ struct efi_system_table __efi_runtime_data systab = { .headersize = sizeof(struct efi_table_hdr), }, .fw_vendor = (long)firmware_vendor, + .con_in_handle = &efi_console_input_obj, .con_in = (void*)&efi_con_in, + .con_out_handle = &efi_console_output_obj, .con_out = (void*)&efi_con_out, + .stderr_handle = &efi_console_output_obj, .std_err = (void*)&efi_con_out, .runtime = (void*)&efi_runtime_services, .boottime = (void*)&efi_boot_services, diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index afc725a2c7..2e13fdc096 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -50,6 +50,10 @@ const efi_guid_t efi_guid_console_control = CONSOLE_CONTROL_GUID; #define cESC '\x1b' #define ESC "\x1b" +/* + * EFI_CONSOLE_CONTROL: + */ + static efi_status_t EFIAPI efi_cin_get_mode( struct efi_console_control_protocol *this, int *mode, char *uga_exists, char *std_in_locked) @@ -97,6 +101,11 @@ static struct simple_text_output_mode efi_con_mode = { .cursor_visible = 1, }; + +/* + * EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL: + */ + static int term_read_reply(int *n, int maxnum, char end_char) { char c; @@ -364,6 +373,11 @@ const struct efi_simple_text_output_protocol efi_con_out = { .mode = (void*)&efi_con_mode, }; + +/* + * EFI_SIMPLE_TEXT_INPUT_PROTOCOL: + */ + static efi_status_t EFIAPI efi_cin_reset( struct efi_simple_input_interface *this, bool extended_verification) @@ -372,9 +386,7 @@ static efi_status_t EFIAPI efi_cin_reset( return EFI_EXIT(EFI_UNSUPPORTED); } -static efi_status_t EFIAPI efi_cin_read_key_stroke( - struct efi_simple_input_interface *this, - struct efi_input_key *key) +static efi_status_t read_key_stroke(struct efi_key_data *key_data) { struct efi_input_key pressed_key = { .scan_code = 0, @@ -382,14 +394,12 @@ static efi_status_t EFIAPI efi_cin_read_key_stroke( }; char ch; - EFI_ENTRY("%p, %p", this, key); - /* We don't do interrupts, so check for timers cooperatively */ efi_timer_check(); if (!tstc()) { /* No key pressed */ - return EFI_EXIT(EFI_NOT_READY); + return EFI_NOT_READY; } ch = getc(); @@ -438,9 +448,31 @@ static efi_status_t EFIAPI efi_cin_read_key_stroke( ch = 0x08; } pressed_key.unicode_char = ch; - *key = pressed_key; + key_data->key = pressed_key; - return EFI_EXIT(EFI_SUCCESS); + /* TODO not sure if we have a way to get this from stdin? + * We might need to use keyboard driver directly for _ex + * stuff? + */ + memset(&key_data->key_state, 0, sizeof(key_data->key_state)); + + return EFI_SUCCESS; +} + +static efi_status_t EFIAPI efi_cin_read_key_stroke( + struct efi_simple_input_interface *this, + struct efi_input_key *key) +{ + struct efi_key_data key_data; + efi_status_t ret; + + EFI_ENTRY("%p, %p", this, key); + + ret = read_key_stroke(&key_data); + if (ret == EFI_SUCCESS) + *key = key_data.key; + + return EFI_EXIT(ret); } struct efi_simple_input_interface efi_con_in = { @@ -465,12 +497,81 @@ static void EFIAPI efi_console_timer_notify(struct efi_event *event, } -static struct efi_object efi_console_control_obj = - EFI_PROTOCOL_OBJECT(efi_guid_console_control, &efi_console_control); -static struct efi_object efi_console_output_obj = - EFI_PROTOCOL_OBJECT(EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID, &efi_con_out); -static struct efi_object efi_console_input_obj = - EFI_PROTOCOL_OBJECT(EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID, &efi_con_in); +/* + * EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL + */ + +static efi_status_t EFIAPI efi_cin_ex_reset( + struct efi_simple_text_input_ex_interface *this, + bool extended_verification) +{ + EFI_ENTRY("%p, %d", this, extended_verification); + return EFI_EXIT(EFI_UNSUPPORTED); +} + +static efi_status_t EFIAPI efi_cin_ex_read_key_stroke( + struct efi_simple_text_input_ex_interface *this, + struct efi_key_data *key_data) +{ + EFI_ENTRY("%p, %p", this, key_data); + return EFI_EXIT(read_key_stroke(key_data)); +} + +static efi_status_t EFIAPI efi_cin_ex_set_state( + struct efi_simple_text_input_ex_interface *this, + uint8_t key_toggle_state) +{ + EFI_ENTRY("%p, %x", this, key_toggle_state); + return EFI_EXIT(EFI_SUCCESS); +} + +static efi_status_t EFIAPI efi_cin_ex_register_key_notify( + struct efi_simple_text_input_ex_interface *this, + efi_status_t (EFIAPI *notify_fn)(struct efi_key_data *key_data), + efi_handle_t *notify_handle) +{ + EFI_ENTRY("%p, %p, %p", this, notify_fn, notify_handle); + return EFI_EXIT(EFI_OUT_OF_RESOURCES); +} + +static efi_status_t EFIAPI efi_cin_ex_unregister_key_notify( + struct efi_simple_text_input_ex_interface *this, + efi_handle_t notify_handle) +{ + EFI_ENTRY("%p, %p", this, notify_handle); + return EFI_EXIT(EFI_INVALID_PARAMETER); +} + +static struct efi_simple_text_input_ex_interface efi_con_in_ex = { + .reset = efi_cin_ex_reset, + .read_key_stroke = efi_cin_ex_read_key_stroke, + .wait_for_key = NULL, + .set_state = efi_cin_ex_set_state, + .register_key_notify = efi_cin_ex_register_key_notify, + .unregister_key_notify = efi_cin_ex_unregister_key_notify, +}; + +static struct efi_object efi_console_control_obj = { + .protocols = { + { &efi_guid_console_control, (void *)&efi_console_control }, + }, + .handle = &efi_console_control_obj, +}; + +struct efi_object efi_console_output_obj = { + .protocols = { + {&EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID, (void *)&efi_con_out}, + }, + .handle = &efi_console_output_obj, +}; + +struct efi_object efi_console_input_obj = { + .protocols = { + {&EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID, (void *)&efi_con_in}, + {&EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID, (void *)&efi_con_in_ex}, + }, + .handle = &efi_console_input_obj, +}; /* This gets called from do_bootefi_exec(). */ int efi_console_register(void) From patchwork Sun Sep 10 13:22:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 812145 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="atausQi1"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xqsMJ3cpWz9s7g for ; Sun, 10 Sep 2017 23:28:28 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 3CCA3C21E8C; Sun, 10 Sep 2017 13:26:15 +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, 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 4E6E7C21F56; Sun, 10 Sep 2017 13:24:04 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E12C6C21F6C; Sun, 10 Sep 2017 13:23:19 +0000 (UTC) Received: from mail-qk0-f193.google.com (mail-qk0-f193.google.com [209.85.220.193]) by lists.denx.de (Postfix) with ESMTPS id D0885C21F3C for ; Sun, 10 Sep 2017 13:23:10 +0000 (UTC) Received: by mail-qk0-f193.google.com with SMTP id d70so4071027qkc.1 for ; Sun, 10 Sep 2017 06:23:10 -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 :mime-version:content-transfer-encoding; bh=2xAWRAf/a5Nbxul9xbdSVE572q0Z9uMMhO3kG8dCpaQ=; b=atausQi1Lvynv6jduAI3c4iixa1xo0FH63k+tsLwIE/S5nHonxQgL/8oC+brfsez2Y DIYPcWjBFIU2QRKGOv9JgQYqAwq7wJICYWfHRq2jiSkOvzwzPSF3ct1UjfsC5liddC/h ROTas5meLdeM/CHRf4suFrr1XYCnOazuoAH+hNM7dxA9Yt1/B6lDhjbnOQGyzNBGrBpg 4L8EfO9lT6S4jQ70y9mFwt5PJPosu+itkQ0XFEYIWJNeV5m3GgU3v6fhtNt8DKXGacXd ezK/zAoASjRf4urMNUC2VQ6pDll7bQ6MbGqPw4HFN0mvDtoTV+5Sq4T0T4qGQCgz2vXh fkXQ== 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:mime-version:content-transfer-encoding; bh=2xAWRAf/a5Nbxul9xbdSVE572q0Z9uMMhO3kG8dCpaQ=; b=WI84A00J2Id8JL1A+wftxkJCJBR9BkGXXrMNR8YofHbccy/fS5sBnf6swMm070wj60 GXQH+M2rJDkc8fNjIbHpPeTIYSPL4OmZ6HeY/dkRjCqvJbIUwy6zaNVsG2utehklX1ld H9ylXXBLzfHX05btKZA6oFTiA84/F5Si+xFqPN5zXrMBvlcjSQFz7spzu+sBCl2D7H1j 2ciehyEFusjsF/vyybQSEbpgymf9G6zGqhHE8w26mT9D6g9gXQ2K+k/91L4WjwG68Yla K2V785XNZlGfk8Mo+obgin2Xa+PrZj8gE6mTsCkqOZX1jAlYkO7UvFqCY8w/Wrp7dLMj 9qtg== X-Gm-Message-State: AHPjjUgtEi4yqNS9Wd8J3mjodG302E17BvoWVpVMhKpndiVb6OaESaww Pjbr3gyNZN6M27AxWvI= X-Google-Smtp-Source: AOwi7QCaVHxsRAIof83mQSH9B/LZ2kW4tq6U1CeB25IEcMTHLkpoW/OjHIfsCA445m+VwxBsTfP+Yw== X-Received: by 10.55.76.196 with SMTP id z187mr11956889qka.100.1505049789483; Sun, 10 Sep 2017 06:23:09 -0700 (PDT) Received: from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a]) by smtp.gmail.com with ESMTPSA id g132sm4200279qke.11.2017.09.10.06.23.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Sep 2017 06:23:08 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Sun, 10 Sep 2017 09:22:29 -0400 Message-Id: <20170910132236.14318-9-robdclark@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170910132236.14318-1-robdclark@gmail.com> References: <20170910132236.14318-1-robdclark@gmail.com> MIME-Version: 1.0 Cc: Heinrich Schuchardt , Peter Jones , Leif Lindholm Subject: [U-Boot] [PATCH v1 08/12] efi_loader: console support for color attributes 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Shell.efi uses this, and supporting color attributes makes things look nicer. Map the EFI fg/bg color attributes to ANSI escape sequences. Not all colors have a perfect match, but spec just says "Devices supporting a different number of text colors are required to emulate the above colors to the best of the device’s capabilities". Signed-off-by: Rob Clark --- include/efi_api.h | 29 +++++++++++++++++++++++++++++ lib/efi_loader/efi_console.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/include/efi_api.h b/include/efi_api.h index 87c8ffe68e..3cc1dbac2e 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -426,6 +426,35 @@ struct simple_text_output_mode { EFI_GUID(0x387477c2, 0x69c7, 0x11d2, \ 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b) +#define EFI_BLACK 0x00 +#define EFI_BLUE 0x01 +#define EFI_GREEN 0x02 +#define EFI_CYAN 0x03 +#define EFI_RED 0x04 +#define EFI_MAGENTA 0x05 +#define EFI_BROWN 0x06 +#define EFI_LIGHTGRAY 0x07 +#define EFI_BRIGHT 0x08 +#define EFI_DARKGRAY 0x08 +#define EFI_LIGHTBLUE 0x09 +#define EFI_LIGHTGREEN 0x0a +#define EFI_LIGHTCYAN 0x0b +#define EFI_LIGHTRED 0x0c +#define EFI_LIGHTMAGENTA 0x0d +#define EFI_YELLOW 0x0e +#define EFI_WHITE 0x0f +#define EFI_BACKGROUND_BLACK 0x00 +#define EFI_BACKGROUND_BLUE 0x10 +#define EFI_BACKGROUND_GREEN 0x20 +#define EFI_BACKGROUND_CYAN 0x30 +#define EFI_BACKGROUND_RED 0x40 +#define EFI_BACKGROUND_MAGENTA 0x50 +#define EFI_BACKGROUND_BROWN 0x60 +#define EFI_BACKGROUND_LIGHTGRAY 0x70 + +#define EFI_ATTR_FG(attr) ((attr) & 0x0f) +#define EFI_ATTR_BG(attr) (((attr) >> 4) & 0x7) + struct efi_simple_text_output_protocol { void *reset; efi_status_t (EFIAPI *output_string)( diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 2e13fdc096..fcd65ca488 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -316,12 +316,42 @@ static efi_status_t EFIAPI efi_cout_set_mode( return EFI_EXIT(EFI_SUCCESS); } +static const struct { + unsigned fg; + unsigned bg; +} color[] = { + { 30, 40 }, /* 0: black */ + { 34, 44 }, /* 1: blue */ + { 32, 42 }, /* 2: green */ + { 36, 46 }, /* 3: cyan */ + { 31, 41 }, /* 4: red */ + { 35, 45 }, /* 5: magenta */ + { 30, 40 }, /* 6: brown, map to black */ + { 37, 47 }, /* 7: light grey, map to white */ + { 37, 47 }, /* 8: bright, map to white */ + { 34, 44 }, /* 9: light blue, map to blue */ + { 32, 42 }, /* A: light green, map to green */ + { 36, 46 }, /* B: light cyan, map to cyan */ + { 31, 41 }, /* C: light red, map to red */ + { 35, 45 }, /* D: light magenta, map to magenta */ + { 33, 43 }, /* E: yellow */ + { 37, 47 }, /* F: white */ +}; + static efi_status_t EFIAPI efi_cout_set_attribute( struct efi_simple_text_output_protocol *this, unsigned long attribute) { + unsigned fg = EFI_ATTR_FG(attribute); + unsigned bg = EFI_ATTR_BG(attribute); + EFI_ENTRY("%p, %lx", this, attribute); + if (attribute) + printf(ESC"[%u;%um", color[fg].fg, color[bg].bg); + else + printf(ESC"[37;40m"); + /* Just ignore attributes (colors) for now */ return EFI_EXIT(EFI_UNSUPPORTED); } From patchwork Sun Sep 10 13:22:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 812142 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZK3zZgRd"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xqsKj0F2Qz9s7g for ; Sun, 10 Sep 2017 23:27:04 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 9FA3FC21EDB; Sun, 10 Sep 2017 13:26:00 +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, 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 4A1D3C21F3A; Sun, 10 Sep 2017 13:24:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B8973C21E40; Sun, 10 Sep 2017 13:23:23 +0000 (UTC) Received: from mail-qk0-f193.google.com (mail-qk0-f193.google.com [209.85.220.193]) by lists.denx.de (Postfix) with ESMTPS id 27CE9C21F21 for ; Sun, 10 Sep 2017 13:23:14 +0000 (UTC) Received: by mail-qk0-f193.google.com with SMTP id c69so4063059qke.5 for ; Sun, 10 Sep 2017 06:23:14 -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=r/bhCAJ8JDz2goG1KgDPPLDzuaAvPHuu7Eu9hHjwt5s=; b=ZK3zZgRdSWApwWwmtBcSllIWDRu52MlF2zb2qgNeASIwRliuAP9jH8d26kMqQSZuf5 tM5HphvJKaKNGpk/zoZ6CkFadgnbOIOSOROewa4KrH4orLYu76kA1mcHKItXzvSfX8JJ hHiBwIuv7I3lr8DvsjQBgJkAMKyVYjELtzeXdFnkq8YynqWm/5EFjzyvD6FAWiI3XCL3 MxTWXg00OgQ4V2l1IMyw8nOCui0qYEpTYgXInk5WFBIvh5VoXazG2l1TKZOroHP+RfSu ROL6Ld87pVKIOoLM/6jxt6UbTSsIa6i/5XbkJsH+KnCISitJVjAtirL1IGNe1ZkDkyUQ lo7g== 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=r/bhCAJ8JDz2goG1KgDPPLDzuaAvPHuu7Eu9hHjwt5s=; b=Fi4GvjLgsrkcGHopnUtmuYTj8InYaDCP5efoZt6tytBstSRsy5cM6s2scqbnAxovti 1/EY2z8oBBiWY4SiP1djA+IsESVRpj+6q6XJ7slYt0swaLjRfLdqeuYaunrsRhHFkmDG s1634jrFSidkvflyQNeCFd2yUw7VWTSKMNpHZw0Efu7tjWL1qVYNSmWBk72+9nhPAXSj uVxqAncXpVZ7RNevEBUnf3lhgM30TZnbbb7H4CtpCDfKGwsAW+oHi/9hZ3MScj/v3a08 sX+FS2V4bWZwOlQsCPQ2zP9uo/TZyzorUQDDY8ttOvxGpo3Df+EOOGnG3UXg4INBGdH/ DuXw== X-Gm-Message-State: AHPjjUhjm63HnwhM/dZWQDoz9MGStb0Hvyyv/OClPUPR4IBXwuAERgwf uPQzCVlfjhaClr+jTBI= X-Google-Smtp-Source: AOwi7QDUPHtuSn9YDvudAvlM2jV0P1h7tRmPat/mAFFyBvcsWTtS//48x+MWJ9fMRLFIs7z//eLIvw== X-Received: by 10.55.18.137 with SMTP id 9mr11763126qks.208.1505049792505; Sun, 10 Sep 2017 06:23:12 -0700 (PDT) Received: from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a]) by smtp.gmail.com with ESMTPSA id t65sm4364713qke.12.2017.09.10.06.23.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Sep 2017 06:23:11 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Sun, 10 Sep 2017 09:22:30 -0400 Message-Id: <20170910132236.14318-10-robdclark@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170910132236.14318-1-robdclark@gmail.com> References: <20170910132236.14318-1-robdclark@gmail.com> Cc: Heinrich Schuchardt , Leif Lindholm Subject: [U-Boot] [PATCH v1 09/12] dm: video: Fix cache flushes 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" Content can come to screen via putc() and we cannot always rely on updates ending with a puts(). This is the case with efi_console output to vidconsole. Fixes corruption with Shell.efi. Signed-off-by: Rob Clark Acked-by: Heinrich Schuchardt --- drivers/video/vidconsole-uclass.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index b5afd72227..e081d5a0ee 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -163,6 +163,7 @@ static void vidconsole_putc(struct stdio_dev *sdev, const char ch) struct udevice *dev = sdev->priv; vidconsole_put_char(dev, ch); + video_sync(dev->parent); } static void vidconsole_puts(struct stdio_dev *sdev, const char *s) @@ -260,6 +261,8 @@ static int do_video_puts(cmd_tbl_t *cmdtp, int flag, int argc, for (s = argv[1]; *s; s++) vidconsole_put_char(dev, *s); + video_sync(dev->parent); + return 0; } From patchwork Sun Sep 10 13:22:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 812147 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NWutoXP7"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xqsMj15rpz9s7g for ; Sun, 10 Sep 2017 23:28:49 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id DE653C21F56; Sun, 10 Sep 2017 13:25:41 +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, 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 AEB75C21F75; Sun, 10 Sep 2017 13:23:49 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3C266C21E74; Sun, 10 Sep 2017 13:23:26 +0000 (UTC) Received: from mail-qk0-f196.google.com (mail-qk0-f196.google.com [209.85.220.196]) by lists.denx.de (Postfix) with ESMTPS id 3B71DC21F45 for ; Sun, 10 Sep 2017 13:23:17 +0000 (UTC) Received: by mail-qk0-f196.google.com with SMTP id o77so4071278qke.2 for ; Sun, 10 Sep 2017 06:23:17 -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=GnCbt6wDutOp1Its48Jw1KJBVrf0O/Td7i8nyOgJjQA=; b=NWutoXP7nSlXD8QxNZdmrtDGHRiHdZfY9FLDuaZxAgDWMSCKX7TOkR1JjjzaXyR7h0 V7aOvWBLK4DPVxG6zIbE/kpoNlcrUt1KYQBJpxRBcVpyi4Uj3PMYCLwrx8oPw9nFVucH 27xwbuwX6cocULjucyswWlXjZGXUL9E01CkRhijghzNejUqrKcVtxlyfLvyNkeCfda3P yIF1SWYe1Z3atUL+dy7+MUscdMr7Devm+LxOpURuY63oYpBpZAyKnm1t5LNOdS90efgq h06zDMqW9UgTLNs78skyMwM0HKdfnvi4BTVIOy2Dam4ce2vCp/8MHWJM9VFGVZKH+UVE VMEw== 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=GnCbt6wDutOp1Its48Jw1KJBVrf0O/Td7i8nyOgJjQA=; b=t4W2cOwn1b+HaCEvJiogH/j2xOJgrqRhv1LtZAuC7dmBHMZRZXSkzit6QDl0LFiYki +Df98uAU4eVSynQsVIYdU1qzPx9ik/bc5lM49456uwHujLcbXxo1lNxQGcsXr3T3Umwc 8QmbiE+Kgol+eHgJ2iQxxPcidQyvsfK9pZLScMcjUHUID0VX6ZH5CtvkTPlq1TNC71zJ f3sD6rYkJnO6F1Y0Gmzxrb64ppNYb/wD+2C1DWbx5MjSSek/+oaI+p260T84FooowrJX JPh9yysHVP8fBO+/HSQuYF4/EaXjqDcT3Ivmq7KhfWtmGeEmFOhVhvi9tswSzPYCGEA8 8wAg== X-Gm-Message-State: AHPjjUjX8HPX2PH8fGW01cxLs8JemiACHNyoFFd96cW5wfzYoqAp5BqN IvpdgCL3G3BcCzourVI= X-Google-Smtp-Source: AOwi7QB+WYqj917GWZexMVZQh2rGQJdNuJD3shb3AlahdiaVzhEDNdMZtZ0ihgUbjqPjAGMWq5c4Zg== X-Received: by 10.233.244.72 with SMTP id z8mr11594013qkl.186.1505049795877; Sun, 10 Sep 2017 06:23:15 -0700 (PDT) Received: from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a]) by smtp.gmail.com with ESMTPSA id m29sm3490521qtk.58.2017.09.10.06.23.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Sep 2017 06:23:14 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Sun, 10 Sep 2017 09:22:31 -0400 Message-Id: <20170910132236.14318-11-robdclark@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170910132236.14318-1-robdclark@gmail.com> References: <20170910132236.14318-1-robdclark@gmail.com> Cc: Heinrich Schuchardt , Leif Lindholm Subject: [U-Boot] [PATCH v1 10/12] dm: video: Add basic ANSI escape sequence support 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" Really just the subset that is needed by efi_console. Perhaps more will be added later, for example color support would be useful to implement efi_cout_set_attribute(). Signed-off-by: Rob Clark --- drivers/video/vidconsole-uclass.c | 112 ++++++++++++++++++++++++++++++++++++++ drivers/video/video-uclass.c | 4 +- include/video.h | 7 +++ include/video_console.h | 11 ++++ 4 files changed, 131 insertions(+), 3 deletions(-) diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index e081d5a0ee..7998b4cf5f 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -107,12 +108,123 @@ static void vidconsole_newline(struct udevice *dev) video_sync(dev->parent); } +/* + * Parse a number from string that ends in a non-numeric character.. + * sscanf() would be nice. This is just enough for parsing ANSI escape + * sequences. + */ +static char *parsenum(char *s, int *num) +{ + int n = 0; + + while (isdigit(*s)) { + n = (10 * n) + (*s - '0'); + s++; + } + + *num = n; + return s; +} + +static void vidconsole_escape_char(struct udevice *dev, char ch) +{ + struct vidconsole_priv *priv = dev_get_uclass_priv(dev); + + /* Sanity checking for bogus ESC sequences: */ + if (priv->escape_len >= sizeof(priv->escape_buf)) + goto error; + if (priv->escape_len == 0 && ch != '[') + goto error; + + priv->escape_buf[priv->escape_len++] = ch; + + /* + * Escape sequences are terminated by a letter, so keep + * accumulating until we get one: + */ + if (!isalpha(ch)) + return; + + /* + * clear escape mode first, otherwise things will get highly + * surprising if you hit any debug prints that come back to + * this console. + */ + priv->escape = 0; + + switch (ch) { + case 'H': + case 'f': { + int row, col; + char *s = priv->escape_buf; + + /* + * Set cursor position: [%d;%df or [%d;%dH + */ + s++; /* [ */ + s = parsenum(s, &row); + s++; /* ; */ + s = parsenum(s, &col); + + priv->ycur = row * priv->y_charsize; + priv->xcur_frac = priv->xstart_frac + + VID_TO_POS(col * priv->x_charsize); + + break; + } + case 'J': { + int mode; + + /* + * Clear part/all screen: + * [J or [0J - clear screen from cursor down + * [1J - clear screen from cursor up + * [2J - clear entire screen + * + * TODO we really only handle entire-screen case, others + * probably require some additions to video-uclass (and + * are not really needed yet by efi_console) + */ + parsenum(priv->escape_buf + 1, &mode); + + if (mode == 2) { + video_clear(dev->parent); + video_sync(dev->parent); + priv->ycur = 0; + priv->xcur_frac = priv->xstart_frac; + } else { + debug("unsupported clear mode: %d\n", mode); + } + break; + } + default: + debug("unrecognized escape sequence: %*s\n", + priv->escape_len, priv->escape_buf); + } + + return; + +error: + /* something went wrong, just revert to normal mode: */ + priv->escape = 0; + return; +} + int vidconsole_put_char(struct udevice *dev, char ch) { struct vidconsole_priv *priv = dev_get_uclass_priv(dev); int ret; + if (priv->escape) { + vidconsole_escape_char(dev, ch); + return 0; + } + switch (ch) { + case '\x1b': + priv->escape_len = 0; + priv->escape = 1; + break; case '\a': /* beep */ break; diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 3036e3a1f2..0163039821 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -87,7 +87,7 @@ int video_reserve(ulong *addrp) return 0; } -static int video_clear(struct udevice *dev) +void video_clear(struct udevice *dev) { struct video_priv *priv = dev_get_uclass_priv(dev); @@ -100,8 +100,6 @@ static int video_clear(struct udevice *dev) } else { memset(priv->fb, priv->colour_bg, priv->fb_size); } - - return 0; } /* Flush video activity to the caches */ diff --git a/include/video.h b/include/video.h index 5b4e78b182..61ff653121 100644 --- a/include/video.h +++ b/include/video.h @@ -115,6 +115,13 @@ struct video_ops { int video_reserve(ulong *addrp); /** + * video_clear() - Clear a device's frame buffer to background color. + * + * @dev: Device to clear + */ +void video_clear(struct udevice *dev); + +/** * video_sync() - Sync a device's frame buffer with its hardware * * Some frame buffers are cached or have a secondary frame buffer. This diff --git a/include/video_console.h b/include/video_console.h index 26047934da..9dce234bd9 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -29,6 +29,9 @@ * @xsize_frac: Width of the display in fractional units * @xstart_frac: Left margin for the text console in fractional units * @last_ch: Last character written to the text console on this line + * @escape: TRUE if currently accumulating an ANSI escape sequence + * @escape_len: Length of accumulated escape sequence so far + * @escape_buf: Buffer to accumulate escape sequence */ struct vidconsole_priv { struct stdio_dev sdev; @@ -42,6 +45,14 @@ struct vidconsole_priv { int xsize_frac; int xstart_frac; int last_ch; + /* + * ANSI escape sequences are accumulated character by character, + * starting after the ESC char (0x1b) until the entire sequence + * is consumed at which point it is acted upon. + */ + int escape; + int escape_len; + char escape_buf[32]; }; /** From patchwork Sun Sep 10 13:22:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 812146 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IkGB8ZpK"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xqsMR6M8Cz9s7g for ; Sun, 10 Sep 2017 23:28:35 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 902E3C21E8C; Sun, 10 Sep 2017 13:27:09 +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, 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 66F96C21F9C; Sun, 10 Sep 2017 13:24:11 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A8A9DC21F7E; Sun, 10 Sep 2017 13:23:29 +0000 (UTC) Received: from mail-qk0-f195.google.com (mail-qk0-f195.google.com [209.85.220.195]) by lists.denx.de (Postfix) with ESMTPS id 08936C21F26 for ; Sun, 10 Sep 2017 13:23:20 +0000 (UTC) Received: by mail-qk0-f195.google.com with SMTP id r66so3910387qke.4 for ; Sun, 10 Sep 2017 06:23:19 -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=pSolHKWIFOYLriYRoaJrrVzZEfv3e0nodFSb8VLTvys=; b=IkGB8ZpK5bj3JzTcZFf/edG9GM+Q9xqR8G24TxdMoBb4ilAuXhVbVLSyOE05qpmEvC BFpmU+PaSXDPfTcD2e7B1HfwSVc3EpB/GJYz1mLu+cIhiRhQqdJm9VBqnHEgiKFkkwFp TpBwHzNFvG85Z+bGDqHTA4G4+WywP9d2wFx7IESxIAV00H2BzxP1xDHvcZUdViY+y1Kr tY7Lg7fduJAjGv9PT1BtP2pczI52n4zmUjZ7CgkyfdTmyK/0d6h6bM1JrrnyuCboSpiR dzc214NcqcFC9NBEV3d1SGKNqdmz69jZ0MRki1sglLnee4y3sEZUF6sZA98QsX5ETGya xUeA== 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=pSolHKWIFOYLriYRoaJrrVzZEfv3e0nodFSb8VLTvys=; b=XYSXfJNx0GIMhS9quiMvi7ZCiP4TSYt1bRBScOLap6c56TOTWGDS2uPsYf/ZE5SALy ignvvEdNqVfVVKCha1v/TId1Xt2GB7HRIDhXQSApqX4fjOw8Nl3YL1Bl7077d9+jJb+k 6X2JqMnMlA2PPSqImMtrhzkdbU2+Y9UEx5wxgZkAcHkVIi9w8ANhbg8LfVdtwo2ulhqk dJp/zBVt0Rgr6xUeu3zGx1aks/bM8S17eKktFmX7Q/d8Q5d2NTNHJfPpyMYk7H36MVYE 4SK25K4bcAVZ/G7l5mBvDulwRZUZZcW0T0FtVuU06MnqNSuWpIgs74N6H/xg0lvE0E4M tMkQ== X-Gm-Message-State: AHPjjUgiJU9ILdCuR13IYr3ehjABNXmeR5p4Sqt0QNTyYZ5w4TS6Bknm d4+4xP9ZOC0HdsQuq1s= X-Google-Smtp-Source: ADKCNb747oukZBi7ORFsqjCBqBLXfi/JHPKcy87+WT4qnEbFR3J9hbmpVNrFgK5VrrwArbJvTT8lXQ== X-Received: by 10.55.141.66 with SMTP id p63mr11236283qkd.210.1505049798745; Sun, 10 Sep 2017 06:23:18 -0700 (PDT) Received: from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a]) by smtp.gmail.com with ESMTPSA id m14sm4407130qti.51.2017.09.10.06.23.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Sep 2017 06:23:17 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Sun, 10 Sep 2017 09:22:32 -0400 Message-Id: <20170910132236.14318-12-robdclark@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170910132236.14318-1-robdclark@gmail.com> References: <20170910132236.14318-1-robdclark@gmail.com> Cc: Heinrich Schuchardt , Leif Lindholm Subject: [U-Boot] [PATCH v1 11/12] dm: video: Add color ANSI escape sequence support 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" Note that this doesn't differentiate (due to lack of information in video_priv) between different possible component orders for 32bpp. But the main user at this point is efi_loader, and GOP expects xBGR so any video drivers that this is incorrect for already have problems. (Also, conveniently, this matches what simple-framebuffer bindings expect for kernels that use the simple-framebuffer DT binding to take over the bootloader display.) Signed-off-by: Rob Clark --- drivers/video/vidconsole-uclass.c | 94 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 7998b4cf5f..dae65a21ed 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -108,6 +108,41 @@ static void vidconsole_newline(struct udevice *dev) video_sync(dev->parent); } +static const struct { + unsigned r; + unsigned g; + unsigned b; +} colors[] = { + { 0x00, 0x00, 0x00 }, /* black */ + { 0xff, 0x00, 0x00 }, /* red */ + { 0x00, 0xff, 0x00 }, /* green */ + { 0xff, 0xff, 0x00 }, /* yellow */ + { 0x00, 0x00, 0xff }, /* blue */ + { 0xff, 0x00, 0xff }, /* magenta */ + { 0x00, 0xff, 0xff }, /* cyan */ + { 0xff, 0xff, 0xff }, /* white */ +}; + +static void set_color(struct video_priv *priv, unsigned idx, unsigned *c) +{ + switch (priv->bpix) { + case VIDEO_BPP16: + *c = ((colors[idx].r >> 3) << 0) | + ((colors[idx].g >> 2) << 5) | + ((colors[idx].b >> 3) << 11); + break; + case VIDEO_BPP32: + *c = 0xff000000 | + (colors[idx].r << 0) | + (colors[idx].g << 8) | + (colors[idx].b << 16); + break; + default: + /* unsupported, leave current color in place */ + break; + } +} + /* * Parse a number from string that ends in a non-numeric character.. * sscanf() would be nice. This is just enough for parsing ANSI escape @@ -197,6 +232,65 @@ static void vidconsole_escape_char(struct udevice *dev, char ch) } break; } + case 'm': { + struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); + char *s = priv->escape_buf; + char *end = &priv->escape_buf[priv->escape_len]; + + /* + * Set graphics mode: [%d;...;%dm + * + * Currently only supports the color attributes: + * + * Foreground Colors: + * + * 30 Black + * 31 Red + * 32 Green + * 33 Yellow + * 34 Blue + * 35 Magenta + * 36 Cyan + * 37 White + * + * Background Colors: + * + * 40 Black + * 41 Red + * 42 Green + * 43 Yellow + * 44 Blue + * 45 Magenta + * 46 Cyan + * 47 White + */ + + s++; /* [ */ + while (s < end) { + int val; + + s = parsenum(s, &val); + s++; + + switch (val) { + case 30 ... 37: + /* fg color */ + set_color(vid_priv, val - 30, + (unsigned *)&vid_priv->colour_fg); + break; + case 40 ... 47: + /* bg color */ + set_color(vid_priv, val - 40, + (unsigned *)&vid_priv->colour_bg); + break; + default: + /* unknown/unsupported */ + break; + } + } + + break; + } default: debug("unrecognized escape sequence: %*s\n", priv->escape_len, priv->escape_buf); From patchwork Sun Sep 10 13:22:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 812148 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dh2ZclPn"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xqsMz0f1rz9s7g for ; Sun, 10 Sep 2017 23:29:03 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id D48DCC21EE4; Sun, 10 Sep 2017 13:26: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_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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 53153C21E1D; Sun, 10 Sep 2017 13:24:10 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id CD902C21F94; Sun, 10 Sep 2017 13:23:32 +0000 (UTC) Received: from mail-qk0-f172.google.com (mail-qk0-f172.google.com [209.85.220.172]) by lists.denx.de (Postfix) with ESMTPS id D7EEFC21F56 for ; Sun, 10 Sep 2017 13:23:23 +0000 (UTC) Received: by mail-qk0-f172.google.com with SMTP id b82so14298512qkc.4 for ; Sun, 10 Sep 2017 06:23:23 -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=FVOt/YC/ElIJ+vQG6Z0RsNRlZ0fWOtQcY9X24GXgOrg=; b=dh2ZclPn9scRVi3G6OUHmdS8ygw6PhoFSuVwPWABV30iF3kOQEdO83h4DTqkDLY88o MGRmx3dY61ge4sFdyO4LIgEbGakuGYJGNg/zr4JNhA2ly1bN4XC8H/23PkbrHsm/DF9H ujzNaxkY3PaSyLHMq/t53axUf3JBjaV3/vkOuDiE1b0jQgwjFHBv/LxeFX/8yDjR4pAD artKyjwMUfWvJuomWkWJvykrmTUlgYJTr2NA+36w7htzQm2DK5OfmRj0gNNxz04gbI5B 80f/KuTKMwgOiB9BbZ3Mh7NU6saznqbebt6oBxv1EZEvdT4j5sbgMSNfSyEll2HP2qJi M/nA== 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=FVOt/YC/ElIJ+vQG6Z0RsNRlZ0fWOtQcY9X24GXgOrg=; b=AN91SYlILDh+irr51uZhIhc7FV/4QzHBkcFH6GsOrfNJAW7ltAplMGZG+jeWtUjmeA D34TamKQQdDMp6HLgxsrKEDsnjvVJ0AZrqLTVgKxQcJ5LFYiC/A7na8suXrFmBdwoW2w US3UJScxa+MvUsKtFTl6aKLCPlWR4ZQubAAMktV7yBRSXYoMB0zpbc/WXD+jZAWUzW+r k++zPnvkDCrlnXLZ3U4evtM7PK3Y2olvZZAQcV8Gtosd2kj+XG3UnkIfMuuZJXcRMS2c QdYaIXQn09h+mNgVdQOgGfXsav5zebwgkhYw3Q4C4rgM/NYYtPLECTdGYukRWHGZk9PC r7gA== X-Gm-Message-State: AHPjjUiRSw/mCg+ncemYji40k14GST7VRdOnl0W1ZkVXR7sfcQHiRaAP +p/ZysaXQ0nS5tDGqIw= X-Google-Smtp-Source: AOwi7QBWDhBwPW44VcIusomxaLTWQ8bjfgSJKfBG1PUSvPe21/sKosyHtB/Q5pxlpCUvrL6D8lDpMw== X-Received: by 10.55.165.81 with SMTP id o78mr10891944qke.313.1505049802570; Sun, 10 Sep 2017 06:23:22 -0700 (PDT) Received: from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a]) by smtp.gmail.com with ESMTPSA id g31sm4526589qtg.21.2017.09.10.06.23.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Sep 2017 06:23:21 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Sun, 10 Sep 2017 09:22:33 -0400 Message-Id: <20170910132236.14318-13-robdclark@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170910132236.14318-1-robdclark@gmail.com> References: <20170910132236.14318-1-robdclark@gmail.com> Cc: Heinrich Schuchardt , Leif Lindholm Subject: [U-Boot] [PATCH v1 12/12] HACK: efi_loader: hacks for SCT 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" Not intended to be merged, just to show the remaning TODOs to get SCT.efi working. --- include/config_distro_bootcmd.h | 2 +- lib/efi_loader/efi_boottime.c | 4 ++-- lib/efi_loader/efi_console.c | 3 ++- lib/efi_loader/efi_file.c | 11 +++++++++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h index e0d0034ed3..e232a62996 100644 --- a/include/config_distro_bootcmd.h +++ b/include/config_distro_bootcmd.h @@ -88,7 +88,7 @@ #ifdef CONFIG_EFI_LOADER #if defined(CONFIG_ARM64) -#define BOOTEFI_NAME "bootaa64.efi" +#define BOOTEFI_NAME "shell.efi" #elif defined(CONFIG_ARM) #define BOOTEFI_NAME "bootarm.efi" #endif diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 9628bef474..5db8ea9090 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -172,7 +172,7 @@ static efi_status_t efi_unsupported(const char *funcname) static unsigned long EFIAPI efi_raise_tpl(UINTN new_tpl) { EFI_ENTRY("0x%zx", new_tpl); - return EFI_EXIT(0); + return EFI_EXIT(TPL_APPLICATION); } static void EFIAPI efi_restore_tpl(UINTN old_tpl) @@ -1021,7 +1021,7 @@ static efi_status_t EFIAPI efi_set_watchdog_timer(unsigned long timeout, { EFI_ENTRY("%ld, 0x%"PRIx64", %ld, %p", timeout, watchdog_code, data_size, watchdog_data); - return efi_unsupported(__func__); + return EFI_EXIT(EFI_SUCCESS); } static efi_status_t EFIAPI efi_connect_controller( diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index fcd65ca488..139f7ea55b 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -561,7 +561,8 @@ static efi_status_t EFIAPI efi_cin_ex_register_key_notify( efi_handle_t *notify_handle) { EFI_ENTRY("%p, %p, %p", this, notify_fn, notify_handle); - return EFI_EXIT(EFI_OUT_OF_RESOURCES); +// return EFI_EXIT(EFI_OUT_OF_RESOURCES); + return EFI_EXIT(EFI_SUCCESS); } static efi_status_t EFIAPI efi_cin_ex_unregister_key_notify( diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c index 118d83ad7c..d66b0d0370 100644 --- a/lib/efi_loader/efi_file.c +++ b/lib/efi_loader/efi_file.c @@ -218,8 +218,8 @@ static efi_status_t EFIAPI efi_file_delete(struct efi_file_handle *file) { struct file_handle *fh = to_fh(file); EFI_ENTRY("%p", file); - file_close(fh); - return EFI_EXIT(EFI_WARN_DELETE_FAILURE); + // TODO need fs_rm().. + return EFI_EXIT(file_close(fh)); } static efi_status_t file_read(struct file_handle *fh, u64 *buffer_size, @@ -340,6 +340,13 @@ static efi_status_t EFIAPI efi_file_write(struct efi_file_handle *file, EFI_ENTRY("%p, %p, %p", file, buffer_size, buffer); + // XXX hack because fat_write is horrible: + if (!fs_exists(fh->path)) { + char *p = fh->path; + while ((p = strchr(p, '/'))) + *p++ = '_'; + } + if (set_blk_dev(fh)) { ret = EFI_DEVICE_ERROR; goto error;