gregory@gandalf.nosc.mil (Gregory L. Meckstroth) (10/27/88)
Thanks to John Connin I now have the Caps Lock and Num Lock leds
working on my Zenith 248. The set_leds routine that John posted
did not work because leds is passed as an argument and in console
it's calculated. I tried to put in the ps/2 support but I don't
have one to test it on.
--Greg
*** old/console.c Fri Oct 14 06:34:30 1988
--- console.c Wed Oct 26 12:05:32 1988
***************
*** 38,43
#define TIMER2 0x42 /* I/O port for timer channel 2 */
#define TIMER3 0x43 /* I/O port for timer channel 3 */
#define KEYBD 0x60 /* I/O port for keyboard data */
#define PORT_B 0x61 /* I/O port for 8255 port B */
#define KBIT 0x80 /* bit used to ack characters to keyboard */
#define LED_CODE 0xED /* command to keyboard to set LEDs */
--- 38,44 -----
#define TIMER2 0x42 /* I/O port for timer channel 2 */
#define TIMER3 0x43 /* I/O port for timer channel 3 */
#define KEYBD 0x60 /* I/O port for keyboard data */
+ #define KB_ACK 0xFA /* keyboard ack response */
#define PORT_B 0x61 /* I/O port for 8255 port B */
#define KBIT 0x80 /* bit used to ack characters to keyboard */
#define LED_CODE 0xED /* command to keyboard to set LEDs */
***************
*** 68,73
#define SPACE_SCAN 57 /* a space */
#define PS_LED_DELAY 1200 /* delay for PS/2 */
#define PS_KEYBD 0x68 /* I/O port for data on ps/2 */
/* Scan codes to ASCII for IBM DUTCH extended keyboard */
#define MINUS_DU 0x0035 /* scan code of '-' on Dutch extended keybd */
--- 69,75 -----
#define SPACE_SCAN 57 /* a space */
#define PS_LED_DELAY 1200 /* delay for PS/2 */
#define PS_KEYBD 0x68 /* I/O port for data on ps/2 */
+ #define PS_KB_STATUS 0x72 /* I/O port for status on ps/2 */
/* Scan codes to ASCII for IBM DUTCH extended keyboard */
#define MINUS_DU 0x0035 /* scan code of '-' on Dutch extended keybd */
***************
*** 831,837
{
/* Set the LEDs on the caps lock and num lock keys */
! int count, leds, dummy, i, port;
if (pc_at == 0 && !ps) return; /* PC/XT doesn't have LEDs */
leds = (numlock<<1) | (capslock<<2); /* encode LED bits */
--- 833,839 -----
{
/* Set the LEDs on the caps lock and num lock keys */
! int leds, data_port, status_port;
if (pc_at == 0 && !ps) return; /* PC/XT doesn't have LEDs */
leds = (numlock<<1) | (capslock<<2); /* encode LED bits */
***************
*** 837,844
leds = (numlock<<1) | (capslock<<2); /* encode LED bits */
if (ps) {
! port = PS_KEYBD;
! count = PS_LED_DELAY;
} else {
count = LED_DELAY;
port = KEYBD;
--- 839,846 -----
leds = (numlock<<1) | (capslock<<2); /* encode LED bits */
if (ps) {
! data_port = PS_KEYBD;
! status_port = PS_KB_STATUS;
} else {
data_port = KEYBD;
status_port = KB_STATUS;
***************
*** 840,847
port = PS_KEYBD;
count = PS_LED_DELAY;
} else {
! count = LED_DELAY;
! port = KEYBD;
}
port_out(port, LED_CODE); /* prepare keyboard to accept LED values */
--- 842,849 -----
data_port = PS_KEYBD;
status_port = PS_KB_STATUS;
} else {
! data_port = KEYBD;
! status_port = KB_STATUS;
}
kb_ready(status_port); /* wait for buffer empty */
***************
*** 844,854
port = KEYBD;
}
! port_out(port, LED_CODE); /* prepare keyboard to accept LED values */
! port_in(port, &dummy); /* keyboard sends ack; accept it */
! for (i = 0; i < count; i++) ; /* delay needed */
! port_out(port, leds); /* give keyboard LED values */
! port_in(port, &dummy); /* keyboard sends ack; accept it */
}
/*===========================================================================*
--- 846,884 -----
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 *
! *===========================================================================*/
! PRIVATE kb_ready(port)
! int port;
! {
! int status;
!
! do { port_in(port,&status); }
! while (status & KB_BUSY);
! }
!
! /*===========================================================================*
! * kb_ack *
! *===========================================================================*/
! PRIVATE kb_ack(port)
! int port;
! {
! int response;
!
! do { port_in(port,&response); }
! while (response != KB_ACK);
}
/*===========================================================================*