Re: [RESUBMIT] [PATCH] Use BIOS Keyboard variable to set Numlock

From: Bodo Eggert
Date: Wed Feb 29 2012 - 12:54:03 EST


On Wed, 29 Feb 2012, Joshua C. wrote:
2012/2/28 H. Peter Anvin <hpa@xxxxxxxxx>:
On 02/28/2012 10:32 AM, Bodo Eggert wrote:

Asking the BIOS is as correct as querying the memory location (defined
to have same result), but more expensive.


Not quite, in reality; it is more likely to work on systems which implement
various kinds of bypass schemes.  The key aspect of this, though, is that
this is done on a BIOS path and not by groping a memory location which may
not even be initialized on non-BIOS systems.

I got the idea that we should somehow check the kbd_state and set the
numlock accordingly but this is behind my capabilities. I tried
several times to read those boot_params but I have no idea how to do
it. Where are they stored, how to access them? Help anyone?

There are two bytes in the BIOS data area, one (0x417 + 0x418) containing the settings that are supposed to be set and one that contains the values sent to the keyboard most recently (0x496 + 0x497). Both values are compared on each int16 call and the LED are set accordingly if the corresponding bits differ.

You can change the LED states by setting the according byte and calling any keyboard interrupt function, e.g. querying the availability of characters in the buffer. I don't know about any other way to do the same using only the BIOS.