1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * ebcdic keycode functions for s390 console drivers
4 *
5 * Copyright IBM Corp. 2003
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
7 */
8
9 #include <linux/tty.h>
10 #include <linux/tty_flip.h>
11 #include <linux/keyboard.h>
12
13 #define NR_FN_HANDLER 20
14
15 struct kbd_data;
16
17 extern int ebc_funcbufsize, ebc_funcbufleft;
18 extern char *ebc_func_table[MAX_NR_FUNC];
19 extern char ebc_func_buf[];
20 extern char *ebc_funcbufptr;
21 extern unsigned int ebc_keymap_count;
22
23 extern struct kbdiacruc ebc_accent_table[];
24 extern unsigned int ebc_accent_table_size;
25 extern unsigned short *ebc_key_maps[MAX_NR_KEYMAPS];
26 extern unsigned short ebc_plain_map[NR_KEYS];
27
28 typedef void (fn_handler_fn)(struct kbd_data *);
29
30 /*
31 * FIXME: explain key_maps tricks.
32 */
33
34 struct kbd_data {
35 struct tty_port *port;
36 unsigned short **key_maps;
37 char **func_table;
38 fn_handler_fn **fn_handler;
39 struct kbdiacruc *accent_table;
40 unsigned int accent_table_size;
41 unsigned int diacr;
42 unsigned short sysrq;
43 };
44
45 struct kbd_data *kbd_alloc(void);
46 void kbd_free(struct kbd_data *);
47 void kbd_ascebc(struct kbd_data *, unsigned char *);
48
49 void kbd_keycode(struct kbd_data *, unsigned int);
50 int kbd_ioctl(struct kbd_data *, unsigned int, unsigned long);
51
52 /*
53 * Helper Functions.
54 */
55 static inline void
kbd_put_queue(struct tty_port * port,int ch)56 kbd_put_queue(struct tty_port *port, int ch)
57 {
58 tty_insert_flip_char(port, ch, 0);
59 tty_flip_buffer_push(port);
60 }
61
62 static inline void
kbd_puts_queue(struct tty_port * port,char * cp)63 kbd_puts_queue(struct tty_port *port, char *cp)
64 {
65 while (*cp)
66 tty_insert_flip_char(port, *cp++, 0);
67 tty_flip_buffer_push(port);
68 }
69