1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _VT_KERN_H
3 #define _VT_KERN_H
4 
5 /*
6  * this really is an extension of the vc_cons structure in console.c, but
7  * with information needed by the vt package
8  */
9 
10 #include <linux/vt.h>
11 #include <linux/kd.h>
12 #include <linux/tty.h>
13 #include <linux/mutex.h>
14 #include <linux/console_struct.h>
15 #include <linux/mm.h>
16 #include <linux/consolemap.h>
17 #include <linux/notifier.h>
18 
19 void kd_mksound(unsigned int hz, unsigned int ticks);
20 int kbd_rate(struct kbd_repeat *rep);
21 
22 extern int fg_console, last_console, want_console;
23 
24 /* console.c */
25 
26 int vc_allocate(unsigned int console);
27 int vc_cons_allocated(unsigned int console);
28 int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines);
29 struct vc_data *vc_deallocate(unsigned int console);
30 void reset_palette(struct vc_data *vc);
31 void do_blank_screen(int entering_gfx);
32 void do_unblank_screen(int leaving_gfx);
33 void unblank_screen(void);
34 void poke_blanked_console(void);
35 int con_font_op(struct vc_data *vc, struct console_font_op *op);
36 int con_set_cmap(unsigned char __user *cmap);
37 int con_get_cmap(unsigned char __user *cmap);
38 void scrollback(struct vc_data *vc);
39 void scrollfront(struct vc_data *vc, int lines);
40 void clear_buffer_attributes(struct vc_data *vc);
41 void update_region(struct vc_data *vc, unsigned long start, int count);
42 void redraw_screen(struct vc_data *vc, int is_switch);
43 #define update_screen(x) redraw_screen(x, 0)
44 #define switch_screen(x) redraw_screen(x, 1)
45 
46 struct tty_struct;
47 int tioclinux(struct tty_struct *tty, unsigned long arg);
48 
49 #ifdef CONFIG_CONSOLE_TRANSLATIONS
50 /* consolemap.c */
51 
52 struct unipair;
53 
54 int con_set_trans_old(unsigned char __user * table);
55 int con_get_trans_old(unsigned char __user * table);
56 int con_set_trans_new(unsigned short __user * table);
57 int con_get_trans_new(unsigned short __user * table);
58 int con_clear_unimap(struct vc_data *vc);
59 int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list);
60 int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct unipair __user *list);
61 int con_set_default_unimap(struct vc_data *vc);
62 void con_free_unimap(struct vc_data *vc);
63 int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc);
64 
65 #else
con_set_trans_old(unsigned char __user * table)66 static inline int con_set_trans_old(unsigned char __user *table)
67 {
68 	return 0;
69 }
con_get_trans_old(unsigned char __user * table)70 static inline int con_get_trans_old(unsigned char __user *table)
71 {
72 	return -EINVAL;
73 }
con_set_trans_new(unsigned short __user * table)74 static inline int con_set_trans_new(unsigned short __user *table)
75 {
76 	return 0;
77 }
con_get_trans_new(unsigned short __user * table)78 static inline int con_get_trans_new(unsigned short __user *table)
79 {
80 	return -EINVAL;
81 }
con_clear_unimap(struct vc_data * vc)82 static inline int con_clear_unimap(struct vc_data *vc)
83 {
84 	return 0;
85 }
86 static inline
con_set_unimap(struct vc_data * vc,ushort ct,struct unipair __user * list)87 int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
88 {
89 	return 0;
90 }
91 static inline
con_get_unimap(struct vc_data * vc,ushort ct,ushort __user * uct,struct unipair __user * list)92 int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct,
93 		   struct unipair __user *list)
94 {
95 	return -EINVAL;
96 }
con_set_default_unimap(struct vc_data * vc)97 static inline int con_set_default_unimap(struct vc_data *vc)
98 {
99 	return 0;
100 }
con_free_unimap(struct vc_data * vc)101 static inline void con_free_unimap(struct vc_data *vc)
102 {
103 }
con_protect_unimap(struct vc_data * vc,int rdonly)104 static inline void con_protect_unimap(struct vc_data *vc, int rdonly)
105 {
106 }
107 static inline
con_copy_unimap(struct vc_data * dst_vc,struct vc_data * src_vc)108 int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc)
109 {
110 	return 0;
111 }
112 
113 #endif
114 
115 /* vt.c */
116 void vt_event_post(unsigned int event, unsigned int old, unsigned int new);
117 int vt_waitactive(int n);
118 void change_console(struct vc_data *new_vc);
119 void reset_vc(struct vc_data *vc);
120 int do_unbind_con_driver(const struct consw *csw, int first, int last,
121 			 int deflt);
122 int vty_init(const struct file_operations *console_fops);
123 
124 extern bool vt_dont_switch;
125 extern int default_utf8;
126 extern int global_cursor_default;
127 
128 struct vt_spawn_console {
129 	spinlock_t lock;
130 	struct pid *pid;
131 	int sig;
132 };
133 extern struct vt_spawn_console vt_spawn_con;
134 
135 int vt_move_to_console(unsigned int vt, int alloc);
136 
137 /* Interfaces for VC notification of character events (for accessibility etc) */
138 
139 struct vt_notifier_param {
140 	struct vc_data *vc;	/* VC on which the update happened */
141 	unsigned int c;		/* Printed char */
142 };
143 
144 int register_vt_notifier(struct notifier_block *nb);
145 int unregister_vt_notifier(struct notifier_block *nb);
146 
147 void hide_boot_cursor(bool hide);
148 
149 /* keyboard  provided interfaces */
150 int vt_do_diacrit(unsigned int cmd, void __user *up, int eperm);
151 int vt_do_kdskbmode(unsigned int console, unsigned int arg);
152 int vt_do_kdskbmeta(unsigned int console, unsigned int arg);
153 int vt_do_kbkeycode_ioctl(int cmd, struct kbkeycode __user *user_kbkc,
154 			  int perm);
155 int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
156 		     unsigned int console);
157 int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm);
158 int vt_do_kdskled(unsigned int console, int cmd, unsigned long arg, int perm);
159 int vt_do_kdgkbmode(unsigned int console);
160 int vt_do_kdgkbmeta(unsigned int console);
161 void vt_reset_unicode(unsigned int console);
162 int vt_get_shift_state(void);
163 void vt_reset_keyboard(unsigned int console);
164 int vt_get_leds(unsigned int console, int flag);
165 int vt_get_kbd_mode_bit(unsigned int console, int bit);
166 void vt_set_kbd_mode_bit(unsigned int console, int bit);
167 void vt_clr_kbd_mode_bit(unsigned int console, int bit);
168 void vt_set_led_state(unsigned int console, int leds);
169 void vt_kbd_con_start(unsigned int console);
170 void vt_kbd_con_stop(unsigned int console);
171 
172 void vc_scrolldelta_helper(struct vc_data *c, int lines,
173 		unsigned int rolled_over, void *_base, unsigned int size);
174 
175 #endif /* _VT_KERN_H */
176