Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D7F4C433F5 for ; Sat, 25 Sep 2021 00:37:00 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A816B61039 for ; Sat, 25 Sep 2021 00:36:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A816B61039 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1CB6683569; Sat, 25 Sep 2021 02:36:13 +0200 (CEST) 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="dAG578Sv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1A380834E3; Sat, 25 Sep 2021 02:32:26 +0200 (CEST) Received: from mail-oo1-xc2b.google.com (mail-oo1-xc2b.google.com [IPv6:2607:f8b0:4864:20::c2b]) (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 4A5488350D for ; Sat, 25 Sep 2021 02:31:25 +0200 (CEST) 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-oo1-xc2b.google.com with SMTP id w6-20020a4aa446000000b002b5795cca03so1279329ool.6 for ; Fri, 24 Sep 2021 17:31:25 -0700 (PDT) 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=hHeESoTQfDuuNke70C5Z2Swni4S7vmko3MUZOIUCwic=; b=dAG578Sv2faOdSMDfK8PxEHifmqo9j9EpDJ40rXXd9VbQ9NlnANv2KVUOUiWtIiETJ Wr605J39F8R1OfueK0PLT5OrhHH0iMfSPodOY++Tg5V1jVB3UBlc85l1NYz4TQ78nsXZ jc8kWR+KTTt2W+bDMF3It22r+4JLpNJ43/xBk= 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=hHeESoTQfDuuNke70C5Z2Swni4S7vmko3MUZOIUCwic=; b=cCntPetZwR39dme7CZCaRSS6SCSVUmx19xdeRHT71TPwQftfa8NyHPNd0MLoTudtpn eD/gf//+bAOx0T+m24Ld0Sdk/28Uh4yzv79etWSpt7BAaRyltiUGzFcnLznuZ3OEQ9WT uxLb9Pycu1WFg2NEN8bXowp/PXqkxBcNomfehHaESlE8Oe/zqxvBzUgNENdYVaYHFKGK wMERMRMo17zrW+CPtt4O1Y8Y+qkRbkfZYnu1lXi0b1f5S3BkPSwygiErcrKkSCMsazNG aq5N/FLTIpIVfmctF6lcE7F3xQu9Rw9gbg+deQlC3eNwwdCJTKOx3Ycf2846PCc4dy8k SZLQ== X-Gm-Message-State: AOAM533SLD4O9ZU4JF8tLVyt8TbFRgv77CoAiGY42X7Zv1HnG4flh6xa bbd8Y+jFg4GqS217+ahKXEIarr8r6+vO0A== X-Google-Smtp-Source: ABdhPJyj80l2FcFwAvcpin8Wx2U8JM1uhYaYwxzkYbHhoWv8bR0o/XjSLZjZ4MGMqYLvUso/pjglvg== X-Received: by 2002:a4a:c592:: with SMTP id x18mr10902052oop.54.1632529883578; Fri, 24 Sep 2021 17:31:23 -0700 (PDT) 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 y83sm2491462oia.47.2021.09.24.17.31.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 17:31:23 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Bin Meng , Christian Melki , Tom Rini , Ilias Apalodimas , Simon Glass , Alexander Graf Subject: [PATCH v2 24/39] efi: serial: Support arrow keys Date: Fri, 24 Sep 2021 18:30:40 -0600 Message-Id: <20210925003055.759305-9-sjg@chromium.org> X-Mailer: git-send-email 2.33.0.685.g46640cef36-goog In-Reply-To: <20210925003055.759305-1-sjg@chromium.org> References: <20210925003055.759305-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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; -- 2.33.0.685.g46640cef36-goog