[comp.os.minix] Keyboard LEDs

johnc@rtmvax.UUCP (John Connin) (10/19/88)

The function set_leds() within console.c does not work with my AT-clone.
More likely than not it will cause the 8042 keyboard controller to
reset its self.  The net effect is that either the typematic rate
will be reset (ie. I have it to 30 char / sec) or more importantly
will cause the system reset line to be set -- inturn causing the
system to reboot.

NB: increasing the delay parmeter 'LED_DELAY' is not enough.

The following code, which I believe corresponds to how the 8042 should
be programmed, solves the problem -- at least in my machine.  However,
beware that it does not contain any error recover mechanism.


#define KB_DATA         0x60    /* I/O port for keyboard data */
#define KB_STATUS       0x64    /* I/O port for keyboard status */
#define KB_FULL         0x02    /* keyboard full status mask */

#define LED_CODE        0xED	/* command to keyboard to set LEDs */
#define KB_ACK          0xFA    /* keyboard ack response  */


set_leds(leds)
int  leds;
{
    int  data_port, status_port;
    int  dummy;

    data_port   = KB_DATA;
    status_port = KB_STATUS;

    kb_ready(status_port);           /* wait for buffer empty  */

    port_out(data_port, LED_CODE);   /* prepare keyboard to accept LED values */

    kb_ack(data_port);               /* wait for ack response  */
    kb_ready(status_port);           /* wait for buffer empty  */

    port_out(data_port, leds & 0x0007);   /* give keyboard LED values */
    kb_ack(data_port);                    /* wait for ack response  */
}

kb_ready(port)
int port;
{
    int  status;

    do {  port_in(port,&status); }
    while (status & KB_FULL);
}

kb_ack(port)
int  port;
{
    int  response;

    do {  port_in(port,&response); }
    while (response != KB_ACK);
}

arensb@cvl.umd.edu (Andrew Arensburger) (06/05/89)

	I'm running Minix 1.2 on a vintage (read: antedeluvian) AT&T 6300
(PC clone). One thing that bothers me is that the keyboard LEDs (CapsLock
and NumLock) don't work. Does version 1.3 solve this problem? If not, has
anyone solved this problem? Any hints?
	Thanks in advance.

-- 
-------------------------------------------------------------------\\\\^
Andrew Arensburger            | K&R C!   | This space                  o\\\\\-
...!uunet!mimsy!cvl!arensb    | ANSI no! | unintentionally         __   /
arensb@cvl.umd.edu            |          | left blank                \_/