18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *    ebcdic keycode functions for s390 console drivers
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *    Copyright IBM Corp. 2003
68c2ecf20Sopenharmony_ci *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/tty.h>
108c2ecf20Sopenharmony_ci#include <linux/tty_flip.h>
118c2ecf20Sopenharmony_ci#include <linux/keyboard.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#define NR_FN_HANDLER	20
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cistruct kbd_data;
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ciextern int ebc_funcbufsize, ebc_funcbufleft;
188c2ecf20Sopenharmony_ciextern char *ebc_func_table[MAX_NR_FUNC];
198c2ecf20Sopenharmony_ciextern char ebc_func_buf[];
208c2ecf20Sopenharmony_ciextern char *ebc_funcbufptr;
218c2ecf20Sopenharmony_ciextern unsigned int ebc_keymap_count;
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ciextern struct kbdiacruc ebc_accent_table[];
248c2ecf20Sopenharmony_ciextern unsigned int ebc_accent_table_size;
258c2ecf20Sopenharmony_ciextern unsigned short *ebc_key_maps[MAX_NR_KEYMAPS];
268c2ecf20Sopenharmony_ciextern unsigned short ebc_plain_map[NR_KEYS];
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_citypedef void (fn_handler_fn)(struct kbd_data *);
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci/*
318c2ecf20Sopenharmony_ci * FIXME: explain key_maps tricks.
328c2ecf20Sopenharmony_ci */
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_cistruct kbd_data {
358c2ecf20Sopenharmony_ci	struct tty_port *port;
368c2ecf20Sopenharmony_ci	unsigned short **key_maps;
378c2ecf20Sopenharmony_ci	char **func_table;
388c2ecf20Sopenharmony_ci	fn_handler_fn **fn_handler;
398c2ecf20Sopenharmony_ci	struct kbdiacruc *accent_table;
408c2ecf20Sopenharmony_ci	unsigned int accent_table_size;
418c2ecf20Sopenharmony_ci	unsigned int diacr;
428c2ecf20Sopenharmony_ci	unsigned short sysrq;
438c2ecf20Sopenharmony_ci};
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_cistruct kbd_data *kbd_alloc(void);
468c2ecf20Sopenharmony_civoid kbd_free(struct kbd_data *);
478c2ecf20Sopenharmony_civoid kbd_ascebc(struct kbd_data *, unsigned char *);
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_civoid kbd_keycode(struct kbd_data *, unsigned int);
508c2ecf20Sopenharmony_ciint kbd_ioctl(struct kbd_data *, unsigned int, unsigned long);
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci/*
538c2ecf20Sopenharmony_ci * Helper Functions.
548c2ecf20Sopenharmony_ci */
558c2ecf20Sopenharmony_cistatic inline void
568c2ecf20Sopenharmony_cikbd_put_queue(struct tty_port *port, int ch)
578c2ecf20Sopenharmony_ci{
588c2ecf20Sopenharmony_ci	tty_insert_flip_char(port, ch, 0);
598c2ecf20Sopenharmony_ci	tty_flip_buffer_push(port);
608c2ecf20Sopenharmony_ci}
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_cistatic inline void
638c2ecf20Sopenharmony_cikbd_puts_queue(struct tty_port *port, char *cp)
648c2ecf20Sopenharmony_ci{
658c2ecf20Sopenharmony_ci	while (*cp)
668c2ecf20Sopenharmony_ci		tty_insert_flip_char(port, *cp++, 0);
678c2ecf20Sopenharmony_ci	tty_flip_buffer_push(port);
688c2ecf20Sopenharmony_ci}
69