Storing grubenv in nvram

2014-02-04 Thread Sergey Mironov
Hello, list!

I want to write a grub.conf which would allow me to keep a
crash-detection/fallback logic. In order to implement it, I need to
keep a state, so load_env and save_env are my friends. Unfortunately,
the storage I am using  is unreliable and I don't want to store the
bootloader's state in the filesystem. I am thinking about storing it
in the nvram. AFAIK, mainstream grub doesn't support accessing nvram
at the moment. But are there any forks which do support it? If no,
could you please point me to examples of accessing X86-64 nvram chips
in other projects (I am not afraid of doing some coding) ?

Thanks in advance,
Sergey

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH] Make CTRL and ALT keys work as expected on EFI systems.

2014-02-04 Thread Peter Jones
Signed-off-by: Peter Jones 
---
 grub-core/term/efi/console.c | 119 +++
 include/grub/efi/api.h   |  65 ++-
 2 files changed, 174 insertions(+), 10 deletions(-)

diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c
index a37eb84..8c3b52b 100644
--- a/grub-core/term/efi/console.c
+++ b/grub-core/term/efi/console.c
@@ -109,15 +109,12 @@ const unsigned efi_codes[] =
 
 
 static int
-grub_console_getkey (struct grub_term_input *term __attribute__ ((unused)))
+grub_console_getkey_con (struct grub_term_input *term __attribute__ ((unused)))
 {
   grub_efi_simple_input_interface_t *i;
   grub_efi_input_key_t key;
   grub_efi_status_t status;
 
-  if (grub_efi_is_finished)
-return 0;
-
   i = grub_efi_system_table->con_in;
   status = efi_call_2 (i->read_key_stroke, i, &key);
 
@@ -142,6 +139,109 @@ grub_console_getkey (struct grub_term_input *term 
__attribute__ ((unused)))
   return GRUB_TERM_NO_KEY;
 }
 
+static int
+grub_console_getkey_ex(struct grub_term_input *term)
+{
+  grub_efi_key_data_t key_data;
+  grub_efi_status_t status;
+  grub_efi_uint32_t kss;
+  int key = -1;
+
+  grub_efi_simple_text_input_ex_interface_t *text_input = term->data;
+
+  status = efi_call_2 (text_input->read_key_stroke, text_input, &key_data);
+
+  if (status != GRUB_EFI_SUCCESS)
+return GRUB_TERM_NO_KEY;
+
+  if (key_data.key.scan_code == 0)
+{
+  /* Some firmware implementations use VT100-style codes against the spec.
+This is especially likely if driven by serial.
+   */
+  if (key_data.key.unicode_char < 0x20
+ && key_data.key.unicode_char != 0
+ && key_data.key.unicode_char != '\t'
+ && key_data.key.unicode_char != '\b'
+ && key_data.key.unicode_char != '\n'
+ && key_data.key.unicode_char != '\r')
+   key = GRUB_TERM_CTRL | (key_data.key.unicode_char - 1 + 'a');
+  else
+   key = key_data.key.unicode_char;
+}
+  else if (key_data.key.scan_code < ARRAY_SIZE (efi_codes))
+key = efi_codes[key_data.key.scan_code];
+
+  if (key == -1)
+return GRUB_TERM_NO_KEY;
+
+  kss = key_data.key_state.key_shift_state;
+  if (kss & GRUB_EFI_SHIFT_STATE_VALID)
+{
+  if (kss & GRUB_EFI_LEFT_ALT_PRESSED || kss & GRUB_EFI_RIGHT_ALT_PRESSED)
+   key |= GRUB_TERM_ALT;
+  if (kss & GRUB_EFI_LEFT_CONTROL_PRESSED
+ || kss & GRUB_EFI_RIGHT_CONTROL_PRESSED)
+   key |= GRUB_TERM_CTRL;
+}
+
+  return key;
+}
+
+static grub_err_t
+grub_efi_console_input_init (struct grub_term_input *term)
+{
+  grub_efi_uintn_t num_handles = 0;
+  grub_efi_handle_t *handles = NULL;
+  grub_efi_handle_t *handle = NULL;
+  grub_efi_guid_t text_input_ex_guid =
+GRUB_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID;
+  grub_efi_guid_t text_input_guid = GRUB_EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID;
+
+  if (grub_efi_is_finished)
+return 0;
+
+  grub_efi_simple_text_input_ex_interface_t *text_input = term->data;
+  if (text_input)
+return 0;
+
+  handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL,
+   &text_input_ex_guid,
+   0, &num_handles);
+
+  for (handle = handles; num_handles--; handle++)
+{
+  grub_efi_simple_input_interface_t *st;
+
+  st = grub_efi_open_protocol(*handle, &text_input_guid,
+ GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+
+  if (st != grub_efi_system_table->con_in)
+   continue;
+  if (st == NULL)
+   continue;
+
+  text_input = grub_efi_open_protocol(*handle, &text_input_ex_guid,
+ GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+  break;
+}
+if (text_input)
+  term->data = (void *)text_input;
+return 0;
+}
+
+static int
+grub_console_getkey (struct grub_term_input *term)
+{
+  if (grub_efi_is_finished)
+return 0;
+
+  if (term->data)
+return grub_console_getkey_ex(term);
+  else
+return grub_console_getkey_con(term);
+}
+
 static struct grub_term_coordinate
 grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
 {
@@ -243,7 +343,7 @@ grub_console_setcursor (struct grub_term_output *term 
__attribute__ ((unused)),
 }
 
 static grub_err_t
-grub_efi_console_init (struct grub_term_output *term)
+grub_efi_console_output_init (struct grub_term_output *term)
 {
   grub_efi_set_text_mode (1);
   grub_console_setcursor (term, 1);
@@ -251,7 +351,7 @@ grub_efi_console_init (struct grub_term_output *term)
 }
 
 static grub_err_t
-grub_efi_console_fini (struct grub_term_output *term)
+grub_efi_console_output_fini (struct grub_term_output *term)
 {
   grub_console_setcursor (term, 0);
   grub_efi_set_text_mode (0);
@@ -262,13 +362,14 @@ static struct grub_term_input grub_console_term_input =
   {
 .name = "console",
 .getkey = grub_console_getkey,
+.init = grub_efi_console_input_init,
   };
 
 static struct grub_term_output grub_console_term_out

[PATCH] Make CTRL and ALT keys work as expected on EFI systems (version 2).

2014-02-04 Thread Peter Jones
This is version 2.  Changes from version 1:

- handles SHIFT as a modifier
- handles F11 and F12 keys
- uses the handle provided by the system table to find our _EX protocol.

Signed-off-by: Peter Jones 
---
 grub-core/term/efi/console.c | 104 ++-
 include/grub/efi/api.h   |  65 ++-
 2 files changed, 158 insertions(+), 11 deletions(-)

diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c
index a37eb84..2ca3f81 100644
--- a/grub-core/term/efi/console.c
+++ b/grub-core/term/efi/console.c
@@ -104,20 +104,17 @@ const unsigned efi_codes[] =
 GRUB_TERM_KEY_DC, GRUB_TERM_KEY_PPAGE, GRUB_TERM_KEY_NPAGE, 
GRUB_TERM_KEY_F1,
 GRUB_TERM_KEY_F2, GRUB_TERM_KEY_F3, GRUB_TERM_KEY_F4, GRUB_TERM_KEY_F5,
 GRUB_TERM_KEY_F6, GRUB_TERM_KEY_F7, GRUB_TERM_KEY_F8, GRUB_TERM_KEY_F9,
-GRUB_TERM_KEY_F10, 0, 0, '\e'
+GRUB_TERM_KEY_F10, GRUB_TERM_KEY_F10, GRUB_TERM_KEY_F11, '\e'
   };
 
 
 static int
-grub_console_getkey (struct grub_term_input *term __attribute__ ((unused)))
+grub_console_getkey_con (struct grub_term_input *term __attribute__ ((unused)))
 {
   grub_efi_simple_input_interface_t *i;
   grub_efi_input_key_t key;
   grub_efi_status_t status;
 
-  if (grub_efi_is_finished)
-return 0;
-
   i = grub_efi_system_table->con_in;
   status = efi_call_2 (i->read_key_stroke, i, &key);
 
@@ -142,6 +139,92 @@ grub_console_getkey (struct grub_term_input *term 
__attribute__ ((unused)))
   return GRUB_TERM_NO_KEY;
 }
 
+static int
+grub_console_getkey_ex(struct grub_term_input *term)
+{
+  grub_efi_key_data_t key_data;
+  grub_efi_status_t status;
+  grub_efi_uint32_t kss;
+  int key = -1;
+
+  grub_efi_simple_text_input_ex_interface_t *text_input = term->data;
+
+  status = efi_call_2 (text_input->read_key_stroke, text_input, &key_data);
+
+  if (status != GRUB_EFI_SUCCESS)
+return GRUB_TERM_NO_KEY;
+
+  if (key_data.key.scan_code == 0)
+{
+  /* Some firmware implementations use VT100-style codes against the spec.
+This is especially likely if driven by serial.
+   */
+  if (key_data.key.unicode_char < 0x20
+ && key_data.key.unicode_char != 0
+ && key_data.key.unicode_char != '\t'
+ && key_data.key.unicode_char != '\b'
+ && key_data.key.unicode_char != '\n'
+ && key_data.key.unicode_char != '\r')
+   key = GRUB_TERM_CTRL | (key_data.key.unicode_char - 1 + 'a');
+  else
+   key = key_data.key.unicode_char;
+}
+  else if (key_data.key.scan_code < ARRAY_SIZE (efi_codes))
+key = efi_codes[key_data.key.scan_code];
+
+  if (key == -1)
+return GRUB_TERM_NO_KEY;
+
+  kss = key_data.key_state.key_shift_state;
+  if (kss & GRUB_EFI_SHIFT_STATE_VALID)
+{
+  if (kss & GRUB_EFI_LEFT_SHIFT_PRESSED
+ || kss & GRUB_EFI_RIGHT_SHIFT_PRESSED)
+   key |= GRUB_TERM_SHIFT;
+  if (kss & GRUB_EFI_LEFT_ALT_PRESSED || kss & GRUB_EFI_RIGHT_ALT_PRESSED)
+   key |= GRUB_TERM_ALT;
+  if (kss & GRUB_EFI_LEFT_CONTROL_PRESSED
+ || kss & GRUB_EFI_RIGHT_CONTROL_PRESSED)
+   key |= GRUB_TERM_CTRL;
+}
+
+  return key;
+}
+
+static grub_err_t
+grub_efi_console_input_init (struct grub_term_input *term)
+{
+  grub_efi_guid_t text_input_ex_guid =
+GRUB_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID;
+
+  if (grub_efi_is_finished)
+return 0;
+
+  grub_efi_simple_text_input_ex_interface_t *text_input = term->data;
+  if (text_input)
+return 0;
+
+  text_input = 
grub_efi_open_protocol(grub_efi_system_table->console_in_handler,
+ &text_input_ex_guid,
+ GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+  if (text_input)
+term->data = (void *)text_input;
+
+  return 0;
+}
+
+static int
+grub_console_getkey (struct grub_term_input *term)
+{
+  if (grub_efi_is_finished)
+return 0;
+
+  if (term->data)
+return grub_console_getkey_ex(term);
+  else
+return grub_console_getkey_con(term);
+}
+
 static struct grub_term_coordinate
 grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
 {
@@ -243,7 +326,7 @@ grub_console_setcursor (struct grub_term_output *term 
__attribute__ ((unused)),
 }
 
 static grub_err_t
-grub_efi_console_init (struct grub_term_output *term)
+grub_efi_console_output_init (struct grub_term_output *term)
 {
   grub_efi_set_text_mode (1);
   grub_console_setcursor (term, 1);
@@ -251,7 +334,7 @@ grub_efi_console_init (struct grub_term_output *term)
 }
 
 static grub_err_t
-grub_efi_console_fini (struct grub_term_output *term)
+grub_efi_console_output_fini (struct grub_term_output *term)
 {
   grub_console_setcursor (term, 0);
   grub_efi_set_text_mode (0);
@@ -262,13 +345,14 @@ static struct grub_term_input grub_console_term_input =
   {
 .name = "console",
 .getkey = grub_console_getkey,
+.init = grub_efi_console_input_init,
   };
 
 static struct grub_term_output grub_console_term_output =
   {
 .name =

[PATCH] Make CTRL and ALT keys work as expected on EFI systems (version 3).

2014-02-04 Thread Peter Jones
This is version 3.

Changes from version 1:
- handles SHIFT as a modifier
- handles F11 and F12 keys
- uses the handle provided by the system table to find our _EX protocol.

Changes from version 2:
- eliminate duplicate keycode translation.

Signed-off-by: Peter Jones 
---
 grub-core/term/efi/console.c | 115 +++
 include/grub/efi/api.h   |  65 +++-
 2 files changed, 158 insertions(+), 22 deletions(-)

diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c
index a37eb84..95aedb7 100644
--- a/grub-core/term/efi/console.c
+++ b/grub-core/term/efi/console.c
@@ -104,26 +104,12 @@ const unsigned efi_codes[] =
 GRUB_TERM_KEY_DC, GRUB_TERM_KEY_PPAGE, GRUB_TERM_KEY_NPAGE, 
GRUB_TERM_KEY_F1,
 GRUB_TERM_KEY_F2, GRUB_TERM_KEY_F3, GRUB_TERM_KEY_F4, GRUB_TERM_KEY_F5,
 GRUB_TERM_KEY_F6, GRUB_TERM_KEY_F7, GRUB_TERM_KEY_F8, GRUB_TERM_KEY_F9,
-GRUB_TERM_KEY_F10, 0, 0, '\e'
+GRUB_TERM_KEY_F10, GRUB_TERM_KEY_F10, GRUB_TERM_KEY_F11, '\e'
   };
 
-
 static int
-grub_console_getkey (struct grub_term_input *term __attribute__ ((unused)))
+grub_efi_translate_key (grub_efi_input_key_t key)
 {
-  grub_efi_simple_input_interface_t *i;
-  grub_efi_input_key_t key;
-  grub_efi_status_t status;
-
-  if (grub_efi_is_finished)
-return 0;
-
-  i = grub_efi_system_table->con_in;
-  status = efi_call_2 (i->read_key_stroke, i, &key);
-
-  if (status != GRUB_EFI_SUCCESS)
-return GRUB_TERM_NO_KEY;
-
   if (key.scan_code == 0)
 {
   /* Some firmware implementations use VT100-style codes against the spec.
@@ -142,6 +128,92 @@ grub_console_getkey (struct grub_term_input *term 
__attribute__ ((unused)))
   return GRUB_TERM_NO_KEY;
 }
 
+static int
+grub_console_getkey_con (struct grub_term_input *term __attribute__ ((unused)))
+{
+  grub_efi_simple_input_interface_t *i;
+  grub_efi_input_key_t key;
+  grub_efi_status_t status;
+
+  i = grub_efi_system_table->con_in;
+  status = efi_call_2 (i->read_key_stroke, i, &key);
+
+  if (status != GRUB_EFI_SUCCESS)
+return GRUB_TERM_NO_KEY;
+
+  return grub_efi_translate_key(key);
+}
+
+static int
+grub_console_getkey_ex(struct grub_term_input *term)
+{
+  grub_efi_key_data_t key_data;
+  grub_efi_status_t status;
+  grub_efi_uint32_t kss;
+  int key = -1;
+
+  grub_efi_simple_text_input_ex_interface_t *text_input = term->data;
+
+  status = efi_call_2 (text_input->read_key_stroke, text_input, &key_data);
+
+  if (status != GRUB_EFI_SUCCESS)
+return GRUB_TERM_NO_KEY;
+
+  key = grub_efi_translate_key(key_data.key);
+
+  if (key == GRUB_TERM_NO_KEY)
+return GRUB_TERM_NO_KEY;
+
+  kss = key_data.key_state.key_shift_state;
+  if (kss & GRUB_EFI_SHIFT_STATE_VALID)
+{
+  if (kss & GRUB_EFI_LEFT_SHIFT_PRESSED
+ || kss & GRUB_EFI_RIGHT_SHIFT_PRESSED)
+   key |= GRUB_TERM_SHIFT;
+  if (kss & GRUB_EFI_LEFT_ALT_PRESSED || kss & GRUB_EFI_RIGHT_ALT_PRESSED)
+   key |= GRUB_TERM_ALT;
+  if (kss & GRUB_EFI_LEFT_CONTROL_PRESSED
+ || kss & GRUB_EFI_RIGHT_CONTROL_PRESSED)
+   key |= GRUB_TERM_CTRL;
+}
+
+  return key;
+}
+
+static grub_err_t
+grub_efi_console_input_init (struct grub_term_input *term)
+{
+  grub_efi_guid_t text_input_ex_guid =
+GRUB_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID;
+
+  if (grub_efi_is_finished)
+return 0;
+
+  grub_efi_simple_text_input_ex_interface_t *text_input = term->data;
+  if (text_input)
+return 0;
+
+  text_input = 
grub_efi_open_protocol(grub_efi_system_table->console_in_handler,
+ &text_input_ex_guid,
+ GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+  if (text_input)
+term->data = (void *)text_input;
+
+  return 0;
+}
+
+static int
+grub_console_getkey (struct grub_term_input *term)
+{
+  if (grub_efi_is_finished)
+return 0;
+
+  if (term->data)
+return grub_console_getkey_ex(term);
+  else
+return grub_console_getkey_con(term);
+}
+
 static struct grub_term_coordinate
 grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
 {
@@ -243,7 +315,7 @@ grub_console_setcursor (struct grub_term_output *term 
__attribute__ ((unused)),
 }
 
 static grub_err_t
-grub_efi_console_init (struct grub_term_output *term)
+grub_efi_console_output_init (struct grub_term_output *term)
 {
   grub_efi_set_text_mode (1);
   grub_console_setcursor (term, 1);
@@ -251,7 +323,7 @@ grub_efi_console_init (struct grub_term_output *term)
 }
 
 static grub_err_t
-grub_efi_console_fini (struct grub_term_output *term)
+grub_efi_console_output_fini (struct grub_term_output *term)
 {
   grub_console_setcursor (term, 0);
   grub_efi_set_text_mode (0);
@@ -262,13 +334,14 @@ static struct grub_term_input grub_console_term_input =
   {
 .name = "console",
 .getkey = grub_console_getkey,
+.init = grub_efi_console_input_init,
   };
 
 static struct grub_term_output grub_console_term_output =
   {
 .name = "console",
-.init = g

Re: Fix serial output for OpenBSD current

2014-02-04 Thread Markus Müller
Am Montag, den 03.02.2014, 18:03 +0100 schrieb Vladimir
'φ-coder/phcoder' Serbinenko:
> On 02.02.2014 11:48, Markus Müller wrote:
> > Hi all,
> > 
> > attached is a patch that fixes serial console output with OpenBSD
> > current (will be 5.5). Grub uses an old struct for providing the kernel
> > with information about the serial console that is now gone [1]. Since
> > the new way is in OpenBSD since 5.2, even older versions are still
> > supported with this patch.
> > 
> Could you try this patch instead?

Seems to be working fine. I'm getting serial output with all releases
and custom kernels I've tested before.

Regards,
Markus


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: Fix serial output for OpenBSD current

2014-02-04 Thread SevenBits
On Feb 4, 2014, at 5:46 PM, Markus Müller  wrote:

> Am Montag, den 03.02.2014, 18:03 +0100 schrieb Vladimir
> 'φ-coder/phcoder' Serbinenko:
>> On 02.02.2014 11:48, Markus Müller wrote:
>>> Hi all,
>>> 
>>> attached is a patch that fixes serial console output with OpenBSD
>>> current (will be 5.5). Grub uses an old struct for providing the kernel
>>> with information about the serial console that is now gone [1]. Since
>>> the new way is in OpenBSD since 5.2, even older versions are still
>>> supported with this patch.
>>> 
>> Could you try this patch instead?
> 
> Seems to be working fine. I'm getting serial output with all releases
> and custom kernels I've tested before.

I’ve never had any problems either.

> 
> Regards,
> Markus
> 
> 
> ___
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


RE: grub2 code

2014-02-04 Thread Roger Cruz
This was a bug that was introduced into GRUB when the code to detect if the 
SHIFT key is being pressed was added.  The symptom was that customers were 
complaining that even though they had turn on NUMLOCK in the BIOS, once we 
booted our software, NUMLOCK was off.  It was easy to "see" when the bug was 
happening because the NUMLOCK LED would turn off sometime during GRUB running. 

I tracked it down to that one line which ANDs the BIOS state area and blows 
away the NUMLOCK state in it  (it stores the value in the address in BX via 
indirect addressing).  

Hope this helps.  If it is not clear, please feel free to ask for more details.

Roger R. Cruz


-Original Message-
From: ben.gut...@gmail.com [mailto:ben.gut...@gmail.com] On Behalf Of Ben Guthro
Sent: Monday, February 03, 2014 7:42 AM
To: Colin Watson
Cc: grub-devel@gnu.org; Roger Cruz
Subject: Re: grub2 code

On Mon, Feb 3, 2014 at 6:57 AM, Colin Watson  wrote:
> On Sun, Feb 02, 2014 at 07:25:51PM +, Robert Parnell wrote:
>> I was just looking at the grub2 source code and saw that 
>> https://bazaar.launchpad.net/~ubuntu-branches/ubuntu/trusty/grub2/tru
>> sty/view/head:/TODO 
>> > trusty/view/head:/TODO>
>> says to contact with questions.
>> I was looking at the source because I encountered a bug on my machine 
>> that has been previously reported
>> (https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1027694) and 
>> thought I'd have a look to see if I could find the problem.
>> So I have 2 questions:
>> 1. Is the code on launchpad the up to date code?
>
> It's an automatically-imported version of the Ubuntu packaging.  It's 
> up-to-date with what we're shipping, yes, but we do our work in git 
> these days.  The upstream code is here:
>
>   http://git.savannah.gnu.org/gitweb/?p=grub.git
>
> ... and the packaging used by both Debian and Ubuntu is here (the 
> "experimental" branch is most current):
>
>   http://anonscm.debian.org/gitweb/?p=pkg-grub/grub.git
>
>> 2. Line 177 of
>> https://bazaar.launchpad.net/~ubuntu-branches/ubuntu/trusty/grub2/tru
>> sty/view/head:/grub-core/boot/i386/pc/startup_raw.S
>> > trusty/view/head:/grub-core/boot/i386/pc/startup_raw.S>
>> is a function that flushes the keyboard buffer, could this be what is 
>> causing the bug?
>
> That seems unrelated.
>
> Ben's patch referenced in https://savannah.gnu.org/bugs/?34547 touches 
> code that I wrote and that I maintain as a patch, so this would 
> presumably be my problem to fix.  But I don't understand why Ben's 
> patch fixes anything related to NumLock.  The code being commented out 
> is
> essentially:
>
> movw$(GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR + 0x17), %bx
> andb$3, (%bx)
>
> ... followed by something that tests the condition flags.  But all 
> that does is test whether either Shift key is held down, not actually 
> set the NumLock state (see http://www.bioscentral.com/misc/bda.htm).  
> That is, it reads from the BIOS Data Area, but it doesn't write to it.
>
> Ben (CCed), could you shed some light on why your patch would fix this?

Adding Roger Cruz, as he was the original author of this fix, where I was just 
trying to get it upstreamed - though, this was quite some time since he 
developed it (Oct 2011), so I'm sure this isn't exactly fresh in his mind.

Roger, could you shed some light on  this?

Ben

>
> Thanks,
>
> --
> Colin Watson   [cjwat...@ubuntu.com]

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


RE: grub2 code

2014-02-04 Thread Roger Cruz
Yes,  that certainly would be a better fix.  Thanks for addressing it.

Roger

-Original Message-
From: Colin Watson [mailto:cjwat...@ubuntu.com] 
Sent: Monday, February 03, 2014 10:51 AM
To: Roger Cruz
Cc: Ben Guthro; grub-devel@gnu.org
Subject: Re: grub2 code

On Mon, Feb 03, 2014 at 03:44:01PM +, Roger Cruz wrote:
> This was a bug that was introduced into GRUB when the code to detect 
> if the SHIFT key is being pressed was added.  The symptom was that 
> customers were complaining that even though they had turn on NUMLOCK 
> in the BIOS, once we booted our software, NUMLOCK was off.  It was 
> easy to "see" when the bug was happening because the NUMLOCK LED would 
> turn off sometime during GRUB running.
> 
> I tracked it down to that one line which ANDs the BIOS state area and 
> blows away the NUMLOCK state in it  (it stores the value in the 
> address in BX via indirect addressing).

Oh, of course, I missed the indirect store even on a second reading.
I'm pretty sure that the correct fix isn't to remove the code, but rather to 
use testb instead of andb.  I'll see about getting that fixed soon.

-- 
Colin Watson   [cjwat...@ubuntu.com]

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel