11 #include <linux/types.h>
12 #include <linux/errno.h>
13 #include <linux/sched.h>
14 #include <linux/tty.h>
16 #include <linux/kernel.h>
18 #include <linux/module.h>
21 #include <linux/string.h>
22 #include <linux/slab.h>
27 #include <linux/signal.h>
28 #include <linux/timex.h>
31 #include <asm/uaccess.h>
41 #define VT_IS_IN_USE(i) (console_driver->ttys[i] && console_driver->ttys[i]->count)
42 #define VT_BUSY(i) (VT_IS_IN_USE(i) || i == fg_console || vc_cons[i].d == sel_cons)
61 static void complete_change_console(
struct vc_data *
vc);
98 if (!(ve->
event.event & event))
103 ve->
event.oldev = old + 1;
104 ve->
event.newev =
new + 1;
108 spin_unlock_irqrestore(&vt_event_lock, flags);
117 INIT_LIST_HEAD(&vw->
list);
121 list_add(&vw->
list, &vt_events);
122 spin_unlock_irqrestore(&vt_event_lock, flags);
138 spin_unlock_irqrestore(&vt_event_lock, flags);
152 __vt_event_queue(vw);
154 __vt_event_dequeue(vw);
164 static int vt_event_wait_ioctl(
struct vt_event __user *
event)
198 __vt_event_queue(&vw);
200 __vt_event_dequeue(&vw);
203 __vt_event_wait(&vw);
204 __vt_event_dequeue(&vw);
207 }
while (vw.
event.newev != n);
215 #define GPFIRST 0x3b4
217 #define GPNUM (GPLAST - GPFIRST + 1)
292 unsigned int cmd,
unsigned long arg)
348 ticks =
HZ * ((arg >> 16) & 0xffff) / 1000;
349 count = ticks ? (arg & 0xffff) : 0;
379 if (arg < GPFIRST || arg >
GPLAST) {
438 if (vc->
vc_mode == (
unsigned char) arg)
539 if (!valid_signal(arg) || arg < 1 || arg ==
SIGKILL)
624 uival = i < MAX_NR_CONSOLES ? (i+1) : -1;
635 if (arg == 0 || arg > MAX_NR_CONSOLES)
693 if (arg == 0 || arg > MAX_NR_CONSOLES)
748 complete_change_console(
vc_cons[newvt].
d);
767 if (arg > MAX_NR_CONSOLES) {
839 if (ll != vlin/clin) {
849 if (cc != vcol/ccol) {
869 vc_cons[
i].d->vc_font.height = clin;
914 ret = do_fontx_ioctl(cmd, up, perm, &op);
922 #ifdef BROKEN_GRAPHICS_PROGRAMS
993 ret = do_unimap_ioctl(cmd, up, perm, vc);
1008 (
unsigned short __user *)arg);
1059 #ifdef CONFIG_COMPAT
1061 struct compat_consolefontdesc {
1062 unsigned short charcount;
1063 unsigned short charheight;
1068 compat_fontx_ioctl(
int cmd,
struct compat_consolefontdesc __user *user_cfd,
1071 struct compat_consolefontdesc cfdarg;
1074 if (
copy_from_user(&cfdarg, user_cfd,
sizeof(
struct compat_consolefontdesc)))
1084 op->
height = cfdarg.charheight;
1086 op->
data = compat_ptr(cfdarg.chardata);
1092 op->
height = cfdarg.charheight;
1094 op->
data = compat_ptr(cfdarg.chardata);
1098 cfdarg.charheight = op->
height;
1100 if (
copy_to_user(user_cfd, &cfdarg,
sizeof(
struct compat_consolefontdesc)))
1107 struct compat_console_font_op {
1116 compat_kdfontop_ioctl(
struct compat_console_font_op __user *fontop,
1121 if (
copy_from_user(op, fontop,
sizeof(
struct compat_console_font_op)))
1125 op->
data = compat_ptr(((
struct compat_console_font_op *)op)->
data);
1129 ((
struct compat_console_font_op *)op)->data = (
unsigned long)op->
data;
1130 if (
copy_to_user(fontop, op,
sizeof(
struct compat_console_font_op)))
1135 struct compat_unimapdesc {
1136 unsigned short entry_ct;
1141 compat_unimap_ioctl(
unsigned int cmd,
struct compat_unimapdesc __user *user_ud,
1144 struct compat_unimapdesc
tmp;
1149 tmp_entries = compat_ptr(
tmp.entries);
1168 unsigned int cmd,
unsigned long arg)
1198 ret = compat_fontx_ioctl(cmd, up, perm, &op);
1202 ret = compat_kdfontop_ioctl(up, perm, &op, vc);
1207 ret = compat_unimap_ioctl(cmd, up, perm, vc);
1240 arg = (
unsigned long)compat_ptr(arg);
1258 static void complete_change_console(
struct vc_data *vc)
1260 unsigned char old_vc_mode;
1283 if (old_vc_mode != vc->
vc_mode) {
1313 if (old_vc_mode != vc->
vc_mode) {
1396 complete_change_console(new_vc);
1401 static int disable_vt_switch;
1409 if (disable_vt_switch) {
1433 pr_debug(
"Suspend: Can't switch VCs.");
1449 disable_vt_switch = !do_switch;