From nobody Sat May 10 07:38:46 2025 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) client-ip=80.81.252.135; envelope-from=seabios-bounces@seabios.org; helo=mail.coreboot.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org Return-Path: Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) by mx.zohomail.com with SMTPS id 1504851546711413.3271337742274; Thu, 7 Sep 2017 23:19:06 -0700 (PDT) Received: from [127.0.0.1] (helo=ra.coreboot.org) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1dqCcV-0002Tf-47; Fri, 08 Sep 2017 08:18:27 +0200 Received: from mx1.redhat.com ([209.132.183.28]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1dqCcL-0002T6-C9 for seabios@seabios.org; Fri, 08 Sep 2017 08:18:24 +0200 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 621607E424 for ; Fri, 8 Sep 2017 06:18:32 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-175.ams2.redhat.com [10.36.117.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3E246BF98; Fri, 8 Sep 2017 06:18:29 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 1079E3FBB7; Fri, 8 Sep 2017 08:18:28 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 621607E424 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: seabios@seabios.org Date: Fri, 8 Sep 2017 08:18:24 +0200 Message-Id: <20170908061828.13732-3-kraxel@redhat.com> In-Reply-To: <20170908061828.13732-1-kraxel@redhat.com> References: <20170908061828.13732-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 08 Sep 2017 06:18:32 +0000 (UTC) X-Spam-Score: -6.5 (------) Subject: [SeaBIOS] [PATCH 2/6] kbd: make enqueue_key public, add ascii_to_keycode X-BeenThere: seabios@seabios.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SeaBIOS mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: seabios-bounces@seabios.org Sender: "SeaBIOS" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" serial console wants queue key events and needs to map ascii chars to the keycode, so make enqueue_key public and also exports a helper function so sercon can use the scan_to_keycode mapping table. Signed-off-by: Gerd Hoffmann --- src/util.h | 2 ++ src/kbd.c | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/util.h b/src/util.h index 8269057fe7..da9059a9bf 100644 --- a/src/util.h +++ b/src/util.h @@ -186,6 +186,8 @@ int jpeg_show(struct jpeg_decdata *jpeg, unsigned char = *pic, int width void kbd_init(void); void handle_15c2(struct bregs *regs); void process_key(u8 key); +u8 enqueue_key(u16 keycode); +u16 ascii_to_keycode(u8 ascii); =20 // misc.c extern int HaveRunPost; diff --git a/src/kbd.c b/src/kbd.c index 916358eed7..15e5ae789c 100644 --- a/src/kbd.c +++ b/src/kbd.c @@ -29,7 +29,7 @@ kbd_init(void) , x + FIELD_SIZEOF(struct bios_data_area_s, kbd_buf)); } =20 -static u8 +u8 enqueue_key(u16 keycode) { u16 buffer_start =3D GET_BDA(kbd_buf_start_offset); @@ -375,6 +375,22 @@ struct scaninfo key_ext_slash VAR16 =3D { 0xe02f, 0xe02f, 0x9500, 0xa400 }; =20 +u16 ascii_to_keycode(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 GET_GLOBAL(scan_to_keycode[i].normal); + if ((GET_GLOBAL(scan_to_keycode[i].shift) & 0xff) =3D=3D ascii) + return GET_GLOBAL(scan_to_keycode[i].shift); + if ((GET_GLOBAL(scan_to_keycode[i].control) & 0xff) =3D=3D ascii) + return GET_GLOBAL(scan_to_keycode[i].control); + } + 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.9.3 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios