ps2 keyboard filter hook
IBM Retail Store Solutions dept has certain PS/2 keyboards which extend the standard PS/2 specification in order to support addition hardware built into the keyboard (such as a Magnetic Strip Reader, Keylock, Tone generator, extra keys, extra LEDs, etc). This addition hardware behaves in a manner that makes it unusable if driven by a standard PS/2 driver (sadly, due to the fact that its design is "IP" I can't elaborate on how or why it is incompatible with the standard PS/2 specification). In order to use these keyboards, a the standard PS/2 driver needs to behave a bit differently; thus attached is a modifcation to the PS/2 driver which allows other drivers to register with the PS/2 driver as 'filters'. There is a arbitrary max number of 'filters' set to 1, which is a compile-time define. The registered drivers are called (in order of registration) for every scancode, and they may change or consume the scancode (or allow it to pass). Also the 'filters' are given a function to send an variable-sized buffer to the keyboard output port; this function is synchronized using a semaphore which also coordinates with pckbd_leds(). -Dan diff -urN 2.4.5-clean/Documentation/Configure.help linux/Documentation/Configure.help --- 2.4.5-clean/Documentation/Configure.helpThu May 24 18:03:06 2001 +++ linux/Documentation/Configure.help Fri Jun 15 13:34:18 2001 @@ -13274,6 +13274,21 @@ If you are unsure, say N and read the HOWTO nevertheless: it will tell you what you have. +PS/2 Keyboard Filter support +CONFIG_PC_KEYB_FILTER + This enables filter support in the PS/2 keyboard driver. With + this enabled, other drivers will be able to register with the + PS/2 driver and filter all incoming scancodes. This is useful + for keyboards which extend the PS/2 keyboard standard with + non-standard scancodes which should not be normally routed to + the current console. + + This option does not actually filter any scancodes, it only + allows other drivers (who will do the filtering) to register + with the PS/2 driver. + + If unsure, say N. + QIC-02 tape support CONFIG_QIC02_TAPE If you have a non-SCSI tape drive like that, say Y. Or, if you want diff -urN 2.4.5-clean/drivers/char/Config.in linux/drivers/char/Config.in --- 2.4.5-clean/drivers/char/Config.in Tue Mar 6 22:44:34 2001 +++ linux/drivers/char/Config.inFri Jun 15 13:34:18 2001 @@ -105,6 +105,11 @@ source drivers/char/joystick/Config.in +mainmenu_option next_comment +comment 'Keyboards' +bool 'PS/2 Keyboard Filter support' CONFIG_PC_KEYB_FILTER +endmenu + tristate 'QIC-02 tape support' CONFIG_QIC02_TAPE if [ "$CONFIG_QIC02_TAPE" != "n" ]; then bool ' Do you want runtime configuration for QIC-02' CONFIG_QIC02_DYNCONF diff -urN 2.4.5-clean/drivers/char/Makefile linux/drivers/char/Makefile --- 2.4.5-clean/drivers/char/Makefile Wed May 16 13:27:02 2001 +++ linux/drivers/char/Makefile Fri Jun 15 13:34:18 2001 @@ -21,7 +21,7 @@ # All of the (potential) objects that export symbols. # This list comes from 'grep -l EXPORT_SYMBOL *.[hc]'. -export-objs := busmouse.o console.o keyboard.o sysrq.o \ +export-objs := busmouse.o console.o keyboard.o pc_keyb.o sysrq.o \ misc.o pty.o random.o selection.o serial.o \ tty_io.o diff -urN 2.4.5-clean/drivers/char/pc_keyb.c linux/drivers/char/pc_keyb.c --- 2.4.5-clean/drivers/char/pc_keyb.c Fri Apr 6 13:42:55 2001 +++ linux/drivers/char/pc_keyb.cFri Jun 15 13:34:18 2001 @@ -13,6 +13,11 @@ * Code fixes to handle mouse ACKs properly. * C. Scott Ananian <[EMAIL PROTECTED]> 1999-01-29. * + * Added optional scancode filtering, used in keyboards which + * (incompatibly) extend the standard PS/2 specification. + * Also added synchronized output writing using a semaphore. + * Dan Streetman <[EMAIL PROTECTED]> 2001-03-14 + * */ #include @@ -32,6 +37,7 @@ #include #include #include +#include #include #include @@ -60,6 +66,7 @@ static void kbd_write_command_w(int data); static void kbd_write_output_w(int data); +static void kb_wait(void); #ifdef CONFIG_PSMOUSE static void aux_write_ack(int val); static void __aux_write_ack(int val); @@ -68,7 +75,7 @@ static spinlock_t kbd_controller_lock = SPIN_LOCK_UNLOCKED; static unsigned char handle_kbd_event(void); -/* used only by send_data - set by keyboard_interrupt */ +/* used by send_data and send_data_buffer - set by keyboard_interrupt */ static volatile unsigned char reply_expected; static volatile unsigned char acknowledge; static volatile unsigned char resend; @@ -94,6 +101,104 @@ #define MAX_RETRIES60 /* some aux operations take long time*/ #endif /* CONFIG_PSMOUSE */ +#ifdef CONFIG_PC_KEYB_FILTER +/* Use an array (instead of a linked list) to save time in_interrupt() */ +static struct pc_keyb_filter
ps2 keyboard filter hook
IBM Retail Store Solutions dept has certain PS/2 keyboards which extend the standard PS/2 specification in order to support addition hardware built into the keyboard (such as a Magnetic Strip Reader, Keylock, Tone generator, extra keys, extra LEDs, etc). This addition hardware behaves in a manner that makes it unusable if driven by a standard PS/2 driver (sadly, due to the fact that its design is IP I can't elaborate on how or why it is incompatible with the standard PS/2 specification). In order to use these keyboards, a the standard PS/2 driver needs to behave a bit differently; thus attached is a modifcation to the PS/2 driver which allows other drivers to register with the PS/2 driver as 'filters'. There is a arbitrary max number of 'filters' set to 1, which is a compile-time define. The registered drivers are called (in order of registration) for every scancode, and they may change or consume the scancode (or allow it to pass). Also the 'filters' are given a function to send an variable-sized buffer to the keyboard output port; this function is synchronized using a semaphore which also coordinates with pckbd_leds(). -Dan diff -urN 2.4.5-clean/Documentation/Configure.help linux/Documentation/Configure.help --- 2.4.5-clean/Documentation/Configure.helpThu May 24 18:03:06 2001 +++ linux/Documentation/Configure.help Fri Jun 15 13:34:18 2001 @@ -13274,6 +13274,21 @@ If you are unsure, say N and read the HOWTO nevertheless: it will tell you what you have. +PS/2 Keyboard Filter support +CONFIG_PC_KEYB_FILTER + This enables filter support in the PS/2 keyboard driver. With + this enabled, other drivers will be able to register with the + PS/2 driver and filter all incoming scancodes. This is useful + for keyboards which extend the PS/2 keyboard standard with + non-standard scancodes which should not be normally routed to + the current console. + + This option does not actually filter any scancodes, it only + allows other drivers (who will do the filtering) to register + with the PS/2 driver. + + If unsure, say N. + QIC-02 tape support CONFIG_QIC02_TAPE If you have a non-SCSI tape drive like that, say Y. Or, if you want diff -urN 2.4.5-clean/drivers/char/Config.in linux/drivers/char/Config.in --- 2.4.5-clean/drivers/char/Config.in Tue Mar 6 22:44:34 2001 +++ linux/drivers/char/Config.inFri Jun 15 13:34:18 2001 @@ -105,6 +105,11 @@ source drivers/char/joystick/Config.in +mainmenu_option next_comment +comment 'Keyboards' +bool 'PS/2 Keyboard Filter support' CONFIG_PC_KEYB_FILTER +endmenu + tristate 'QIC-02 tape support' CONFIG_QIC02_TAPE if [ $CONFIG_QIC02_TAPE != n ]; then bool ' Do you want runtime configuration for QIC-02' CONFIG_QIC02_DYNCONF diff -urN 2.4.5-clean/drivers/char/Makefile linux/drivers/char/Makefile --- 2.4.5-clean/drivers/char/Makefile Wed May 16 13:27:02 2001 +++ linux/drivers/char/Makefile Fri Jun 15 13:34:18 2001 @@ -21,7 +21,7 @@ # All of the (potential) objects that export symbols. # This list comes from 'grep -l EXPORT_SYMBOL *.[hc]'. -export-objs := busmouse.o console.o keyboard.o sysrq.o \ +export-objs := busmouse.o console.o keyboard.o pc_keyb.o sysrq.o \ misc.o pty.o random.o selection.o serial.o \ tty_io.o diff -urN 2.4.5-clean/drivers/char/pc_keyb.c linux/drivers/char/pc_keyb.c --- 2.4.5-clean/drivers/char/pc_keyb.c Fri Apr 6 13:42:55 2001 +++ linux/drivers/char/pc_keyb.cFri Jun 15 13:34:18 2001 @@ -13,6 +13,11 @@ * Code fixes to handle mouse ACKs properly. * C. Scott Ananian [EMAIL PROTECTED] 1999-01-29. * + * Added optional scancode filtering, used in keyboards which + * (incompatibly) extend the standard PS/2 specification. + * Also added synchronized output writing using a semaphore. + * Dan Streetman [EMAIL PROTECTED] 2001-03-14 + * */ #include linux/config.h @@ -32,6 +37,7 @@ #include linux/slab.h #include linux/kbd_kern.h #include linux/smp_lock.h +#include linux/module.h #include asm/keyboard.h #include asm/bitops.h @@ -60,6 +66,7 @@ static void kbd_write_command_w(int data); static void kbd_write_output_w(int data); +static void kb_wait(void); #ifdef CONFIG_PSMOUSE static void aux_write_ack(int val); static void __aux_write_ack(int val); @@ -68,7 +75,7 @@ static spinlock_t kbd_controller_lock = SPIN_LOCK_UNLOCKED; static unsigned char handle_kbd_event(void); -/* used only by send_data - set by keyboard_interrupt */ +/* used by send_data and send_data_buffer - set by keyboard_interrupt */ static volatile unsigned char reply_expected; static volatile unsigned char acknowledge; static volatile unsigned char resend; @@ -94,6 +101,104 @@ #define MAX_RETRIES60 /* some aux operations take long time*/ #endif /* CONFIG_PSMOUSE */ +#ifdef CONFIG_PC_KEYB_FILTER +/* Use an array (instead of a