Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1i1bPh-0001yx-80 for mharc-grub-devel@gnu.org; Sat, 24 Aug 2019 15:09:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51489) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1bPe-0001wE-Hb for grub-devel@gnu.org; Sat, 24 Aug 2019 15:09:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i1bPc-0002lg-VJ for grub-devel@gnu.org; Sat, 24 Aug 2019 15:09:22 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:59509) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i1bPc-0002k0-MG for grub-devel@gnu.org; Sat, 24 Aug 2019 15:09:20 -0400 X-Originating-IP: 80.215.222.2 Received: from [10.89.167.236] (unknown [80.215.222.2]) (Authenticated sender: perso@michaelbideau.net) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 79645240005 for ; Sat, 24 Aug 2019 19:09:16 +0000 (UTC) Date: Sat, 24 Aug 2019 21:09:13 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----B2CPBIGTS5ZNJ9FNYMRPJBZAUGNBXU" Content-Transfer-Encoding: 7bit Subject: Patch that fixes an 'at_keyboard' module issue (unreliable key presses) Reply-to: mica.perso@gmail.com To: grub-devel@gnu.org From: Michael Bideau Message-ID: <9AF3595C-1B98-4368-82AE-29EC48B4030B@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 217.70.183.193 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Aug 2019 19:09:24 -0000 ------B2CPBIGTS5ZNJ9FNYMRPJBZAUGNBXU Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi all, This patch fixes an issue that prevented the 'at_keyboard' module to work (for me)=2E The cause is a bad/wrong return value in the function 'grub_at_keyboard_getkey()' in file=20 'grub-core/term/at_keyboard=2Ec' at line 234=2E ///////// patch ///////// diff --git a/grub-core/term/at_keyboard=2Ec b/grub-core/term/at_keyboard= =2Ec index f0a986eb1=2E=2E597111077 100644 --- a/grub-core/term/at_keyboard=2Ec +++ b/grub-core/term/at_keyboard=2Ec @@ -234,7 +234,7 @@ grub_at_keyboard_getkey (struct grub_term_input *term = __attribute__ ((unused))) return GRUB_TERM_NO_KEY; =20 if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS))) - return -1; + return GRUB_TERM_NO_KEY; at_key =3D grub_inb (KEYBOARD_REG_DATA); old_led =3D ps2_state=2Eled_status; ///////// end of patch ///////// My symptoms were to have an unresponsive keyboard: keys needed to be pressed 10x and more to effectively be printed, sometimes generating multiple key presses (after 1 or 2 sec of no printing)=2E Very problematic for typing passphrase in early stage (with GRUB_ENABLE_CRYPTODISK)=2E When switching to 'console' terminal input, keyboard works perfectly=2E It also worked great with grub 2=2E02 packaged by Debian (2=2E02+dfsg1-20)= =2E It was not an output issue, but an input one=2E I've managed to analyse the issue and found where it came from: the following commit: ///////// commit ///////// Commit: 216950a4eea1a1ead1c28eaca94e34ea2ef2ad19 Author: Vladimir Serbinenko Date: Mon May 8 21:41:22 2017 +0200 at_keyboard: Split protocol from controller code=2E =20 On vexpress controller is different but protocol is the same, so reuse= the code=2E ///////// end of commit ///////// 3 lines where moved from the function 'fetch_key()' in file 'grub- core/term/at_keyboard=2Ec', to the begining of function 'grub_at_keyboard_getkey()' (same file)=2E But returning '-1' made sense when in function 'fetch_key()' but not anymore in function 'grub_at_keyboard_getkey()', which should return 'GRUB_TERM_NO_KEY'=2E See by yourself: ///////// git diff ///////// ~> git diff ac6b41b89fbb82a3ba843a7ed19115d81432b604 216950a4eea1a1ead1c28= eaca94e34ea2ef2ad19 =2E=2Etruncated=2E=2E diff --git a/grub-core/term/at_keyboard=2Ec b/grub-core/term/at_keyboard= =2Ec index b4ea9ff7e=2E=2E3ab4e205f 100644 --- a/grub-core/term/at_keyboard=2Ec +++ b/grub-core/term/at_keyboard=2Ec =2E=2Etruncated=2E=2E @@ -386,164 +195,10 @@ keyboard_controller_led (grub_uint8_t leds) grub_outb (leds & 0x7, KEYBOARD_REG_DATA); } =20 -static int -fetch_key (int *is_break) -{ - int was_ext =3D 0; - grub_uint8_t at_key; - int ret =3D 0; - - if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS))) - return -1; - at_key =3D grub_inb (KEYBOARD_REG_DATA); =2E=2Etruncated=2E=2E @@ -566,51 +221,28 @@ grub_at_keyboard_is_alive (void) static int grub_at_keyboard_getkey (struct grub_term_input *term __attribute__ ((unu= sed))) { - int code; + grub_uint8_t at_key; =2E=2Etruncated=2E=2E if (!grub_at_keyboard_is_alive ()) return GRUB_TERM_NO_KEY; =2E=2Etruncated=2E=2E + if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS))) + return -1; + at_key =3D grub_inb (KEYBOARD_REG_DATA); =2E=2Etruncated=2E=2E ///////// end of git diff ///////// If you want me to fill a bug, just tell me and I'll do it=2E PS: this is my first contribution to grub, to "low level" code, and in C, so please be kind ;-) Best regards, and thank you all, for your great work on grub=2E Michael Bideau [FR|France]=2E ------B2CPBIGTS5ZNJ9FNYMRPJBZAUGNBXU Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi all,

This patch fixes an issue that prevented the 'at_keyboard' m= odule to
work (for me)=2E

The cause is a bad/wrong return value i= n the function
'grub_at_keyboard_getkey()' in file
'grub-core/term/a= t_keyboard=2Ec' at line 234=2E


///////// patch /////////
diff= --git a/grub-core/term/at_keyboard=2Ec b/grub-core/term/at_keyboard=2Ecindex f0a986eb1=2E=2E597111077 100644
--- a/grub-core/term/at_keyboard= =2Ec
+++ b/grub-core/term/at_keyboard=2Ec
@@ -234,7 +234,7 @@ grub_at= _keyboard_getkey (struct grub_term_input *term __attribute__ ((unused))) return GRUB_TERM_NO_KEY;

if (! KEYBOARD_ISREADY (grub_inb = (KEYBOARD_REG_STATUS)))
- return -1;
+ return GRUB_TERM_NO_KEY;=
at_key =3D grub_inb (KEYBOARD_REG_DATA);
old_led =3D ps2_state= =2Eled_status;
///////// end of patch /////////


My symptoms w= ere to have an unresponsive keyboard: keys needed to be
pressed 10x and = more to
effectively be printed, sometimes generating multiple key presse= s
(after 1 or 2 sec of no printing)=2E
Very problematic for typing pa= ssphrase in early stage (with
GRUB_ENABLE_CRYPTODISK)=2E
When switchi= ng to 'console' terminal input, keyboard works perfectly=2E
It also work= ed great with grub 2=2E02 packaged by Debian (2=2E02+dfsg1-20)=2E
It was= not an output issue, but an input one=2E


I've managed to analys= e the issue and found where it came from: the
following commit:
/////= //// commit /////////
Commit: 216950a4eea1a1ead1c28eaca94e34ea2ef2ad19Author: Vladimir Serbinenko <phcoder@gmail=2Ecom>
Date: Mon Ma= y 8 21:41:22 2017 +0200

at_keyboard: Split protocol from control= ler code=2E

On vexpress controller is different but protocol= is the same, so reuse the
code=2E
///////// end of commit //////= ///


3 lines where moved from the function 'fetch_key()' in file = 'grub-
core/term/at_keyboard=2Ec', to the
begining of function 'grub_= at_keyboard_getkey()' (same file)=2E
But returning '-1' made sense when = in function 'fetch_key()' but not
anymore in function
'grub_at_keyboa= rd_getkey()', which should return 'GRUB_TERM_NO_KEY'=2E


See by y= ourself:

///////// git diff /////////
~> git diff ac6b41b89fbb= 82a3ba843a7ed19115d81432b604 216950a4eea1a1ead1c28eaca94e34ea2ef2ad19
=2E=2Etruncated=2E=2E

diff --git a/grub-core/term/at_keyboard=2Ec = b/grub-core/term/at_keyboard=2Ec
index b4ea9ff7e=2E=2E3ab4e205f 100644--- a/grub-core/term/at_keyboard=2Ec
+++ b/grub-core/term/at_keyboard= =2Ec

=2E=2Etruncated=2E=2E

@@ -386,164 +195,10 @@ keyboard_co= ntroller_led (grub_uint8_t leds)
grub_outb (leds & 0x7, KEYBOARD_= REG_DATA);
}

-static int
-fetch_key (int *is_break)
-{- int was_ext =3D 0;
- grub_uint8_t at_key;
- int ret =3D 0;
-=
- if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS)))
- ret= urn -1;
- at_key =3D grub_inb (KEYBOARD_REG_DATA);

=2E=2Etruncat= ed=2E=2E

@@ -566,51 +221,28 @@ grub_at_keyboard_is_alive (void)
= static int
grub_at_keyboard_getkey (struct grub_term_input *term __attr= ibute__ ((unused)))
{
- int code;
+ grub_uint8_t at_key;
=2E=2Etruncated=2E=2E

if (!grub_at_keyboard_is_alive ())
= return GRUB_TERM_NO_KEY;

=2E=2Etruncated=2E=2E

+ if (! KEYB= OARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS)))
+ return -1;
+ at_= key =3D grub_inb (KEYBOARD_REG_DATA);

=2E=2Etruncated=2E=2E
/////= //// end of git diff /////////


If you want me to fill a bug, jus= t tell me and I'll do it=2E


PS: this is my first contribution to= grub, to "low level" code, and in
C, so please be kind ;-)

Best = regards, and thank you all, for your great work on grub=2E
Michael Bidea= u [FR|France]=2E

------B2CPBIGTS5ZNJ9FNYMRPJBZAUGNBXU--