From nobody Thu Apr 25 06:47:53 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555012911; cv=none; d=zoho.com; s=zohoarc; b=kR7oI2iojMy5Dv0UnWx+TeqRDhv0AdWgV/C9dekPqUGsSuuNhrxxjYpUipM+uZf0o0Qm/w8rbMosdpwxCkY5ZGvrM0V5ux22Dt4HPuXu27Tbu7envN/VL+MAVse56QCuXY6LoyXf6weVWqeh0bxW+R6KePjSqxLBGU5u7iO7rQc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555012911; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Subject:To:ARC-Authentication-Results; bh=VrgZI/ep1cf/1Y+gikqydDw75/yCDcT6GVanZ79s0rQ=; b=MRTk0gxs9R488VCBZAc7HxrMDsy1tZWsH5H6N1iQxYrFViconQUtSF4b2Ter3rEAQ+btSAd3z7A3BRs9KE0SFFfwHhPiSAxA3VnN3vTdRC31WfyHaoCgCG6u4JewlWmOvHR12njhJATi7mfRB8sxzgnbD+5j+XGkaXx6W4cOoj4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1555012911439103.0559646195378; Thu, 11 Apr 2019 13:01:51 -0700 (PDT) Received: from [192.168.203.99] (mailu_mailman-core_1.mailu_default [192.168.203.99]) by coreboot.org (Postfix) with ESMTP id 1081F116108C; Thu, 11 Apr 2019 20:01:47 +0000 (UTC) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by coreboot.org (Postfix) with ESMTP id 54C101161089 for ; Thu, 11 Apr 2019 20:01:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E110430EBB34 for ; Thu, 11 Apr 2019 20:01:33 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-65.ams2.redhat.com [10.36.116.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67D1319C58; Thu, 11 Apr 2019 20:01:31 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id A0E2516E03; Thu, 11 Apr 2019 22:01:30 +0200 (CEST) From: Gerd Hoffmann To: seabios@seabios.org Date: Thu, 11 Apr 2019 22:01:20 +0200 Message-Id: <20190411200120.4594-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 11 Apr 2019 20:01:33 +0000 (UTC) Message-ID-Hash: NZJVBHM34XRB6DDQ6OLQ4QRF6QLLHACO X-Message-ID-Hash: NZJVBHM34XRB6DDQ6OLQ4QRF6QLLHACO X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Gerd Hoffmann X-Mailman-Version: 3.2.2 Precedence: list Subject: [SeaBIOS] [PATCH v2] bootmenu: add support for more than 9 entries List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: ++++ X-Spam-Level: **** Authentication-Results: coreboot.org Content-Type: text/plain; charset="utf-8" 10th and following entries can be selected using letters. Signed-off-by: Gerd Hoffmann --- src/util.h | 1 + src/boot.c | 49 ++++++++++++++++++++++++++++++++++--------------- src/kbd.c | 19 +++++++++++++++++-- 3 files changed, 52 insertions(+), 17 deletions(-) diff --git a/src/util.h b/src/util.h index 9c06850353a4..c8e3b818d23e 100644 --- a/src/util.h +++ b/src/util.h @@ -189,6 +189,7 @@ void handle_15c2(struct bregs *regs); void process_key(u8 key); u8 enqueue_key(u16 keycode); u16 ascii_to_keycode(u8 ascii); +u16 ascii_to_scancode(u8 ascii); =20 // misc.c extern int HaveRunPost; diff --git a/src/boot.c b/src/boot.c index 9f82f3ca0c3e..43160f8ee5b9 100644 --- a/src/boot.c +++ b/src/boot.c @@ -465,6 +465,14 @@ get_keystroke(int msec) =20 #define DEFAULT_BOOTMENU_WAIT 2500 =20 +static const char menuchars[] =3D { + '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', + 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', + 's', /* skip t (tpm menu) */ + 'u', 'v', 'w', 'x', 'y', 'z' +}; + // Show IPL option menu. void interactive_bootmenu(void) @@ -497,12 +505,15 @@ interactive_bootmenu(void) =20 // Show menu items int maxmenu =3D 0; - struct bootentry_s *pos; + struct bootentry_s *pos, *boot =3D NULL; hlist_for_each_entry(pos, &BootList, node) { char desc[77]; - maxmenu++; - printf("%d. %s\n", maxmenu + if (maxmenu >=3D ARRAY_SIZE(menuchars)) { + break; + } + printf("%c. %s\n", menuchars[maxmenu] , strtcpy(desc, pos->description, ARRAY_SIZE(desc))); + maxmenu++; } if (tpm_can_show_menu()) { printf("\nt. TPM Configuration\n"); @@ -521,23 +532,31 @@ interactive_bootmenu(void) printf("\n"); tpm_menu(); } - if (scan_code >=3D 1 && scan_code <=3D maxmenu+1) + if (scan_code =3D=3D 1) { + // ESC + printf("\n"); + return; + } + + maxmenu =3D 0; + hlist_for_each_entry(pos, &BootList, node) { + if (maxmenu >=3D ARRAY_SIZE(menuchars)) + break; + if (scan_code =3D=3D ascii_to_scancode(menuchars[maxmenu])) { + boot =3D pos; + break; + } + maxmenu++; + } + if (boot) break; } printf("\n"); - if (scan_code =3D=3D 0x01) - // ESC - return; =20 // Find entry and make top priority. - int choice =3D scan_code - 1; - hlist_for_each_entry(pos, &BootList, node) { - if (! --choice) - break; - } - hlist_del(&pos->node); - pos->priority =3D 0; - hlist_add_head(&pos->node, &BootList); + hlist_del(&boot->node); + boot->priority =3D 0; + hlist_add_head(&boot->node, &BootList); } =20 // BEV (Boot Execution Vector) list diff --git a/src/kbd.c b/src/kbd.c index 15e5ae789cd3..f54d9fe94287 100644 --- a/src/kbd.c +++ b/src/kbd.c @@ -271,12 +271,12 @@ handle_16(struct bregs *regs) =20 #define none 0 =20 -static struct scaninfo { +struct scaninfo { u16 normal; u16 shift; u16 control; u16 alt; -} scan_to_keycode[] VAR16 =3D { +} scan_to_keycode[] VARFSEG =3D { { none, none, none, none }, { 0x011b, 0x011b, 0x011b, 0x01f0 }, /* escape */ { 0x0231, 0x0221, none, 0x7800 }, /* 1! */ @@ -390,6 +390,21 @@ u16 ascii_to_keycode(u8 ascii) return 0; } =20 +u16 ascii_to_scancode(u8 ascii) +{ + int i; + + for (i =3D 0; i < ARRAY_SIZE(scan_to_keycode); i++) { + if ((GET_GLOBAL(scan_to_keycode[i].normal) & 0xff) =3D=3D ascii) + return i; + if ((GET_GLOBAL(scan_to_keycode[i].shift) & 0xff) =3D=3D ascii) + return i; + if ((GET_GLOBAL(scan_to_keycode[i].control) & 0xff) =3D=3D ascii) + return i; + } + return 0; +} + // Handle a ps2 style scancode read from the keyboard. static void kbd_set_flag(int key_release, u16 set_bit0, u8 set_bit1, u16 toggle_bit) --=20 2.18.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org