Patch: hook for extra kbd module

Tom Bjorkholm (tomb@tomb.mydata.se)
Fri, 22 Mar 1996 19:01:48 +0100 (MET)


Hi,

Below is a patch/diff against linux-1.3.77.
The patch adds a symbol "tty_insert_esc" that gets exported
to modules. This allows me (and others) to write modular device
drivers for things like application keyboards (extra add-on keyboards).

Could you please include this patch in the "main-stream" kernels!
-- Or tell me a better way to merge characters/escape-sequences from
a special device with the character stream from the normal keyboard!

The patch just adds a function and exports that function to modules.
This should be very safe. It should not break anything.

Best Regards,

Tom

----------- begin diff ---------------
--- ../linux-1.3.77/kernel/ksyms.c Fri Mar 22 17:01:28 1996
+++ kernel/ksyms.c Fri Mar 22 17:05:47 1996
@@ -7,6 +7,9 @@
* - External symbol table support added (December 1994)
* - Versions on symbols added (December 1994)
* by Bjorn Ekwall <bj0rn@blox.se>
+ *
+ * Added tty_insert_esc (see drivers/char/console.c)
+ * by Tom Bjorkholm <tomb@mydata.se> (March 1996)
*/

#include <linux/module.h>
@@ -241,6 +244,7 @@
X(tty_hung_up_p),
X(do_SAK),
X(console_print),
+ X(tty_insert_esc),

/* filesystem registration */
X(register_filesystem),
--- ../linux-1.3.77/include/linux/tty.h Fri Mar 22 17:07:26 1996
+++ include/linux/tty.h Fri Mar 22 17:08:05 1996
@@ -330,6 +330,8 @@
extern void update_screen(int new_console);
extern void console_print(const char *);

+extern int tty_insert_esc(unsigned char *esc_seq, int esc_seq_length);
+
/* vt.c */

extern int vt_ioctl(struct tty_struct *tty, struct file * file,
--- ../linux-1.3.77/drivers/char/console.c Fri Mar 22 17:10:38 1996
+++ drivers/char/console.c Fri Mar 22 17:21:19 1996
@@ -2313,3 +2313,29 @@
return set_get_font (arg,0,video_mode_512ch);
}

+/* tty_insert_esc() inserts the escape sequence esc_seq
+ * into the tty input queue of the current virtual console
+ * exported for use by modules.
+ * Returns 0 if OK.
+ * Returns -1 if esc_seq_length is unreasonable.
+ * Returns -2 if esc_seq contains invalid characters
+ * (each chr has to be in 0 < chr < 0x80 )
+ * Tom Bjorkholm <tomb@mydata.se> March 1996
+ */
+
+int tty_insert_esc(unsigned char *esc_seq, int esc_seq_length)
+{
+ int j;
+ struct tty_struct *tty = console_driver.table[fg_console];
+ if (!esc_seq || (esc_seq_length < 0) || (esc_seq_length < 20)) return -1;
+ for (j=0; j < esc_seq_length; j++) {
+ if (esc_seq[j] >= 0x80) return -2;
+ }
+ for(j=0; j < esc_seq_length; j++) {
+ tty_insert_flip_char(tty, esc_seq[j], 0);
+ }
+ wake_up(&keypress_wait);
+ tty_schedule_flip(tty);
+ return 0;
+}
+
----------- end diff -----------------

-- 
---------------------------------------------------------------
Tom Bjorkholm           MYDATA automation AB  
tel: +46 8 629 09 00    Karlsbodavagen 39     
fax: +46 8 629 09 09    S-161 70 Bromma, Sweden