From patchwork Sat Dec 4 15:56:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1563608 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=XOrCdnBM; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J5vVS5pj6z9sCD for ; Sun, 5 Dec 2021 02:58:08 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BA5D082FE9; Sat, 4 Dec 2021 16:57:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="XOrCdnBM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 72D2C830C0; Sat, 4 Dec 2021 16:57:27 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A265B83094 for ; Sat, 4 Dec 2021 16:57:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-ot1-x32d.google.com with SMTP id x19-20020a9d7053000000b0055c8b39420bso7679071otj.1 for ; Sat, 04 Dec 2021 07:57:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eTPJUVOIysek8n24LQDKJt7bYe8W6UsHlnNEndBuPkI=; b=XOrCdnBMqVKRYU6mwqGPQNWC4REd8pMNKe5To4eCCQYJVB+ntBZyih9QwFT6tr9E/a xiNrQAth9eRhqVOoHHwbqAfiGyGtQsdZTgFFQTJNCaY0JJ1xu02ej9d8mH81vtHRZUvH Fo4ZMzOklZro7leogB+XCLvgUpMaqAtMPuumk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eTPJUVOIysek8n24LQDKJt7bYe8W6UsHlnNEndBuPkI=; b=UDG43EpdxEpF/hKv+D3z1ZVTkZS4qsbhI8B3SV42v1F4sGR63kC58GMFd+tSsmn85s I/zN7xPif5Zme1QUJH9km0a3m1UnGWF2l8C8YFKlA7eef1f1Y5nLbhsnkGsWfU8I6u5w b4OaLWkD0XT8IhoTV2wL2tEiEqakIPmtWIX3aWjT3Lu3Jc7T8VGbshOe+s8tmdcupXA7 NRYbt5nLF8DNzF7UPQoFEHzCkGPMlojGxlKJ/hKwratISprcSFvSLkWOBdQYPA8vwbn6 Vbe7hZw/wIU3DuiKMezJG/7+xteabAD5ifhdfV0sIO7Gyot/nq9zK7PDpI0FTpgX+JwK kCHw== X-Gm-Message-State: AOAM5308KsgCkJtXNnF9lLf+X8L8povr8bC30cYmwDhwLbTWqtb/8cqX lEV5sX8XMSODluBMuyWcsWO+JRxCb1XfEA== X-Google-Smtp-Source: ABdhPJxTRVDFi+NYgzvhKvCMK8sO3bZPNyMfk9g/xAEFQ/vScuchaWru5X84PEWmdmWFC4fx+NkvaQ== X-Received: by 2002:a05:6830:1392:: with SMTP id d18mr20983597otq.374.1638633436193; Sat, 04 Dec 2021 07:57:16 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id a12sm1230513otk.35.2021.12.04.07.57.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Dec 2021 07:57:15 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Christian Melki , Bin Meng , Heinrich Schuchardt , Tom Rini , Simon Glass , Alexander Graf Subject: [PATCH v5 05/28] efi: serial: Support arrow keys Date: Sat, 4 Dec 2021 08:56:34 -0700 Message-Id: <20211204155657.2913911-2-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog In-Reply-To: <20211204155657.2913911-1-sjg@chromium.org> References: <20211204155657.2913911-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean At present only the backspace key is supported in U-Boot, when running as an EFI app. Add support for arrows, home and end as well, to make the CLI more friendly. Signed-off-by: Simon Glass --- (no changes since v1) drivers/serial/serial_efi.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c index 33ddbd6080c..0067576389d 100644 --- a/drivers/serial/serial_efi.c +++ b/drivers/serial/serial_efi.c @@ -24,6 +24,9 @@ struct serial_efi_priv { bool have_key; }; +/* Convert a lower-case character to its ctrl-char equivalent */ +#define CTL_CH(c) ((c) - 'a' + 1) + int serial_efi_setbrg(struct udevice *dev, int baudrate) { return 0; @@ -49,6 +52,7 @@ static int serial_efi_get_key(struct serial_efi_priv *priv) static int serial_efi_getc(struct udevice *dev) { struct serial_efi_priv *priv = dev_get_priv(dev); + char conv_scan[10] = {0, 'p', 'n', 'f', 'b', 'a', 'e', 0, 8}; int ret, ch; ret = serial_efi_get_key(priv); @@ -63,8 +67,11 @@ static int serial_efi_getc(struct udevice *dev) * key scan code of 8. Handle this so that backspace works correctly * in the U-Boot command line. */ - if (!ch && priv->key.scan_code == 8) - ch = 8; + if (!ch && priv->key.scan_code < sizeof(conv_scan)) { + ch = conv_scan[priv->key.scan_code]; + if (ch >= 'a') + ch -= 'a' - 1; + } debug(" [%x %x %x] ", ch, priv->key.unicode_char, priv->key.scan_code); return ch;