This source file includes following definitions.
- kiocsound
- vt_ioctl
1
2
3
4
5
6
7 #include <linux/types.h>
8 #include <linux/errno.h>
9 #include <linux/sched.h>
10 #include <linux/tty.h>
11 #include <linux/timer.h>
12 #include <linux/kernel.h>
13 #include <linux/keyboard.h>
14 #include <linux/kd.h>
15 #include <linux/vt.h>
16
17 #include <asm/io.h>
18 #include <asm/segment.h>
19
20 #include "vt_kern.h"
21
22
23
24
25
26 struct vt_cons vt_cons[NR_CONSOLES];
27
28 extern int sys_ioperm(unsigned long from, unsigned long num, int on);
29 extern void set_leds(void);
30
31
32
33
34
35 #define GPFIRST 0x3b4
36 #define GPLAST 0x3df
37 #define GPNUM (GPLAST - GPFIRST + 1)
38
39
40
41
42
43 static int
44 kiocsound(unsigned int freq)
45 {
46 if (freq == 0) {
47
48 outb(inb_p(0x61)&0xFC, 0x61);
49 }
50 else {
51
52 outb_p(inb_p(0x61)|3, 0x61);
53
54 outb_p(0xB6, 0x43);
55
56 outb_p(freq & 0xff, 0x42);
57 outb((freq >> 8) & 0xff, 0x42);
58 }
59 return 0;
60 }
61
62
63
64
65
66 int vt_ioctl(struct tty_struct *tty, struct file * file,
67 unsigned int cmd, unsigned int arg)
68 {
69 int console;
70 unsigned char ucval;
71 struct kbd_struct * kbd;
72
73 console = tty->line - 1;
74
75 if (console < 0 || console >= NR_CONSOLES)
76 return -EINVAL;
77
78 kbd = kbd_table + console;
79 switch (cmd) {
80 case KIOCSOUND:
81 return kiocsound((unsigned int)arg);
82
83 case KDGKBTYPE:
84
85
86
87 verify_area((void *) arg, sizeof(unsigned char));
88 put_fs_byte(KB_101, (unsigned char *) arg);
89 return 0;
90
91 case KDADDIO:
92 case KDDELIO:
93
94
95
96
97 if (arg < GPFIRST || arg > GPLAST)
98 return -EINVAL;
99 return sys_ioperm(arg, 1, (cmd == KDADDIO)) ? -ENXIO : 0;
100
101 case KDENABIO:
102 case KDDISABIO:
103 return sys_ioperm(GPFIRST, GPNUM,
104 (cmd == KDENABIO)) ? -ENXIO : 0;
105
106 case KDSETMODE:
107
108
109
110
111
112 switch (arg) {
113 case KD_GRAPHICS:
114 break;
115 case KD_TEXT0:
116 case KD_TEXT1:
117 arg = KD_TEXT;
118 case KD_TEXT:
119 break;
120 default:
121 return -EINVAL;
122 }
123 if (vt_cons[console].vt_mode == (unsigned char) arg)
124 return 0;
125 vt_cons[console].vt_mode = (unsigned char) arg;
126 if (console != fg_console)
127 return 0;
128 if (arg == KD_TEXT)
129 unblank_screen();
130 else {
131 timer_active &= 1<<BLANK_TIMER;
132 blank_screen();
133 }
134 return 0;
135 case KDGETMODE:
136 verify_area((void *) arg, sizeof(unsigned long));
137 put_fs_long(vt_cons[console].vt_mode, (unsigned long *) arg);
138 return 0;
139
140 case KDMAPDISP:
141 case KDUNMAPDISP:
142
143
144
145
146 return -EINVAL;
147
148 case KDSKBMODE:
149 if (arg == K_RAW) {
150 set_vc_kbd_flag(kbd, VC_RAW);
151 } else if (arg == K_XLATE) {
152 clr_vc_kbd_flag(kbd, VC_RAW);
153 }
154 else
155 return -EINVAL;
156 flush_input(tty);
157 return 0;
158 case KDGKBMODE:
159 verify_area((void *) arg, sizeof(unsigned long));
160 ucval = vc_kbd_flag(kbd, VC_RAW);
161 put_fs_long(ucval ? K_RAW : K_XLATE, (unsigned long *) arg);
162 return 0;
163
164 case KDGETLED:
165 verify_area((void *) arg, sizeof(unsigned char));
166 ucval = 0;
167 if (vc_kbd_flag(kbd, VC_SCROLLOCK))
168 ucval |= LED_SCR;
169 if (vc_kbd_flag(kbd, VC_NUMLOCK))
170 ucval |= LED_NUM;
171 if (vc_kbd_flag(kbd, VC_CAPSLOCK))
172 ucval |= LED_CAP;
173 put_fs_byte(ucval, (unsigned char *) arg);
174 return 0;
175 case KDSETLED:
176 if (arg & ~7)
177 return -EINVAL;
178 if (arg & LED_SCR)
179 set_vc_kbd_flag(kbd, VC_SCROLLOCK);
180 else
181 clr_vc_kbd_flag(kbd, VC_SCROLLOCK);
182 if (arg & LED_NUM)
183 set_vc_kbd_flag(kbd, VC_NUMLOCK);
184 else
185 clr_vc_kbd_flag(kbd, VC_NUMLOCK);
186 if (arg & LED_CAP)
187 set_vc_kbd_flag(kbd, VC_CAPSLOCK);
188 else
189 clr_vc_kbd_flag(kbd, VC_CAPSLOCK);
190 set_leds();
191 return 0;
192
193 default:
194 return -EINVAL;
195 }
196 }