Commit a29ccf6f823a84d89e1c7aaaf221cf7282022024

Authored by David Woodhouse
1 parent 1beee8dc8c

Make console charset translation optional

By turning off the new CONSOLE_TRANSLATIONS option and dropping the
associated code and tables from the kernel, we can save about 7KiB.

Taken from linux-tiny project by Tim Bird and mangled further by dwmw2.

Signed-off-by: Tim Bird <tim.bird@am.sony.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>

Showing 5 changed files with 44 additions and 3 deletions Inline Diff

drivers/char/Kconfig
1 # 1 #
2 # Character device configuration 2 # Character device configuration
3 # 3 #
4 4
5 menu "Character devices" 5 menu "Character devices"
6 6
7 config VT 7 config VT
8 bool "Virtual terminal" if EMBEDDED 8 bool "Virtual terminal" if EMBEDDED
9 depends on !S390 9 depends on !S390
10 select INPUT 10 select INPUT
11 default y if !VIOCONS 11 default y if !VIOCONS
12 ---help--- 12 ---help---
13 If you say Y here, you will get support for terminal devices with 13 If you say Y here, you will get support for terminal devices with
14 display and keyboard devices. These are called "virtual" because you 14 display and keyboard devices. These are called "virtual" because you
15 can run several virtual terminals (also called virtual consoles) on 15 can run several virtual terminals (also called virtual consoles) on
16 one physical terminal. This is rather useful, for example one 16 one physical terminal. This is rather useful, for example one
17 virtual terminal can collect system messages and warnings, another 17 virtual terminal can collect system messages and warnings, another
18 one can be used for a text-mode user session, and a third could run 18 one can be used for a text-mode user session, and a third could run
19 an X session, all in parallel. Switching between virtual terminals 19 an X session, all in parallel. Switching between virtual terminals
20 is done with certain key combinations, usually Alt-<function key>. 20 is done with certain key combinations, usually Alt-<function key>.
21 21
22 The setterm command ("man setterm") can be used to change the 22 The setterm command ("man setterm") can be used to change the
23 properties (such as colors or beeping) of a virtual terminal. The 23 properties (such as colors or beeping) of a virtual terminal. The
24 man page console_codes(4) ("man console_codes") contains the special 24 man page console_codes(4) ("man console_codes") contains the special
25 character sequences that can be used to change those properties 25 character sequences that can be used to change those properties
26 directly. The fonts used on virtual terminals can be changed with 26 directly. The fonts used on virtual terminals can be changed with
27 the setfont ("man setfont") command and the key bindings are defined 27 the setfont ("man setfont") command and the key bindings are defined
28 with the loadkeys ("man loadkeys") command. 28 with the loadkeys ("man loadkeys") command.
29 29
30 You need at least one virtual terminal device in order to make use 30 You need at least one virtual terminal device in order to make use
31 of your keyboard and monitor. Therefore, only people configuring an 31 of your keyboard and monitor. Therefore, only people configuring an
32 embedded system would want to say N here in order to save some 32 embedded system would want to say N here in order to save some
33 memory; the only way to log into such a system is then via a serial 33 memory; the only way to log into such a system is then via a serial
34 or network connection. 34 or network connection.
35 35
36 If unsure, say Y, or else you won't be able to do much with your new 36 If unsure, say Y, or else you won't be able to do much with your new
37 shiny Linux system :-) 37 shiny Linux system :-)
38 38
39 config CONSOLE_TRANSLATIONS
40 depends on VT
41 default y
42 bool "Enable character translations in console" if EMBEDDED
43 ---help---
44 This enables support for font mapping and Unicode translation
45 on virtual consoles.
46
39 config VT_CONSOLE 47 config VT_CONSOLE
40 bool "Support for console on virtual terminal" if EMBEDDED 48 bool "Support for console on virtual terminal" if EMBEDDED
41 depends on VT 49 depends on VT
42 default y 50 default y
43 ---help--- 51 ---help---
44 The system console is the device which receives all kernel messages 52 The system console is the device which receives all kernel messages
45 and warnings and which allows logins in single user mode. If you 53 and warnings and which allows logins in single user mode. If you
46 answer Y here, a virtual terminal (the device used to interact with 54 answer Y here, a virtual terminal (the device used to interact with
47 a physical terminal) can be used as system console. This is the most 55 a physical terminal) can be used as system console. This is the most
48 common mode of operations, so you should say Y here unless you want 56 common mode of operations, so you should say Y here unless you want
49 the kernel messages be output only to a serial port (in which case 57 the kernel messages be output only to a serial port (in which case
50 you should say Y to "Console on serial port", below). 58 you should say Y to "Console on serial port", below).
51 59
52 If you do say Y here, by default the currently visible virtual 60 If you do say Y here, by default the currently visible virtual
53 terminal (/dev/tty0) will be used as system console. You can change 61 terminal (/dev/tty0) will be used as system console. You can change
54 that with a kernel command line option such as "console=tty3" which 62 that with a kernel command line option such as "console=tty3" which
55 would use the third virtual terminal as system console. (Try "man 63 would use the third virtual terminal as system console. (Try "man
56 bootparam" or see the documentation of your boot loader (lilo or 64 bootparam" or see the documentation of your boot loader (lilo or
57 loadlin) about how to pass options to the kernel at boot time.) 65 loadlin) about how to pass options to the kernel at boot time.)
58 66
59 If unsure, say Y. 67 If unsure, say Y.
60 68
61 config HW_CONSOLE 69 config HW_CONSOLE
62 bool 70 bool
63 depends on VT && !S390 && !UML 71 depends on VT && !S390 && !UML
64 default y 72 default y
65 73
66 config VT_HW_CONSOLE_BINDING 74 config VT_HW_CONSOLE_BINDING
67 bool "Support for binding and unbinding console drivers" 75 bool "Support for binding and unbinding console drivers"
68 depends on HW_CONSOLE 76 depends on HW_CONSOLE
69 default n 77 default n
70 ---help--- 78 ---help---
71 The virtual terminal is the device that interacts with the physical 79 The virtual terminal is the device that interacts with the physical
72 terminal through console drivers. On these systems, at least one 80 terminal through console drivers. On these systems, at least one
73 console driver is loaded. In other configurations, additional console 81 console driver is loaded. In other configurations, additional console
74 drivers may be enabled, such as the framebuffer console. If more than 82 drivers may be enabled, such as the framebuffer console. If more than
75 1 console driver is enabled, setting this to 'y' will allow you to 83 1 console driver is enabled, setting this to 'y' will allow you to
76 select the console driver that will serve as the backend for the 84 select the console driver that will serve as the backend for the
77 virtual terminals. 85 virtual terminals.
78 86
79 See <file:Documentation/console/console.txt> for more 87 See <file:Documentation/console/console.txt> for more
80 information. For framebuffer console users, please refer to 88 information. For framebuffer console users, please refer to
81 <file:Documentation/fb/fbcon.txt>. 89 <file:Documentation/fb/fbcon.txt>.
82 90
83 config DEVKMEM 91 config DEVKMEM
84 bool "/dev/kmem virtual device support" 92 bool "/dev/kmem virtual device support"
85 default y 93 default y
86 help 94 help
87 Say Y here if you want to support the /dev/kmem device. The 95 Say Y here if you want to support the /dev/kmem device. The
88 /dev/kmem device is rarely used, but can be used for certain 96 /dev/kmem device is rarely used, but can be used for certain
89 kind of kernel debugging operations. 97 kind of kernel debugging operations.
90 When in doubt, say "N". 98 When in doubt, say "N".
91 99
92 config SERIAL_NONSTANDARD 100 config SERIAL_NONSTANDARD
93 bool "Non-standard serial port support" 101 bool "Non-standard serial port support"
94 depends on HAS_IOMEM 102 depends on HAS_IOMEM
95 ---help--- 103 ---help---
96 Say Y here if you have any non-standard serial boards -- boards 104 Say Y here if you have any non-standard serial boards -- boards
97 which aren't supported using the standard "dumb" serial driver. 105 which aren't supported using the standard "dumb" serial driver.
98 This includes intelligent serial boards such as Cyclades, 106 This includes intelligent serial boards such as Cyclades,
99 Digiboards, etc. These are usually used for systems that need many 107 Digiboards, etc. These are usually used for systems that need many
100 serial ports because they serve many terminals or dial-in 108 serial ports because they serve many terminals or dial-in
101 connections. 109 connections.
102 110
103 Note that the answer to this question won't directly affect the 111 Note that the answer to this question won't directly affect the
104 kernel: saying N will just cause the configurator to skip all 112 kernel: saying N will just cause the configurator to skip all
105 the questions about non-standard serial boards. 113 the questions about non-standard serial boards.
106 114
107 Most people can say N here. 115 Most people can say N here.
108 116
109 config COMPUTONE 117 config COMPUTONE
110 tristate "Computone IntelliPort Plus serial support" 118 tristate "Computone IntelliPort Plus serial support"
111 depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI) 119 depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI)
112 ---help--- 120 ---help---
113 This driver supports the entire family of Intelliport II/Plus 121 This driver supports the entire family of Intelliport II/Plus
114 controllers with the exception of the MicroChannel controllers and 122 controllers with the exception of the MicroChannel controllers and
115 products previous to the Intelliport II. These are multiport cards, 123 products previous to the Intelliport II. These are multiport cards,
116 which give you many serial ports. You would need something like this 124 which give you many serial ports. You would need something like this
117 to connect more than two modems to your Linux box, for instance in 125 to connect more than two modems to your Linux box, for instance in
118 order to become a dial-in server. If you have a card like that, say 126 order to become a dial-in server. If you have a card like that, say
119 Y here and read <file:Documentation/computone.txt>. 127 Y here and read <file:Documentation/computone.txt>.
120 128
121 To compile this driver as modules, choose M here: the 129 To compile this driver as modules, choose M here: the
122 modules will be called ip2 and ip2main. 130 modules will be called ip2 and ip2main.
123 131
124 config ROCKETPORT 132 config ROCKETPORT
125 tristate "Comtrol RocketPort support" 133 tristate "Comtrol RocketPort support"
126 depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI) 134 depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI)
127 help 135 help
128 This driver supports Comtrol RocketPort and RocketModem PCI boards. 136 This driver supports Comtrol RocketPort and RocketModem PCI boards.
129 These boards provide 2, 4, 8, 16, or 32 high-speed serial ports or 137 These boards provide 2, 4, 8, 16, or 32 high-speed serial ports or
130 modems. For information about the RocketPort/RocketModem boards 138 modems. For information about the RocketPort/RocketModem boards
131 and this driver read <file:Documentation/rocket.txt>. 139 and this driver read <file:Documentation/rocket.txt>.
132 140
133 To compile this driver as a module, choose M here: the 141 To compile this driver as a module, choose M here: the
134 module will be called rocket. 142 module will be called rocket.
135 143
136 If you want to compile this driver into the kernel, say Y here. If 144 If you want to compile this driver into the kernel, say Y here. If
137 you don't have a Comtrol RocketPort/RocketModem card installed, say N. 145 you don't have a Comtrol RocketPort/RocketModem card installed, say N.
138 146
139 config CYCLADES 147 config CYCLADES
140 tristate "Cyclades async mux support" 148 tristate "Cyclades async mux support"
141 depends on SERIAL_NONSTANDARD && (PCI || ISA) 149 depends on SERIAL_NONSTANDARD && (PCI || ISA)
142 select FW_LOADER 150 select FW_LOADER
143 ---help--- 151 ---help---
144 This driver supports Cyclades Z and Y multiserial boards. 152 This driver supports Cyclades Z and Y multiserial boards.
145 You would need something like this to connect more than two modems to 153 You would need something like this to connect more than two modems to
146 your Linux box, for instance in order to become a dial-in server. 154 your Linux box, for instance in order to become a dial-in server.
147 155
148 For information about the Cyclades-Z card, read 156 For information about the Cyclades-Z card, read
149 <file:Documentation/README.cycladesZ>. 157 <file:Documentation/README.cycladesZ>.
150 158
151 To compile this driver as a module, choose M here: the 159 To compile this driver as a module, choose M here: the
152 module will be called cyclades. 160 module will be called cyclades.
153 161
154 If you haven't heard about it, it's safe to say N. 162 If you haven't heard about it, it's safe to say N.
155 163
156 config CYZ_INTR 164 config CYZ_INTR
157 bool "Cyclades-Z interrupt mode operation (EXPERIMENTAL)" 165 bool "Cyclades-Z interrupt mode operation (EXPERIMENTAL)"
158 depends on EXPERIMENTAL && CYCLADES 166 depends on EXPERIMENTAL && CYCLADES
159 help 167 help
160 The Cyclades-Z family of multiport cards allows 2 (two) driver op 168 The Cyclades-Z family of multiport cards allows 2 (two) driver op
161 modes: polling and interrupt. In polling mode, the driver will check 169 modes: polling and interrupt. In polling mode, the driver will check
162 the status of the Cyclades-Z ports every certain amount of time 170 the status of the Cyclades-Z ports every certain amount of time
163 (which is called polling cycle and is configurable). In interrupt 171 (which is called polling cycle and is configurable). In interrupt
164 mode, it will use an interrupt line (IRQ) in order to check the 172 mode, it will use an interrupt line (IRQ) in order to check the
165 status of the Cyclades-Z ports. The default op mode is polling. If 173 status of the Cyclades-Z ports. The default op mode is polling. If
166 unsure, say N. 174 unsure, say N.
167 175
168 config DIGIEPCA 176 config DIGIEPCA
169 tristate "Digiboard Intelligent Async Support" 177 tristate "Digiboard Intelligent Async Support"
170 depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI) 178 depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI)
171 ---help--- 179 ---help---
172 This is a driver for Digi International's Xx, Xeve, and Xem series 180 This is a driver for Digi International's Xx, Xeve, and Xem series
173 of cards which provide multiple serial ports. You would need 181 of cards which provide multiple serial ports. You would need
174 something like this to connect more than two modems to your Linux 182 something like this to connect more than two modems to your Linux
175 box, for instance in order to become a dial-in server. This driver 183 box, for instance in order to become a dial-in server. This driver
176 supports the original PC (ISA) boards as well as PCI, and EISA. If 184 supports the original PC (ISA) boards as well as PCI, and EISA. If
177 you have a card like this, say Y here and read the file 185 you have a card like this, say Y here and read the file
178 <file:Documentation/digiepca.txt>. 186 <file:Documentation/digiepca.txt>.
179 187
180 To compile this driver as a module, choose M here: the 188 To compile this driver as a module, choose M here: the
181 module will be called epca. 189 module will be called epca.
182 190
183 config ESPSERIAL 191 config ESPSERIAL
184 tristate "Hayes ESP serial port support" 192 tristate "Hayes ESP serial port support"
185 depends on SERIAL_NONSTANDARD && ISA && ISA_DMA_API 193 depends on SERIAL_NONSTANDARD && ISA && ISA_DMA_API
186 help 194 help
187 This is a driver which supports Hayes ESP serial ports. Both single 195 This is a driver which supports Hayes ESP serial ports. Both single
188 port cards and multiport cards are supported. Make sure to read 196 port cards and multiport cards are supported. Make sure to read
189 <file:Documentation/hayes-esp.txt>. 197 <file:Documentation/hayes-esp.txt>.
190 198
191 To compile this driver as a module, choose M here: the 199 To compile this driver as a module, choose M here: the
192 module will be called esp. 200 module will be called esp.
193 201
194 If unsure, say N. 202 If unsure, say N.
195 203
196 config MOXA_INTELLIO 204 config MOXA_INTELLIO
197 tristate "Moxa Intellio support" 205 tristate "Moxa Intellio support"
198 depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI) 206 depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI)
199 select FW_LOADER 207 select FW_LOADER
200 help 208 help
201 Say Y here if you have a Moxa Intellio multiport serial card. 209 Say Y here if you have a Moxa Intellio multiport serial card.
202 210
203 To compile this driver as a module, choose M here: the 211 To compile this driver as a module, choose M here: the
204 module will be called moxa. 212 module will be called moxa.
205 213
206 config MOXA_SMARTIO 214 config MOXA_SMARTIO
207 tristate "Moxa SmartIO support v. 2.0" 215 tristate "Moxa SmartIO support v. 2.0"
208 depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA) 216 depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA)
209 help 217 help
210 Say Y here if you have a Moxa SmartIO multiport serial card and/or 218 Say Y here if you have a Moxa SmartIO multiport serial card and/or
211 want to help develop a new version of this driver. 219 want to help develop a new version of this driver.
212 220
213 This is upgraded (1.9.1) driver from original Moxa drivers with 221 This is upgraded (1.9.1) driver from original Moxa drivers with
214 changes finally resulting in PCI probing. 222 changes finally resulting in PCI probing.
215 223
216 This driver can also be built as a module. The module will be called 224 This driver can also be built as a module. The module will be called
217 mxser. If you want to do that, say M here. 225 mxser. If you want to do that, say M here.
218 226
219 config ISI 227 config ISI
220 tristate "Multi-Tech multiport card support (EXPERIMENTAL)" 228 tristate "Multi-Tech multiport card support (EXPERIMENTAL)"
221 depends on SERIAL_NONSTANDARD && PCI 229 depends on SERIAL_NONSTANDARD && PCI
222 select FW_LOADER 230 select FW_LOADER
223 help 231 help
224 This is a driver for the Multi-Tech cards which provide several 232 This is a driver for the Multi-Tech cards which provide several
225 serial ports. The driver is experimental and can currently only be 233 serial ports. The driver is experimental and can currently only be
226 built as a module. The module will be called isicom. 234 built as a module. The module will be called isicom.
227 If you want to do that, choose M here. 235 If you want to do that, choose M here.
228 236
229 config SYNCLINK 237 config SYNCLINK
230 tristate "Microgate SyncLink card support" 238 tristate "Microgate SyncLink card support"
231 depends on SERIAL_NONSTANDARD && PCI && ISA_DMA_API 239 depends on SERIAL_NONSTANDARD && PCI && ISA_DMA_API
232 help 240 help
233 Provides support for the SyncLink ISA and PCI multiprotocol serial 241 Provides support for the SyncLink ISA and PCI multiprotocol serial
234 adapters. These adapters support asynchronous and HDLC bit 242 adapters. These adapters support asynchronous and HDLC bit
235 synchronous communication up to 10Mbps (PCI adapter). 243 synchronous communication up to 10Mbps (PCI adapter).
236 244
237 This driver can only be built as a module ( = code which can be 245 This driver can only be built as a module ( = code which can be
238 inserted in and removed from the running kernel whenever you want). 246 inserted in and removed from the running kernel whenever you want).
239 The module will be called synclink. If you want to do that, say M 247 The module will be called synclink. If you want to do that, say M
240 here. 248 here.
241 249
242 config SYNCLINKMP 250 config SYNCLINKMP
243 tristate "SyncLink Multiport support" 251 tristate "SyncLink Multiport support"
244 depends on SERIAL_NONSTANDARD && PCI 252 depends on SERIAL_NONSTANDARD && PCI
245 help 253 help
246 Enable support for the SyncLink Multiport (2 or 4 ports) 254 Enable support for the SyncLink Multiport (2 or 4 ports)
247 serial adapter, running asynchronous and HDLC communications up 255 serial adapter, running asynchronous and HDLC communications up
248 to 2.048Mbps. Each ports is independently selectable for 256 to 2.048Mbps. Each ports is independently selectable for
249 RS-232, V.35, RS-449, RS-530, and X.21 257 RS-232, V.35, RS-449, RS-530, and X.21
250 258
251 This driver may be built as a module ( = code which can be 259 This driver may be built as a module ( = code which can be
252 inserted in and removed from the running kernel whenever you want). 260 inserted in and removed from the running kernel whenever you want).
253 The module will be called synclinkmp. If you want to do that, say M 261 The module will be called synclinkmp. If you want to do that, say M
254 here. 262 here.
255 263
256 config SYNCLINK_GT 264 config SYNCLINK_GT
257 tristate "SyncLink GT/AC support" 265 tristate "SyncLink GT/AC support"
258 depends on SERIAL_NONSTANDARD && PCI 266 depends on SERIAL_NONSTANDARD && PCI
259 help 267 help
260 Support for SyncLink GT and SyncLink AC families of 268 Support for SyncLink GT and SyncLink AC families of
261 synchronous and asynchronous serial adapters 269 synchronous and asynchronous serial adapters
262 manufactured by Microgate Systems, Ltd. (www.microgate.com) 270 manufactured by Microgate Systems, Ltd. (www.microgate.com)
263 271
264 config N_HDLC 272 config N_HDLC
265 tristate "HDLC line discipline support" 273 tristate "HDLC line discipline support"
266 depends on SERIAL_NONSTANDARD 274 depends on SERIAL_NONSTANDARD
267 help 275 help
268 Allows synchronous HDLC communications with tty device drivers that 276 Allows synchronous HDLC communications with tty device drivers that
269 support synchronous HDLC such as the Microgate SyncLink adapter. 277 support synchronous HDLC such as the Microgate SyncLink adapter.
270 278
271 This driver can only be built as a module ( = code which can be 279 This driver can only be built as a module ( = code which can be
272 inserted in and removed from the running kernel whenever you want). 280 inserted in and removed from the running kernel whenever you want).
273 The module will be called n_hdlc. If you want to do that, say M 281 The module will be called n_hdlc. If you want to do that, say M
274 here. 282 here.
275 283
276 config RISCOM8 284 config RISCOM8
277 tristate "SDL RISCom/8 card support" 285 tristate "SDL RISCom/8 card support"
278 depends on SERIAL_NONSTANDARD 286 depends on SERIAL_NONSTANDARD
279 help 287 help
280 This is a driver for the SDL Communications RISCom/8 multiport card, 288 This is a driver for the SDL Communications RISCom/8 multiport card,
281 which gives you many serial ports. You would need something like 289 which gives you many serial ports. You would need something like
282 this to connect more than two modems to your Linux box, for instance 290 this to connect more than two modems to your Linux box, for instance
283 in order to become a dial-in server. If you have a card like that, 291 in order to become a dial-in server. If you have a card like that,
284 say Y here and read the file <file:Documentation/riscom8.txt>. 292 say Y here and read the file <file:Documentation/riscom8.txt>.
285 293
286 Also it's possible to say M here and compile this driver as kernel 294 Also it's possible to say M here and compile this driver as kernel
287 loadable module; the module will be called riscom8. 295 loadable module; the module will be called riscom8.
288 296
289 config SPECIALIX 297 config SPECIALIX
290 tristate "Specialix IO8+ card support" 298 tristate "Specialix IO8+ card support"
291 depends on SERIAL_NONSTANDARD 299 depends on SERIAL_NONSTANDARD
292 help 300 help
293 This is a driver for the Specialix IO8+ multiport card (both the 301 This is a driver for the Specialix IO8+ multiport card (both the
294 ISA and the PCI version) which gives you many serial ports. You 302 ISA and the PCI version) which gives you many serial ports. You
295 would need something like this to connect more than two modems to 303 would need something like this to connect more than two modems to
296 your Linux box, for instance in order to become a dial-in server. 304 your Linux box, for instance in order to become a dial-in server.
297 305
298 If you have a card like that, say Y here and read the file 306 If you have a card like that, say Y here and read the file
299 <file:Documentation/specialix.txt>. Also it's possible to say M here 307 <file:Documentation/specialix.txt>. Also it's possible to say M here
300 and compile this driver as kernel loadable module which will be 308 and compile this driver as kernel loadable module which will be
301 called specialix. 309 called specialix.
302 310
303 config SPECIALIX_RTSCTS 311 config SPECIALIX_RTSCTS
304 bool "Specialix DTR/RTS pin is RTS" 312 bool "Specialix DTR/RTS pin is RTS"
305 depends on SPECIALIX 313 depends on SPECIALIX
306 help 314 help
307 The Specialix IO8+ card can only support either RTS or DTR. If you 315 The Specialix IO8+ card can only support either RTS or DTR. If you
308 say N here, the driver will use the pin as "DTR" when the tty is in 316 say N here, the driver will use the pin as "DTR" when the tty is in
309 software handshake mode. If you say Y here or hardware handshake is 317 software handshake mode. If you say Y here or hardware handshake is
310 on, it will always be RTS. Read the file 318 on, it will always be RTS. Read the file
311 <file:Documentation/specialix.txt> for more information. 319 <file:Documentation/specialix.txt> for more information.
312 320
313 config SX 321 config SX
314 tristate "Specialix SX (and SI) card support" 322 tristate "Specialix SX (and SI) card support"
315 depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA) 323 depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA)
316 help 324 help
317 This is a driver for the SX and SI multiport serial cards. 325 This is a driver for the SX and SI multiport serial cards.
318 Please read the file <file:Documentation/sx.txt> for details. 326 Please read the file <file:Documentation/sx.txt> for details.
319 327
320 This driver can only be built as a module ( = code which can be 328 This driver can only be built as a module ( = code which can be
321 inserted in and removed from the running kernel whenever you want). 329 inserted in and removed from the running kernel whenever you want).
322 The module will be called sx. If you want to do that, say M here. 330 The module will be called sx. If you want to do that, say M here.
323 331
324 config RIO 332 config RIO
325 tristate "Specialix RIO system support" 333 tristate "Specialix RIO system support"
326 depends on SERIAL_NONSTANDARD 334 depends on SERIAL_NONSTANDARD
327 help 335 help
328 This is a driver for the Specialix RIO, a smart serial card which 336 This is a driver for the Specialix RIO, a smart serial card which
329 drives an outboard box that can support up to 128 ports. Product 337 drives an outboard box that can support up to 128 ports. Product
330 information is at <http://www.perle.com/support/documentation.html#multiport>. 338 information is at <http://www.perle.com/support/documentation.html#multiport>.
331 There are both ISA and PCI versions. 339 There are both ISA and PCI versions.
332 340
333 config RIO_OLDPCI 341 config RIO_OLDPCI
334 bool "Support really old RIO/PCI cards" 342 bool "Support really old RIO/PCI cards"
335 depends on RIO 343 depends on RIO
336 help 344 help
337 Older RIO PCI cards need some initialization-time configuration to 345 Older RIO PCI cards need some initialization-time configuration to
338 determine the IRQ and some control addresses. If you have a RIO and 346 determine the IRQ and some control addresses. If you have a RIO and
339 this doesn't seem to work, try setting this to Y. 347 this doesn't seem to work, try setting this to Y.
340 348
341 config STALDRV 349 config STALDRV
342 bool "Stallion multiport serial support" 350 bool "Stallion multiport serial support"
343 depends on SERIAL_NONSTANDARD 351 depends on SERIAL_NONSTANDARD
344 help 352 help
345 Stallion cards give you many serial ports. You would need something 353 Stallion cards give you many serial ports. You would need something
346 like this to connect more than two modems to your Linux box, for 354 like this to connect more than two modems to your Linux box, for
347 instance in order to become a dial-in server. If you say Y here, 355 instance in order to become a dial-in server. If you say Y here,
348 you will be asked for your specific card model in the next 356 you will be asked for your specific card model in the next
349 questions. Make sure to read <file:Documentation/stallion.txt> in 357 questions. Make sure to read <file:Documentation/stallion.txt> in
350 this case. If you have never heard about all this, it's safe to 358 this case. If you have never heard about all this, it's safe to
351 say N. 359 say N.
352 360
353 config STALLION 361 config STALLION
354 tristate "Stallion EasyIO or EC8/32 support" 362 tristate "Stallion EasyIO or EC8/32 support"
355 depends on STALDRV && BROKEN_ON_SMP && (ISA || EISA || PCI) 363 depends on STALDRV && BROKEN_ON_SMP && (ISA || EISA || PCI)
356 help 364 help
357 If you have an EasyIO or EasyConnection 8/32 multiport Stallion 365 If you have an EasyIO or EasyConnection 8/32 multiport Stallion
358 card, then this is for you; say Y. Make sure to read 366 card, then this is for you; say Y. Make sure to read
359 <file:Documentation/stallion.txt>. 367 <file:Documentation/stallion.txt>.
360 368
361 To compile this driver as a module, choose M here: the 369 To compile this driver as a module, choose M here: the
362 module will be called stallion. 370 module will be called stallion.
363 371
364 config ISTALLION 372 config ISTALLION
365 tristate "Stallion EC8/64, ONboard, Brumby support" 373 tristate "Stallion EC8/64, ONboard, Brumby support"
366 depends on STALDRV && BROKEN_ON_SMP && (ISA || EISA || PCI) 374 depends on STALDRV && BROKEN_ON_SMP && (ISA || EISA || PCI)
367 help 375 help
368 If you have an EasyConnection 8/64, ONboard, Brumby or Stallion 376 If you have an EasyConnection 8/64, ONboard, Brumby or Stallion
369 serial multiport card, say Y here. Make sure to read 377 serial multiport card, say Y here. Make sure to read
370 <file:Documentation/stallion.txt>. 378 <file:Documentation/stallion.txt>.
371 379
372 To compile this driver as a module, choose M here: the 380 To compile this driver as a module, choose M here: the
373 module will be called istallion. 381 module will be called istallion.
374 382
375 config NOZOMI 383 config NOZOMI
376 tristate "HSDPA Broadband Wireless Data Card - Globe Trotter" 384 tristate "HSDPA Broadband Wireless Data Card - Globe Trotter"
377 depends on PCI && EXPERIMENTAL 385 depends on PCI && EXPERIMENTAL
378 help 386 help
379 If you have a HSDPA driver Broadband Wireless Data Card - 387 If you have a HSDPA driver Broadband Wireless Data Card -
380 Globe Trotter PCMCIA card, say Y here. 388 Globe Trotter PCMCIA card, say Y here.
381 389
382 To compile this driver as a module, choose M here, the module 390 To compile this driver as a module, choose M here, the module
383 will be called nozomi. 391 will be called nozomi.
384 392
385 config A2232 393 config A2232
386 tristate "Commodore A2232 serial support (EXPERIMENTAL)" 394 tristate "Commodore A2232 serial support (EXPERIMENTAL)"
387 depends on EXPERIMENTAL && ZORRO && BROKEN_ON_SMP 395 depends on EXPERIMENTAL && ZORRO && BROKEN_ON_SMP
388 ---help--- 396 ---help---
389 This option supports the 2232 7-port serial card shipped with the 397 This option supports the 2232 7-port serial card shipped with the
390 Amiga 2000 and other Zorro-bus machines, dating from 1989. At 398 Amiga 2000 and other Zorro-bus machines, dating from 1989. At
391 a max of 19,200 bps, the ports are served by a 6551 ACIA UART chip 399 a max of 19,200 bps, the ports are served by a 6551 ACIA UART chip
392 each, plus a 8520 CIA, and a master 6502 CPU and buffer as well. The 400 each, plus a 8520 CIA, and a master 6502 CPU and buffer as well. The
393 ports were connected with 8 pin DIN connectors on the card bracket, 401 ports were connected with 8 pin DIN connectors on the card bracket,
394 for which 8 pin to DB25 adapters were supplied. The card also had 402 for which 8 pin to DB25 adapters were supplied. The card also had
395 jumpers internally to toggle various pinning configurations. 403 jumpers internally to toggle various pinning configurations.
396 404
397 This driver can be built as a module; but then "generic_serial" 405 This driver can be built as a module; but then "generic_serial"
398 will also be built as a module. This has to be loaded before 406 will also be built as a module. This has to be loaded before
399 "ser_a2232". If you want to do this, answer M here. 407 "ser_a2232". If you want to do this, answer M here.
400 408
401 config SGI_SNSC 409 config SGI_SNSC
402 bool "SGI Altix system controller communication support" 410 bool "SGI Altix system controller communication support"
403 depends on (IA64_SGI_SN2 || IA64_GENERIC) 411 depends on (IA64_SGI_SN2 || IA64_GENERIC)
404 help 412 help
405 If you have an SGI Altix and you want to enable system 413 If you have an SGI Altix and you want to enable system
406 controller communication from user space (you want this!), 414 controller communication from user space (you want this!),
407 say Y. Otherwise, say N. 415 say Y. Otherwise, say N.
408 416
409 config SGI_TIOCX 417 config SGI_TIOCX
410 bool "SGI TIO CX driver support" 418 bool "SGI TIO CX driver support"
411 depends on (IA64_SGI_SN2 || IA64_GENERIC) 419 depends on (IA64_SGI_SN2 || IA64_GENERIC)
412 help 420 help
413 If you have an SGI Altix and you have fpga devices attached 421 If you have an SGI Altix and you have fpga devices attached
414 to your TIO, say Y here, otherwise say N. 422 to your TIO, say Y here, otherwise say N.
415 423
416 config SGI_MBCS 424 config SGI_MBCS
417 tristate "SGI FPGA Core Services driver support" 425 tristate "SGI FPGA Core Services driver support"
418 depends on SGI_TIOCX 426 depends on SGI_TIOCX
419 help 427 help
420 If you have an SGI Altix with an attached SABrick 428 If you have an SGI Altix with an attached SABrick
421 say Y or M here, otherwise say N. 429 say Y or M here, otherwise say N.
422 430
423 source "drivers/serial/Kconfig" 431 source "drivers/serial/Kconfig"
424 432
425 config UNIX98_PTYS 433 config UNIX98_PTYS
426 bool "Unix98 PTY support" if EMBEDDED 434 bool "Unix98 PTY support" if EMBEDDED
427 default y 435 default y
428 ---help--- 436 ---help---
429 A pseudo terminal (PTY) is a software device consisting of two 437 A pseudo terminal (PTY) is a software device consisting of two
430 halves: a master and a slave. The slave device behaves identical to 438 halves: a master and a slave. The slave device behaves identical to
431 a physical terminal; the master device is used by a process to 439 a physical terminal; the master device is used by a process to
432 read data from and write data to the slave, thereby emulating a 440 read data from and write data to the slave, thereby emulating a
433 terminal. Typical programs for the master side are telnet servers 441 terminal. Typical programs for the master side are telnet servers
434 and xterms. 442 and xterms.
435 443
436 Linux has traditionally used the BSD-like names /dev/ptyxx for 444 Linux has traditionally used the BSD-like names /dev/ptyxx for
437 masters and /dev/ttyxx for slaves of pseudo terminals. This scheme 445 masters and /dev/ttyxx for slaves of pseudo terminals. This scheme
438 has a number of problems. The GNU C library glibc 2.1 and later, 446 has a number of problems. The GNU C library glibc 2.1 and later,
439 however, supports the Unix98 naming standard: in order to acquire a 447 however, supports the Unix98 naming standard: in order to acquire a
440 pseudo terminal, a process opens /dev/ptmx; the number of the pseudo 448 pseudo terminal, a process opens /dev/ptmx; the number of the pseudo
441 terminal is then made available to the process and the pseudo 449 terminal is then made available to the process and the pseudo
442 terminal slave can be accessed as /dev/pts/<number>. What was 450 terminal slave can be accessed as /dev/pts/<number>. What was
443 traditionally /dev/ttyp2 will then be /dev/pts/2, for example. 451 traditionally /dev/ttyp2 will then be /dev/pts/2, for example.
444 452
445 All modern Linux systems use the Unix98 ptys. Say Y unless 453 All modern Linux systems use the Unix98 ptys. Say Y unless
446 you're on an embedded system and want to conserve memory. 454 you're on an embedded system and want to conserve memory.
447 455
448 config LEGACY_PTYS 456 config LEGACY_PTYS
449 bool "Legacy (BSD) PTY support" 457 bool "Legacy (BSD) PTY support"
450 default y 458 default y
451 ---help--- 459 ---help---
452 A pseudo terminal (PTY) is a software device consisting of two 460 A pseudo terminal (PTY) is a software device consisting of two
453 halves: a master and a slave. The slave device behaves identical to 461 halves: a master and a slave. The slave device behaves identical to
454 a physical terminal; the master device is used by a process to 462 a physical terminal; the master device is used by a process to
455 read data from and write data to the slave, thereby emulating a 463 read data from and write data to the slave, thereby emulating a
456 terminal. Typical programs for the master side are telnet servers 464 terminal. Typical programs for the master side are telnet servers
457 and xterms. 465 and xterms.
458 466
459 Linux has traditionally used the BSD-like names /dev/ptyxx 467 Linux has traditionally used the BSD-like names /dev/ptyxx
460 for masters and /dev/ttyxx for slaves of pseudo 468 for masters and /dev/ttyxx for slaves of pseudo
461 terminals. This scheme has a number of problems, including 469 terminals. This scheme has a number of problems, including
462 security. This option enables these legacy devices; on most 470 security. This option enables these legacy devices; on most
463 systems, it is safe to say N. 471 systems, it is safe to say N.
464 472
465 473
466 config LEGACY_PTY_COUNT 474 config LEGACY_PTY_COUNT
467 int "Maximum number of legacy PTY in use" 475 int "Maximum number of legacy PTY in use"
468 depends on LEGACY_PTYS 476 depends on LEGACY_PTYS
469 range 0 256 477 range 0 256
470 default "256" 478 default "256"
471 ---help--- 479 ---help---
472 The maximum number of legacy PTYs that can be used at any one time. 480 The maximum number of legacy PTYs that can be used at any one time.
473 The default is 256, and should be more than enough. Embedded 481 The default is 256, and should be more than enough. Embedded
474 systems may want to reduce this to save memory. 482 systems may want to reduce this to save memory.
475 483
476 When not in use, each legacy PTY occupies 12 bytes on 32-bit 484 When not in use, each legacy PTY occupies 12 bytes on 32-bit
477 architectures and 24 bytes on 64-bit architectures. 485 architectures and 24 bytes on 64-bit architectures.
478 486
479 config BRIQ_PANEL 487 config BRIQ_PANEL
480 tristate 'Total Impact briQ front panel driver' 488 tristate 'Total Impact briQ front panel driver'
481 depends on PPC_CHRP 489 depends on PPC_CHRP
482 ---help--- 490 ---help---
483 The briQ is a small footprint CHRP computer with a frontpanel VFD, a 491 The briQ is a small footprint CHRP computer with a frontpanel VFD, a
484 tristate led and two switches. It is the size of a CDROM drive. 492 tristate led and two switches. It is the size of a CDROM drive.
485 493
486 If you have such one and want anything showing on the VFD then you 494 If you have such one and want anything showing on the VFD then you
487 must answer Y here. 495 must answer Y here.
488 496
489 To compile this driver as a module, choose M here: the 497 To compile this driver as a module, choose M here: the
490 module will be called briq_panel. 498 module will be called briq_panel.
491 499
492 It's safe to say N here. 500 It's safe to say N here.
493 501
494 config BFIN_OTP 502 config BFIN_OTP
495 tristate "Blackfin On-Chip OTP Memory Support" 503 tristate "Blackfin On-Chip OTP Memory Support"
496 depends on BLACKFIN && (BF52x || BF54x) 504 depends on BLACKFIN && (BF52x || BF54x)
497 default y 505 default y
498 help 506 help
499 If you say Y here, you will get support for a character device 507 If you say Y here, you will get support for a character device
500 interface into the One Time Programmable memory pages that are 508 interface into the One Time Programmable memory pages that are
501 stored on the Blackfin processor. This will not get you access 509 stored on the Blackfin processor. This will not get you access
502 to the secure memory pages however. You will need to write your 510 to the secure memory pages however. You will need to write your
503 own secure code and reader for that. 511 own secure code and reader for that.
504 512
505 To compile this driver as a module, choose M here: the module 513 To compile this driver as a module, choose M here: the module
506 will be called bfin-otp. 514 will be called bfin-otp.
507 515
508 If unsure, it is safe to say Y. 516 If unsure, it is safe to say Y.
509 517
510 config BFIN_OTP_WRITE_ENABLE 518 config BFIN_OTP_WRITE_ENABLE
511 bool "Enable writing support of OTP pages" 519 bool "Enable writing support of OTP pages"
512 depends on BFIN_OTP 520 depends on BFIN_OTP
513 default n 521 default n
514 help 522 help
515 If you say Y here, you will enable support for writing of the 523 If you say Y here, you will enable support for writing of the
516 OTP pages. This is dangerous by nature as you can only program 524 OTP pages. This is dangerous by nature as you can only program
517 the pages once, so only enable this option when you actually 525 the pages once, so only enable this option when you actually
518 need it so as to not inadvertently clobber data. 526 need it so as to not inadvertently clobber data.
519 527
520 If unsure, say N. 528 If unsure, say N.
521 529
522 config PRINTER 530 config PRINTER
523 tristate "Parallel printer support" 531 tristate "Parallel printer support"
524 depends on PARPORT 532 depends on PARPORT
525 ---help--- 533 ---help---
526 If you intend to attach a printer to the parallel port of your Linux 534 If you intend to attach a printer to the parallel port of your Linux
527 box (as opposed to using a serial printer; if the connector at the 535 box (as opposed to using a serial printer; if the connector at the
528 printer has 9 or 25 holes ["female"], then it's serial), say Y. 536 printer has 9 or 25 holes ["female"], then it's serial), say Y.
529 Also read the Printing-HOWTO, available from 537 Also read the Printing-HOWTO, available from
530 <http://www.tldp.org/docs.html#howto>. 538 <http://www.tldp.org/docs.html#howto>.
531 539
532 It is possible to share one parallel port among several devices 540 It is possible to share one parallel port among several devices
533 (e.g. printer and ZIP drive) and it is safe to compile the 541 (e.g. printer and ZIP drive) and it is safe to compile the
534 corresponding drivers into the kernel. 542 corresponding drivers into the kernel.
535 543
536 To compile this driver as a module, choose M here and read 544 To compile this driver as a module, choose M here and read
537 <file:Documentation/parport.txt>. The module will be called lp. 545 <file:Documentation/parport.txt>. The module will be called lp.
538 546
539 If you have several parallel ports, you can specify which ports to 547 If you have several parallel ports, you can specify which ports to
540 use with the "lp" kernel command line option. (Try "man bootparam" 548 use with the "lp" kernel command line option. (Try "man bootparam"
541 or see the documentation of your boot loader (lilo or loadlin) about 549 or see the documentation of your boot loader (lilo or loadlin) about
542 how to pass options to the kernel at boot time.) The syntax of the 550 how to pass options to the kernel at boot time.) The syntax of the
543 "lp" command line option can be found in <file:drivers/char/lp.c>. 551 "lp" command line option can be found in <file:drivers/char/lp.c>.
544 552
545 If you have more than 8 printers, you need to increase the LP_NO 553 If you have more than 8 printers, you need to increase the LP_NO
546 macro in lp.c and the PARPORT_MAX macro in parport.h. 554 macro in lp.c and the PARPORT_MAX macro in parport.h.
547 555
548 config LP_CONSOLE 556 config LP_CONSOLE
549 bool "Support for console on line printer" 557 bool "Support for console on line printer"
550 depends on PRINTER 558 depends on PRINTER
551 ---help--- 559 ---help---
552 If you want kernel messages to be printed out as they occur, you 560 If you want kernel messages to be printed out as they occur, you
553 can have a console on the printer. This option adds support for 561 can have a console on the printer. This option adds support for
554 doing that; to actually get it to happen you need to pass the 562 doing that; to actually get it to happen you need to pass the
555 option "console=lp0" to the kernel at boot time. 563 option "console=lp0" to the kernel at boot time.
556 564
557 If the printer is out of paper (or off, or unplugged, or too 565 If the printer is out of paper (or off, or unplugged, or too
558 busy..) the kernel will stall until the printer is ready again. 566 busy..) the kernel will stall until the printer is ready again.
559 By defining CONSOLE_LP_STRICT to 0 (at your own risk) you 567 By defining CONSOLE_LP_STRICT to 0 (at your own risk) you
560 can make the kernel continue when this happens, 568 can make the kernel continue when this happens,
561 but it'll lose the kernel messages. 569 but it'll lose the kernel messages.
562 570
563 If unsure, say N. 571 If unsure, say N.
564 572
565 config PPDEV 573 config PPDEV
566 tristate "Support for user-space parallel port device drivers" 574 tristate "Support for user-space parallel port device drivers"
567 depends on PARPORT 575 depends on PARPORT
568 ---help--- 576 ---help---
569 Saying Y to this adds support for /dev/parport device nodes. This 577 Saying Y to this adds support for /dev/parport device nodes. This
570 is needed for programs that want portable access to the parallel 578 is needed for programs that want portable access to the parallel
571 port, for instance deviceid (which displays Plug-and-Play device 579 port, for instance deviceid (which displays Plug-and-Play device
572 IDs). 580 IDs).
573 581
574 This is the parallel port equivalent of SCSI generic support (sg). 582 This is the parallel port equivalent of SCSI generic support (sg).
575 It is safe to say N to this -- it is not needed for normal printing 583 It is safe to say N to this -- it is not needed for normal printing
576 or parallel port CD-ROM/disk support. 584 or parallel port CD-ROM/disk support.
577 585
578 To compile this driver as a module, choose M here: the 586 To compile this driver as a module, choose M here: the
579 module will be called ppdev. 587 module will be called ppdev.
580 588
581 If unsure, say N. 589 If unsure, say N.
582 590
583 config HVC_DRIVER 591 config HVC_DRIVER
584 bool 592 bool
585 help 593 help
586 Generic "hypervisor virtual console" infrastructure for various 594 Generic "hypervisor virtual console" infrastructure for various
587 hypervisors (pSeries, iSeries, Xen, lguest). 595 hypervisors (pSeries, iSeries, Xen, lguest).
588 It will automatically be selected if one of the back-end console drivers 596 It will automatically be selected if one of the back-end console drivers
589 is selected. 597 is selected.
590 598
591 599
592 config HVC_CONSOLE 600 config HVC_CONSOLE
593 bool "pSeries Hypervisor Virtual Console support" 601 bool "pSeries Hypervisor Virtual Console support"
594 depends on PPC_PSERIES 602 depends on PPC_PSERIES
595 select HVC_DRIVER 603 select HVC_DRIVER
596 help 604 help
597 pSeries machines when partitioned support a hypervisor virtual 605 pSeries machines when partitioned support a hypervisor virtual
598 console. This driver allows each pSeries partition to have a console 606 console. This driver allows each pSeries partition to have a console
599 which is accessed via the HMC. 607 which is accessed via the HMC.
600 608
601 config HVC_ISERIES 609 config HVC_ISERIES
602 bool "iSeries Hypervisor Virtual Console support" 610 bool "iSeries Hypervisor Virtual Console support"
603 depends on PPC_ISERIES 611 depends on PPC_ISERIES
604 default y 612 default y
605 select HVC_DRIVER 613 select HVC_DRIVER
606 help 614 help
607 iSeries machines support a hypervisor virtual console. 615 iSeries machines support a hypervisor virtual console.
608 616
609 config HVC_RTAS 617 config HVC_RTAS
610 bool "IBM RTAS Console support" 618 bool "IBM RTAS Console support"
611 depends on PPC_RTAS 619 depends on PPC_RTAS
612 select HVC_DRIVER 620 select HVC_DRIVER
613 help 621 help
614 IBM Console device driver which makes use of RTAS 622 IBM Console device driver which makes use of RTAS
615 623
616 config HVC_BEAT 624 config HVC_BEAT
617 bool "Toshiba's Beat Hypervisor Console support" 625 bool "Toshiba's Beat Hypervisor Console support"
618 depends on PPC_CELLEB 626 depends on PPC_CELLEB
619 select HVC_DRIVER 627 select HVC_DRIVER
620 help 628 help
621 Toshiba's Cell Reference Set Beat Console device driver 629 Toshiba's Cell Reference Set Beat Console device driver
622 630
623 config HVC_XEN 631 config HVC_XEN
624 bool "Xen Hypervisor Console support" 632 bool "Xen Hypervisor Console support"
625 depends on XEN 633 depends on XEN
626 select HVC_DRIVER 634 select HVC_DRIVER
627 default y 635 default y
628 help 636 help
629 Xen virtual console device driver 637 Xen virtual console device driver
630 638
631 config VIRTIO_CONSOLE 639 config VIRTIO_CONSOLE
632 bool 640 bool
633 select HVC_DRIVER 641 select HVC_DRIVER
634 642
635 config HVCS 643 config HVCS
636 tristate "IBM Hypervisor Virtual Console Server support" 644 tristate "IBM Hypervisor Virtual Console Server support"
637 depends on PPC_PSERIES 645 depends on PPC_PSERIES
638 help 646 help
639 Partitionable IBM Power5 ppc64 machines allow hosting of 647 Partitionable IBM Power5 ppc64 machines allow hosting of
640 firmware virtual consoles from one Linux partition by 648 firmware virtual consoles from one Linux partition by
641 another Linux partition. This driver allows console data 649 another Linux partition. This driver allows console data
642 from Linux partitions to be accessed through TTY device 650 from Linux partitions to be accessed through TTY device
643 interfaces in the device tree of a Linux partition running 651 interfaces in the device tree of a Linux partition running
644 this driver. 652 this driver.
645 653
646 To compile this driver as a module, choose M here: the 654 To compile this driver as a module, choose M here: the
647 module will be called hvcs.ko. Additionally, this module 655 module will be called hvcs.ko. Additionally, this module
648 will depend on arch specific APIs exported from hvcserver.ko 656 will depend on arch specific APIs exported from hvcserver.ko
649 which will also be compiled when this driver is built as a 657 which will also be compiled when this driver is built as a
650 module. 658 module.
651 659
652 source "drivers/char/ipmi/Kconfig" 660 source "drivers/char/ipmi/Kconfig"
653 661
654 config DS1620 662 config DS1620
655 tristate "NetWinder thermometer support" 663 tristate "NetWinder thermometer support"
656 depends on ARCH_NETWINDER 664 depends on ARCH_NETWINDER
657 help 665 help
658 Say Y here to include support for the thermal management hardware 666 Say Y here to include support for the thermal management hardware
659 found in the NetWinder. This driver allows the user to control the 667 found in the NetWinder. This driver allows the user to control the
660 temperature set points and to read the current temperature. 668 temperature set points and to read the current temperature.
661 669
662 It is also possible to say M here to build it as a module (ds1620) 670 It is also possible to say M here to build it as a module (ds1620)
663 It is recommended to be used on a NetWinder, but it is not a 671 It is recommended to be used on a NetWinder, but it is not a
664 necessity. 672 necessity.
665 673
666 config NWBUTTON 674 config NWBUTTON
667 tristate "NetWinder Button" 675 tristate "NetWinder Button"
668 depends on ARCH_NETWINDER 676 depends on ARCH_NETWINDER
669 ---help--- 677 ---help---
670 If you say Y here and create a character device node /dev/nwbutton 678 If you say Y here and create a character device node /dev/nwbutton
671 with major and minor numbers 10 and 158 ("man mknod"), then every 679 with major and minor numbers 10 and 158 ("man mknod"), then every
672 time the orange button is pressed a number of times, the number of 680 time the orange button is pressed a number of times, the number of
673 times the button was pressed will be written to that device. 681 times the button was pressed will be written to that device.
674 682
675 This is most useful for applications, as yet unwritten, which 683 This is most useful for applications, as yet unwritten, which
676 perform actions based on how many times the button is pressed in a 684 perform actions based on how many times the button is pressed in a
677 row. 685 row.
678 686
679 Do not hold the button down for too long, as the driver does not 687 Do not hold the button down for too long, as the driver does not
680 alter the behaviour of the hardware reset circuitry attached to the 688 alter the behaviour of the hardware reset circuitry attached to the
681 button; it will still execute a hard reset if the button is held 689 button; it will still execute a hard reset if the button is held
682 down for longer than approximately five seconds. 690 down for longer than approximately five seconds.
683 691
684 To compile this driver as a module, choose M here: the 692 To compile this driver as a module, choose M here: the
685 module will be called nwbutton. 693 module will be called nwbutton.
686 694
687 Most people will answer Y to this question and "Reboot Using Button" 695 Most people will answer Y to this question and "Reboot Using Button"
688 below to be able to initiate a system shutdown from the button. 696 below to be able to initiate a system shutdown from the button.
689 697
690 config NWBUTTON_REBOOT 698 config NWBUTTON_REBOOT
691 bool "Reboot Using Button" 699 bool "Reboot Using Button"
692 depends on NWBUTTON 700 depends on NWBUTTON
693 help 701 help
694 If you say Y here, then you will be able to initiate a system 702 If you say Y here, then you will be able to initiate a system
695 shutdown and reboot by pressing the orange button a number of times. 703 shutdown and reboot by pressing the orange button a number of times.
696 The number of presses to initiate the shutdown is two by default, 704 The number of presses to initiate the shutdown is two by default,
697 but this can be altered by modifying the value of NUM_PRESSES_REBOOT 705 but this can be altered by modifying the value of NUM_PRESSES_REBOOT
698 in nwbutton.h and recompiling the driver or, if you compile the 706 in nwbutton.h and recompiling the driver or, if you compile the
699 driver as a module, you can specify the number of presses at load 707 driver as a module, you can specify the number of presses at load
700 time with "insmod button reboot_count=<something>". 708 time with "insmod button reboot_count=<something>".
701 709
702 config NWFLASH 710 config NWFLASH
703 tristate "NetWinder flash support" 711 tristate "NetWinder flash support"
704 depends on ARCH_NETWINDER 712 depends on ARCH_NETWINDER
705 ---help--- 713 ---help---
706 If you say Y here and create a character device /dev/flash with 714 If you say Y here and create a character device /dev/flash with
707 major 10 and minor 160 you can manipulate the flash ROM containing 715 major 10 and minor 160 you can manipulate the flash ROM containing
708 the NetWinder firmware. Be careful as accidentally overwriting the 716 the NetWinder firmware. Be careful as accidentally overwriting the
709 flash contents can render your computer unbootable. On no account 717 flash contents can render your computer unbootable. On no account
710 allow random users access to this device. :-) 718 allow random users access to this device. :-)
711 719
712 To compile this driver as a module, choose M here: the 720 To compile this driver as a module, choose M here: the
713 module will be called nwflash. 721 module will be called nwflash.
714 722
715 If you're not sure, say N. 723 If you're not sure, say N.
716 724
717 source "drivers/char/hw_random/Kconfig" 725 source "drivers/char/hw_random/Kconfig"
718 726
719 config NVRAM 727 config NVRAM
720 tristate "/dev/nvram support" 728 tristate "/dev/nvram support"
721 depends on ATARI || X86 || ARM || GENERIC_NVRAM 729 depends on ATARI || X86 || ARM || GENERIC_NVRAM
722 ---help--- 730 ---help---
723 If you say Y here and create a character special file /dev/nvram 731 If you say Y here and create a character special file /dev/nvram
724 with major number 10 and minor number 144 using mknod ("man mknod"), 732 with major number 10 and minor number 144 using mknod ("man mknod"),
725 you get read and write access to the extra bytes of non-volatile 733 you get read and write access to the extra bytes of non-volatile
726 memory in the real time clock (RTC), which is contained in every PC 734 memory in the real time clock (RTC), which is contained in every PC
727 and most Ataris. The actual number of bytes varies, depending on the 735 and most Ataris. The actual number of bytes varies, depending on the
728 nvram in the system, but is usually 114 (128-14 for the RTC). 736 nvram in the system, but is usually 114 (128-14 for the RTC).
729 737
730 This memory is conventionally called "CMOS RAM" on PCs and "NVRAM" 738 This memory is conventionally called "CMOS RAM" on PCs and "NVRAM"
731 on Ataris. /dev/nvram may be used to view settings there, or to 739 on Ataris. /dev/nvram may be used to view settings there, or to
732 change them (with some utility). It could also be used to frequently 740 change them (with some utility). It could also be used to frequently
733 save a few bits of very important data that may not be lost over 741 save a few bits of very important data that may not be lost over
734 power-off and for which writing to disk is too insecure. Note 742 power-off and for which writing to disk is too insecure. Note
735 however that most NVRAM space in a PC belongs to the BIOS and you 743 however that most NVRAM space in a PC belongs to the BIOS and you
736 should NEVER idly tamper with it. See Ralf Brown's interrupt list 744 should NEVER idly tamper with it. See Ralf Brown's interrupt list
737 for a guide to the use of CMOS bytes by your BIOS. 745 for a guide to the use of CMOS bytes by your BIOS.
738 746
739 On Atari machines, /dev/nvram is always configured and does not need 747 On Atari machines, /dev/nvram is always configured and does not need
740 to be selected. 748 to be selected.
741 749
742 To compile this driver as a module, choose M here: the 750 To compile this driver as a module, choose M here: the
743 module will be called nvram. 751 module will be called nvram.
744 752
745 # 753 #
746 # These legacy RTC drivers just cause too many conflicts with the generic 754 # These legacy RTC drivers just cause too many conflicts with the generic
747 # RTC framework ... let's not even try to coexist any more. 755 # RTC framework ... let's not even try to coexist any more.
748 # 756 #
749 if RTC_LIB=n 757 if RTC_LIB=n
750 758
751 config RTC 759 config RTC
752 tristate "Enhanced Real Time Clock Support" 760 tristate "Enhanced Real Time Clock Support"
753 depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV \ 761 depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV \
754 && !ARM && !SUPERH && !S390 && !AVR32 762 && !ARM && !SUPERH && !S390 && !AVR32
755 ---help--- 763 ---help---
756 If you say Y here and create a character special file /dev/rtc with 764 If you say Y here and create a character special file /dev/rtc with
757 major number 10 and minor number 135 using mknod ("man mknod"), you 765 major number 10 and minor number 135 using mknod ("man mknod"), you
758 will get access to the real time clock (or hardware clock) built 766 will get access to the real time clock (or hardware clock) built
759 into your computer. 767 into your computer.
760 768
761 Every PC has such a clock built in. It can be used to generate 769 Every PC has such a clock built in. It can be used to generate
762 signals from as low as 1Hz up to 8192Hz, and can also be used 770 signals from as low as 1Hz up to 8192Hz, and can also be used
763 as a 24 hour alarm. It reports status information via the file 771 as a 24 hour alarm. It reports status information via the file
764 /proc/driver/rtc and its behaviour is set by various ioctls on 772 /proc/driver/rtc and its behaviour is set by various ioctls on
765 /dev/rtc. 773 /dev/rtc.
766 774
767 If you run Linux on a multiprocessor machine and said Y to 775 If you run Linux on a multiprocessor machine and said Y to
768 "Symmetric Multi Processing" above, you should say Y here to read 776 "Symmetric Multi Processing" above, you should say Y here to read
769 and set the RTC in an SMP compatible fashion. 777 and set the RTC in an SMP compatible fashion.
770 778
771 If you think you have a use for such a device (such as periodic data 779 If you think you have a use for such a device (such as periodic data
772 sampling), then say Y here, and read <file:Documentation/rtc.txt> 780 sampling), then say Y here, and read <file:Documentation/rtc.txt>
773 for details. 781 for details.
774 782
775 To compile this driver as a module, choose M here: the 783 To compile this driver as a module, choose M here: the
776 module will be called rtc. 784 module will be called rtc.
777 785
778 config JS_RTC 786 config JS_RTC
779 tristate "Enhanced Real Time Clock Support" 787 tristate "Enhanced Real Time Clock Support"
780 depends on SPARC32 && PCI 788 depends on SPARC32 && PCI
781 ---help--- 789 ---help---
782 If you say Y here and create a character special file /dev/rtc with 790 If you say Y here and create a character special file /dev/rtc with
783 major number 10 and minor number 135 using mknod ("man mknod"), you 791 major number 10 and minor number 135 using mknod ("man mknod"), you
784 will get access to the real time clock (or hardware clock) built 792 will get access to the real time clock (or hardware clock) built
785 into your computer. 793 into your computer.
786 794
787 Every PC has such a clock built in. It can be used to generate 795 Every PC has such a clock built in. It can be used to generate
788 signals from as low as 1Hz up to 8192Hz, and can also be used 796 signals from as low as 1Hz up to 8192Hz, and can also be used
789 as a 24 hour alarm. It reports status information via the file 797 as a 24 hour alarm. It reports status information via the file
790 /proc/driver/rtc and its behaviour is set by various ioctls on 798 /proc/driver/rtc and its behaviour is set by various ioctls on
791 /dev/rtc. 799 /dev/rtc.
792 800
793 If you think you have a use for such a device (such as periodic data 801 If you think you have a use for such a device (such as periodic data
794 sampling), then say Y here, and read <file:Documentation/rtc.txt> 802 sampling), then say Y here, and read <file:Documentation/rtc.txt>
795 for details. 803 for details.
796 804
797 To compile this driver as a module, choose M here: the 805 To compile this driver as a module, choose M here: the
798 module will be called js-rtc. 806 module will be called js-rtc.
799 807
800 config SGI_DS1286 808 config SGI_DS1286
801 tristate "SGI DS1286 RTC support" 809 tristate "SGI DS1286 RTC support"
802 depends on SGI_HAS_DS1286 810 depends on SGI_HAS_DS1286
803 help 811 help
804 If you say Y here and create a character special file /dev/rtc with 812 If you say Y here and create a character special file /dev/rtc with
805 major number 10 and minor number 135 using mknod ("man mknod"), you 813 major number 10 and minor number 135 using mknod ("man mknod"), you
806 will get access to the real time clock built into your computer. 814 will get access to the real time clock built into your computer.
807 Every SGI has such a clock built in. It reports status information 815 Every SGI has such a clock built in. It reports status information
808 via the file /proc/rtc and its behaviour is set by various ioctls on 816 via the file /proc/rtc and its behaviour is set by various ioctls on
809 /dev/rtc. 817 /dev/rtc.
810 818
811 config SGI_IP27_RTC 819 config SGI_IP27_RTC
812 bool "SGI M48T35 RTC support" 820 bool "SGI M48T35 RTC support"
813 depends on SGI_IP27 821 depends on SGI_IP27
814 help 822 help
815 If you say Y here and create a character special file /dev/rtc with 823 If you say Y here and create a character special file /dev/rtc with
816 major number 10 and minor number 135 using mknod ("man mknod"), you 824 major number 10 and minor number 135 using mknod ("man mknod"), you
817 will get access to the real time clock built into your computer. 825 will get access to the real time clock built into your computer.
818 Every SGI has such a clock built in. It reports status information 826 Every SGI has such a clock built in. It reports status information
819 via the file /proc/rtc and its behaviour is set by various ioctls on 827 via the file /proc/rtc and its behaviour is set by various ioctls on
820 /dev/rtc. 828 /dev/rtc.
821 829
822 config GEN_RTC 830 config GEN_RTC
823 tristate "Generic /dev/rtc emulation" 831 tristate "Generic /dev/rtc emulation"
824 depends on RTC!=y && !IA64 && !ARM && !M32R && !MIPS && !SPARC && !FRV && !S390 && !SUPERH && !AVR32 832 depends on RTC!=y && !IA64 && !ARM && !M32R && !MIPS && !SPARC && !FRV && !S390 && !SUPERH && !AVR32
825 ---help--- 833 ---help---
826 If you say Y here and create a character special file /dev/rtc with 834 If you say Y here and create a character special file /dev/rtc with
827 major number 10 and minor number 135 using mknod ("man mknod"), you 835 major number 10 and minor number 135 using mknod ("man mknod"), you
828 will get access to the real time clock (or hardware clock) built 836 will get access to the real time clock (or hardware clock) built
829 into your computer. 837 into your computer.
830 838
831 It reports status information via the file /proc/driver/rtc and its 839 It reports status information via the file /proc/driver/rtc and its
832 behaviour is set by various ioctls on /dev/rtc. If you enable the 840 behaviour is set by various ioctls on /dev/rtc. If you enable the
833 "extended RTC operation" below it will also provide an emulation 841 "extended RTC operation" below it will also provide an emulation
834 for RTC_UIE which is required by some programs and may improve 842 for RTC_UIE which is required by some programs and may improve
835 precision in some cases. 843 precision in some cases.
836 844
837 To compile this driver as a module, choose M here: the 845 To compile this driver as a module, choose M here: the
838 module will be called genrtc. 846 module will be called genrtc.
839 847
840 config GEN_RTC_X 848 config GEN_RTC_X
841 bool "Extended RTC operation" 849 bool "Extended RTC operation"
842 depends on GEN_RTC 850 depends on GEN_RTC
843 help 851 help
844 Provides an emulation for RTC_UIE which is required by some programs 852 Provides an emulation for RTC_UIE which is required by some programs
845 and may improve precision of the generic RTC support in some cases. 853 and may improve precision of the generic RTC support in some cases.
846 854
847 config EFI_RTC 855 config EFI_RTC
848 bool "EFI Real Time Clock Services" 856 bool "EFI Real Time Clock Services"
849 depends on IA64 857 depends on IA64
850 858
851 config DS1302 859 config DS1302
852 tristate "DS1302 RTC support" 860 tristate "DS1302 RTC support"
853 depends on M32R && (PLAT_M32700UT || PLAT_OPSPUT) 861 depends on M32R && (PLAT_M32700UT || PLAT_OPSPUT)
854 help 862 help
855 If you say Y here and create a character special file /dev/rtc with 863 If you say Y here and create a character special file /dev/rtc with
856 major number 121 and minor number 0 using mknod ("man mknod"), you 864 major number 121 and minor number 0 using mknod ("man mknod"), you
857 will get access to the real time clock (or hardware clock) built 865 will get access to the real time clock (or hardware clock) built
858 into your computer. 866 into your computer.
859 867
860 endif # RTC_LIB 868 endif # RTC_LIB
861 869
862 config COBALT_LCD 870 config COBALT_LCD
863 bool "Support for Cobalt LCD" 871 bool "Support for Cobalt LCD"
864 depends on MIPS_COBALT 872 depends on MIPS_COBALT
865 help 873 help
866 This option enables support for the LCD display and buttons found 874 This option enables support for the LCD display and buttons found
867 on Cobalt systems through a misc device. 875 on Cobalt systems through a misc device.
868 876
869 config DTLK 877 config DTLK
870 tristate "Double Talk PC internal speech card support" 878 tristate "Double Talk PC internal speech card support"
871 depends on ISA 879 depends on ISA
872 help 880 help
873 This driver is for the DoubleTalk PC, a speech synthesizer 881 This driver is for the DoubleTalk PC, a speech synthesizer
874 manufactured by RC Systems (<http://www.rcsys.com/>). It is also 882 manufactured by RC Systems (<http://www.rcsys.com/>). It is also
875 called the `internal DoubleTalk'. 883 called the `internal DoubleTalk'.
876 884
877 To compile this driver as a module, choose M here: the 885 To compile this driver as a module, choose M here: the
878 module will be called dtlk. 886 module will be called dtlk.
879 887
880 config XILINX_HWICAP 888 config XILINX_HWICAP
881 tristate "Xilinx HWICAP Support" 889 tristate "Xilinx HWICAP Support"
882 depends on XILINX_VIRTEX 890 depends on XILINX_VIRTEX
883 help 891 help
884 This option enables support for Xilinx Internal Configuration 892 This option enables support for Xilinx Internal Configuration
885 Access Port (ICAP) driver. The ICAP is used on Xilinx Virtex 893 Access Port (ICAP) driver. The ICAP is used on Xilinx Virtex
886 FPGA platforms to partially reconfigure the FPGA at runtime. 894 FPGA platforms to partially reconfigure the FPGA at runtime.
887 895
888 If unsure, say N. 896 If unsure, say N.
889 897
890 config R3964 898 config R3964
891 tristate "Siemens R3964 line discipline" 899 tristate "Siemens R3964 line discipline"
892 ---help--- 900 ---help---
893 This driver allows synchronous communication with devices using the 901 This driver allows synchronous communication with devices using the
894 Siemens R3964 packet protocol. Unless you are dealing with special 902 Siemens R3964 packet protocol. Unless you are dealing with special
895 hardware like PLCs, you are unlikely to need this. 903 hardware like PLCs, you are unlikely to need this.
896 904
897 To compile this driver as a module, choose M here: the 905 To compile this driver as a module, choose M here: the
898 module will be called n_r3964. 906 module will be called n_r3964.
899 907
900 If unsure, say N. 908 If unsure, say N.
901 909
902 config APPLICOM 910 config APPLICOM
903 tristate "Applicom intelligent fieldbus card support" 911 tristate "Applicom intelligent fieldbus card support"
904 depends on PCI 912 depends on PCI
905 ---help--- 913 ---help---
906 This driver provides the kernel-side support for the intelligent 914 This driver provides the kernel-side support for the intelligent
907 fieldbus cards made by Applicom International. More information 915 fieldbus cards made by Applicom International. More information
908 about these cards can be found on the WWW at the address 916 about these cards can be found on the WWW at the address
909 <http://www.applicom-int.com/>, or by email from David Woodhouse 917 <http://www.applicom-int.com/>, or by email from David Woodhouse
910 <dwmw2@infradead.org>. 918 <dwmw2@infradead.org>.
911 919
912 To compile this driver as a module, choose M here: the 920 To compile this driver as a module, choose M here: the
913 module will be called applicom. 921 module will be called applicom.
914 922
915 If unsure, say N. 923 If unsure, say N.
916 924
917 config SONYPI 925 config SONYPI
918 tristate "Sony Vaio Programmable I/O Control Device support (EXPERIMENTAL)" 926 tristate "Sony Vaio Programmable I/O Control Device support (EXPERIMENTAL)"
919 depends on EXPERIMENTAL && X86 && PCI && INPUT && !64BIT 927 depends on EXPERIMENTAL && X86 && PCI && INPUT && !64BIT
920 ---help--- 928 ---help---
921 This driver enables access to the Sony Programmable I/O Control 929 This driver enables access to the Sony Programmable I/O Control
922 Device which can be found in many (all ?) Sony Vaio laptops. 930 Device which can be found in many (all ?) Sony Vaio laptops.
923 931
924 If you have one of those laptops, read 932 If you have one of those laptops, read
925 <file:Documentation/laptops/sonypi.txt>, and say Y or M here. 933 <file:Documentation/laptops/sonypi.txt>, and say Y or M here.
926 934
927 To compile this driver as a module, choose M here: the 935 To compile this driver as a module, choose M here: the
928 module will be called sonypi. 936 module will be called sonypi.
929 937
930 config GPIO_TB0219 938 config GPIO_TB0219
931 tristate "TANBAC TB0219 GPIO support" 939 tristate "TANBAC TB0219 GPIO support"
932 depends on TANBAC_TB022X 940 depends on TANBAC_TB022X
933 select GPIO_VR41XX 941 select GPIO_VR41XX
934 942
935 source "drivers/char/pcmcia/Kconfig" 943 source "drivers/char/pcmcia/Kconfig"
936 944
937 config MWAVE 945 config MWAVE
938 tristate "ACP Modem (Mwave) support" 946 tristate "ACP Modem (Mwave) support"
939 depends on X86 947 depends on X86
940 select SERIAL_8250 948 select SERIAL_8250
941 ---help--- 949 ---help---
942 The ACP modem (Mwave) for Linux is a WinModem. It is composed of a 950 The ACP modem (Mwave) for Linux is a WinModem. It is composed of a
943 kernel driver and a user level application. Together these components 951 kernel driver and a user level application. Together these components
944 support direct attachment to public switched telephone networks (PSTNs) 952 support direct attachment to public switched telephone networks (PSTNs)
945 and support selected world wide countries. 953 and support selected world wide countries.
946 954
947 This version of the ACP Modem driver supports the IBM Thinkpad 600E, 955 This version of the ACP Modem driver supports the IBM Thinkpad 600E,
948 600, and 770 that include on board ACP modem hardware. 956 600, and 770 that include on board ACP modem hardware.
949 957
950 The modem also supports the standard communications port interface 958 The modem also supports the standard communications port interface
951 (ttySx) and is compatible with the Hayes AT Command Set. 959 (ttySx) and is compatible with the Hayes AT Command Set.
952 960
953 The user level application needed to use this driver can be found at 961 The user level application needed to use this driver can be found at
954 the IBM Linux Technology Center (LTC) web site: 962 the IBM Linux Technology Center (LTC) web site:
955 <http://www.ibm.com/linux/ltc/>. 963 <http://www.ibm.com/linux/ltc/>.
956 964
957 If you own one of the above IBM Thinkpads which has the Mwave chipset 965 If you own one of the above IBM Thinkpads which has the Mwave chipset
958 in it, say Y. 966 in it, say Y.
959 967
960 To compile this driver as a module, choose M here: the 968 To compile this driver as a module, choose M here: the
961 module will be called mwave. 969 module will be called mwave.
962 970
963 config SCx200_GPIO 971 config SCx200_GPIO
964 tristate "NatSemi SCx200 GPIO Support" 972 tristate "NatSemi SCx200 GPIO Support"
965 depends on SCx200 973 depends on SCx200
966 select NSC_GPIO 974 select NSC_GPIO
967 help 975 help
968 Give userspace access to the GPIO pins on the National 976 Give userspace access to the GPIO pins on the National
969 Semiconductor SCx200 processors. 977 Semiconductor SCx200 processors.
970 978
971 If compiled as a module, it will be called scx200_gpio. 979 If compiled as a module, it will be called scx200_gpio.
972 980
973 config PC8736x_GPIO 981 config PC8736x_GPIO
974 tristate "NatSemi PC8736x GPIO Support" 982 tristate "NatSemi PC8736x GPIO Support"
975 depends on X86 983 depends on X86
976 default SCx200_GPIO # mostly N 984 default SCx200_GPIO # mostly N
977 select NSC_GPIO # needed for support routines 985 select NSC_GPIO # needed for support routines
978 help 986 help
979 Give userspace access to the GPIO pins on the National 987 Give userspace access to the GPIO pins on the National
980 Semiconductor PC-8736x (x=[03456]) SuperIO chip. The chip 988 Semiconductor PC-8736x (x=[03456]) SuperIO chip. The chip
981 has multiple functional units, inc several managed by 989 has multiple functional units, inc several managed by
982 hwmon/pc87360 driver. Tested with PC-87366 990 hwmon/pc87360 driver. Tested with PC-87366
983 991
984 If compiled as a module, it will be called pc8736x_gpio. 992 If compiled as a module, it will be called pc8736x_gpio.
985 993
986 config NSC_GPIO 994 config NSC_GPIO
987 tristate "NatSemi Base GPIO Support" 995 tristate "NatSemi Base GPIO Support"
988 depends on X86_32 996 depends on X86_32
989 # selected by SCx200_GPIO and PC8736x_GPIO 997 # selected by SCx200_GPIO and PC8736x_GPIO
990 # what about 2 selectors differing: m != y 998 # what about 2 selectors differing: m != y
991 help 999 help
992 Common support used (and needed) by scx200_gpio and 1000 Common support used (and needed) by scx200_gpio and
993 pc8736x_gpio drivers. If those drivers are built as 1001 pc8736x_gpio drivers. If those drivers are built as
994 modules, this one will be too, named nsc_gpio 1002 modules, this one will be too, named nsc_gpio
995 1003
996 config CS5535_GPIO 1004 config CS5535_GPIO
997 tristate "AMD CS5535/CS5536 GPIO (Geode Companion Device)" 1005 tristate "AMD CS5535/CS5536 GPIO (Geode Companion Device)"
998 depends on X86_32 1006 depends on X86_32
999 help 1007 help
1000 Give userspace access to the GPIO pins on the AMD CS5535 and 1008 Give userspace access to the GPIO pins on the AMD CS5535 and
1001 CS5536 Geode companion devices. 1009 CS5536 Geode companion devices.
1002 1010
1003 If compiled as a module, it will be called cs5535_gpio. 1011 If compiled as a module, it will be called cs5535_gpio.
1004 1012
1005 config GPIO_VR41XX 1013 config GPIO_VR41XX
1006 tristate "NEC VR4100 series General-purpose I/O Unit support" 1014 tristate "NEC VR4100 series General-purpose I/O Unit support"
1007 depends on CPU_VR41XX 1015 depends on CPU_VR41XX
1008 1016
1009 config RAW_DRIVER 1017 config RAW_DRIVER
1010 tristate "RAW driver (/dev/raw/rawN)" 1018 tristate "RAW driver (/dev/raw/rawN)"
1011 depends on BLOCK 1019 depends on BLOCK
1012 help 1020 help
1013 The raw driver permits block devices to be bound to /dev/raw/rawN. 1021 The raw driver permits block devices to be bound to /dev/raw/rawN.
1014 Once bound, I/O against /dev/raw/rawN uses efficient zero-copy I/O. 1022 Once bound, I/O against /dev/raw/rawN uses efficient zero-copy I/O.
1015 See the raw(8) manpage for more details. 1023 See the raw(8) manpage for more details.
1016 1024
1017 Applications should preferably open the device (eg /dev/hda1) 1025 Applications should preferably open the device (eg /dev/hda1)
1018 with the O_DIRECT flag. 1026 with the O_DIRECT flag.
1019 1027
1020 config MAX_RAW_DEVS 1028 config MAX_RAW_DEVS
1021 int "Maximum number of RAW devices to support (1-8192)" 1029 int "Maximum number of RAW devices to support (1-8192)"
1022 depends on RAW_DRIVER 1030 depends on RAW_DRIVER
1023 default "256" 1031 default "256"
1024 help 1032 help
1025 The maximum number of RAW devices that are supported. 1033 The maximum number of RAW devices that are supported.
1026 Default is 256. Increase this number in case you need lots of 1034 Default is 256. Increase this number in case you need lots of
1027 raw devices. 1035 raw devices.
1028 1036
1029 config HPET 1037 config HPET
1030 bool "HPET - High Precision Event Timer" if (X86 || IA64) 1038 bool "HPET - High Precision Event Timer" if (X86 || IA64)
1031 default n 1039 default n
1032 depends on ACPI 1040 depends on ACPI
1033 help 1041 help
1034 If you say Y here, you will have a miscdevice named "/dev/hpet/". Each 1042 If you say Y here, you will have a miscdevice named "/dev/hpet/". Each
1035 open selects one of the timers supported by the HPET. The timers are 1043 open selects one of the timers supported by the HPET. The timers are
1036 non-periodic and/or periodic. 1044 non-periodic and/or periodic.
1037 1045
1038 config HPET_RTC_IRQ 1046 config HPET_RTC_IRQ
1039 bool "HPET Control RTC IRQ" if !HPET_EMULATE_RTC 1047 bool "HPET Control RTC IRQ" if !HPET_EMULATE_RTC
1040 default n 1048 default n
1041 depends on HPET 1049 depends on HPET
1042 help 1050 help
1043 If you say Y here, you will disable RTC_IRQ in drivers/char/rtc.c. It 1051 If you say Y here, you will disable RTC_IRQ in drivers/char/rtc.c. It
1044 is assumed the platform called hpet_alloc with the RTC IRQ values for 1052 is assumed the platform called hpet_alloc with the RTC IRQ values for
1045 the HPET timers. 1053 the HPET timers.
1046 1054
1047 config HPET_MMAP 1055 config HPET_MMAP
1048 bool "Allow mmap of HPET" 1056 bool "Allow mmap of HPET"
1049 default y 1057 default y
1050 depends on HPET 1058 depends on HPET
1051 help 1059 help
1052 If you say Y here, user applications will be able to mmap 1060 If you say Y here, user applications will be able to mmap
1053 the HPET registers. 1061 the HPET registers.
1054 1062
1055 In some hardware implementations, the page containing HPET 1063 In some hardware implementations, the page containing HPET
1056 registers may also contain other things that shouldn't be 1064 registers may also contain other things that shouldn't be
1057 exposed to the user. If this applies to your hardware, 1065 exposed to the user. If this applies to your hardware,
1058 say N here. 1066 say N here.
1059 1067
1060 config HANGCHECK_TIMER 1068 config HANGCHECK_TIMER
1061 tristate "Hangcheck timer" 1069 tristate "Hangcheck timer"
1062 depends on X86 || IA64 || PPC64 || S390 1070 depends on X86 || IA64 || PPC64 || S390
1063 help 1071 help
1064 The hangcheck-timer module detects when the system has gone 1072 The hangcheck-timer module detects when the system has gone
1065 out to lunch past a certain margin. It can reboot the system 1073 out to lunch past a certain margin. It can reboot the system
1066 or merely print a warning. 1074 or merely print a warning.
1067 1075
1068 config MMTIMER 1076 config MMTIMER
1069 tristate "MMTIMER Memory mapped RTC for SGI Altix" 1077 tristate "MMTIMER Memory mapped RTC for SGI Altix"
1070 depends on IA64_GENERIC || IA64_SGI_SN2 1078 depends on IA64_GENERIC || IA64_SGI_SN2
1071 default y 1079 default y
1072 help 1080 help
1073 The mmtimer device allows direct userspace access to the 1081 The mmtimer device allows direct userspace access to the
1074 Altix system timer. 1082 Altix system timer.
1075 1083
1076 source "drivers/char/tpm/Kconfig" 1084 source "drivers/char/tpm/Kconfig"
1077 1085
1078 config TELCLOCK 1086 config TELCLOCK
1079 tristate "Telecom clock driver for ATCA SBC" 1087 tristate "Telecom clock driver for ATCA SBC"
1080 depends on EXPERIMENTAL && X86 1088 depends on EXPERIMENTAL && X86
1081 default n 1089 default n
1082 help 1090 help
1083 The telecom clock device is specific to the MPCBL0010 and MPCBL0050 1091 The telecom clock device is specific to the MPCBL0010 and MPCBL0050
1084 ATCA computers and allows direct userspace access to the 1092 ATCA computers and allows direct userspace access to the
1085 configuration of the telecom clock configuration settings. This 1093 configuration of the telecom clock configuration settings. This
1086 device is used for hardware synchronization across the ATCA backplane 1094 device is used for hardware synchronization across the ATCA backplane
1087 fabric. Upon loading, the driver exports a sysfs directory, 1095 fabric. Upon loading, the driver exports a sysfs directory,
1088 /sys/devices/platform/telco_clock, with a number of files for 1096 /sys/devices/platform/telco_clock, with a number of files for
1089 controlling the behavior of this hardware. 1097 controlling the behavior of this hardware.
1090 1098
1091 config DEVPORT 1099 config DEVPORT
1092 bool 1100 bool
1093 depends on !M68K 1101 depends on !M68K
1094 depends on ISA || PCI 1102 depends on ISA || PCI
1095 default y 1103 default y
1096 1104
1097 source "drivers/s390/char/Kconfig" 1105 source "drivers/s390/char/Kconfig"
1098 1106
1099 endmenu 1107 endmenu
1100 1108
1101 1109
drivers/char/Makefile
1 # 1 #
2 # Makefile for the kernel character device drivers. 2 # Makefile for the kernel character device drivers.
3 # 3 #
4 4
5 # 5 #
6 # This file contains the font map for the default (hardware) font 6 # This file contains the font map for the default (hardware) font
7 # 7 #
8 FONTMAPFILE = cp437.uni 8 FONTMAPFILE = cp437.uni
9 9
10 obj-y += mem.o random.o tty_io.o n_tty.o tty_ioctl.o 10 obj-y += mem.o random.o tty_io.o n_tty.o tty_ioctl.o
11 11
12 obj-$(CONFIG_LEGACY_PTYS) += pty.o 12 obj-$(CONFIG_LEGACY_PTYS) += pty.o
13 obj-$(CONFIG_UNIX98_PTYS) += pty.o 13 obj-$(CONFIG_UNIX98_PTYS) += pty.o
14 obj-y += misc.o 14 obj-y += misc.o
15 obj-$(CONFIG_VT) += vt_ioctl.o vc_screen.o consolemap.o \ 15 obj-$(CONFIG_VT) += vt_ioctl.o vc_screen.o selection.o keyboard.o
16 consolemap_deftbl.o selection.o keyboard.o 16 obj-$(CONFIG_CONSOLE_TRANSLATIONS) += consolemap.o consolemap_deftbl.o
17 obj-$(CONFIG_HW_CONSOLE) += vt.o defkeymap.o 17 obj-$(CONFIG_HW_CONSOLE) += vt.o defkeymap.o
18 obj-$(CONFIG_AUDIT) += tty_audit.o 18 obj-$(CONFIG_AUDIT) += tty_audit.o
19 obj-$(CONFIG_MAGIC_SYSRQ) += sysrq.o 19 obj-$(CONFIG_MAGIC_SYSRQ) += sysrq.o
20 obj-$(CONFIG_ESPSERIAL) += esp.o 20 obj-$(CONFIG_ESPSERIAL) += esp.o
21 obj-$(CONFIG_MVME147_SCC) += generic_serial.o vme_scc.o 21 obj-$(CONFIG_MVME147_SCC) += generic_serial.o vme_scc.o
22 obj-$(CONFIG_MVME162_SCC) += generic_serial.o vme_scc.o 22 obj-$(CONFIG_MVME162_SCC) += generic_serial.o vme_scc.o
23 obj-$(CONFIG_BVME6000_SCC) += generic_serial.o vme_scc.o 23 obj-$(CONFIG_BVME6000_SCC) += generic_serial.o vme_scc.o
24 obj-$(CONFIG_ROCKETPORT) += rocket.o 24 obj-$(CONFIG_ROCKETPORT) += rocket.o
25 obj-$(CONFIG_SERIAL167) += serial167.o 25 obj-$(CONFIG_SERIAL167) += serial167.o
26 obj-$(CONFIG_CYCLADES) += cyclades.o 26 obj-$(CONFIG_CYCLADES) += cyclades.o
27 obj-$(CONFIG_STALLION) += stallion.o 27 obj-$(CONFIG_STALLION) += stallion.o
28 obj-$(CONFIG_ISTALLION) += istallion.o 28 obj-$(CONFIG_ISTALLION) += istallion.o
29 obj-$(CONFIG_NOZOMI) += nozomi.o 29 obj-$(CONFIG_NOZOMI) += nozomi.o
30 obj-$(CONFIG_DIGIEPCA) += epca.o 30 obj-$(CONFIG_DIGIEPCA) += epca.o
31 obj-$(CONFIG_SPECIALIX) += specialix.o 31 obj-$(CONFIG_SPECIALIX) += specialix.o
32 obj-$(CONFIG_MOXA_INTELLIO) += moxa.o 32 obj-$(CONFIG_MOXA_INTELLIO) += moxa.o
33 obj-$(CONFIG_A2232) += ser_a2232.o generic_serial.o 33 obj-$(CONFIG_A2232) += ser_a2232.o generic_serial.o
34 obj-$(CONFIG_ATARI_DSP56K) += dsp56k.o 34 obj-$(CONFIG_ATARI_DSP56K) += dsp56k.o
35 obj-$(CONFIG_MOXA_SMARTIO) += mxser.o 35 obj-$(CONFIG_MOXA_SMARTIO) += mxser.o
36 obj-$(CONFIG_COMPUTONE) += ip2/ 36 obj-$(CONFIG_COMPUTONE) += ip2/
37 obj-$(CONFIG_RISCOM8) += riscom8.o 37 obj-$(CONFIG_RISCOM8) += riscom8.o
38 obj-$(CONFIG_ISI) += isicom.o 38 obj-$(CONFIG_ISI) += isicom.o
39 obj-$(CONFIG_SYNCLINK) += synclink.o 39 obj-$(CONFIG_SYNCLINK) += synclink.o
40 obj-$(CONFIG_SYNCLINKMP) += synclinkmp.o 40 obj-$(CONFIG_SYNCLINKMP) += synclinkmp.o
41 obj-$(CONFIG_SYNCLINK_GT) += synclink_gt.o 41 obj-$(CONFIG_SYNCLINK_GT) += synclink_gt.o
42 obj-$(CONFIG_N_HDLC) += n_hdlc.o 42 obj-$(CONFIG_N_HDLC) += n_hdlc.o
43 obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o 43 obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o
44 obj-$(CONFIG_SX) += sx.o generic_serial.o 44 obj-$(CONFIG_SX) += sx.o generic_serial.o
45 obj-$(CONFIG_RIO) += rio/ generic_serial.o 45 obj-$(CONFIG_RIO) += rio/ generic_serial.o
46 obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o hvsi.o 46 obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o hvsi.o
47 obj-$(CONFIG_HVC_ISERIES) += hvc_iseries.o 47 obj-$(CONFIG_HVC_ISERIES) += hvc_iseries.o
48 obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o 48 obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o
49 obj-$(CONFIG_HVC_BEAT) += hvc_beat.o 49 obj-$(CONFIG_HVC_BEAT) += hvc_beat.o
50 obj-$(CONFIG_HVC_DRIVER) += hvc_console.o 50 obj-$(CONFIG_HVC_DRIVER) += hvc_console.o
51 obj-$(CONFIG_HVC_XEN) += hvc_xen.o 51 obj-$(CONFIG_HVC_XEN) += hvc_xen.o
52 obj-$(CONFIG_VIRTIO_CONSOLE) += virtio_console.o 52 obj-$(CONFIG_VIRTIO_CONSOLE) += virtio_console.o
53 obj-$(CONFIG_RAW_DRIVER) += raw.o 53 obj-$(CONFIG_RAW_DRIVER) += raw.o
54 obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o 54 obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o
55 obj-$(CONFIG_MSPEC) += mspec.o 55 obj-$(CONFIG_MSPEC) += mspec.o
56 obj-$(CONFIG_MMTIMER) += mmtimer.o 56 obj-$(CONFIG_MMTIMER) += mmtimer.o
57 obj-$(CONFIG_VIOCONS) += viocons.o 57 obj-$(CONFIG_VIOCONS) += viocons.o
58 obj-$(CONFIG_VIOTAPE) += viotape.o 58 obj-$(CONFIG_VIOTAPE) += viotape.o
59 obj-$(CONFIG_HVCS) += hvcs.o 59 obj-$(CONFIG_HVCS) += hvcs.o
60 obj-$(CONFIG_SGI_MBCS) += mbcs.o 60 obj-$(CONFIG_SGI_MBCS) += mbcs.o
61 obj-$(CONFIG_BRIQ_PANEL) += briq_panel.o 61 obj-$(CONFIG_BRIQ_PANEL) += briq_panel.o
62 obj-$(CONFIG_BFIN_OTP) += bfin-otp.o 62 obj-$(CONFIG_BFIN_OTP) += bfin-otp.o
63 63
64 obj-$(CONFIG_PRINTER) += lp.o 64 obj-$(CONFIG_PRINTER) += lp.o
65 obj-$(CONFIG_TIPAR) += tipar.o 65 obj-$(CONFIG_TIPAR) += tipar.o
66 66
67 obj-$(CONFIG_APM_EMULATION) += apm-emulation.o 67 obj-$(CONFIG_APM_EMULATION) += apm-emulation.o
68 68
69 obj-$(CONFIG_DTLK) += dtlk.o 69 obj-$(CONFIG_DTLK) += dtlk.o
70 obj-$(CONFIG_R3964) += n_r3964.o 70 obj-$(CONFIG_R3964) += n_r3964.o
71 obj-$(CONFIG_APPLICOM) += applicom.o 71 obj-$(CONFIG_APPLICOM) += applicom.o
72 obj-$(CONFIG_SONYPI) += sonypi.o 72 obj-$(CONFIG_SONYPI) += sonypi.o
73 obj-$(CONFIG_RTC) += rtc.o 73 obj-$(CONFIG_RTC) += rtc.o
74 obj-$(CONFIG_HPET) += hpet.o 74 obj-$(CONFIG_HPET) += hpet.o
75 obj-$(CONFIG_GEN_RTC) += genrtc.o 75 obj-$(CONFIG_GEN_RTC) += genrtc.o
76 obj-$(CONFIG_EFI_RTC) += efirtc.o 76 obj-$(CONFIG_EFI_RTC) += efirtc.o
77 obj-$(CONFIG_SGI_DS1286) += ds1286.o 77 obj-$(CONFIG_SGI_DS1286) += ds1286.o
78 obj-$(CONFIG_SGI_IP27_RTC) += ip27-rtc.o 78 obj-$(CONFIG_SGI_IP27_RTC) += ip27-rtc.o
79 obj-$(CONFIG_DS1302) += ds1302.o 79 obj-$(CONFIG_DS1302) += ds1302.o
80 obj-$(CONFIG_XILINX_HWICAP) += xilinx_hwicap/ 80 obj-$(CONFIG_XILINX_HWICAP) += xilinx_hwicap/
81 ifeq ($(CONFIG_GENERIC_NVRAM),y) 81 ifeq ($(CONFIG_GENERIC_NVRAM),y)
82 obj-$(CONFIG_NVRAM) += generic_nvram.o 82 obj-$(CONFIG_NVRAM) += generic_nvram.o
83 else 83 else
84 obj-$(CONFIG_NVRAM) += nvram.o 84 obj-$(CONFIG_NVRAM) += nvram.o
85 endif 85 endif
86 obj-$(CONFIG_TOSHIBA) += toshiba.o 86 obj-$(CONFIG_TOSHIBA) += toshiba.o
87 obj-$(CONFIG_I8K) += i8k.o 87 obj-$(CONFIG_I8K) += i8k.o
88 obj-$(CONFIG_DS1620) += ds1620.o 88 obj-$(CONFIG_DS1620) += ds1620.o
89 obj-$(CONFIG_HW_RANDOM) += hw_random/ 89 obj-$(CONFIG_HW_RANDOM) += hw_random/
90 obj-$(CONFIG_COBALT_LCD) += lcd.o 90 obj-$(CONFIG_COBALT_LCD) += lcd.o
91 obj-$(CONFIG_PPDEV) += ppdev.o 91 obj-$(CONFIG_PPDEV) += ppdev.o
92 obj-$(CONFIG_NWBUTTON) += nwbutton.o 92 obj-$(CONFIG_NWBUTTON) += nwbutton.o
93 obj-$(CONFIG_NWFLASH) += nwflash.o 93 obj-$(CONFIG_NWFLASH) += nwflash.o
94 obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o 94 obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o
95 obj-$(CONFIG_PC8736x_GPIO) += pc8736x_gpio.o 95 obj-$(CONFIG_PC8736x_GPIO) += pc8736x_gpio.o
96 obj-$(CONFIG_NSC_GPIO) += nsc_gpio.o 96 obj-$(CONFIG_NSC_GPIO) += nsc_gpio.o
97 obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o 97 obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o
98 obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o 98 obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o
99 obj-$(CONFIG_GPIO_TB0219) += tb0219.o 99 obj-$(CONFIG_GPIO_TB0219) += tb0219.o
100 obj-$(CONFIG_TELCLOCK) += tlclk.o 100 obj-$(CONFIG_TELCLOCK) += tlclk.o
101 101
102 obj-$(CONFIG_MWAVE) += mwave/ 102 obj-$(CONFIG_MWAVE) += mwave/
103 obj-$(CONFIG_AGP) += agp/ 103 obj-$(CONFIG_AGP) += agp/
104 obj-$(CONFIG_DRM) += drm/ 104 obj-$(CONFIG_DRM) += drm/
105 obj-$(CONFIG_PCMCIA) += pcmcia/ 105 obj-$(CONFIG_PCMCIA) += pcmcia/
106 obj-$(CONFIG_IPMI_HANDLER) += ipmi/ 106 obj-$(CONFIG_IPMI_HANDLER) += ipmi/
107 107
108 obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o 108 obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o
109 obj-$(CONFIG_TCG_TPM) += tpm/ 109 obj-$(CONFIG_TCG_TPM) += tpm/
110 110
111 obj-$(CONFIG_PS3_FLASH) += ps3flash.o 111 obj-$(CONFIG_PS3_FLASH) += ps3flash.o
112 112
113 obj-$(CONFIG_JS_RTC) += js-rtc.o 113 obj-$(CONFIG_JS_RTC) += js-rtc.o
114 js-rtc-y = rtc.o 114 js-rtc-y = rtc.o
115 115
116 # Files generated that shall be removed upon make clean 116 # Files generated that shall be removed upon make clean
117 clean-files := consolemap_deftbl.c defkeymap.c 117 clean-files := consolemap_deftbl.c defkeymap.c
118 118
119 quiet_cmd_conmk = CONMK $@ 119 quiet_cmd_conmk = CONMK $@
120 cmd_conmk = scripts/conmakehash $< > $@ 120 cmd_conmk = scripts/conmakehash $< > $@
121 121
122 $(obj)/consolemap_deftbl.c: $(src)/$(FONTMAPFILE) 122 $(obj)/consolemap_deftbl.c: $(src)/$(FONTMAPFILE)
123 $(call cmd,conmk) 123 $(call cmd,conmk)
124 124
125 $(obj)/defkeymap.o: $(obj)/defkeymap.c 125 $(obj)/defkeymap.o: $(obj)/defkeymap.c
126 126
127 # Uncomment if you're changing the keymap and have an appropriate 127 # Uncomment if you're changing the keymap and have an appropriate
128 # loadkeys version for the map. By default, we'll use the shipped 128 # loadkeys version for the map. By default, we'll use the shipped
129 # versions. 129 # versions.
130 # GENERATE_KEYMAP := 1 130 # GENERATE_KEYMAP := 1
131 131
132 ifdef GENERATE_KEYMAP 132 ifdef GENERATE_KEYMAP
133 133
134 $(obj)/defkeymap.c: $(obj)/%.c: $(src)/%.map 134 $(obj)/defkeymap.c: $(obj)/%.c: $(src)/%.map
135 loadkeys --mktable $< > $@.tmp 135 loadkeys --mktable $< > $@.tmp
136 sed -e 's/^static *//' $@.tmp > $@ 136 sed -e 's/^static *//' $@.tmp > $@
137 rm $@.tmp 137 rm $@.tmp
138 138
139 endif 139 endif
140 140
1 /* 1 /*
2 * linux/drivers/char/vt.c 2 * linux/drivers/char/vt.c
3 * 3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds 4 * Copyright (C) 1991, 1992 Linus Torvalds
5 */ 5 */
6 6
7 /* 7 /*
8 * Hopefully this will be a rather complete VT102 implementation. 8 * Hopefully this will be a rather complete VT102 implementation.
9 * 9 *
10 * Beeping thanks to John T Kohl. 10 * Beeping thanks to John T Kohl.
11 * 11 *
12 * Virtual Consoles, Screen Blanking, Screen Dumping, Color, Graphics 12 * Virtual Consoles, Screen Blanking, Screen Dumping, Color, Graphics
13 * Chars, and VT100 enhancements by Peter MacDonald. 13 * Chars, and VT100 enhancements by Peter MacDonald.
14 * 14 *
15 * Copy and paste function by Andrew Haylett, 15 * Copy and paste function by Andrew Haylett,
16 * some enhancements by Alessandro Rubini. 16 * some enhancements by Alessandro Rubini.
17 * 17 *
18 * Code to check for different video-cards mostly by Galen Hunt, 18 * Code to check for different video-cards mostly by Galen Hunt,
19 * <g-hunt@ee.utah.edu> 19 * <g-hunt@ee.utah.edu>
20 * 20 *
21 * Rudimentary ISO 10646/Unicode/UTF-8 character set support by 21 * Rudimentary ISO 10646/Unicode/UTF-8 character set support by
22 * Markus Kuhn, <mskuhn@immd4.informatik.uni-erlangen.de>. 22 * Markus Kuhn, <mskuhn@immd4.informatik.uni-erlangen.de>.
23 * 23 *
24 * Dynamic allocation of consoles, aeb@cwi.nl, May 1994 24 * Dynamic allocation of consoles, aeb@cwi.nl, May 1994
25 * Resizing of consoles, aeb, 940926 25 * Resizing of consoles, aeb, 940926
26 * 26 *
27 * Code for xterm like mouse click reporting by Peter Orbaek 20-Jul-94 27 * Code for xterm like mouse click reporting by Peter Orbaek 20-Jul-94
28 * <poe@daimi.aau.dk> 28 * <poe@daimi.aau.dk>
29 * 29 *
30 * User-defined bell sound, new setterm control sequences and printk 30 * User-defined bell sound, new setterm control sequences and printk
31 * redirection by Martin Mares <mj@k332.feld.cvut.cz> 19-Nov-95 31 * redirection by Martin Mares <mj@k332.feld.cvut.cz> 19-Nov-95
32 * 32 *
33 * APM screenblank bug fixed Takashi Manabe <manabe@roy.dsl.tutics.tut.jp> 33 * APM screenblank bug fixed Takashi Manabe <manabe@roy.dsl.tutics.tut.jp>
34 * 34 *
35 * Merge with the abstract console driver by Geert Uytterhoeven 35 * Merge with the abstract console driver by Geert Uytterhoeven
36 * <geert@linux-m68k.org>, Jan 1997. 36 * <geert@linux-m68k.org>, Jan 1997.
37 * 37 *
38 * Original m68k console driver modifications by 38 * Original m68k console driver modifications by
39 * 39 *
40 * - Arno Griffioen <arno@usn.nl> 40 * - Arno Griffioen <arno@usn.nl>
41 * - David Carter <carter@cs.bris.ac.uk> 41 * - David Carter <carter@cs.bris.ac.uk>
42 * 42 *
43 * The abstract console driver provides a generic interface for a text 43 * The abstract console driver provides a generic interface for a text
44 * console. It supports VGA text mode, frame buffer based graphical consoles 44 * console. It supports VGA text mode, frame buffer based graphical consoles
45 * and special graphics processors that are only accessible through some 45 * and special graphics processors that are only accessible through some
46 * registers (e.g. a TMS340x0 GSP). 46 * registers (e.g. a TMS340x0 GSP).
47 * 47 *
48 * The interface to the hardware is specified using a special structure 48 * The interface to the hardware is specified using a special structure
49 * (struct consw) which contains function pointers to console operations 49 * (struct consw) which contains function pointers to console operations
50 * (see <linux/console.h> for more information). 50 * (see <linux/console.h> for more information).
51 * 51 *
52 * Support for changeable cursor shape 52 * Support for changeable cursor shape
53 * by Pavel Machek <pavel@atrey.karlin.mff.cuni.cz>, August 1997 53 * by Pavel Machek <pavel@atrey.karlin.mff.cuni.cz>, August 1997
54 * 54 *
55 * Ported to i386 and con_scrolldelta fixed 55 * Ported to i386 and con_scrolldelta fixed
56 * by Emmanuel Marty <core@ggi-project.org>, April 1998 56 * by Emmanuel Marty <core@ggi-project.org>, April 1998
57 * 57 *
58 * Resurrected character buffers in videoram plus lots of other trickery 58 * Resurrected character buffers in videoram plus lots of other trickery
59 * by Martin Mares <mj@atrey.karlin.mff.cuni.cz>, July 1998 59 * by Martin Mares <mj@atrey.karlin.mff.cuni.cz>, July 1998
60 * 60 *
61 * Removed old-style timers, introduced console_timer, made timer 61 * Removed old-style timers, introduced console_timer, made timer
62 * deletion SMP-safe. 17Jun00, Andrew Morton <andrewm@uow.edu.au> 62 * deletion SMP-safe. 17Jun00, Andrew Morton <andrewm@uow.edu.au>
63 * 63 *
64 * Removed console_lock, enabled interrupts across all console operations 64 * Removed console_lock, enabled interrupts across all console operations
65 * 13 March 2001, Andrew Morton 65 * 13 March 2001, Andrew Morton
66 * 66 *
67 * Fixed UTF-8 mode so alternate charset modes always work according 67 * Fixed UTF-8 mode so alternate charset modes always work according
68 * to control sequences interpreted in do_con_trol function 68 * to control sequences interpreted in do_con_trol function
69 * preserving backward VT100 semigraphics compatibility, 69 * preserving backward VT100 semigraphics compatibility,
70 * malformed UTF sequences represented as sequences of replacement glyphs, 70 * malformed UTF sequences represented as sequences of replacement glyphs,
71 * original codes or '?' as a last resort if replacement glyph is undefined 71 * original codes or '?' as a last resort if replacement glyph is undefined
72 * by Adam Tla/lka <atlka@pg.gda.pl>, Aug 2006 72 * by Adam Tla/lka <atlka@pg.gda.pl>, Aug 2006
73 */ 73 */
74 74
75 #include <linux/module.h> 75 #include <linux/module.h>
76 #include <linux/types.h> 76 #include <linux/types.h>
77 #include <linux/sched.h> 77 #include <linux/sched.h>
78 #include <linux/tty.h> 78 #include <linux/tty.h>
79 #include <linux/tty_flip.h> 79 #include <linux/tty_flip.h>
80 #include <linux/kernel.h> 80 #include <linux/kernel.h>
81 #include <linux/string.h> 81 #include <linux/string.h>
82 #include <linux/errno.h> 82 #include <linux/errno.h>
83 #include <linux/kd.h> 83 #include <linux/kd.h>
84 #include <linux/slab.h> 84 #include <linux/slab.h>
85 #include <linux/major.h> 85 #include <linux/major.h>
86 #include <linux/mm.h> 86 #include <linux/mm.h>
87 #include <linux/console.h> 87 #include <linux/console.h>
88 #include <linux/init.h> 88 #include <linux/init.h>
89 #include <linux/mutex.h> 89 #include <linux/mutex.h>
90 #include <linux/vt_kern.h> 90 #include <linux/vt_kern.h>
91 #include <linux/selection.h> 91 #include <linux/selection.h>
92 #include <linux/tiocl.h> 92 #include <linux/tiocl.h>
93 #include <linux/kbd_kern.h> 93 #include <linux/kbd_kern.h>
94 #include <linux/consolemap.h> 94 #include <linux/consolemap.h>
95 #include <linux/timer.h> 95 #include <linux/timer.h>
96 #include <linux/interrupt.h> 96 #include <linux/interrupt.h>
97 #include <linux/workqueue.h> 97 #include <linux/workqueue.h>
98 #include <linux/bootmem.h> 98 #include <linux/bootmem.h>
99 #include <linux/pm.h> 99 #include <linux/pm.h>
100 #include <linux/font.h> 100 #include <linux/font.h>
101 #include <linux/bitops.h> 101 #include <linux/bitops.h>
102 #include <linux/notifier.h> 102 #include <linux/notifier.h>
103 103
104 #include <asm/io.h> 104 #include <asm/io.h>
105 #include <asm/system.h> 105 #include <asm/system.h>
106 #include <asm/uaccess.h> 106 #include <asm/uaccess.h>
107 107
108 #define MAX_NR_CON_DRIVER 16 108 #define MAX_NR_CON_DRIVER 16
109 109
110 #define CON_DRIVER_FLAG_MODULE 1 110 #define CON_DRIVER_FLAG_MODULE 1
111 #define CON_DRIVER_FLAG_INIT 2 111 #define CON_DRIVER_FLAG_INIT 2
112 #define CON_DRIVER_FLAG_ATTR 4 112 #define CON_DRIVER_FLAG_ATTR 4
113 113
114 struct con_driver { 114 struct con_driver {
115 const struct consw *con; 115 const struct consw *con;
116 const char *desc; 116 const char *desc;
117 struct device *dev; 117 struct device *dev;
118 int node; 118 int node;
119 int first; 119 int first;
120 int last; 120 int last;
121 int flag; 121 int flag;
122 }; 122 };
123 123
124 static struct con_driver registered_con_driver[MAX_NR_CON_DRIVER]; 124 static struct con_driver registered_con_driver[MAX_NR_CON_DRIVER];
125 const struct consw *conswitchp; 125 const struct consw *conswitchp;
126 126
127 /* A bitmap for codes <32. A bit of 1 indicates that the code 127 /* A bitmap for codes <32. A bit of 1 indicates that the code
128 * corresponding to that bit number invokes some special action 128 * corresponding to that bit number invokes some special action
129 * (such as cursor movement) and should not be displayed as a 129 * (such as cursor movement) and should not be displayed as a
130 * glyph unless the disp_ctrl mode is explicitly enabled. 130 * glyph unless the disp_ctrl mode is explicitly enabled.
131 */ 131 */
132 #define CTRL_ACTION 0x0d00ff81 132 #define CTRL_ACTION 0x0d00ff81
133 #define CTRL_ALWAYS 0x0800f501 /* Cannot be overridden by disp_ctrl */ 133 #define CTRL_ALWAYS 0x0800f501 /* Cannot be overridden by disp_ctrl */
134 134
135 /* 135 /*
136 * Here is the default bell parameters: 750HZ, 1/8th of a second 136 * Here is the default bell parameters: 750HZ, 1/8th of a second
137 */ 137 */
138 #define DEFAULT_BELL_PITCH 750 138 #define DEFAULT_BELL_PITCH 750
139 #define DEFAULT_BELL_DURATION (HZ/8) 139 #define DEFAULT_BELL_DURATION (HZ/8)
140 140
141 struct vc vc_cons [MAX_NR_CONSOLES]; 141 struct vc vc_cons [MAX_NR_CONSOLES];
142 142
143 #ifndef VT_SINGLE_DRIVER 143 #ifndef VT_SINGLE_DRIVER
144 static const struct consw *con_driver_map[MAX_NR_CONSOLES]; 144 static const struct consw *con_driver_map[MAX_NR_CONSOLES];
145 #endif 145 #endif
146 146
147 static int con_open(struct tty_struct *, struct file *); 147 static int con_open(struct tty_struct *, struct file *);
148 static void vc_init(struct vc_data *vc, unsigned int rows, 148 static void vc_init(struct vc_data *vc, unsigned int rows,
149 unsigned int cols, int do_clear); 149 unsigned int cols, int do_clear);
150 static void gotoxy(struct vc_data *vc, int new_x, int new_y); 150 static void gotoxy(struct vc_data *vc, int new_x, int new_y);
151 static void save_cur(struct vc_data *vc); 151 static void save_cur(struct vc_data *vc);
152 static void reset_terminal(struct vc_data *vc, int do_clear); 152 static void reset_terminal(struct vc_data *vc, int do_clear);
153 static void con_flush_chars(struct tty_struct *tty); 153 static void con_flush_chars(struct tty_struct *tty);
154 static int set_vesa_blanking(char __user *p); 154 static int set_vesa_blanking(char __user *p);
155 static void set_cursor(struct vc_data *vc); 155 static void set_cursor(struct vc_data *vc);
156 static void hide_cursor(struct vc_data *vc); 156 static void hide_cursor(struct vc_data *vc);
157 static void console_callback(struct work_struct *ignored); 157 static void console_callback(struct work_struct *ignored);
158 static void blank_screen_t(unsigned long dummy); 158 static void blank_screen_t(unsigned long dummy);
159 static void set_palette(struct vc_data *vc); 159 static void set_palette(struct vc_data *vc);
160 160
161 static int printable; /* Is console ready for printing? */ 161 static int printable; /* Is console ready for printing? */
162 int default_utf8 = true; 162 int default_utf8 = true;
163 module_param(default_utf8, int, S_IRUGO | S_IWUSR); 163 module_param(default_utf8, int, S_IRUGO | S_IWUSR);
164 164
165 /* 165 /*
166 * ignore_poke: don't unblank the screen when things are typed. This is 166 * ignore_poke: don't unblank the screen when things are typed. This is
167 * mainly for the privacy of braille terminal users. 167 * mainly for the privacy of braille terminal users.
168 */ 168 */
169 static int ignore_poke; 169 static int ignore_poke;
170 170
171 int do_poke_blanked_console; 171 int do_poke_blanked_console;
172 int console_blanked; 172 int console_blanked;
173 173
174 static int vesa_blank_mode; /* 0:none 1:suspendV 2:suspendH 3:powerdown */ 174 static int vesa_blank_mode; /* 0:none 1:suspendV 2:suspendH 3:powerdown */
175 static int blankinterval = 10*60*HZ; 175 static int blankinterval = 10*60*HZ;
176 static int vesa_off_interval; 176 static int vesa_off_interval;
177 177
178 static DECLARE_WORK(console_work, console_callback); 178 static DECLARE_WORK(console_work, console_callback);
179 179
180 /* 180 /*
181 * fg_console is the current virtual console, 181 * fg_console is the current virtual console,
182 * last_console is the last used one, 182 * last_console is the last used one,
183 * want_console is the console we want to switch to, 183 * want_console is the console we want to switch to,
184 * kmsg_redirect is the console for kernel messages, 184 * kmsg_redirect is the console for kernel messages,
185 */ 185 */
186 int fg_console; 186 int fg_console;
187 int last_console; 187 int last_console;
188 int want_console = -1; 188 int want_console = -1;
189 int kmsg_redirect; 189 int kmsg_redirect;
190 190
191 /* 191 /*
192 * For each existing display, we have a pointer to console currently visible 192 * For each existing display, we have a pointer to console currently visible
193 * on that display, allowing consoles other than fg_console to be refreshed 193 * on that display, allowing consoles other than fg_console to be refreshed
194 * appropriately. Unless the low-level driver supplies its own display_fg 194 * appropriately. Unless the low-level driver supplies its own display_fg
195 * variable, we use this one for the "master display". 195 * variable, we use this one for the "master display".
196 */ 196 */
197 static struct vc_data *master_display_fg; 197 static struct vc_data *master_display_fg;
198 198
199 /* 199 /*
200 * Unfortunately, we need to delay tty echo when we're currently writing to the 200 * Unfortunately, we need to delay tty echo when we're currently writing to the
201 * console since the code is (and always was) not re-entrant, so we schedule 201 * console since the code is (and always was) not re-entrant, so we schedule
202 * all flip requests to process context with schedule-task() and run it from 202 * all flip requests to process context with schedule-task() and run it from
203 * console_callback(). 203 * console_callback().
204 */ 204 */
205 205
206 /* 206 /*
207 * For the same reason, we defer scrollback to the console callback. 207 * For the same reason, we defer scrollback to the console callback.
208 */ 208 */
209 static int scrollback_delta; 209 static int scrollback_delta;
210 210
211 /* 211 /*
212 * Hook so that the power management routines can (un)blank 212 * Hook so that the power management routines can (un)blank
213 * the console on our behalf. 213 * the console on our behalf.
214 */ 214 */
215 int (*console_blank_hook)(int); 215 int (*console_blank_hook)(int);
216 216
217 static DEFINE_TIMER(console_timer, blank_screen_t, 0, 0); 217 static DEFINE_TIMER(console_timer, blank_screen_t, 0, 0);
218 static int blank_state; 218 static int blank_state;
219 static int blank_timer_expired; 219 static int blank_timer_expired;
220 enum { 220 enum {
221 blank_off = 0, 221 blank_off = 0,
222 blank_normal_wait, 222 blank_normal_wait,
223 blank_vesa_wait, 223 blank_vesa_wait,
224 }; 224 };
225 225
226 /* 226 /*
227 * Notifier list for console events. 227 * Notifier list for console events.
228 */ 228 */
229 static ATOMIC_NOTIFIER_HEAD(vt_notifier_list); 229 static ATOMIC_NOTIFIER_HEAD(vt_notifier_list);
230 230
231 int register_vt_notifier(struct notifier_block *nb) 231 int register_vt_notifier(struct notifier_block *nb)
232 { 232 {
233 return atomic_notifier_chain_register(&vt_notifier_list, nb); 233 return atomic_notifier_chain_register(&vt_notifier_list, nb);
234 } 234 }
235 EXPORT_SYMBOL_GPL(register_vt_notifier); 235 EXPORT_SYMBOL_GPL(register_vt_notifier);
236 236
237 int unregister_vt_notifier(struct notifier_block *nb) 237 int unregister_vt_notifier(struct notifier_block *nb)
238 { 238 {
239 return atomic_notifier_chain_unregister(&vt_notifier_list, nb); 239 return atomic_notifier_chain_unregister(&vt_notifier_list, nb);
240 } 240 }
241 EXPORT_SYMBOL_GPL(unregister_vt_notifier); 241 EXPORT_SYMBOL_GPL(unregister_vt_notifier);
242 242
243 static void notify_write(struct vc_data *vc, unsigned int unicode) 243 static void notify_write(struct vc_data *vc, unsigned int unicode)
244 { 244 {
245 struct vt_notifier_param param = { .vc = vc, unicode = unicode }; 245 struct vt_notifier_param param = { .vc = vc, unicode = unicode };
246 atomic_notifier_call_chain(&vt_notifier_list, VT_WRITE, &param); 246 atomic_notifier_call_chain(&vt_notifier_list, VT_WRITE, &param);
247 } 247 }
248 248
249 static void notify_update(struct vc_data *vc) 249 static void notify_update(struct vc_data *vc)
250 { 250 {
251 struct vt_notifier_param param = { .vc = vc }; 251 struct vt_notifier_param param = { .vc = vc };
252 atomic_notifier_call_chain(&vt_notifier_list, VT_UPDATE, &param); 252 atomic_notifier_call_chain(&vt_notifier_list, VT_UPDATE, &param);
253 } 253 }
254 254
255 /* 255 /*
256 * Low-Level Functions 256 * Low-Level Functions
257 */ 257 */
258 258
259 #define IS_FG(vc) ((vc)->vc_num == fg_console) 259 #define IS_FG(vc) ((vc)->vc_num == fg_console)
260 260
261 #ifdef VT_BUF_VRAM_ONLY 261 #ifdef VT_BUF_VRAM_ONLY
262 #define DO_UPDATE(vc) 0 262 #define DO_UPDATE(vc) 0
263 #else 263 #else
264 #define DO_UPDATE(vc) CON_IS_VISIBLE(vc) 264 #define DO_UPDATE(vc) CON_IS_VISIBLE(vc)
265 #endif 265 #endif
266 266
267 static inline unsigned short *screenpos(struct vc_data *vc, int offset, int viewed) 267 static inline unsigned short *screenpos(struct vc_data *vc, int offset, int viewed)
268 { 268 {
269 unsigned short *p; 269 unsigned short *p;
270 270
271 if (!viewed) 271 if (!viewed)
272 p = (unsigned short *)(vc->vc_origin + offset); 272 p = (unsigned short *)(vc->vc_origin + offset);
273 else if (!vc->vc_sw->con_screen_pos) 273 else if (!vc->vc_sw->con_screen_pos)
274 p = (unsigned short *)(vc->vc_visible_origin + offset); 274 p = (unsigned short *)(vc->vc_visible_origin + offset);
275 else 275 else
276 p = vc->vc_sw->con_screen_pos(vc, offset); 276 p = vc->vc_sw->con_screen_pos(vc, offset);
277 return p; 277 return p;
278 } 278 }
279 279
280 static inline void scrolldelta(int lines) 280 static inline void scrolldelta(int lines)
281 { 281 {
282 scrollback_delta += lines; 282 scrollback_delta += lines;
283 schedule_console_callback(); 283 schedule_console_callback();
284 } 284 }
285 285
286 void schedule_console_callback(void) 286 void schedule_console_callback(void)
287 { 287 {
288 schedule_work(&console_work); 288 schedule_work(&console_work);
289 } 289 }
290 290
291 static void scrup(struct vc_data *vc, unsigned int t, unsigned int b, int nr) 291 static void scrup(struct vc_data *vc, unsigned int t, unsigned int b, int nr)
292 { 292 {
293 unsigned short *d, *s; 293 unsigned short *d, *s;
294 294
295 if (t+nr >= b) 295 if (t+nr >= b)
296 nr = b - t - 1; 296 nr = b - t - 1;
297 if (b > vc->vc_rows || t >= b || nr < 1) 297 if (b > vc->vc_rows || t >= b || nr < 1)
298 return; 298 return;
299 if (CON_IS_VISIBLE(vc) && vc->vc_sw->con_scroll(vc, t, b, SM_UP, nr)) 299 if (CON_IS_VISIBLE(vc) && vc->vc_sw->con_scroll(vc, t, b, SM_UP, nr))
300 return; 300 return;
301 d = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t); 301 d = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t);
302 s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * (t + nr)); 302 s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * (t + nr));
303 scr_memmovew(d, s, (b - t - nr) * vc->vc_size_row); 303 scr_memmovew(d, s, (b - t - nr) * vc->vc_size_row);
304 scr_memsetw(d + (b - t - nr) * vc->vc_cols, vc->vc_scrl_erase_char, 304 scr_memsetw(d + (b - t - nr) * vc->vc_cols, vc->vc_scrl_erase_char,
305 vc->vc_size_row * nr); 305 vc->vc_size_row * nr);
306 } 306 }
307 307
308 static void scrdown(struct vc_data *vc, unsigned int t, unsigned int b, int nr) 308 static void scrdown(struct vc_data *vc, unsigned int t, unsigned int b, int nr)
309 { 309 {
310 unsigned short *s; 310 unsigned short *s;
311 unsigned int step; 311 unsigned int step;
312 312
313 if (t+nr >= b) 313 if (t+nr >= b)
314 nr = b - t - 1; 314 nr = b - t - 1;
315 if (b > vc->vc_rows || t >= b || nr < 1) 315 if (b > vc->vc_rows || t >= b || nr < 1)
316 return; 316 return;
317 if (CON_IS_VISIBLE(vc) && vc->vc_sw->con_scroll(vc, t, b, SM_DOWN, nr)) 317 if (CON_IS_VISIBLE(vc) && vc->vc_sw->con_scroll(vc, t, b, SM_DOWN, nr))
318 return; 318 return;
319 s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t); 319 s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t);
320 step = vc->vc_cols * nr; 320 step = vc->vc_cols * nr;
321 scr_memmovew(s + step, s, (b - t - nr) * vc->vc_size_row); 321 scr_memmovew(s + step, s, (b - t - nr) * vc->vc_size_row);
322 scr_memsetw(s, vc->vc_scrl_erase_char, 2 * step); 322 scr_memsetw(s, vc->vc_scrl_erase_char, 2 * step);
323 } 323 }
324 324
325 static void do_update_region(struct vc_data *vc, unsigned long start, int count) 325 static void do_update_region(struct vc_data *vc, unsigned long start, int count)
326 { 326 {
327 #ifndef VT_BUF_VRAM_ONLY 327 #ifndef VT_BUF_VRAM_ONLY
328 unsigned int xx, yy, offset; 328 unsigned int xx, yy, offset;
329 u16 *p; 329 u16 *p;
330 330
331 p = (u16 *) start; 331 p = (u16 *) start;
332 if (!vc->vc_sw->con_getxy) { 332 if (!vc->vc_sw->con_getxy) {
333 offset = (start - vc->vc_origin) / 2; 333 offset = (start - vc->vc_origin) / 2;
334 xx = offset % vc->vc_cols; 334 xx = offset % vc->vc_cols;
335 yy = offset / vc->vc_cols; 335 yy = offset / vc->vc_cols;
336 } else { 336 } else {
337 int nxx, nyy; 337 int nxx, nyy;
338 start = vc->vc_sw->con_getxy(vc, start, &nxx, &nyy); 338 start = vc->vc_sw->con_getxy(vc, start, &nxx, &nyy);
339 xx = nxx; yy = nyy; 339 xx = nxx; yy = nyy;
340 } 340 }
341 for(;;) { 341 for(;;) {
342 u16 attrib = scr_readw(p) & 0xff00; 342 u16 attrib = scr_readw(p) & 0xff00;
343 int startx = xx; 343 int startx = xx;
344 u16 *q = p; 344 u16 *q = p;
345 while (xx < vc->vc_cols && count) { 345 while (xx < vc->vc_cols && count) {
346 if (attrib != (scr_readw(p) & 0xff00)) { 346 if (attrib != (scr_readw(p) & 0xff00)) {
347 if (p > q) 347 if (p > q)
348 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); 348 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx);
349 startx = xx; 349 startx = xx;
350 q = p; 350 q = p;
351 attrib = scr_readw(p) & 0xff00; 351 attrib = scr_readw(p) & 0xff00;
352 } 352 }
353 p++; 353 p++;
354 xx++; 354 xx++;
355 count--; 355 count--;
356 } 356 }
357 if (p > q) 357 if (p > q)
358 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); 358 vc->vc_sw->con_putcs(vc, q, p-q, yy, startx);
359 if (!count) 359 if (!count)
360 break; 360 break;
361 xx = 0; 361 xx = 0;
362 yy++; 362 yy++;
363 if (vc->vc_sw->con_getxy) { 363 if (vc->vc_sw->con_getxy) {
364 p = (u16 *)start; 364 p = (u16 *)start;
365 start = vc->vc_sw->con_getxy(vc, start, NULL, NULL); 365 start = vc->vc_sw->con_getxy(vc, start, NULL, NULL);
366 } 366 }
367 } 367 }
368 #endif 368 #endif
369 } 369 }
370 370
371 void update_region(struct vc_data *vc, unsigned long start, int count) 371 void update_region(struct vc_data *vc, unsigned long start, int count)
372 { 372 {
373 WARN_CONSOLE_UNLOCKED(); 373 WARN_CONSOLE_UNLOCKED();
374 374
375 if (DO_UPDATE(vc)) { 375 if (DO_UPDATE(vc)) {
376 hide_cursor(vc); 376 hide_cursor(vc);
377 do_update_region(vc, start, count); 377 do_update_region(vc, start, count);
378 set_cursor(vc); 378 set_cursor(vc);
379 } 379 }
380 } 380 }
381 381
382 /* Structure of attributes is hardware-dependent */ 382 /* Structure of attributes is hardware-dependent */
383 383
384 static u8 build_attr(struct vc_data *vc, u8 _color, u8 _intensity, u8 _blink, 384 static u8 build_attr(struct vc_data *vc, u8 _color, u8 _intensity, u8 _blink,
385 u8 _underline, u8 _reverse, u8 _italic) 385 u8 _underline, u8 _reverse, u8 _italic)
386 { 386 {
387 if (vc->vc_sw->con_build_attr) 387 if (vc->vc_sw->con_build_attr)
388 return vc->vc_sw->con_build_attr(vc, _color, _intensity, 388 return vc->vc_sw->con_build_attr(vc, _color, _intensity,
389 _blink, _underline, _reverse, _italic); 389 _blink, _underline, _reverse, _italic);
390 390
391 #ifndef VT_BUF_VRAM_ONLY 391 #ifndef VT_BUF_VRAM_ONLY
392 /* 392 /*
393 * ++roman: I completely changed the attribute format for monochrome 393 * ++roman: I completely changed the attribute format for monochrome
394 * mode (!can_do_color). The formerly used MDA (monochrome display 394 * mode (!can_do_color). The formerly used MDA (monochrome display
395 * adapter) format didn't allow the combination of certain effects. 395 * adapter) format didn't allow the combination of certain effects.
396 * Now the attribute is just a bit vector: 396 * Now the attribute is just a bit vector:
397 * Bit 0..1: intensity (0..2) 397 * Bit 0..1: intensity (0..2)
398 * Bit 2 : underline 398 * Bit 2 : underline
399 * Bit 3 : reverse 399 * Bit 3 : reverse
400 * Bit 7 : blink 400 * Bit 7 : blink
401 */ 401 */
402 { 402 {
403 u8 a = _color; 403 u8 a = _color;
404 if (!vc->vc_can_do_color) 404 if (!vc->vc_can_do_color)
405 return _intensity | 405 return _intensity |
406 (_italic ? 2 : 0) | 406 (_italic ? 2 : 0) |
407 (_underline ? 4 : 0) | 407 (_underline ? 4 : 0) |
408 (_reverse ? 8 : 0) | 408 (_reverse ? 8 : 0) |
409 (_blink ? 0x80 : 0); 409 (_blink ? 0x80 : 0);
410 if (_italic) 410 if (_italic)
411 a = (a & 0xF0) | vc->vc_itcolor; 411 a = (a & 0xF0) | vc->vc_itcolor;
412 else if (_underline) 412 else if (_underline)
413 a = (a & 0xf0) | vc->vc_ulcolor; 413 a = (a & 0xf0) | vc->vc_ulcolor;
414 else if (_intensity == 0) 414 else if (_intensity == 0)
415 a = (a & 0xf0) | vc->vc_ulcolor; 415 a = (a & 0xf0) | vc->vc_ulcolor;
416 if (_reverse) 416 if (_reverse)
417 a = ((a) & 0x88) | ((((a) >> 4) | ((a) << 4)) & 0x77); 417 a = ((a) & 0x88) | ((((a) >> 4) | ((a) << 4)) & 0x77);
418 if (_blink) 418 if (_blink)
419 a ^= 0x80; 419 a ^= 0x80;
420 if (_intensity == 2) 420 if (_intensity == 2)
421 a ^= 0x08; 421 a ^= 0x08;
422 if (vc->vc_hi_font_mask == 0x100) 422 if (vc->vc_hi_font_mask == 0x100)
423 a <<= 1; 423 a <<= 1;
424 return a; 424 return a;
425 } 425 }
426 #else 426 #else
427 return 0; 427 return 0;
428 #endif 428 #endif
429 } 429 }
430 430
431 static void update_attr(struct vc_data *vc) 431 static void update_attr(struct vc_data *vc)
432 { 432 {
433 vc->vc_attr = build_attr(vc, vc->vc_color, vc->vc_intensity, 433 vc->vc_attr = build_attr(vc, vc->vc_color, vc->vc_intensity,
434 vc->vc_blink, vc->vc_underline, 434 vc->vc_blink, vc->vc_underline,
435 vc->vc_reverse ^ vc->vc_decscnm, vc->vc_italic); 435 vc->vc_reverse ^ vc->vc_decscnm, vc->vc_italic);
436 vc->vc_video_erase_char = (build_attr(vc, vc->vc_color, 1, vc->vc_blink, 0, vc->vc_decscnm, 0) << 8) | ' '; 436 vc->vc_video_erase_char = (build_attr(vc, vc->vc_color, 1, vc->vc_blink, 0, vc->vc_decscnm, 0) << 8) | ' ';
437 vc->vc_scrl_erase_char = (build_attr(vc, vc->vc_def_color, 1, false, false, false, false) << 8) | ' '; 437 vc->vc_scrl_erase_char = (build_attr(vc, vc->vc_def_color, 1, false, false, false, false) << 8) | ' ';
438 } 438 }
439 439
440 /* Note: inverting the screen twice should revert to the original state */ 440 /* Note: inverting the screen twice should revert to the original state */
441 void invert_screen(struct vc_data *vc, int offset, int count, int viewed) 441 void invert_screen(struct vc_data *vc, int offset, int count, int viewed)
442 { 442 {
443 unsigned short *p; 443 unsigned short *p;
444 444
445 WARN_CONSOLE_UNLOCKED(); 445 WARN_CONSOLE_UNLOCKED();
446 446
447 count /= 2; 447 count /= 2;
448 p = screenpos(vc, offset, viewed); 448 p = screenpos(vc, offset, viewed);
449 if (vc->vc_sw->con_invert_region) 449 if (vc->vc_sw->con_invert_region)
450 vc->vc_sw->con_invert_region(vc, p, count); 450 vc->vc_sw->con_invert_region(vc, p, count);
451 #ifndef VT_BUF_VRAM_ONLY 451 #ifndef VT_BUF_VRAM_ONLY
452 else { 452 else {
453 u16 *q = p; 453 u16 *q = p;
454 int cnt = count; 454 int cnt = count;
455 u16 a; 455 u16 a;
456 456
457 if (!vc->vc_can_do_color) { 457 if (!vc->vc_can_do_color) {
458 while (cnt--) { 458 while (cnt--) {
459 a = scr_readw(q); 459 a = scr_readw(q);
460 a ^= 0x0800; 460 a ^= 0x0800;
461 scr_writew(a, q); 461 scr_writew(a, q);
462 q++; 462 q++;
463 } 463 }
464 } else if (vc->vc_hi_font_mask == 0x100) { 464 } else if (vc->vc_hi_font_mask == 0x100) {
465 while (cnt--) { 465 while (cnt--) {
466 a = scr_readw(q); 466 a = scr_readw(q);
467 a = ((a) & 0x11ff) | (((a) & 0xe000) >> 4) | (((a) & 0x0e00) << 4); 467 a = ((a) & 0x11ff) | (((a) & 0xe000) >> 4) | (((a) & 0x0e00) << 4);
468 scr_writew(a, q); 468 scr_writew(a, q);
469 q++; 469 q++;
470 } 470 }
471 } else { 471 } else {
472 while (cnt--) { 472 while (cnt--) {
473 a = scr_readw(q); 473 a = scr_readw(q);
474 a = ((a) & 0x88ff) | (((a) & 0x7000) >> 4) | (((a) & 0x0700) << 4); 474 a = ((a) & 0x88ff) | (((a) & 0x7000) >> 4) | (((a) & 0x0700) << 4);
475 scr_writew(a, q); 475 scr_writew(a, q);
476 q++; 476 q++;
477 } 477 }
478 } 478 }
479 } 479 }
480 #endif 480 #endif
481 if (DO_UPDATE(vc)) 481 if (DO_UPDATE(vc))
482 do_update_region(vc, (unsigned long) p, count); 482 do_update_region(vc, (unsigned long) p, count);
483 } 483 }
484 484
485 /* used by selection: complement pointer position */ 485 /* used by selection: complement pointer position */
486 void complement_pos(struct vc_data *vc, int offset) 486 void complement_pos(struct vc_data *vc, int offset)
487 { 487 {
488 static int old_offset = -1; 488 static int old_offset = -1;
489 static unsigned short old; 489 static unsigned short old;
490 static unsigned short oldx, oldy; 490 static unsigned short oldx, oldy;
491 491
492 WARN_CONSOLE_UNLOCKED(); 492 WARN_CONSOLE_UNLOCKED();
493 493
494 if (old_offset != -1 && old_offset >= 0 && 494 if (old_offset != -1 && old_offset >= 0 &&
495 old_offset < vc->vc_screenbuf_size) { 495 old_offset < vc->vc_screenbuf_size) {
496 scr_writew(old, screenpos(vc, old_offset, 1)); 496 scr_writew(old, screenpos(vc, old_offset, 1));
497 if (DO_UPDATE(vc)) 497 if (DO_UPDATE(vc))
498 vc->vc_sw->con_putc(vc, old, oldy, oldx); 498 vc->vc_sw->con_putc(vc, old, oldy, oldx);
499 } 499 }
500 500
501 old_offset = offset; 501 old_offset = offset;
502 502
503 if (offset != -1 && offset >= 0 && 503 if (offset != -1 && offset >= 0 &&
504 offset < vc->vc_screenbuf_size) { 504 offset < vc->vc_screenbuf_size) {
505 unsigned short new; 505 unsigned short new;
506 unsigned short *p; 506 unsigned short *p;
507 p = screenpos(vc, offset, 1); 507 p = screenpos(vc, offset, 1);
508 old = scr_readw(p); 508 old = scr_readw(p);
509 new = old ^ vc->vc_complement_mask; 509 new = old ^ vc->vc_complement_mask;
510 scr_writew(new, p); 510 scr_writew(new, p);
511 if (DO_UPDATE(vc)) { 511 if (DO_UPDATE(vc)) {
512 oldx = (offset >> 1) % vc->vc_cols; 512 oldx = (offset >> 1) % vc->vc_cols;
513 oldy = (offset >> 1) / vc->vc_cols; 513 oldy = (offset >> 1) / vc->vc_cols;
514 vc->vc_sw->con_putc(vc, new, oldy, oldx); 514 vc->vc_sw->con_putc(vc, new, oldy, oldx);
515 } 515 }
516 } 516 }
517 517
518 } 518 }
519 519
520 static void insert_char(struct vc_data *vc, unsigned int nr) 520 static void insert_char(struct vc_data *vc, unsigned int nr)
521 { 521 {
522 unsigned short *p, *q = (unsigned short *)vc->vc_pos; 522 unsigned short *p, *q = (unsigned short *)vc->vc_pos;
523 523
524 p = q + vc->vc_cols - nr - vc->vc_x; 524 p = q + vc->vc_cols - nr - vc->vc_x;
525 while (--p >= q) 525 while (--p >= q)
526 scr_writew(scr_readw(p), p + nr); 526 scr_writew(scr_readw(p), p + nr);
527 scr_memsetw(q, vc->vc_video_erase_char, nr * 2); 527 scr_memsetw(q, vc->vc_video_erase_char, nr * 2);
528 vc->vc_need_wrap = 0; 528 vc->vc_need_wrap = 0;
529 if (DO_UPDATE(vc)) { 529 if (DO_UPDATE(vc)) {
530 unsigned short oldattr = vc->vc_attr; 530 unsigned short oldattr = vc->vc_attr;
531 vc->vc_sw->con_bmove(vc, vc->vc_y, vc->vc_x, vc->vc_y, vc->vc_x + nr, 1, 531 vc->vc_sw->con_bmove(vc, vc->vc_y, vc->vc_x, vc->vc_y, vc->vc_x + nr, 1,
532 vc->vc_cols - vc->vc_x - nr); 532 vc->vc_cols - vc->vc_x - nr);
533 vc->vc_attr = vc->vc_video_erase_char >> 8; 533 vc->vc_attr = vc->vc_video_erase_char >> 8;
534 while (nr--) 534 while (nr--)
535 vc->vc_sw->con_putc(vc, vc->vc_video_erase_char, vc->vc_y, vc->vc_x + nr); 535 vc->vc_sw->con_putc(vc, vc->vc_video_erase_char, vc->vc_y, vc->vc_x + nr);
536 vc->vc_attr = oldattr; 536 vc->vc_attr = oldattr;
537 } 537 }
538 } 538 }
539 539
540 static void delete_char(struct vc_data *vc, unsigned int nr) 540 static void delete_char(struct vc_data *vc, unsigned int nr)
541 { 541 {
542 unsigned int i = vc->vc_x; 542 unsigned int i = vc->vc_x;
543 unsigned short *p = (unsigned short *)vc->vc_pos; 543 unsigned short *p = (unsigned short *)vc->vc_pos;
544 544
545 while (++i <= vc->vc_cols - nr) { 545 while (++i <= vc->vc_cols - nr) {
546 scr_writew(scr_readw(p+nr), p); 546 scr_writew(scr_readw(p+nr), p);
547 p++; 547 p++;
548 } 548 }
549 scr_memsetw(p, vc->vc_video_erase_char, nr * 2); 549 scr_memsetw(p, vc->vc_video_erase_char, nr * 2);
550 vc->vc_need_wrap = 0; 550 vc->vc_need_wrap = 0;
551 if (DO_UPDATE(vc)) { 551 if (DO_UPDATE(vc)) {
552 unsigned short oldattr = vc->vc_attr; 552 unsigned short oldattr = vc->vc_attr;
553 vc->vc_sw->con_bmove(vc, vc->vc_y, vc->vc_x + nr, vc->vc_y, vc->vc_x, 1, 553 vc->vc_sw->con_bmove(vc, vc->vc_y, vc->vc_x + nr, vc->vc_y, vc->vc_x, 1,
554 vc->vc_cols - vc->vc_x - nr); 554 vc->vc_cols - vc->vc_x - nr);
555 vc->vc_attr = vc->vc_video_erase_char >> 8; 555 vc->vc_attr = vc->vc_video_erase_char >> 8;
556 while (nr--) 556 while (nr--)
557 vc->vc_sw->con_putc(vc, vc->vc_video_erase_char, vc->vc_y, 557 vc->vc_sw->con_putc(vc, vc->vc_video_erase_char, vc->vc_y,
558 vc->vc_cols - 1 - nr); 558 vc->vc_cols - 1 - nr);
559 vc->vc_attr = oldattr; 559 vc->vc_attr = oldattr;
560 } 560 }
561 } 561 }
562 562
563 static int softcursor_original; 563 static int softcursor_original;
564 564
565 static void add_softcursor(struct vc_data *vc) 565 static void add_softcursor(struct vc_data *vc)
566 { 566 {
567 int i = scr_readw((u16 *) vc->vc_pos); 567 int i = scr_readw((u16 *) vc->vc_pos);
568 u32 type = vc->vc_cursor_type; 568 u32 type = vc->vc_cursor_type;
569 569
570 if (! (type & 0x10)) return; 570 if (! (type & 0x10)) return;
571 if (softcursor_original != -1) return; 571 if (softcursor_original != -1) return;
572 softcursor_original = i; 572 softcursor_original = i;
573 i |= ((type >> 8) & 0xff00 ); 573 i |= ((type >> 8) & 0xff00 );
574 i ^= ((type) & 0xff00 ); 574 i ^= ((type) & 0xff00 );
575 if ((type & 0x20) && ((softcursor_original & 0x7000) == (i & 0x7000))) i ^= 0x7000; 575 if ((type & 0x20) && ((softcursor_original & 0x7000) == (i & 0x7000))) i ^= 0x7000;
576 if ((type & 0x40) && ((i & 0x700) == ((i & 0x7000) >> 4))) i ^= 0x0700; 576 if ((type & 0x40) && ((i & 0x700) == ((i & 0x7000) >> 4))) i ^= 0x0700;
577 scr_writew(i, (u16 *) vc->vc_pos); 577 scr_writew(i, (u16 *) vc->vc_pos);
578 if (DO_UPDATE(vc)) 578 if (DO_UPDATE(vc))
579 vc->vc_sw->con_putc(vc, i, vc->vc_y, vc->vc_x); 579 vc->vc_sw->con_putc(vc, i, vc->vc_y, vc->vc_x);
580 } 580 }
581 581
582 static void hide_softcursor(struct vc_data *vc) 582 static void hide_softcursor(struct vc_data *vc)
583 { 583 {
584 if (softcursor_original != -1) { 584 if (softcursor_original != -1) {
585 scr_writew(softcursor_original, (u16 *)vc->vc_pos); 585 scr_writew(softcursor_original, (u16 *)vc->vc_pos);
586 if (DO_UPDATE(vc)) 586 if (DO_UPDATE(vc))
587 vc->vc_sw->con_putc(vc, softcursor_original, 587 vc->vc_sw->con_putc(vc, softcursor_original,
588 vc->vc_y, vc->vc_x); 588 vc->vc_y, vc->vc_x);
589 softcursor_original = -1; 589 softcursor_original = -1;
590 } 590 }
591 } 591 }
592 592
593 static void hide_cursor(struct vc_data *vc) 593 static void hide_cursor(struct vc_data *vc)
594 { 594 {
595 if (vc == sel_cons) 595 if (vc == sel_cons)
596 clear_selection(); 596 clear_selection();
597 vc->vc_sw->con_cursor(vc, CM_ERASE); 597 vc->vc_sw->con_cursor(vc, CM_ERASE);
598 hide_softcursor(vc); 598 hide_softcursor(vc);
599 } 599 }
600 600
601 static void set_cursor(struct vc_data *vc) 601 static void set_cursor(struct vc_data *vc)
602 { 602 {
603 if (!IS_FG(vc) || console_blanked || 603 if (!IS_FG(vc) || console_blanked ||
604 vc->vc_mode == KD_GRAPHICS) 604 vc->vc_mode == KD_GRAPHICS)
605 return; 605 return;
606 if (vc->vc_deccm) { 606 if (vc->vc_deccm) {
607 if (vc == sel_cons) 607 if (vc == sel_cons)
608 clear_selection(); 608 clear_selection();
609 add_softcursor(vc); 609 add_softcursor(vc);
610 if ((vc->vc_cursor_type & 0x0f) != 1) 610 if ((vc->vc_cursor_type & 0x0f) != 1)
611 vc->vc_sw->con_cursor(vc, CM_DRAW); 611 vc->vc_sw->con_cursor(vc, CM_DRAW);
612 } else 612 } else
613 hide_cursor(vc); 613 hide_cursor(vc);
614 } 614 }
615 615
616 static void set_origin(struct vc_data *vc) 616 static void set_origin(struct vc_data *vc)
617 { 617 {
618 WARN_CONSOLE_UNLOCKED(); 618 WARN_CONSOLE_UNLOCKED();
619 619
620 if (!CON_IS_VISIBLE(vc) || 620 if (!CON_IS_VISIBLE(vc) ||
621 !vc->vc_sw->con_set_origin || 621 !vc->vc_sw->con_set_origin ||
622 !vc->vc_sw->con_set_origin(vc)) 622 !vc->vc_sw->con_set_origin(vc))
623 vc->vc_origin = (unsigned long)vc->vc_screenbuf; 623 vc->vc_origin = (unsigned long)vc->vc_screenbuf;
624 vc->vc_visible_origin = vc->vc_origin; 624 vc->vc_visible_origin = vc->vc_origin;
625 vc->vc_scr_end = vc->vc_origin + vc->vc_screenbuf_size; 625 vc->vc_scr_end = vc->vc_origin + vc->vc_screenbuf_size;
626 vc->vc_pos = vc->vc_origin + vc->vc_size_row * vc->vc_y + 2 * vc->vc_x; 626 vc->vc_pos = vc->vc_origin + vc->vc_size_row * vc->vc_y + 2 * vc->vc_x;
627 } 627 }
628 628
629 static inline void save_screen(struct vc_data *vc) 629 static inline void save_screen(struct vc_data *vc)
630 { 630 {
631 WARN_CONSOLE_UNLOCKED(); 631 WARN_CONSOLE_UNLOCKED();
632 632
633 if (vc->vc_sw->con_save_screen) 633 if (vc->vc_sw->con_save_screen)
634 vc->vc_sw->con_save_screen(vc); 634 vc->vc_sw->con_save_screen(vc);
635 } 635 }
636 636
637 /* 637 /*
638 * Redrawing of screen 638 * Redrawing of screen
639 */ 639 */
640 640
641 static void clear_buffer_attributes(struct vc_data *vc) 641 static void clear_buffer_attributes(struct vc_data *vc)
642 { 642 {
643 unsigned short *p = (unsigned short *)vc->vc_origin; 643 unsigned short *p = (unsigned short *)vc->vc_origin;
644 int count = vc->vc_screenbuf_size / 2; 644 int count = vc->vc_screenbuf_size / 2;
645 int mask = vc->vc_hi_font_mask | 0xff; 645 int mask = vc->vc_hi_font_mask | 0xff;
646 646
647 for (; count > 0; count--, p++) { 647 for (; count > 0; count--, p++) {
648 scr_writew((scr_readw(p)&mask) | (vc->vc_video_erase_char & ~mask), p); 648 scr_writew((scr_readw(p)&mask) | (vc->vc_video_erase_char & ~mask), p);
649 } 649 }
650 } 650 }
651 651
652 void redraw_screen(struct vc_data *vc, int is_switch) 652 void redraw_screen(struct vc_data *vc, int is_switch)
653 { 653 {
654 int redraw = 0; 654 int redraw = 0;
655 655
656 WARN_CONSOLE_UNLOCKED(); 656 WARN_CONSOLE_UNLOCKED();
657 657
658 if (!vc) { 658 if (!vc) {
659 /* strange ... */ 659 /* strange ... */
660 /* printk("redraw_screen: tty %d not allocated ??\n", new_console+1); */ 660 /* printk("redraw_screen: tty %d not allocated ??\n", new_console+1); */
661 return; 661 return;
662 } 662 }
663 663
664 if (is_switch) { 664 if (is_switch) {
665 struct vc_data *old_vc = vc_cons[fg_console].d; 665 struct vc_data *old_vc = vc_cons[fg_console].d;
666 if (old_vc == vc) 666 if (old_vc == vc)
667 return; 667 return;
668 if (!CON_IS_VISIBLE(vc)) 668 if (!CON_IS_VISIBLE(vc))
669 redraw = 1; 669 redraw = 1;
670 *vc->vc_display_fg = vc; 670 *vc->vc_display_fg = vc;
671 fg_console = vc->vc_num; 671 fg_console = vc->vc_num;
672 hide_cursor(old_vc); 672 hide_cursor(old_vc);
673 if (!CON_IS_VISIBLE(old_vc)) { 673 if (!CON_IS_VISIBLE(old_vc)) {
674 save_screen(old_vc); 674 save_screen(old_vc);
675 set_origin(old_vc); 675 set_origin(old_vc);
676 } 676 }
677 } else { 677 } else {
678 hide_cursor(vc); 678 hide_cursor(vc);
679 redraw = 1; 679 redraw = 1;
680 } 680 }
681 681
682 if (redraw) { 682 if (redraw) {
683 int update; 683 int update;
684 int old_was_color = vc->vc_can_do_color; 684 int old_was_color = vc->vc_can_do_color;
685 685
686 set_origin(vc); 686 set_origin(vc);
687 update = vc->vc_sw->con_switch(vc); 687 update = vc->vc_sw->con_switch(vc);
688 set_palette(vc); 688 set_palette(vc);
689 /* 689 /*
690 * If console changed from mono<->color, the best we can do 690 * If console changed from mono<->color, the best we can do
691 * is to clear the buffer attributes. As it currently stands, 691 * is to clear the buffer attributes. As it currently stands,
692 * rebuilding new attributes from the old buffer is not doable 692 * rebuilding new attributes from the old buffer is not doable
693 * without overly complex code. 693 * without overly complex code.
694 */ 694 */
695 if (old_was_color != vc->vc_can_do_color) { 695 if (old_was_color != vc->vc_can_do_color) {
696 update_attr(vc); 696 update_attr(vc);
697 clear_buffer_attributes(vc); 697 clear_buffer_attributes(vc);
698 } 698 }
699 if (update && vc->vc_mode != KD_GRAPHICS) 699 if (update && vc->vc_mode != KD_GRAPHICS)
700 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); 700 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2);
701 } 701 }
702 set_cursor(vc); 702 set_cursor(vc);
703 if (is_switch) { 703 if (is_switch) {
704 set_leds(); 704 set_leds();
705 compute_shiftstate(); 705 compute_shiftstate();
706 notify_update(vc); 706 notify_update(vc);
707 } 707 }
708 } 708 }
709 709
710 /* 710 /*
711 * Allocation, freeing and resizing of VTs. 711 * Allocation, freeing and resizing of VTs.
712 */ 712 */
713 713
714 int vc_cons_allocated(unsigned int i) 714 int vc_cons_allocated(unsigned int i)
715 { 715 {
716 return (i < MAX_NR_CONSOLES && vc_cons[i].d); 716 return (i < MAX_NR_CONSOLES && vc_cons[i].d);
717 } 717 }
718 718
719 static void visual_init(struct vc_data *vc, int num, int init) 719 static void visual_init(struct vc_data *vc, int num, int init)
720 { 720 {
721 /* ++Geert: vc->vc_sw->con_init determines console size */ 721 /* ++Geert: vc->vc_sw->con_init determines console size */
722 if (vc->vc_sw) 722 if (vc->vc_sw)
723 module_put(vc->vc_sw->owner); 723 module_put(vc->vc_sw->owner);
724 vc->vc_sw = conswitchp; 724 vc->vc_sw = conswitchp;
725 #ifndef VT_SINGLE_DRIVER 725 #ifndef VT_SINGLE_DRIVER
726 if (con_driver_map[num]) 726 if (con_driver_map[num])
727 vc->vc_sw = con_driver_map[num]; 727 vc->vc_sw = con_driver_map[num];
728 #endif 728 #endif
729 __module_get(vc->vc_sw->owner); 729 __module_get(vc->vc_sw->owner);
730 vc->vc_num = num; 730 vc->vc_num = num;
731 vc->vc_display_fg = &master_display_fg; 731 vc->vc_display_fg = &master_display_fg;
732 vc->vc_uni_pagedir_loc = &vc->vc_uni_pagedir; 732 vc->vc_uni_pagedir_loc = &vc->vc_uni_pagedir;
733 vc->vc_uni_pagedir = 0; 733 vc->vc_uni_pagedir = 0;
734 vc->vc_hi_font_mask = 0; 734 vc->vc_hi_font_mask = 0;
735 vc->vc_complement_mask = 0; 735 vc->vc_complement_mask = 0;
736 vc->vc_can_do_color = 0; 736 vc->vc_can_do_color = 0;
737 vc->vc_sw->con_init(vc, init); 737 vc->vc_sw->con_init(vc, init);
738 if (!vc->vc_complement_mask) 738 if (!vc->vc_complement_mask)
739 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; 739 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
740 vc->vc_s_complement_mask = vc->vc_complement_mask; 740 vc->vc_s_complement_mask = vc->vc_complement_mask;
741 vc->vc_size_row = vc->vc_cols << 1; 741 vc->vc_size_row = vc->vc_cols << 1;
742 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row; 742 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row;
743 } 743 }
744 744
745 int vc_allocate(unsigned int currcons) /* return 0 on success */ 745 int vc_allocate(unsigned int currcons) /* return 0 on success */
746 { 746 {
747 WARN_CONSOLE_UNLOCKED(); 747 WARN_CONSOLE_UNLOCKED();
748 748
749 if (currcons >= MAX_NR_CONSOLES) 749 if (currcons >= MAX_NR_CONSOLES)
750 return -ENXIO; 750 return -ENXIO;
751 if (!vc_cons[currcons].d) { 751 if (!vc_cons[currcons].d) {
752 struct vc_data *vc; 752 struct vc_data *vc;
753 struct vt_notifier_param param; 753 struct vt_notifier_param param;
754 754
755 /* prevent users from taking too much memory */ 755 /* prevent users from taking too much memory */
756 if (currcons >= MAX_NR_USER_CONSOLES && !capable(CAP_SYS_RESOURCE)) 756 if (currcons >= MAX_NR_USER_CONSOLES && !capable(CAP_SYS_RESOURCE))
757 return -EPERM; 757 return -EPERM;
758 758
759 /* due to the granularity of kmalloc, we waste some memory here */ 759 /* due to the granularity of kmalloc, we waste some memory here */
760 /* the alloc is done in two steps, to optimize the common situation 760 /* the alloc is done in two steps, to optimize the common situation
761 of a 25x80 console (structsize=216, screenbuf_size=4000) */ 761 of a 25x80 console (structsize=216, screenbuf_size=4000) */
762 /* although the numbers above are not valid since long ago, the 762 /* although the numbers above are not valid since long ago, the
763 point is still up-to-date and the comment still has its value 763 point is still up-to-date and the comment still has its value
764 even if only as a historical artifact. --mj, July 1998 */ 764 even if only as a historical artifact. --mj, July 1998 */
765 param.vc = vc = kzalloc(sizeof(struct vc_data), GFP_KERNEL); 765 param.vc = vc = kzalloc(sizeof(struct vc_data), GFP_KERNEL);
766 if (!vc) 766 if (!vc)
767 return -ENOMEM; 767 return -ENOMEM;
768 vc_cons[currcons].d = vc; 768 vc_cons[currcons].d = vc;
769 INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK); 769 INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK);
770 visual_init(vc, currcons, 1); 770 visual_init(vc, currcons, 1);
771 if (!*vc->vc_uni_pagedir_loc) 771 if (!*vc->vc_uni_pagedir_loc)
772 con_set_default_unimap(vc); 772 con_set_default_unimap(vc);
773 if (!vc->vc_kmalloced) 773 if (!vc->vc_kmalloced)
774 vc->vc_screenbuf = kmalloc(vc->vc_screenbuf_size, GFP_KERNEL); 774 vc->vc_screenbuf = kmalloc(vc->vc_screenbuf_size, GFP_KERNEL);
775 if (!vc->vc_screenbuf) { 775 if (!vc->vc_screenbuf) {
776 kfree(vc); 776 kfree(vc);
777 vc_cons[currcons].d = NULL; 777 vc_cons[currcons].d = NULL;
778 return -ENOMEM; 778 return -ENOMEM;
779 } 779 }
780 vc->vc_kmalloced = 1; 780 vc->vc_kmalloced = 1;
781 vc_init(vc, vc->vc_rows, vc->vc_cols, 1); 781 vc_init(vc, vc->vc_rows, vc->vc_cols, 1);
782 atomic_notifier_call_chain(&vt_notifier_list, VT_ALLOCATE, &param); 782 atomic_notifier_call_chain(&vt_notifier_list, VT_ALLOCATE, &param);
783 } 783 }
784 return 0; 784 return 0;
785 } 785 }
786 786
787 static inline int resize_screen(struct vc_data *vc, int width, int height, 787 static inline int resize_screen(struct vc_data *vc, int width, int height,
788 int user) 788 int user)
789 { 789 {
790 /* Resizes the resolution of the display adapater */ 790 /* Resizes the resolution of the display adapater */
791 int err = 0; 791 int err = 0;
792 792
793 if (vc->vc_mode != KD_GRAPHICS && vc->vc_sw->con_resize) 793 if (vc->vc_mode != KD_GRAPHICS && vc->vc_sw->con_resize)
794 err = vc->vc_sw->con_resize(vc, width, height, user); 794 err = vc->vc_sw->con_resize(vc, width, height, user);
795 795
796 return err; 796 return err;
797 } 797 }
798 798
799 /* 799 /*
800 * Change # of rows and columns (0 means unchanged/the size of fg_console) 800 * Change # of rows and columns (0 means unchanged/the size of fg_console)
801 * [this is to be used together with some user program 801 * [this is to be used together with some user program
802 * like resize that changes the hardware videomode] 802 * like resize that changes the hardware videomode]
803 */ 803 */
804 #define VC_RESIZE_MAXCOL (32767) 804 #define VC_RESIZE_MAXCOL (32767)
805 #define VC_RESIZE_MAXROW (32767) 805 #define VC_RESIZE_MAXROW (32767)
806 int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines) 806 int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines)
807 { 807 {
808 unsigned long old_origin, new_origin, new_scr_end, rlth, rrem, err = 0; 808 unsigned long old_origin, new_origin, new_scr_end, rlth, rrem, err = 0;
809 unsigned int old_cols, old_rows, old_row_size, old_screen_size; 809 unsigned int old_cols, old_rows, old_row_size, old_screen_size;
810 unsigned int new_cols, new_rows, new_row_size, new_screen_size; 810 unsigned int new_cols, new_rows, new_row_size, new_screen_size;
811 unsigned int end, user; 811 unsigned int end, user;
812 unsigned short *newscreen; 812 unsigned short *newscreen;
813 813
814 WARN_CONSOLE_UNLOCKED(); 814 WARN_CONSOLE_UNLOCKED();
815 815
816 if (!vc) 816 if (!vc)
817 return -ENXIO; 817 return -ENXIO;
818 818
819 user = vc->vc_resize_user; 819 user = vc->vc_resize_user;
820 vc->vc_resize_user = 0; 820 vc->vc_resize_user = 0;
821 821
822 if (cols > VC_RESIZE_MAXCOL || lines > VC_RESIZE_MAXROW) 822 if (cols > VC_RESIZE_MAXCOL || lines > VC_RESIZE_MAXROW)
823 return -EINVAL; 823 return -EINVAL;
824 824
825 new_cols = (cols ? cols : vc->vc_cols); 825 new_cols = (cols ? cols : vc->vc_cols);
826 new_rows = (lines ? lines : vc->vc_rows); 826 new_rows = (lines ? lines : vc->vc_rows);
827 new_row_size = new_cols << 1; 827 new_row_size = new_cols << 1;
828 new_screen_size = new_row_size * new_rows; 828 new_screen_size = new_row_size * new_rows;
829 829
830 if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) 830 if (new_cols == vc->vc_cols && new_rows == vc->vc_rows)
831 return 0; 831 return 0;
832 832
833 newscreen = kmalloc(new_screen_size, GFP_USER); 833 newscreen = kmalloc(new_screen_size, GFP_USER);
834 if (!newscreen) 834 if (!newscreen)
835 return -ENOMEM; 835 return -ENOMEM;
836 836
837 old_rows = vc->vc_rows; 837 old_rows = vc->vc_rows;
838 old_cols = vc->vc_cols; 838 old_cols = vc->vc_cols;
839 old_row_size = vc->vc_size_row; 839 old_row_size = vc->vc_size_row;
840 old_screen_size = vc->vc_screenbuf_size; 840 old_screen_size = vc->vc_screenbuf_size;
841 841
842 err = resize_screen(vc, new_cols, new_rows, user); 842 err = resize_screen(vc, new_cols, new_rows, user);
843 if (err) { 843 if (err) {
844 kfree(newscreen); 844 kfree(newscreen);
845 return err; 845 return err;
846 } 846 }
847 847
848 vc->vc_rows = new_rows; 848 vc->vc_rows = new_rows;
849 vc->vc_cols = new_cols; 849 vc->vc_cols = new_cols;
850 vc->vc_size_row = new_row_size; 850 vc->vc_size_row = new_row_size;
851 vc->vc_screenbuf_size = new_screen_size; 851 vc->vc_screenbuf_size = new_screen_size;
852 852
853 rlth = min(old_row_size, new_row_size); 853 rlth = min(old_row_size, new_row_size);
854 rrem = new_row_size - rlth; 854 rrem = new_row_size - rlth;
855 old_origin = vc->vc_origin; 855 old_origin = vc->vc_origin;
856 new_origin = (long) newscreen; 856 new_origin = (long) newscreen;
857 new_scr_end = new_origin + new_screen_size; 857 new_scr_end = new_origin + new_screen_size;
858 858
859 if (vc->vc_y > new_rows) { 859 if (vc->vc_y > new_rows) {
860 if (old_rows - vc->vc_y < new_rows) { 860 if (old_rows - vc->vc_y < new_rows) {
861 /* 861 /*
862 * Cursor near the bottom, copy contents from the 862 * Cursor near the bottom, copy contents from the
863 * bottom of buffer 863 * bottom of buffer
864 */ 864 */
865 old_origin += (old_rows - new_rows) * old_row_size; 865 old_origin += (old_rows - new_rows) * old_row_size;
866 end = vc->vc_scr_end; 866 end = vc->vc_scr_end;
867 } else { 867 } else {
868 /* 868 /*
869 * Cursor is in no man's land, copy 1/2 screenful 869 * Cursor is in no man's land, copy 1/2 screenful
870 * from the top and bottom of cursor position 870 * from the top and bottom of cursor position
871 */ 871 */
872 old_origin += (vc->vc_y - new_rows/2) * old_row_size; 872 old_origin += (vc->vc_y - new_rows/2) * old_row_size;
873 end = old_origin + (old_row_size * new_rows); 873 end = old_origin + (old_row_size * new_rows);
874 } 874 }
875 } else 875 } else
876 /* 876 /*
877 * Cursor near the top, copy contents from the top of buffer 877 * Cursor near the top, copy contents from the top of buffer
878 */ 878 */
879 end = (old_rows > new_rows) ? old_origin + 879 end = (old_rows > new_rows) ? old_origin +
880 (old_row_size * new_rows) : 880 (old_row_size * new_rows) :
881 vc->vc_scr_end; 881 vc->vc_scr_end;
882 882
883 update_attr(vc); 883 update_attr(vc);
884 884
885 while (old_origin < end) { 885 while (old_origin < end) {
886 scr_memcpyw((unsigned short *) new_origin, 886 scr_memcpyw((unsigned short *) new_origin,
887 (unsigned short *) old_origin, rlth); 887 (unsigned short *) old_origin, rlth);
888 if (rrem) 888 if (rrem)
889 scr_memsetw((void *)(new_origin + rlth), 889 scr_memsetw((void *)(new_origin + rlth),
890 vc->vc_video_erase_char, rrem); 890 vc->vc_video_erase_char, rrem);
891 old_origin += old_row_size; 891 old_origin += old_row_size;
892 new_origin += new_row_size; 892 new_origin += new_row_size;
893 } 893 }
894 if (new_scr_end > new_origin) 894 if (new_scr_end > new_origin)
895 scr_memsetw((void *)new_origin, vc->vc_video_erase_char, 895 scr_memsetw((void *)new_origin, vc->vc_video_erase_char,
896 new_scr_end - new_origin); 896 new_scr_end - new_origin);
897 if (vc->vc_kmalloced) 897 if (vc->vc_kmalloced)
898 kfree(vc->vc_screenbuf); 898 kfree(vc->vc_screenbuf);
899 vc->vc_screenbuf = newscreen; 899 vc->vc_screenbuf = newscreen;
900 vc->vc_kmalloced = 1; 900 vc->vc_kmalloced = 1;
901 vc->vc_screenbuf_size = new_screen_size; 901 vc->vc_screenbuf_size = new_screen_size;
902 set_origin(vc); 902 set_origin(vc);
903 903
904 /* do part of a reset_terminal() */ 904 /* do part of a reset_terminal() */
905 vc->vc_top = 0; 905 vc->vc_top = 0;
906 vc->vc_bottom = vc->vc_rows; 906 vc->vc_bottom = vc->vc_rows;
907 gotoxy(vc, vc->vc_x, vc->vc_y); 907 gotoxy(vc, vc->vc_x, vc->vc_y);
908 save_cur(vc); 908 save_cur(vc);
909 909
910 if (vc->vc_tty) { 910 if (vc->vc_tty) {
911 struct winsize ws, *cws = &vc->vc_tty->winsize; 911 struct winsize ws, *cws = &vc->vc_tty->winsize;
912 unsigned long flags; 912 unsigned long flags;
913 913
914 memset(&ws, 0, sizeof(ws)); 914 memset(&ws, 0, sizeof(ws));
915 ws.ws_row = vc->vc_rows; 915 ws.ws_row = vc->vc_rows;
916 ws.ws_col = vc->vc_cols; 916 ws.ws_col = vc->vc_cols;
917 ws.ws_ypixel = vc->vc_scan_lines; 917 ws.ws_ypixel = vc->vc_scan_lines;
918 918
919 mutex_lock(&vc->vc_tty->termios_mutex); 919 mutex_lock(&vc->vc_tty->termios_mutex);
920 spin_lock_irqsave(&vc->vc_tty->ctrl_lock, flags); 920 spin_lock_irqsave(&vc->vc_tty->ctrl_lock, flags);
921 if ((ws.ws_row != cws->ws_row || ws.ws_col != cws->ws_col) && 921 if ((ws.ws_row != cws->ws_row || ws.ws_col != cws->ws_col) &&
922 vc->vc_tty->pgrp) 922 vc->vc_tty->pgrp)
923 kill_pgrp(vc->vc_tty->pgrp, SIGWINCH, 1); 923 kill_pgrp(vc->vc_tty->pgrp, SIGWINCH, 1);
924 spin_unlock_irqrestore(&vc->vc_tty->ctrl_lock, flags); 924 spin_unlock_irqrestore(&vc->vc_tty->ctrl_lock, flags);
925 *cws = ws; 925 *cws = ws;
926 mutex_unlock(&vc->vc_tty->termios_mutex); 926 mutex_unlock(&vc->vc_tty->termios_mutex);
927 } 927 }
928 928
929 if (CON_IS_VISIBLE(vc)) 929 if (CON_IS_VISIBLE(vc))
930 update_screen(vc); 930 update_screen(vc);
931 return err; 931 return err;
932 } 932 }
933 933
934 int vc_lock_resize(struct vc_data *vc, unsigned int cols, unsigned int lines) 934 int vc_lock_resize(struct vc_data *vc, unsigned int cols, unsigned int lines)
935 { 935 {
936 int rc; 936 int rc;
937 937
938 acquire_console_sem(); 938 acquire_console_sem();
939 rc = vc_resize(vc, cols, lines); 939 rc = vc_resize(vc, cols, lines);
940 release_console_sem(); 940 release_console_sem();
941 return rc; 941 return rc;
942 } 942 }
943 943
944 void vc_deallocate(unsigned int currcons) 944 void vc_deallocate(unsigned int currcons)
945 { 945 {
946 WARN_CONSOLE_UNLOCKED(); 946 WARN_CONSOLE_UNLOCKED();
947 947
948 if (vc_cons_allocated(currcons)) { 948 if (vc_cons_allocated(currcons)) {
949 struct vc_data *vc = vc_cons[currcons].d; 949 struct vc_data *vc = vc_cons[currcons].d;
950 struct vt_notifier_param param = { .vc = vc }; 950 struct vt_notifier_param param = { .vc = vc };
951 atomic_notifier_call_chain(&vt_notifier_list, VT_DEALLOCATE, &param); 951 atomic_notifier_call_chain(&vt_notifier_list, VT_DEALLOCATE, &param);
952 vc->vc_sw->con_deinit(vc); 952 vc->vc_sw->con_deinit(vc);
953 put_pid(vc->vt_pid); 953 put_pid(vc->vt_pid);
954 module_put(vc->vc_sw->owner); 954 module_put(vc->vc_sw->owner);
955 if (vc->vc_kmalloced) 955 if (vc->vc_kmalloced)
956 kfree(vc->vc_screenbuf); 956 kfree(vc->vc_screenbuf);
957 if (currcons >= MIN_NR_CONSOLES) 957 if (currcons >= MIN_NR_CONSOLES)
958 kfree(vc); 958 kfree(vc);
959 vc_cons[currcons].d = NULL; 959 vc_cons[currcons].d = NULL;
960 } 960 }
961 } 961 }
962 962
963 /* 963 /*
964 * VT102 emulator 964 * VT102 emulator
965 */ 965 */
966 966
967 #define set_kbd(vc, x) set_vc_kbd_mode(kbd_table + (vc)->vc_num, (x)) 967 #define set_kbd(vc, x) set_vc_kbd_mode(kbd_table + (vc)->vc_num, (x))
968 #define clr_kbd(vc, x) clr_vc_kbd_mode(kbd_table + (vc)->vc_num, (x)) 968 #define clr_kbd(vc, x) clr_vc_kbd_mode(kbd_table + (vc)->vc_num, (x))
969 #define is_kbd(vc, x) vc_kbd_mode(kbd_table + (vc)->vc_num, (x)) 969 #define is_kbd(vc, x) vc_kbd_mode(kbd_table + (vc)->vc_num, (x))
970 970
971 #define decarm VC_REPEAT 971 #define decarm VC_REPEAT
972 #define decckm VC_CKMODE 972 #define decckm VC_CKMODE
973 #define kbdapplic VC_APPLIC 973 #define kbdapplic VC_APPLIC
974 #define lnm VC_CRLF 974 #define lnm VC_CRLF
975 975
976 /* 976 /*
977 * this is what the terminal answers to a ESC-Z or csi0c query. 977 * this is what the terminal answers to a ESC-Z or csi0c query.
978 */ 978 */
979 #define VT100ID "\033[?1;2c" 979 #define VT100ID "\033[?1;2c"
980 #define VT102ID "\033[?6c" 980 #define VT102ID "\033[?6c"
981 981
982 unsigned char color_table[] = { 0, 4, 2, 6, 1, 5, 3, 7, 982 unsigned char color_table[] = { 0, 4, 2, 6, 1, 5, 3, 7,
983 8,12,10,14, 9,13,11,15 }; 983 8,12,10,14, 9,13,11,15 };
984 984
985 /* the default colour table, for VGA+ colour systems */ 985 /* the default colour table, for VGA+ colour systems */
986 int default_red[] = {0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa, 986 int default_red[] = {0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,
987 0x55,0xff,0x55,0xff,0x55,0xff,0x55,0xff}; 987 0x55,0xff,0x55,0xff,0x55,0xff,0x55,0xff};
988 int default_grn[] = {0x00,0x00,0xaa,0x55,0x00,0x00,0xaa,0xaa, 988 int default_grn[] = {0x00,0x00,0xaa,0x55,0x00,0x00,0xaa,0xaa,
989 0x55,0x55,0xff,0xff,0x55,0x55,0xff,0xff}; 989 0x55,0x55,0xff,0xff,0x55,0x55,0xff,0xff};
990 int default_blu[] = {0x00,0x00,0x00,0x00,0xaa,0xaa,0xaa,0xaa, 990 int default_blu[] = {0x00,0x00,0x00,0x00,0xaa,0xaa,0xaa,0xaa,
991 0x55,0x55,0x55,0x55,0xff,0xff,0xff,0xff}; 991 0x55,0x55,0x55,0x55,0xff,0xff,0xff,0xff};
992 992
993 module_param_array(default_red, int, NULL, S_IRUGO | S_IWUSR); 993 module_param_array(default_red, int, NULL, S_IRUGO | S_IWUSR);
994 module_param_array(default_grn, int, NULL, S_IRUGO | S_IWUSR); 994 module_param_array(default_grn, int, NULL, S_IRUGO | S_IWUSR);
995 module_param_array(default_blu, int, NULL, S_IRUGO | S_IWUSR); 995 module_param_array(default_blu, int, NULL, S_IRUGO | S_IWUSR);
996 996
997 /* 997 /*
998 * gotoxy() must verify all boundaries, because the arguments 998 * gotoxy() must verify all boundaries, because the arguments
999 * might also be negative. If the given position is out of 999 * might also be negative. If the given position is out of
1000 * bounds, the cursor is placed at the nearest margin. 1000 * bounds, the cursor is placed at the nearest margin.
1001 */ 1001 */
1002 static void gotoxy(struct vc_data *vc, int new_x, int new_y) 1002 static void gotoxy(struct vc_data *vc, int new_x, int new_y)
1003 { 1003 {
1004 int min_y, max_y; 1004 int min_y, max_y;
1005 1005
1006 if (new_x < 0) 1006 if (new_x < 0)
1007 vc->vc_x = 0; 1007 vc->vc_x = 0;
1008 else { 1008 else {
1009 if (new_x >= vc->vc_cols) 1009 if (new_x >= vc->vc_cols)
1010 vc->vc_x = vc->vc_cols - 1; 1010 vc->vc_x = vc->vc_cols - 1;
1011 else 1011 else
1012 vc->vc_x = new_x; 1012 vc->vc_x = new_x;
1013 } 1013 }
1014 1014
1015 if (vc->vc_decom) { 1015 if (vc->vc_decom) {
1016 min_y = vc->vc_top; 1016 min_y = vc->vc_top;
1017 max_y = vc->vc_bottom; 1017 max_y = vc->vc_bottom;
1018 } else { 1018 } else {
1019 min_y = 0; 1019 min_y = 0;
1020 max_y = vc->vc_rows; 1020 max_y = vc->vc_rows;
1021 } 1021 }
1022 if (new_y < min_y) 1022 if (new_y < min_y)
1023 vc->vc_y = min_y; 1023 vc->vc_y = min_y;
1024 else if (new_y >= max_y) 1024 else if (new_y >= max_y)
1025 vc->vc_y = max_y - 1; 1025 vc->vc_y = max_y - 1;
1026 else 1026 else
1027 vc->vc_y = new_y; 1027 vc->vc_y = new_y;
1028 vc->vc_pos = vc->vc_origin + vc->vc_y * vc->vc_size_row + (vc->vc_x<<1); 1028 vc->vc_pos = vc->vc_origin + vc->vc_y * vc->vc_size_row + (vc->vc_x<<1);
1029 vc->vc_need_wrap = 0; 1029 vc->vc_need_wrap = 0;
1030 } 1030 }
1031 1031
1032 /* for absolute user moves, when decom is set */ 1032 /* for absolute user moves, when decom is set */
1033 static void gotoxay(struct vc_data *vc, int new_x, int new_y) 1033 static void gotoxay(struct vc_data *vc, int new_x, int new_y)
1034 { 1034 {
1035 gotoxy(vc, new_x, vc->vc_decom ? (vc->vc_top + new_y) : new_y); 1035 gotoxy(vc, new_x, vc->vc_decom ? (vc->vc_top + new_y) : new_y);
1036 } 1036 }
1037 1037
1038 void scrollback(struct vc_data *vc, int lines) 1038 void scrollback(struct vc_data *vc, int lines)
1039 { 1039 {
1040 if (!lines) 1040 if (!lines)
1041 lines = vc->vc_rows / 2; 1041 lines = vc->vc_rows / 2;
1042 scrolldelta(-lines); 1042 scrolldelta(-lines);
1043 } 1043 }
1044 1044
1045 void scrollfront(struct vc_data *vc, int lines) 1045 void scrollfront(struct vc_data *vc, int lines)
1046 { 1046 {
1047 if (!lines) 1047 if (!lines)
1048 lines = vc->vc_rows / 2; 1048 lines = vc->vc_rows / 2;
1049 scrolldelta(lines); 1049 scrolldelta(lines);
1050 } 1050 }
1051 1051
1052 static void lf(struct vc_data *vc) 1052 static void lf(struct vc_data *vc)
1053 { 1053 {
1054 /* don't scroll if above bottom of scrolling region, or 1054 /* don't scroll if above bottom of scrolling region, or
1055 * if below scrolling region 1055 * if below scrolling region
1056 */ 1056 */
1057 if (vc->vc_y + 1 == vc->vc_bottom) 1057 if (vc->vc_y + 1 == vc->vc_bottom)
1058 scrup(vc, vc->vc_top, vc->vc_bottom, 1); 1058 scrup(vc, vc->vc_top, vc->vc_bottom, 1);
1059 else if (vc->vc_y < vc->vc_rows - 1) { 1059 else if (vc->vc_y < vc->vc_rows - 1) {
1060 vc->vc_y++; 1060 vc->vc_y++;
1061 vc->vc_pos += vc->vc_size_row; 1061 vc->vc_pos += vc->vc_size_row;
1062 } 1062 }
1063 vc->vc_need_wrap = 0; 1063 vc->vc_need_wrap = 0;
1064 notify_write(vc, '\n'); 1064 notify_write(vc, '\n');
1065 } 1065 }
1066 1066
1067 static void ri(struct vc_data *vc) 1067 static void ri(struct vc_data *vc)
1068 { 1068 {
1069 /* don't scroll if below top of scrolling region, or 1069 /* don't scroll if below top of scrolling region, or
1070 * if above scrolling region 1070 * if above scrolling region
1071 */ 1071 */
1072 if (vc->vc_y == vc->vc_top) 1072 if (vc->vc_y == vc->vc_top)
1073 scrdown(vc, vc->vc_top, vc->vc_bottom, 1); 1073 scrdown(vc, vc->vc_top, vc->vc_bottom, 1);
1074 else if (vc->vc_y > 0) { 1074 else if (vc->vc_y > 0) {
1075 vc->vc_y--; 1075 vc->vc_y--;
1076 vc->vc_pos -= vc->vc_size_row; 1076 vc->vc_pos -= vc->vc_size_row;
1077 } 1077 }
1078 vc->vc_need_wrap = 0; 1078 vc->vc_need_wrap = 0;
1079 } 1079 }
1080 1080
1081 static inline void cr(struct vc_data *vc) 1081 static inline void cr(struct vc_data *vc)
1082 { 1082 {
1083 vc->vc_pos -= vc->vc_x << 1; 1083 vc->vc_pos -= vc->vc_x << 1;
1084 vc->vc_need_wrap = vc->vc_x = 0; 1084 vc->vc_need_wrap = vc->vc_x = 0;
1085 notify_write(vc, '\r'); 1085 notify_write(vc, '\r');
1086 } 1086 }
1087 1087
1088 static inline void bs(struct vc_data *vc) 1088 static inline void bs(struct vc_data *vc)
1089 { 1089 {
1090 if (vc->vc_x) { 1090 if (vc->vc_x) {
1091 vc->vc_pos -= 2; 1091 vc->vc_pos -= 2;
1092 vc->vc_x--; 1092 vc->vc_x--;
1093 vc->vc_need_wrap = 0; 1093 vc->vc_need_wrap = 0;
1094 notify_write(vc, '\b'); 1094 notify_write(vc, '\b');
1095 } 1095 }
1096 } 1096 }
1097 1097
1098 static inline void del(struct vc_data *vc) 1098 static inline void del(struct vc_data *vc)
1099 { 1099 {
1100 /* ignored */ 1100 /* ignored */
1101 } 1101 }
1102 1102
1103 static void csi_J(struct vc_data *vc, int vpar) 1103 static void csi_J(struct vc_data *vc, int vpar)
1104 { 1104 {
1105 unsigned int count; 1105 unsigned int count;
1106 unsigned short * start; 1106 unsigned short * start;
1107 1107
1108 switch (vpar) { 1108 switch (vpar) {
1109 case 0: /* erase from cursor to end of display */ 1109 case 0: /* erase from cursor to end of display */
1110 count = (vc->vc_scr_end - vc->vc_pos) >> 1; 1110 count = (vc->vc_scr_end - vc->vc_pos) >> 1;
1111 start = (unsigned short *)vc->vc_pos; 1111 start = (unsigned short *)vc->vc_pos;
1112 if (DO_UPDATE(vc)) { 1112 if (DO_UPDATE(vc)) {
1113 /* do in two stages */ 1113 /* do in two stages */
1114 vc->vc_sw->con_clear(vc, vc->vc_y, vc->vc_x, 1, 1114 vc->vc_sw->con_clear(vc, vc->vc_y, vc->vc_x, 1,
1115 vc->vc_cols - vc->vc_x); 1115 vc->vc_cols - vc->vc_x);
1116 vc->vc_sw->con_clear(vc, vc->vc_y + 1, 0, 1116 vc->vc_sw->con_clear(vc, vc->vc_y + 1, 0,
1117 vc->vc_rows - vc->vc_y - 1, 1117 vc->vc_rows - vc->vc_y - 1,
1118 vc->vc_cols); 1118 vc->vc_cols);
1119 } 1119 }
1120 break; 1120 break;
1121 case 1: /* erase from start to cursor */ 1121 case 1: /* erase from start to cursor */
1122 count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1; 1122 count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1;
1123 start = (unsigned short *)vc->vc_origin; 1123 start = (unsigned short *)vc->vc_origin;
1124 if (DO_UPDATE(vc)) { 1124 if (DO_UPDATE(vc)) {
1125 /* do in two stages */ 1125 /* do in two stages */
1126 vc->vc_sw->con_clear(vc, 0, 0, vc->vc_y, 1126 vc->vc_sw->con_clear(vc, 0, 0, vc->vc_y,
1127 vc->vc_cols); 1127 vc->vc_cols);
1128 vc->vc_sw->con_clear(vc, vc->vc_y, 0, 1, 1128 vc->vc_sw->con_clear(vc, vc->vc_y, 0, 1,
1129 vc->vc_x + 1); 1129 vc->vc_x + 1);
1130 } 1130 }
1131 break; 1131 break;
1132 case 2: /* erase whole display */ 1132 case 2: /* erase whole display */
1133 count = vc->vc_cols * vc->vc_rows; 1133 count = vc->vc_cols * vc->vc_rows;
1134 start = (unsigned short *)vc->vc_origin; 1134 start = (unsigned short *)vc->vc_origin;
1135 if (DO_UPDATE(vc)) 1135 if (DO_UPDATE(vc))
1136 vc->vc_sw->con_clear(vc, 0, 0, 1136 vc->vc_sw->con_clear(vc, 0, 0,
1137 vc->vc_rows, 1137 vc->vc_rows,
1138 vc->vc_cols); 1138 vc->vc_cols);
1139 break; 1139 break;
1140 default: 1140 default:
1141 return; 1141 return;
1142 } 1142 }
1143 scr_memsetw(start, vc->vc_video_erase_char, 2 * count); 1143 scr_memsetw(start, vc->vc_video_erase_char, 2 * count);
1144 vc->vc_need_wrap = 0; 1144 vc->vc_need_wrap = 0;
1145 } 1145 }
1146 1146
1147 static void csi_K(struct vc_data *vc, int vpar) 1147 static void csi_K(struct vc_data *vc, int vpar)
1148 { 1148 {
1149 unsigned int count; 1149 unsigned int count;
1150 unsigned short * start; 1150 unsigned short * start;
1151 1151
1152 switch (vpar) { 1152 switch (vpar) {
1153 case 0: /* erase from cursor to end of line */ 1153 case 0: /* erase from cursor to end of line */
1154 count = vc->vc_cols - vc->vc_x; 1154 count = vc->vc_cols - vc->vc_x;
1155 start = (unsigned short *)vc->vc_pos; 1155 start = (unsigned short *)vc->vc_pos;
1156 if (DO_UPDATE(vc)) 1156 if (DO_UPDATE(vc))
1157 vc->vc_sw->con_clear(vc, vc->vc_y, vc->vc_x, 1, 1157 vc->vc_sw->con_clear(vc, vc->vc_y, vc->vc_x, 1,
1158 vc->vc_cols - vc->vc_x); 1158 vc->vc_cols - vc->vc_x);
1159 break; 1159 break;
1160 case 1: /* erase from start of line to cursor */ 1160 case 1: /* erase from start of line to cursor */
1161 start = (unsigned short *)(vc->vc_pos - (vc->vc_x << 1)); 1161 start = (unsigned short *)(vc->vc_pos - (vc->vc_x << 1));
1162 count = vc->vc_x + 1; 1162 count = vc->vc_x + 1;
1163 if (DO_UPDATE(vc)) 1163 if (DO_UPDATE(vc))
1164 vc->vc_sw->con_clear(vc, vc->vc_y, 0, 1, 1164 vc->vc_sw->con_clear(vc, vc->vc_y, 0, 1,
1165 vc->vc_x + 1); 1165 vc->vc_x + 1);
1166 break; 1166 break;
1167 case 2: /* erase whole line */ 1167 case 2: /* erase whole line */
1168 start = (unsigned short *)(vc->vc_pos - (vc->vc_x << 1)); 1168 start = (unsigned short *)(vc->vc_pos - (vc->vc_x << 1));
1169 count = vc->vc_cols; 1169 count = vc->vc_cols;
1170 if (DO_UPDATE(vc)) 1170 if (DO_UPDATE(vc))
1171 vc->vc_sw->con_clear(vc, vc->vc_y, 0, 1, 1171 vc->vc_sw->con_clear(vc, vc->vc_y, 0, 1,
1172 vc->vc_cols); 1172 vc->vc_cols);
1173 break; 1173 break;
1174 default: 1174 default:
1175 return; 1175 return;
1176 } 1176 }
1177 scr_memsetw(start, vc->vc_video_erase_char, 2 * count); 1177 scr_memsetw(start, vc->vc_video_erase_char, 2 * count);
1178 vc->vc_need_wrap = 0; 1178 vc->vc_need_wrap = 0;
1179 } 1179 }
1180 1180
1181 static void csi_X(struct vc_data *vc, int vpar) /* erase the following vpar positions */ 1181 static void csi_X(struct vc_data *vc, int vpar) /* erase the following vpar positions */
1182 { /* not vt100? */ 1182 { /* not vt100? */
1183 int count; 1183 int count;
1184 1184
1185 if (!vpar) 1185 if (!vpar)
1186 vpar++; 1186 vpar++;
1187 count = (vpar > vc->vc_cols - vc->vc_x) ? (vc->vc_cols - vc->vc_x) : vpar; 1187 count = (vpar > vc->vc_cols - vc->vc_x) ? (vc->vc_cols - vc->vc_x) : vpar;
1188 1188
1189 scr_memsetw((unsigned short *)vc->vc_pos, vc->vc_video_erase_char, 2 * count); 1189 scr_memsetw((unsigned short *)vc->vc_pos, vc->vc_video_erase_char, 2 * count);
1190 if (DO_UPDATE(vc)) 1190 if (DO_UPDATE(vc))
1191 vc->vc_sw->con_clear(vc, vc->vc_y, vc->vc_x, 1, count); 1191 vc->vc_sw->con_clear(vc, vc->vc_y, vc->vc_x, 1, count);
1192 vc->vc_need_wrap = 0; 1192 vc->vc_need_wrap = 0;
1193 } 1193 }
1194 1194
1195 static void default_attr(struct vc_data *vc) 1195 static void default_attr(struct vc_data *vc)
1196 { 1196 {
1197 vc->vc_intensity = 1; 1197 vc->vc_intensity = 1;
1198 vc->vc_italic = 0; 1198 vc->vc_italic = 0;
1199 vc->vc_underline = 0; 1199 vc->vc_underline = 0;
1200 vc->vc_reverse = 0; 1200 vc->vc_reverse = 0;
1201 vc->vc_blink = 0; 1201 vc->vc_blink = 0;
1202 vc->vc_color = vc->vc_def_color; 1202 vc->vc_color = vc->vc_def_color;
1203 } 1203 }
1204 1204
1205 /* console_sem is held */ 1205 /* console_sem is held */
1206 static void csi_m(struct vc_data *vc) 1206 static void csi_m(struct vc_data *vc)
1207 { 1207 {
1208 int i; 1208 int i;
1209 1209
1210 for (i = 0; i <= vc->vc_npar; i++) 1210 for (i = 0; i <= vc->vc_npar; i++)
1211 switch (vc->vc_par[i]) { 1211 switch (vc->vc_par[i]) {
1212 case 0: /* all attributes off */ 1212 case 0: /* all attributes off */
1213 default_attr(vc); 1213 default_attr(vc);
1214 break; 1214 break;
1215 case 1: 1215 case 1:
1216 vc->vc_intensity = 2; 1216 vc->vc_intensity = 2;
1217 break; 1217 break;
1218 case 2: 1218 case 2:
1219 vc->vc_intensity = 0; 1219 vc->vc_intensity = 0;
1220 break; 1220 break;
1221 case 3: 1221 case 3:
1222 vc->vc_italic = 1; 1222 vc->vc_italic = 1;
1223 break; 1223 break;
1224 case 4: 1224 case 4:
1225 vc->vc_underline = 1; 1225 vc->vc_underline = 1;
1226 break; 1226 break;
1227 case 5: 1227 case 5:
1228 vc->vc_blink = 1; 1228 vc->vc_blink = 1;
1229 break; 1229 break;
1230 case 7: 1230 case 7:
1231 vc->vc_reverse = 1; 1231 vc->vc_reverse = 1;
1232 break; 1232 break;
1233 case 10: /* ANSI X3.64-1979 (SCO-ish?) 1233 case 10: /* ANSI X3.64-1979 (SCO-ish?)
1234 * Select primary font, don't display 1234 * Select primary font, don't display
1235 * control chars if defined, don't set 1235 * control chars if defined, don't set
1236 * bit 8 on output. 1236 * bit 8 on output.
1237 */ 1237 */
1238 vc->vc_translate = set_translate(vc->vc_charset == 0 1238 vc->vc_translate = set_translate(vc->vc_charset == 0
1239 ? vc->vc_G0_charset 1239 ? vc->vc_G0_charset
1240 : vc->vc_G1_charset, vc); 1240 : vc->vc_G1_charset, vc);
1241 vc->vc_disp_ctrl = 0; 1241 vc->vc_disp_ctrl = 0;
1242 vc->vc_toggle_meta = 0; 1242 vc->vc_toggle_meta = 0;
1243 break; 1243 break;
1244 case 11: /* ANSI X3.64-1979 (SCO-ish?) 1244 case 11: /* ANSI X3.64-1979 (SCO-ish?)
1245 * Select first alternate font, lets 1245 * Select first alternate font, lets
1246 * chars < 32 be displayed as ROM chars. 1246 * chars < 32 be displayed as ROM chars.
1247 */ 1247 */
1248 vc->vc_translate = set_translate(IBMPC_MAP, vc); 1248 vc->vc_translate = set_translate(IBMPC_MAP, vc);
1249 vc->vc_disp_ctrl = 1; 1249 vc->vc_disp_ctrl = 1;
1250 vc->vc_toggle_meta = 0; 1250 vc->vc_toggle_meta = 0;
1251 break; 1251 break;
1252 case 12: /* ANSI X3.64-1979 (SCO-ish?) 1252 case 12: /* ANSI X3.64-1979 (SCO-ish?)
1253 * Select second alternate font, toggle 1253 * Select second alternate font, toggle
1254 * high bit before displaying as ROM char. 1254 * high bit before displaying as ROM char.
1255 */ 1255 */
1256 vc->vc_translate = set_translate(IBMPC_MAP, vc); 1256 vc->vc_translate = set_translate(IBMPC_MAP, vc);
1257 vc->vc_disp_ctrl = 1; 1257 vc->vc_disp_ctrl = 1;
1258 vc->vc_toggle_meta = 1; 1258 vc->vc_toggle_meta = 1;
1259 break; 1259 break;
1260 case 21: 1260 case 21:
1261 case 22: 1261 case 22:
1262 vc->vc_intensity = 1; 1262 vc->vc_intensity = 1;
1263 break; 1263 break;
1264 case 23: 1264 case 23:
1265 vc->vc_italic = 0; 1265 vc->vc_italic = 0;
1266 break; 1266 break;
1267 case 24: 1267 case 24:
1268 vc->vc_underline = 0; 1268 vc->vc_underline = 0;
1269 break; 1269 break;
1270 case 25: 1270 case 25:
1271 vc->vc_blink = 0; 1271 vc->vc_blink = 0;
1272 break; 1272 break;
1273 case 27: 1273 case 27:
1274 vc->vc_reverse = 0; 1274 vc->vc_reverse = 0;
1275 break; 1275 break;
1276 case 38: /* ANSI X3.64-1979 (SCO-ish?) 1276 case 38: /* ANSI X3.64-1979 (SCO-ish?)
1277 * Enables underscore, white foreground 1277 * Enables underscore, white foreground
1278 * with white underscore (Linux - use 1278 * with white underscore (Linux - use
1279 * default foreground). 1279 * default foreground).
1280 */ 1280 */
1281 vc->vc_color = (vc->vc_def_color & 0x0f) | (vc->vc_color & 0xf0); 1281 vc->vc_color = (vc->vc_def_color & 0x0f) | (vc->vc_color & 0xf0);
1282 vc->vc_underline = 1; 1282 vc->vc_underline = 1;
1283 break; 1283 break;
1284 case 39: /* ANSI X3.64-1979 (SCO-ish?) 1284 case 39: /* ANSI X3.64-1979 (SCO-ish?)
1285 * Disable underline option. 1285 * Disable underline option.
1286 * Reset colour to default? It did this 1286 * Reset colour to default? It did this
1287 * before... 1287 * before...
1288 */ 1288 */
1289 vc->vc_color = (vc->vc_def_color & 0x0f) | (vc->vc_color & 0xf0); 1289 vc->vc_color = (vc->vc_def_color & 0x0f) | (vc->vc_color & 0xf0);
1290 vc->vc_underline = 0; 1290 vc->vc_underline = 0;
1291 break; 1291 break;
1292 case 49: 1292 case 49:
1293 vc->vc_color = (vc->vc_def_color & 0xf0) | (vc->vc_color & 0x0f); 1293 vc->vc_color = (vc->vc_def_color & 0xf0) | (vc->vc_color & 0x0f);
1294 break; 1294 break;
1295 default: 1295 default:
1296 if (vc->vc_par[i] >= 30 && vc->vc_par[i] <= 37) 1296 if (vc->vc_par[i] >= 30 && vc->vc_par[i] <= 37)
1297 vc->vc_color = color_table[vc->vc_par[i] - 30] 1297 vc->vc_color = color_table[vc->vc_par[i] - 30]
1298 | (vc->vc_color & 0xf0); 1298 | (vc->vc_color & 0xf0);
1299 else if (vc->vc_par[i] >= 40 && vc->vc_par[i] <= 47) 1299 else if (vc->vc_par[i] >= 40 && vc->vc_par[i] <= 47)
1300 vc->vc_color = (color_table[vc->vc_par[i] - 40] << 4) 1300 vc->vc_color = (color_table[vc->vc_par[i] - 40] << 4)
1301 | (vc->vc_color & 0x0f); 1301 | (vc->vc_color & 0x0f);
1302 break; 1302 break;
1303 } 1303 }
1304 update_attr(vc); 1304 update_attr(vc);
1305 } 1305 }
1306 1306
1307 static void respond_string(const char *p, struct tty_struct *tty) 1307 static void respond_string(const char *p, struct tty_struct *tty)
1308 { 1308 {
1309 while (*p) { 1309 while (*p) {
1310 tty_insert_flip_char(tty, *p, 0); 1310 tty_insert_flip_char(tty, *p, 0);
1311 p++; 1311 p++;
1312 } 1312 }
1313 con_schedule_flip(tty); 1313 con_schedule_flip(tty);
1314 } 1314 }
1315 1315
1316 static void cursor_report(struct vc_data *vc, struct tty_struct *tty) 1316 static void cursor_report(struct vc_data *vc, struct tty_struct *tty)
1317 { 1317 {
1318 char buf[40]; 1318 char buf[40];
1319 1319
1320 sprintf(buf, "\033[%d;%dR", vc->vc_y + (vc->vc_decom ? vc->vc_top + 1 : 1), vc->vc_x + 1); 1320 sprintf(buf, "\033[%d;%dR", vc->vc_y + (vc->vc_decom ? vc->vc_top + 1 : 1), vc->vc_x + 1);
1321 respond_string(buf, tty); 1321 respond_string(buf, tty);
1322 } 1322 }
1323 1323
1324 static inline void status_report(struct tty_struct *tty) 1324 static inline void status_report(struct tty_struct *tty)
1325 { 1325 {
1326 respond_string("\033[0n", tty); /* Terminal ok */ 1326 respond_string("\033[0n", tty); /* Terminal ok */
1327 } 1327 }
1328 1328
1329 static inline void respond_ID(struct tty_struct * tty) 1329 static inline void respond_ID(struct tty_struct * tty)
1330 { 1330 {
1331 respond_string(VT102ID, tty); 1331 respond_string(VT102ID, tty);
1332 } 1332 }
1333 1333
1334 void mouse_report(struct tty_struct *tty, int butt, int mrx, int mry) 1334 void mouse_report(struct tty_struct *tty, int butt, int mrx, int mry)
1335 { 1335 {
1336 char buf[8]; 1336 char buf[8];
1337 1337
1338 sprintf(buf, "\033[M%c%c%c", (char)(' ' + butt), (char)('!' + mrx), 1338 sprintf(buf, "\033[M%c%c%c", (char)(' ' + butt), (char)('!' + mrx),
1339 (char)('!' + mry)); 1339 (char)('!' + mry));
1340 respond_string(buf, tty); 1340 respond_string(buf, tty);
1341 } 1341 }
1342 1342
1343 /* invoked via ioctl(TIOCLINUX) and through set_selection */ 1343 /* invoked via ioctl(TIOCLINUX) and through set_selection */
1344 int mouse_reporting(void) 1344 int mouse_reporting(void)
1345 { 1345 {
1346 return vc_cons[fg_console].d->vc_report_mouse; 1346 return vc_cons[fg_console].d->vc_report_mouse;
1347 } 1347 }
1348 1348
1349 /* console_sem is held */ 1349 /* console_sem is held */
1350 static void set_mode(struct vc_data *vc, int on_off) 1350 static void set_mode(struct vc_data *vc, int on_off)
1351 { 1351 {
1352 int i; 1352 int i;
1353 1353
1354 for (i = 0; i <= vc->vc_npar; i++) 1354 for (i = 0; i <= vc->vc_npar; i++)
1355 if (vc->vc_ques) { 1355 if (vc->vc_ques) {
1356 switch(vc->vc_par[i]) { /* DEC private modes set/reset */ 1356 switch(vc->vc_par[i]) { /* DEC private modes set/reset */
1357 case 1: /* Cursor keys send ^[Ox/^[[x */ 1357 case 1: /* Cursor keys send ^[Ox/^[[x */
1358 if (on_off) 1358 if (on_off)
1359 set_kbd(vc, decckm); 1359 set_kbd(vc, decckm);
1360 else 1360 else
1361 clr_kbd(vc, decckm); 1361 clr_kbd(vc, decckm);
1362 break; 1362 break;
1363 case 3: /* 80/132 mode switch unimplemented */ 1363 case 3: /* 80/132 mode switch unimplemented */
1364 vc->vc_deccolm = on_off; 1364 vc->vc_deccolm = on_off;
1365 #if 0 1365 #if 0
1366 vc_resize(deccolm ? 132 : 80, vc->vc_rows); 1366 vc_resize(deccolm ? 132 : 80, vc->vc_rows);
1367 /* this alone does not suffice; some user mode 1367 /* this alone does not suffice; some user mode
1368 utility has to change the hardware regs */ 1368 utility has to change the hardware regs */
1369 #endif 1369 #endif
1370 break; 1370 break;
1371 case 5: /* Inverted screen on/off */ 1371 case 5: /* Inverted screen on/off */
1372 if (vc->vc_decscnm != on_off) { 1372 if (vc->vc_decscnm != on_off) {
1373 vc->vc_decscnm = on_off; 1373 vc->vc_decscnm = on_off;
1374 invert_screen(vc, 0, vc->vc_screenbuf_size, 0); 1374 invert_screen(vc, 0, vc->vc_screenbuf_size, 0);
1375 update_attr(vc); 1375 update_attr(vc);
1376 } 1376 }
1377 break; 1377 break;
1378 case 6: /* Origin relative/absolute */ 1378 case 6: /* Origin relative/absolute */
1379 vc->vc_decom = on_off; 1379 vc->vc_decom = on_off;
1380 gotoxay(vc, 0, 0); 1380 gotoxay(vc, 0, 0);
1381 break; 1381 break;
1382 case 7: /* Autowrap on/off */ 1382 case 7: /* Autowrap on/off */
1383 vc->vc_decawm = on_off; 1383 vc->vc_decawm = on_off;
1384 break; 1384 break;
1385 case 8: /* Autorepeat on/off */ 1385 case 8: /* Autorepeat on/off */
1386 if (on_off) 1386 if (on_off)
1387 set_kbd(vc, decarm); 1387 set_kbd(vc, decarm);
1388 else 1388 else
1389 clr_kbd(vc, decarm); 1389 clr_kbd(vc, decarm);
1390 break; 1390 break;
1391 case 9: 1391 case 9:
1392 vc->vc_report_mouse = on_off ? 1 : 0; 1392 vc->vc_report_mouse = on_off ? 1 : 0;
1393 break; 1393 break;
1394 case 25: /* Cursor on/off */ 1394 case 25: /* Cursor on/off */
1395 vc->vc_deccm = on_off; 1395 vc->vc_deccm = on_off;
1396 break; 1396 break;
1397 case 1000: 1397 case 1000:
1398 vc->vc_report_mouse = on_off ? 2 : 0; 1398 vc->vc_report_mouse = on_off ? 2 : 0;
1399 break; 1399 break;
1400 } 1400 }
1401 } else { 1401 } else {
1402 switch(vc->vc_par[i]) { /* ANSI modes set/reset */ 1402 switch(vc->vc_par[i]) { /* ANSI modes set/reset */
1403 case 3: /* Monitor (display ctrls) */ 1403 case 3: /* Monitor (display ctrls) */
1404 vc->vc_disp_ctrl = on_off; 1404 vc->vc_disp_ctrl = on_off;
1405 break; 1405 break;
1406 case 4: /* Insert Mode on/off */ 1406 case 4: /* Insert Mode on/off */
1407 vc->vc_decim = on_off; 1407 vc->vc_decim = on_off;
1408 break; 1408 break;
1409 case 20: /* Lf, Enter == CrLf/Lf */ 1409 case 20: /* Lf, Enter == CrLf/Lf */
1410 if (on_off) 1410 if (on_off)
1411 set_kbd(vc, lnm); 1411 set_kbd(vc, lnm);
1412 else 1412 else
1413 clr_kbd(vc, lnm); 1413 clr_kbd(vc, lnm);
1414 break; 1414 break;
1415 } 1415 }
1416 } 1416 }
1417 } 1417 }
1418 1418
1419 /* console_sem is held */ 1419 /* console_sem is held */
1420 static void setterm_command(struct vc_data *vc) 1420 static void setterm_command(struct vc_data *vc)
1421 { 1421 {
1422 switch(vc->vc_par[0]) { 1422 switch(vc->vc_par[0]) {
1423 case 1: /* set color for underline mode */ 1423 case 1: /* set color for underline mode */
1424 if (vc->vc_can_do_color && 1424 if (vc->vc_can_do_color &&
1425 vc->vc_par[1] < 16) { 1425 vc->vc_par[1] < 16) {
1426 vc->vc_ulcolor = color_table[vc->vc_par[1]]; 1426 vc->vc_ulcolor = color_table[vc->vc_par[1]];
1427 if (vc->vc_underline) 1427 if (vc->vc_underline)
1428 update_attr(vc); 1428 update_attr(vc);
1429 } 1429 }
1430 break; 1430 break;
1431 case 2: /* set color for half intensity mode */ 1431 case 2: /* set color for half intensity mode */
1432 if (vc->vc_can_do_color && 1432 if (vc->vc_can_do_color &&
1433 vc->vc_par[1] < 16) { 1433 vc->vc_par[1] < 16) {
1434 vc->vc_halfcolor = color_table[vc->vc_par[1]]; 1434 vc->vc_halfcolor = color_table[vc->vc_par[1]];
1435 if (vc->vc_intensity == 0) 1435 if (vc->vc_intensity == 0)
1436 update_attr(vc); 1436 update_attr(vc);
1437 } 1437 }
1438 break; 1438 break;
1439 case 8: /* store colors as defaults */ 1439 case 8: /* store colors as defaults */
1440 vc->vc_def_color = vc->vc_attr; 1440 vc->vc_def_color = vc->vc_attr;
1441 if (vc->vc_hi_font_mask == 0x100) 1441 if (vc->vc_hi_font_mask == 0x100)
1442 vc->vc_def_color >>= 1; 1442 vc->vc_def_color >>= 1;
1443 default_attr(vc); 1443 default_attr(vc);
1444 update_attr(vc); 1444 update_attr(vc);
1445 break; 1445 break;
1446 case 9: /* set blanking interval */ 1446 case 9: /* set blanking interval */
1447 blankinterval = ((vc->vc_par[1] < 60) ? vc->vc_par[1] : 60) * 60 * HZ; 1447 blankinterval = ((vc->vc_par[1] < 60) ? vc->vc_par[1] : 60) * 60 * HZ;
1448 poke_blanked_console(); 1448 poke_blanked_console();
1449 break; 1449 break;
1450 case 10: /* set bell frequency in Hz */ 1450 case 10: /* set bell frequency in Hz */
1451 if (vc->vc_npar >= 1) 1451 if (vc->vc_npar >= 1)
1452 vc->vc_bell_pitch = vc->vc_par[1]; 1452 vc->vc_bell_pitch = vc->vc_par[1];
1453 else 1453 else
1454 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; 1454 vc->vc_bell_pitch = DEFAULT_BELL_PITCH;
1455 break; 1455 break;
1456 case 11: /* set bell duration in msec */ 1456 case 11: /* set bell duration in msec */
1457 if (vc->vc_npar >= 1) 1457 if (vc->vc_npar >= 1)
1458 vc->vc_bell_duration = (vc->vc_par[1] < 2000) ? 1458 vc->vc_bell_duration = (vc->vc_par[1] < 2000) ?
1459 vc->vc_par[1] * HZ / 1000 : 0; 1459 vc->vc_par[1] * HZ / 1000 : 0;
1460 else 1460 else
1461 vc->vc_bell_duration = DEFAULT_BELL_DURATION; 1461 vc->vc_bell_duration = DEFAULT_BELL_DURATION;
1462 break; 1462 break;
1463 case 12: /* bring specified console to the front */ 1463 case 12: /* bring specified console to the front */
1464 if (vc->vc_par[1] >= 1 && vc_cons_allocated(vc->vc_par[1] - 1)) 1464 if (vc->vc_par[1] >= 1 && vc_cons_allocated(vc->vc_par[1] - 1))
1465 set_console(vc->vc_par[1] - 1); 1465 set_console(vc->vc_par[1] - 1);
1466 break; 1466 break;
1467 case 13: /* unblank the screen */ 1467 case 13: /* unblank the screen */
1468 poke_blanked_console(); 1468 poke_blanked_console();
1469 break; 1469 break;
1470 case 14: /* set vesa powerdown interval */ 1470 case 14: /* set vesa powerdown interval */
1471 vesa_off_interval = ((vc->vc_par[1] < 60) ? vc->vc_par[1] : 60) * 60 * HZ; 1471 vesa_off_interval = ((vc->vc_par[1] < 60) ? vc->vc_par[1] : 60) * 60 * HZ;
1472 break; 1472 break;
1473 case 15: /* activate the previous console */ 1473 case 15: /* activate the previous console */
1474 set_console(last_console); 1474 set_console(last_console);
1475 break; 1475 break;
1476 } 1476 }
1477 } 1477 }
1478 1478
1479 /* console_sem is held */ 1479 /* console_sem is held */
1480 static void csi_at(struct vc_data *vc, unsigned int nr) 1480 static void csi_at(struct vc_data *vc, unsigned int nr)
1481 { 1481 {
1482 if (nr > vc->vc_cols - vc->vc_x) 1482 if (nr > vc->vc_cols - vc->vc_x)
1483 nr = vc->vc_cols - vc->vc_x; 1483 nr = vc->vc_cols - vc->vc_x;
1484 else if (!nr) 1484 else if (!nr)
1485 nr = 1; 1485 nr = 1;
1486 insert_char(vc, nr); 1486 insert_char(vc, nr);
1487 } 1487 }
1488 1488
1489 /* console_sem is held */ 1489 /* console_sem is held */
1490 static void csi_L(struct vc_data *vc, unsigned int nr) 1490 static void csi_L(struct vc_data *vc, unsigned int nr)
1491 { 1491 {
1492 if (nr > vc->vc_rows - vc->vc_y) 1492 if (nr > vc->vc_rows - vc->vc_y)
1493 nr = vc->vc_rows - vc->vc_y; 1493 nr = vc->vc_rows - vc->vc_y;
1494 else if (!nr) 1494 else if (!nr)
1495 nr = 1; 1495 nr = 1;
1496 scrdown(vc, vc->vc_y, vc->vc_bottom, nr); 1496 scrdown(vc, vc->vc_y, vc->vc_bottom, nr);
1497 vc->vc_need_wrap = 0; 1497 vc->vc_need_wrap = 0;
1498 } 1498 }
1499 1499
1500 /* console_sem is held */ 1500 /* console_sem is held */
1501 static void csi_P(struct vc_data *vc, unsigned int nr) 1501 static void csi_P(struct vc_data *vc, unsigned int nr)
1502 { 1502 {
1503 if (nr > vc->vc_cols - vc->vc_x) 1503 if (nr > vc->vc_cols - vc->vc_x)
1504 nr = vc->vc_cols - vc->vc_x; 1504 nr = vc->vc_cols - vc->vc_x;
1505 else if (!nr) 1505 else if (!nr)
1506 nr = 1; 1506 nr = 1;
1507 delete_char(vc, nr); 1507 delete_char(vc, nr);
1508 } 1508 }
1509 1509
1510 /* console_sem is held */ 1510 /* console_sem is held */
1511 static void csi_M(struct vc_data *vc, unsigned int nr) 1511 static void csi_M(struct vc_data *vc, unsigned int nr)
1512 { 1512 {
1513 if (nr > vc->vc_rows - vc->vc_y) 1513 if (nr > vc->vc_rows - vc->vc_y)
1514 nr = vc->vc_rows - vc->vc_y; 1514 nr = vc->vc_rows - vc->vc_y;
1515 else if (!nr) 1515 else if (!nr)
1516 nr=1; 1516 nr=1;
1517 scrup(vc, vc->vc_y, vc->vc_bottom, nr); 1517 scrup(vc, vc->vc_y, vc->vc_bottom, nr);
1518 vc->vc_need_wrap = 0; 1518 vc->vc_need_wrap = 0;
1519 } 1519 }
1520 1520
1521 /* console_sem is held (except via vc_init->reset_terminal */ 1521 /* console_sem is held (except via vc_init->reset_terminal */
1522 static void save_cur(struct vc_data *vc) 1522 static void save_cur(struct vc_data *vc)
1523 { 1523 {
1524 vc->vc_saved_x = vc->vc_x; 1524 vc->vc_saved_x = vc->vc_x;
1525 vc->vc_saved_y = vc->vc_y; 1525 vc->vc_saved_y = vc->vc_y;
1526 vc->vc_s_intensity = vc->vc_intensity; 1526 vc->vc_s_intensity = vc->vc_intensity;
1527 vc->vc_s_italic = vc->vc_italic; 1527 vc->vc_s_italic = vc->vc_italic;
1528 vc->vc_s_underline = vc->vc_underline; 1528 vc->vc_s_underline = vc->vc_underline;
1529 vc->vc_s_blink = vc->vc_blink; 1529 vc->vc_s_blink = vc->vc_blink;
1530 vc->vc_s_reverse = vc->vc_reverse; 1530 vc->vc_s_reverse = vc->vc_reverse;
1531 vc->vc_s_charset = vc->vc_charset; 1531 vc->vc_s_charset = vc->vc_charset;
1532 vc->vc_s_color = vc->vc_color; 1532 vc->vc_s_color = vc->vc_color;
1533 vc->vc_saved_G0 = vc->vc_G0_charset; 1533 vc->vc_saved_G0 = vc->vc_G0_charset;
1534 vc->vc_saved_G1 = vc->vc_G1_charset; 1534 vc->vc_saved_G1 = vc->vc_G1_charset;
1535 } 1535 }
1536 1536
1537 /* console_sem is held */ 1537 /* console_sem is held */
1538 static void restore_cur(struct vc_data *vc) 1538 static void restore_cur(struct vc_data *vc)
1539 { 1539 {
1540 gotoxy(vc, vc->vc_saved_x, vc->vc_saved_y); 1540 gotoxy(vc, vc->vc_saved_x, vc->vc_saved_y);
1541 vc->vc_intensity = vc->vc_s_intensity; 1541 vc->vc_intensity = vc->vc_s_intensity;
1542 vc->vc_italic = vc->vc_s_italic; 1542 vc->vc_italic = vc->vc_s_italic;
1543 vc->vc_underline = vc->vc_s_underline; 1543 vc->vc_underline = vc->vc_s_underline;
1544 vc->vc_blink = vc->vc_s_blink; 1544 vc->vc_blink = vc->vc_s_blink;
1545 vc->vc_reverse = vc->vc_s_reverse; 1545 vc->vc_reverse = vc->vc_s_reverse;
1546 vc->vc_charset = vc->vc_s_charset; 1546 vc->vc_charset = vc->vc_s_charset;
1547 vc->vc_color = vc->vc_s_color; 1547 vc->vc_color = vc->vc_s_color;
1548 vc->vc_G0_charset = vc->vc_saved_G0; 1548 vc->vc_G0_charset = vc->vc_saved_G0;
1549 vc->vc_G1_charset = vc->vc_saved_G1; 1549 vc->vc_G1_charset = vc->vc_saved_G1;
1550 vc->vc_translate = set_translate(vc->vc_charset ? vc->vc_G1_charset : vc->vc_G0_charset, vc); 1550 vc->vc_translate = set_translate(vc->vc_charset ? vc->vc_G1_charset : vc->vc_G0_charset, vc);
1551 update_attr(vc); 1551 update_attr(vc);
1552 vc->vc_need_wrap = 0; 1552 vc->vc_need_wrap = 0;
1553 } 1553 }
1554 1554
1555 enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey, 1555 enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey,
1556 EShash, ESsetG0, ESsetG1, ESpercent, ESignore, ESnonstd, 1556 EShash, ESsetG0, ESsetG1, ESpercent, ESignore, ESnonstd,
1557 ESpalette }; 1557 ESpalette };
1558 1558
1559 /* console_sem is held (except via vc_init()) */ 1559 /* console_sem is held (except via vc_init()) */
1560 static void reset_terminal(struct vc_data *vc, int do_clear) 1560 static void reset_terminal(struct vc_data *vc, int do_clear)
1561 { 1561 {
1562 vc->vc_top = 0; 1562 vc->vc_top = 0;
1563 vc->vc_bottom = vc->vc_rows; 1563 vc->vc_bottom = vc->vc_rows;
1564 vc->vc_state = ESnormal; 1564 vc->vc_state = ESnormal;
1565 vc->vc_ques = 0; 1565 vc->vc_ques = 0;
1566 vc->vc_translate = set_translate(LAT1_MAP, vc); 1566 vc->vc_translate = set_translate(LAT1_MAP, vc);
1567 vc->vc_G0_charset = LAT1_MAP; 1567 vc->vc_G0_charset = LAT1_MAP;
1568 vc->vc_G1_charset = GRAF_MAP; 1568 vc->vc_G1_charset = GRAF_MAP;
1569 vc->vc_charset = 0; 1569 vc->vc_charset = 0;
1570 vc->vc_need_wrap = 0; 1570 vc->vc_need_wrap = 0;
1571 vc->vc_report_mouse = 0; 1571 vc->vc_report_mouse = 0;
1572 vc->vc_utf = default_utf8; 1572 vc->vc_utf = default_utf8;
1573 vc->vc_utf_count = 0; 1573 vc->vc_utf_count = 0;
1574 1574
1575 vc->vc_disp_ctrl = 0; 1575 vc->vc_disp_ctrl = 0;
1576 vc->vc_toggle_meta = 0; 1576 vc->vc_toggle_meta = 0;
1577 1577
1578 vc->vc_decscnm = 0; 1578 vc->vc_decscnm = 0;
1579 vc->vc_decom = 0; 1579 vc->vc_decom = 0;
1580 vc->vc_decawm = 1; 1580 vc->vc_decawm = 1;
1581 vc->vc_deccm = 1; 1581 vc->vc_deccm = 1;
1582 vc->vc_decim = 0; 1582 vc->vc_decim = 0;
1583 1583
1584 set_kbd(vc, decarm); 1584 set_kbd(vc, decarm);
1585 clr_kbd(vc, decckm); 1585 clr_kbd(vc, decckm);
1586 clr_kbd(vc, kbdapplic); 1586 clr_kbd(vc, kbdapplic);
1587 clr_kbd(vc, lnm); 1587 clr_kbd(vc, lnm);
1588 kbd_table[vc->vc_num].lockstate = 0; 1588 kbd_table[vc->vc_num].lockstate = 0;
1589 kbd_table[vc->vc_num].slockstate = 0; 1589 kbd_table[vc->vc_num].slockstate = 0;
1590 kbd_table[vc->vc_num].ledmode = LED_SHOW_FLAGS; 1590 kbd_table[vc->vc_num].ledmode = LED_SHOW_FLAGS;
1591 kbd_table[vc->vc_num].ledflagstate = kbd_table[vc->vc_num].default_ledflagstate; 1591 kbd_table[vc->vc_num].ledflagstate = kbd_table[vc->vc_num].default_ledflagstate;
1592 /* do not do set_leds here because this causes an endless tasklet loop 1592 /* do not do set_leds here because this causes an endless tasklet loop
1593 when the keyboard hasn't been initialized yet */ 1593 when the keyboard hasn't been initialized yet */
1594 1594
1595 vc->vc_cursor_type = CUR_DEFAULT; 1595 vc->vc_cursor_type = CUR_DEFAULT;
1596 vc->vc_complement_mask = vc->vc_s_complement_mask; 1596 vc->vc_complement_mask = vc->vc_s_complement_mask;
1597 1597
1598 default_attr(vc); 1598 default_attr(vc);
1599 update_attr(vc); 1599 update_attr(vc);
1600 1600
1601 vc->vc_tab_stop[0] = 0x01010100; 1601 vc->vc_tab_stop[0] = 0x01010100;
1602 vc->vc_tab_stop[1] = 1602 vc->vc_tab_stop[1] =
1603 vc->vc_tab_stop[2] = 1603 vc->vc_tab_stop[2] =
1604 vc->vc_tab_stop[3] = 1604 vc->vc_tab_stop[3] =
1605 vc->vc_tab_stop[4] = 0x01010101; 1605 vc->vc_tab_stop[4] = 0x01010101;
1606 1606
1607 vc->vc_bell_pitch = DEFAULT_BELL_PITCH; 1607 vc->vc_bell_pitch = DEFAULT_BELL_PITCH;
1608 vc->vc_bell_duration = DEFAULT_BELL_DURATION; 1608 vc->vc_bell_duration = DEFAULT_BELL_DURATION;
1609 1609
1610 gotoxy(vc, 0, 0); 1610 gotoxy(vc, 0, 0);
1611 save_cur(vc); 1611 save_cur(vc);
1612 if (do_clear) 1612 if (do_clear)
1613 csi_J(vc, 2); 1613 csi_J(vc, 2);
1614 } 1614 }
1615 1615
1616 /* console_sem is held */ 1616 /* console_sem is held */
1617 static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) 1617 static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)
1618 { 1618 {
1619 /* 1619 /*
1620 * Control characters can be used in the _middle_ 1620 * Control characters can be used in the _middle_
1621 * of an escape sequence. 1621 * of an escape sequence.
1622 */ 1622 */
1623 switch (c) { 1623 switch (c) {
1624 case 0: 1624 case 0:
1625 return; 1625 return;
1626 case 7: 1626 case 7:
1627 if (vc->vc_bell_duration) 1627 if (vc->vc_bell_duration)
1628 kd_mksound(vc->vc_bell_pitch, vc->vc_bell_duration); 1628 kd_mksound(vc->vc_bell_pitch, vc->vc_bell_duration);
1629 return; 1629 return;
1630 case 8: 1630 case 8:
1631 bs(vc); 1631 bs(vc);
1632 return; 1632 return;
1633 case 9: 1633 case 9:
1634 vc->vc_pos -= (vc->vc_x << 1); 1634 vc->vc_pos -= (vc->vc_x << 1);
1635 while (vc->vc_x < vc->vc_cols - 1) { 1635 while (vc->vc_x < vc->vc_cols - 1) {
1636 vc->vc_x++; 1636 vc->vc_x++;
1637 if (vc->vc_tab_stop[vc->vc_x >> 5] & (1 << (vc->vc_x & 31))) 1637 if (vc->vc_tab_stop[vc->vc_x >> 5] & (1 << (vc->vc_x & 31)))
1638 break; 1638 break;
1639 } 1639 }
1640 vc->vc_pos += (vc->vc_x << 1); 1640 vc->vc_pos += (vc->vc_x << 1);
1641 notify_write(vc, '\t'); 1641 notify_write(vc, '\t');
1642 return; 1642 return;
1643 case 10: case 11: case 12: 1643 case 10: case 11: case 12:
1644 lf(vc); 1644 lf(vc);
1645 if (!is_kbd(vc, lnm)) 1645 if (!is_kbd(vc, lnm))
1646 return; 1646 return;
1647 case 13: 1647 case 13:
1648 cr(vc); 1648 cr(vc);
1649 return; 1649 return;
1650 case 14: 1650 case 14:
1651 vc->vc_charset = 1; 1651 vc->vc_charset = 1;
1652 vc->vc_translate = set_translate(vc->vc_G1_charset, vc); 1652 vc->vc_translate = set_translate(vc->vc_G1_charset, vc);
1653 vc->vc_disp_ctrl = 1; 1653 vc->vc_disp_ctrl = 1;
1654 return; 1654 return;
1655 case 15: 1655 case 15:
1656 vc->vc_charset = 0; 1656 vc->vc_charset = 0;
1657 vc->vc_translate = set_translate(vc->vc_G0_charset, vc); 1657 vc->vc_translate = set_translate(vc->vc_G0_charset, vc);
1658 vc->vc_disp_ctrl = 0; 1658 vc->vc_disp_ctrl = 0;
1659 return; 1659 return;
1660 case 24: case 26: 1660 case 24: case 26:
1661 vc->vc_state = ESnormal; 1661 vc->vc_state = ESnormal;
1662 return; 1662 return;
1663 case 27: 1663 case 27:
1664 vc->vc_state = ESesc; 1664 vc->vc_state = ESesc;
1665 return; 1665 return;
1666 case 127: 1666 case 127:
1667 del(vc); 1667 del(vc);
1668 return; 1668 return;
1669 case 128+27: 1669 case 128+27:
1670 vc->vc_state = ESsquare; 1670 vc->vc_state = ESsquare;
1671 return; 1671 return;
1672 } 1672 }
1673 switch(vc->vc_state) { 1673 switch(vc->vc_state) {
1674 case ESesc: 1674 case ESesc:
1675 vc->vc_state = ESnormal; 1675 vc->vc_state = ESnormal;
1676 switch (c) { 1676 switch (c) {
1677 case '[': 1677 case '[':
1678 vc->vc_state = ESsquare; 1678 vc->vc_state = ESsquare;
1679 return; 1679 return;
1680 case ']': 1680 case ']':
1681 vc->vc_state = ESnonstd; 1681 vc->vc_state = ESnonstd;
1682 return; 1682 return;
1683 case '%': 1683 case '%':
1684 vc->vc_state = ESpercent; 1684 vc->vc_state = ESpercent;
1685 return; 1685 return;
1686 case 'E': 1686 case 'E':
1687 cr(vc); 1687 cr(vc);
1688 lf(vc); 1688 lf(vc);
1689 return; 1689 return;
1690 case 'M': 1690 case 'M':
1691 ri(vc); 1691 ri(vc);
1692 return; 1692 return;
1693 case 'D': 1693 case 'D':
1694 lf(vc); 1694 lf(vc);
1695 return; 1695 return;
1696 case 'H': 1696 case 'H':
1697 vc->vc_tab_stop[vc->vc_x >> 5] |= (1 << (vc->vc_x & 31)); 1697 vc->vc_tab_stop[vc->vc_x >> 5] |= (1 << (vc->vc_x & 31));
1698 return; 1698 return;
1699 case 'Z': 1699 case 'Z':
1700 respond_ID(tty); 1700 respond_ID(tty);
1701 return; 1701 return;
1702 case '7': 1702 case '7':
1703 save_cur(vc); 1703 save_cur(vc);
1704 return; 1704 return;
1705 case '8': 1705 case '8':
1706 restore_cur(vc); 1706 restore_cur(vc);
1707 return; 1707 return;
1708 case '(': 1708 case '(':
1709 vc->vc_state = ESsetG0; 1709 vc->vc_state = ESsetG0;
1710 return; 1710 return;
1711 case ')': 1711 case ')':
1712 vc->vc_state = ESsetG1; 1712 vc->vc_state = ESsetG1;
1713 return; 1713 return;
1714 case '#': 1714 case '#':
1715 vc->vc_state = EShash; 1715 vc->vc_state = EShash;
1716 return; 1716 return;
1717 case 'c': 1717 case 'c':
1718 reset_terminal(vc, 1); 1718 reset_terminal(vc, 1);
1719 return; 1719 return;
1720 case '>': /* Numeric keypad */ 1720 case '>': /* Numeric keypad */
1721 clr_kbd(vc, kbdapplic); 1721 clr_kbd(vc, kbdapplic);
1722 return; 1722 return;
1723 case '=': /* Appl. keypad */ 1723 case '=': /* Appl. keypad */
1724 set_kbd(vc, kbdapplic); 1724 set_kbd(vc, kbdapplic);
1725 return; 1725 return;
1726 } 1726 }
1727 return; 1727 return;
1728 case ESnonstd: 1728 case ESnonstd:
1729 if (c=='P') { /* palette escape sequence */ 1729 if (c=='P') { /* palette escape sequence */
1730 for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) 1730 for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++)
1731 vc->vc_par[vc->vc_npar] = 0; 1731 vc->vc_par[vc->vc_npar] = 0;
1732 vc->vc_npar = 0; 1732 vc->vc_npar = 0;
1733 vc->vc_state = ESpalette; 1733 vc->vc_state = ESpalette;
1734 return; 1734 return;
1735 } else if (c=='R') { /* reset palette */ 1735 } else if (c=='R') { /* reset palette */
1736 reset_palette(vc); 1736 reset_palette(vc);
1737 vc->vc_state = ESnormal; 1737 vc->vc_state = ESnormal;
1738 } else 1738 } else
1739 vc->vc_state = ESnormal; 1739 vc->vc_state = ESnormal;
1740 return; 1740 return;
1741 case ESpalette: 1741 case ESpalette:
1742 if ( (c>='0'&&c<='9') || (c>='A'&&c<='F') || (c>='a'&&c<='f') ) { 1742 if ( (c>='0'&&c<='9') || (c>='A'&&c<='F') || (c>='a'&&c<='f') ) {
1743 vc->vc_par[vc->vc_npar++] = (c > '9' ? (c & 0xDF) - 'A' + 10 : c - '0'); 1743 vc->vc_par[vc->vc_npar++] = (c > '9' ? (c & 0xDF) - 'A' + 10 : c - '0');
1744 if (vc->vc_npar == 7) { 1744 if (vc->vc_npar == 7) {
1745 int i = vc->vc_par[0] * 3, j = 1; 1745 int i = vc->vc_par[0] * 3, j = 1;
1746 vc->vc_palette[i] = 16 * vc->vc_par[j++]; 1746 vc->vc_palette[i] = 16 * vc->vc_par[j++];
1747 vc->vc_palette[i++] += vc->vc_par[j++]; 1747 vc->vc_palette[i++] += vc->vc_par[j++];
1748 vc->vc_palette[i] = 16 * vc->vc_par[j++]; 1748 vc->vc_palette[i] = 16 * vc->vc_par[j++];
1749 vc->vc_palette[i++] += vc->vc_par[j++]; 1749 vc->vc_palette[i++] += vc->vc_par[j++];
1750 vc->vc_palette[i] = 16 * vc->vc_par[j++]; 1750 vc->vc_palette[i] = 16 * vc->vc_par[j++];
1751 vc->vc_palette[i] += vc->vc_par[j]; 1751 vc->vc_palette[i] += vc->vc_par[j];
1752 set_palette(vc); 1752 set_palette(vc);
1753 vc->vc_state = ESnormal; 1753 vc->vc_state = ESnormal;
1754 } 1754 }
1755 } else 1755 } else
1756 vc->vc_state = ESnormal; 1756 vc->vc_state = ESnormal;
1757 return; 1757 return;
1758 case ESsquare: 1758 case ESsquare:
1759 for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) 1759 for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++)
1760 vc->vc_par[vc->vc_npar] = 0; 1760 vc->vc_par[vc->vc_npar] = 0;
1761 vc->vc_npar = 0; 1761 vc->vc_npar = 0;
1762 vc->vc_state = ESgetpars; 1762 vc->vc_state = ESgetpars;
1763 if (c == '[') { /* Function key */ 1763 if (c == '[') { /* Function key */
1764 vc->vc_state=ESfunckey; 1764 vc->vc_state=ESfunckey;
1765 return; 1765 return;
1766 } 1766 }
1767 vc->vc_ques = (c == '?'); 1767 vc->vc_ques = (c == '?');
1768 if (vc->vc_ques) 1768 if (vc->vc_ques)
1769 return; 1769 return;
1770 case ESgetpars: 1770 case ESgetpars:
1771 if (c == ';' && vc->vc_npar < NPAR - 1) { 1771 if (c == ';' && vc->vc_npar < NPAR - 1) {
1772 vc->vc_npar++; 1772 vc->vc_npar++;
1773 return; 1773 return;
1774 } else if (c>='0' && c<='9') { 1774 } else if (c>='0' && c<='9') {
1775 vc->vc_par[vc->vc_npar] *= 10; 1775 vc->vc_par[vc->vc_npar] *= 10;
1776 vc->vc_par[vc->vc_npar] += c - '0'; 1776 vc->vc_par[vc->vc_npar] += c - '0';
1777 return; 1777 return;
1778 } else 1778 } else
1779 vc->vc_state = ESgotpars; 1779 vc->vc_state = ESgotpars;
1780 case ESgotpars: 1780 case ESgotpars:
1781 vc->vc_state = ESnormal; 1781 vc->vc_state = ESnormal;
1782 switch(c) { 1782 switch(c) {
1783 case 'h': 1783 case 'h':
1784 set_mode(vc, 1); 1784 set_mode(vc, 1);
1785 return; 1785 return;
1786 case 'l': 1786 case 'l':
1787 set_mode(vc, 0); 1787 set_mode(vc, 0);
1788 return; 1788 return;
1789 case 'c': 1789 case 'c':
1790 if (vc->vc_ques) { 1790 if (vc->vc_ques) {
1791 if (vc->vc_par[0]) 1791 if (vc->vc_par[0])
1792 vc->vc_cursor_type = vc->vc_par[0] | (vc->vc_par[1] << 8) | (vc->vc_par[2] << 16); 1792 vc->vc_cursor_type = vc->vc_par[0] | (vc->vc_par[1] << 8) | (vc->vc_par[2] << 16);
1793 else 1793 else
1794 vc->vc_cursor_type = CUR_DEFAULT; 1794 vc->vc_cursor_type = CUR_DEFAULT;
1795 return; 1795 return;
1796 } 1796 }
1797 break; 1797 break;
1798 case 'm': 1798 case 'm':
1799 if (vc->vc_ques) { 1799 if (vc->vc_ques) {
1800 clear_selection(); 1800 clear_selection();
1801 if (vc->vc_par[0]) 1801 if (vc->vc_par[0])
1802 vc->vc_complement_mask = vc->vc_par[0] << 8 | vc->vc_par[1]; 1802 vc->vc_complement_mask = vc->vc_par[0] << 8 | vc->vc_par[1];
1803 else 1803 else
1804 vc->vc_complement_mask = vc->vc_s_complement_mask; 1804 vc->vc_complement_mask = vc->vc_s_complement_mask;
1805 return; 1805 return;
1806 } 1806 }
1807 break; 1807 break;
1808 case 'n': 1808 case 'n':
1809 if (!vc->vc_ques) { 1809 if (!vc->vc_ques) {
1810 if (vc->vc_par[0] == 5) 1810 if (vc->vc_par[0] == 5)
1811 status_report(tty); 1811 status_report(tty);
1812 else if (vc->vc_par[0] == 6) 1812 else if (vc->vc_par[0] == 6)
1813 cursor_report(vc, tty); 1813 cursor_report(vc, tty);
1814 } 1814 }
1815 return; 1815 return;
1816 } 1816 }
1817 if (vc->vc_ques) { 1817 if (vc->vc_ques) {
1818 vc->vc_ques = 0; 1818 vc->vc_ques = 0;
1819 return; 1819 return;
1820 } 1820 }
1821 switch(c) { 1821 switch(c) {
1822 case 'G': case '`': 1822 case 'G': case '`':
1823 if (vc->vc_par[0]) 1823 if (vc->vc_par[0])
1824 vc->vc_par[0]--; 1824 vc->vc_par[0]--;
1825 gotoxy(vc, vc->vc_par[0], vc->vc_y); 1825 gotoxy(vc, vc->vc_par[0], vc->vc_y);
1826 return; 1826 return;
1827 case 'A': 1827 case 'A':
1828 if (!vc->vc_par[0]) 1828 if (!vc->vc_par[0])
1829 vc->vc_par[0]++; 1829 vc->vc_par[0]++;
1830 gotoxy(vc, vc->vc_x, vc->vc_y - vc->vc_par[0]); 1830 gotoxy(vc, vc->vc_x, vc->vc_y - vc->vc_par[0]);
1831 return; 1831 return;
1832 case 'B': case 'e': 1832 case 'B': case 'e':
1833 if (!vc->vc_par[0]) 1833 if (!vc->vc_par[0])
1834 vc->vc_par[0]++; 1834 vc->vc_par[0]++;
1835 gotoxy(vc, vc->vc_x, vc->vc_y + vc->vc_par[0]); 1835 gotoxy(vc, vc->vc_x, vc->vc_y + vc->vc_par[0]);
1836 return; 1836 return;
1837 case 'C': case 'a': 1837 case 'C': case 'a':
1838 if (!vc->vc_par[0]) 1838 if (!vc->vc_par[0])
1839 vc->vc_par[0]++; 1839 vc->vc_par[0]++;
1840 gotoxy(vc, vc->vc_x + vc->vc_par[0], vc->vc_y); 1840 gotoxy(vc, vc->vc_x + vc->vc_par[0], vc->vc_y);
1841 return; 1841 return;
1842 case 'D': 1842 case 'D':
1843 if (!vc->vc_par[0]) 1843 if (!vc->vc_par[0])
1844 vc->vc_par[0]++; 1844 vc->vc_par[0]++;
1845 gotoxy(vc, vc->vc_x - vc->vc_par[0], vc->vc_y); 1845 gotoxy(vc, vc->vc_x - vc->vc_par[0], vc->vc_y);
1846 return; 1846 return;
1847 case 'E': 1847 case 'E':
1848 if (!vc->vc_par[0]) 1848 if (!vc->vc_par[0])
1849 vc->vc_par[0]++; 1849 vc->vc_par[0]++;
1850 gotoxy(vc, 0, vc->vc_y + vc->vc_par[0]); 1850 gotoxy(vc, 0, vc->vc_y + vc->vc_par[0]);
1851 return; 1851 return;
1852 case 'F': 1852 case 'F':
1853 if (!vc->vc_par[0]) 1853 if (!vc->vc_par[0])
1854 vc->vc_par[0]++; 1854 vc->vc_par[0]++;
1855 gotoxy(vc, 0, vc->vc_y - vc->vc_par[0]); 1855 gotoxy(vc, 0, vc->vc_y - vc->vc_par[0]);
1856 return; 1856 return;
1857 case 'd': 1857 case 'd':
1858 if (vc->vc_par[0]) 1858 if (vc->vc_par[0])
1859 vc->vc_par[0]--; 1859 vc->vc_par[0]--;
1860 gotoxay(vc, vc->vc_x ,vc->vc_par[0]); 1860 gotoxay(vc, vc->vc_x ,vc->vc_par[0]);
1861 return; 1861 return;
1862 case 'H': case 'f': 1862 case 'H': case 'f':
1863 if (vc->vc_par[0]) 1863 if (vc->vc_par[0])
1864 vc->vc_par[0]--; 1864 vc->vc_par[0]--;
1865 if (vc->vc_par[1]) 1865 if (vc->vc_par[1])
1866 vc->vc_par[1]--; 1866 vc->vc_par[1]--;
1867 gotoxay(vc, vc->vc_par[1], vc->vc_par[0]); 1867 gotoxay(vc, vc->vc_par[1], vc->vc_par[0]);
1868 return; 1868 return;
1869 case 'J': 1869 case 'J':
1870 csi_J(vc, vc->vc_par[0]); 1870 csi_J(vc, vc->vc_par[0]);
1871 return; 1871 return;
1872 case 'K': 1872 case 'K':
1873 csi_K(vc, vc->vc_par[0]); 1873 csi_K(vc, vc->vc_par[0]);
1874 return; 1874 return;
1875 case 'L': 1875 case 'L':
1876 csi_L(vc, vc->vc_par[0]); 1876 csi_L(vc, vc->vc_par[0]);
1877 return; 1877 return;
1878 case 'M': 1878 case 'M':
1879 csi_M(vc, vc->vc_par[0]); 1879 csi_M(vc, vc->vc_par[0]);
1880 return; 1880 return;
1881 case 'P': 1881 case 'P':
1882 csi_P(vc, vc->vc_par[0]); 1882 csi_P(vc, vc->vc_par[0]);
1883 return; 1883 return;
1884 case 'c': 1884 case 'c':
1885 if (!vc->vc_par[0]) 1885 if (!vc->vc_par[0])
1886 respond_ID(tty); 1886 respond_ID(tty);
1887 return; 1887 return;
1888 case 'g': 1888 case 'g':
1889 if (!vc->vc_par[0]) 1889 if (!vc->vc_par[0])
1890 vc->vc_tab_stop[vc->vc_x >> 5] &= ~(1 << (vc->vc_x & 31)); 1890 vc->vc_tab_stop[vc->vc_x >> 5] &= ~(1 << (vc->vc_x & 31));
1891 else if (vc->vc_par[0] == 3) { 1891 else if (vc->vc_par[0] == 3) {
1892 vc->vc_tab_stop[0] = 1892 vc->vc_tab_stop[0] =
1893 vc->vc_tab_stop[1] = 1893 vc->vc_tab_stop[1] =
1894 vc->vc_tab_stop[2] = 1894 vc->vc_tab_stop[2] =
1895 vc->vc_tab_stop[3] = 1895 vc->vc_tab_stop[3] =
1896 vc->vc_tab_stop[4] = 0; 1896 vc->vc_tab_stop[4] = 0;
1897 } 1897 }
1898 return; 1898 return;
1899 case 'm': 1899 case 'm':
1900 csi_m(vc); 1900 csi_m(vc);
1901 return; 1901 return;
1902 case 'q': /* DECLL - but only 3 leds */ 1902 case 'q': /* DECLL - but only 3 leds */
1903 /* map 0,1,2,3 to 0,1,2,4 */ 1903 /* map 0,1,2,3 to 0,1,2,4 */
1904 if (vc->vc_par[0] < 4) 1904 if (vc->vc_par[0] < 4)
1905 setledstate(kbd_table + vc->vc_num, 1905 setledstate(kbd_table + vc->vc_num,
1906 (vc->vc_par[0] < 3) ? vc->vc_par[0] : 4); 1906 (vc->vc_par[0] < 3) ? vc->vc_par[0] : 4);
1907 return; 1907 return;
1908 case 'r': 1908 case 'r':
1909 if (!vc->vc_par[0]) 1909 if (!vc->vc_par[0])
1910 vc->vc_par[0]++; 1910 vc->vc_par[0]++;
1911 if (!vc->vc_par[1]) 1911 if (!vc->vc_par[1])
1912 vc->vc_par[1] = vc->vc_rows; 1912 vc->vc_par[1] = vc->vc_rows;
1913 /* Minimum allowed region is 2 lines */ 1913 /* Minimum allowed region is 2 lines */
1914 if (vc->vc_par[0] < vc->vc_par[1] && 1914 if (vc->vc_par[0] < vc->vc_par[1] &&
1915 vc->vc_par[1] <= vc->vc_rows) { 1915 vc->vc_par[1] <= vc->vc_rows) {
1916 vc->vc_top = vc->vc_par[0] - 1; 1916 vc->vc_top = vc->vc_par[0] - 1;
1917 vc->vc_bottom = vc->vc_par[1]; 1917 vc->vc_bottom = vc->vc_par[1];
1918 gotoxay(vc, 0, 0); 1918 gotoxay(vc, 0, 0);
1919 } 1919 }
1920 return; 1920 return;
1921 case 's': 1921 case 's':
1922 save_cur(vc); 1922 save_cur(vc);
1923 return; 1923 return;
1924 case 'u': 1924 case 'u':
1925 restore_cur(vc); 1925 restore_cur(vc);
1926 return; 1926 return;
1927 case 'X': 1927 case 'X':
1928 csi_X(vc, vc->vc_par[0]); 1928 csi_X(vc, vc->vc_par[0]);
1929 return; 1929 return;
1930 case '@': 1930 case '@':
1931 csi_at(vc, vc->vc_par[0]); 1931 csi_at(vc, vc->vc_par[0]);
1932 return; 1932 return;
1933 case ']': /* setterm functions */ 1933 case ']': /* setterm functions */
1934 setterm_command(vc); 1934 setterm_command(vc);
1935 return; 1935 return;
1936 } 1936 }
1937 return; 1937 return;
1938 case ESpercent: 1938 case ESpercent:
1939 vc->vc_state = ESnormal; 1939 vc->vc_state = ESnormal;
1940 switch (c) { 1940 switch (c) {
1941 case '@': /* defined in ISO 2022 */ 1941 case '@': /* defined in ISO 2022 */
1942 vc->vc_utf = 0; 1942 vc->vc_utf = 0;
1943 return; 1943 return;
1944 case 'G': /* prelim official escape code */ 1944 case 'G': /* prelim official escape code */
1945 case '8': /* retained for compatibility */ 1945 case '8': /* retained for compatibility */
1946 vc->vc_utf = 1; 1946 vc->vc_utf = 1;
1947 return; 1947 return;
1948 } 1948 }
1949 return; 1949 return;
1950 case ESfunckey: 1950 case ESfunckey:
1951 vc->vc_state = ESnormal; 1951 vc->vc_state = ESnormal;
1952 return; 1952 return;
1953 case EShash: 1953 case EShash:
1954 vc->vc_state = ESnormal; 1954 vc->vc_state = ESnormal;
1955 if (c == '8') { 1955 if (c == '8') {
1956 /* DEC screen alignment test. kludge :-) */ 1956 /* DEC screen alignment test. kludge :-) */
1957 vc->vc_video_erase_char = 1957 vc->vc_video_erase_char =
1958 (vc->vc_video_erase_char & 0xff00) | 'E'; 1958 (vc->vc_video_erase_char & 0xff00) | 'E';
1959 csi_J(vc, 2); 1959 csi_J(vc, 2);
1960 vc->vc_video_erase_char = 1960 vc->vc_video_erase_char =
1961 (vc->vc_video_erase_char & 0xff00) | ' '; 1961 (vc->vc_video_erase_char & 0xff00) | ' ';
1962 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); 1962 do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2);
1963 } 1963 }
1964 return; 1964 return;
1965 case ESsetG0: 1965 case ESsetG0:
1966 if (c == '0') 1966 if (c == '0')
1967 vc->vc_G0_charset = GRAF_MAP; 1967 vc->vc_G0_charset = GRAF_MAP;
1968 else if (c == 'B') 1968 else if (c == 'B')
1969 vc->vc_G0_charset = LAT1_MAP; 1969 vc->vc_G0_charset = LAT1_MAP;
1970 else if (c == 'U') 1970 else if (c == 'U')
1971 vc->vc_G0_charset = IBMPC_MAP; 1971 vc->vc_G0_charset = IBMPC_MAP;
1972 else if (c == 'K') 1972 else if (c == 'K')
1973 vc->vc_G0_charset = USER_MAP; 1973 vc->vc_G0_charset = USER_MAP;
1974 if (vc->vc_charset == 0) 1974 if (vc->vc_charset == 0)
1975 vc->vc_translate = set_translate(vc->vc_G0_charset, vc); 1975 vc->vc_translate = set_translate(vc->vc_G0_charset, vc);
1976 vc->vc_state = ESnormal; 1976 vc->vc_state = ESnormal;
1977 return; 1977 return;
1978 case ESsetG1: 1978 case ESsetG1:
1979 if (c == '0') 1979 if (c == '0')
1980 vc->vc_G1_charset = GRAF_MAP; 1980 vc->vc_G1_charset = GRAF_MAP;
1981 else if (c == 'B') 1981 else if (c == 'B')
1982 vc->vc_G1_charset = LAT1_MAP; 1982 vc->vc_G1_charset = LAT1_MAP;
1983 else if (c == 'U') 1983 else if (c == 'U')
1984 vc->vc_G1_charset = IBMPC_MAP; 1984 vc->vc_G1_charset = IBMPC_MAP;
1985 else if (c == 'K') 1985 else if (c == 'K')
1986 vc->vc_G1_charset = USER_MAP; 1986 vc->vc_G1_charset = USER_MAP;
1987 if (vc->vc_charset == 1) 1987 if (vc->vc_charset == 1)
1988 vc->vc_translate = set_translate(vc->vc_G1_charset, vc); 1988 vc->vc_translate = set_translate(vc->vc_G1_charset, vc);
1989 vc->vc_state = ESnormal; 1989 vc->vc_state = ESnormal;
1990 return; 1990 return;
1991 default: 1991 default:
1992 vc->vc_state = ESnormal; 1992 vc->vc_state = ESnormal;
1993 } 1993 }
1994 } 1994 }
1995 1995
1996 /* This is a temporary buffer used to prepare a tty console write 1996 /* This is a temporary buffer used to prepare a tty console write
1997 * so that we can easily avoid touching user space while holding the 1997 * so that we can easily avoid touching user space while holding the
1998 * console spinlock. It is allocated in con_init and is shared by 1998 * console spinlock. It is allocated in con_init and is shared by
1999 * this code and the vc_screen read/write tty calls. 1999 * this code and the vc_screen read/write tty calls.
2000 * 2000 *
2001 * We have to allocate this statically in the kernel data section 2001 * We have to allocate this statically in the kernel data section
2002 * since console_init (and thus con_init) are called before any 2002 * since console_init (and thus con_init) are called before any
2003 * kernel memory allocation is available. 2003 * kernel memory allocation is available.
2004 */ 2004 */
2005 char con_buf[CON_BUF_SIZE]; 2005 char con_buf[CON_BUF_SIZE];
2006 DEFINE_MUTEX(con_buf_mtx); 2006 DEFINE_MUTEX(con_buf_mtx);
2007 2007
2008 /* is_double_width() is based on the wcwidth() implementation by 2008 /* is_double_width() is based on the wcwidth() implementation by
2009 * Markus Kuhn -- 2007-05-26 (Unicode 5.0) 2009 * Markus Kuhn -- 2007-05-26 (Unicode 5.0)
2010 * Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c 2010 * Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
2011 */ 2011 */
2012 struct interval { 2012 struct interval {
2013 uint32_t first; 2013 uint32_t first;
2014 uint32_t last; 2014 uint32_t last;
2015 }; 2015 };
2016 2016
2017 static int bisearch(uint32_t ucs, const struct interval *table, int max) 2017 static int bisearch(uint32_t ucs, const struct interval *table, int max)
2018 { 2018 {
2019 int min = 0; 2019 int min = 0;
2020 int mid; 2020 int mid;
2021 2021
2022 if (ucs < table[0].first || ucs > table[max].last) 2022 if (ucs < table[0].first || ucs > table[max].last)
2023 return 0; 2023 return 0;
2024 while (max >= min) { 2024 while (max >= min) {
2025 mid = (min + max) / 2; 2025 mid = (min + max) / 2;
2026 if (ucs > table[mid].last) 2026 if (ucs > table[mid].last)
2027 min = mid + 1; 2027 min = mid + 1;
2028 else if (ucs < table[mid].first) 2028 else if (ucs < table[mid].first)
2029 max = mid - 1; 2029 max = mid - 1;
2030 else 2030 else
2031 return 1; 2031 return 1;
2032 } 2032 }
2033 return 0; 2033 return 0;
2034 } 2034 }
2035 2035
2036 static int is_double_width(uint32_t ucs) 2036 static int is_double_width(uint32_t ucs)
2037 { 2037 {
2038 static const struct interval double_width[] = { 2038 static const struct interval double_width[] = {
2039 { 0x1100, 0x115F }, { 0x2329, 0x232A }, { 0x2E80, 0x303E }, 2039 { 0x1100, 0x115F }, { 0x2329, 0x232A }, { 0x2E80, 0x303E },
2040 { 0x3040, 0xA4CF }, { 0xAC00, 0xD7A3 }, { 0xF900, 0xFAFF }, 2040 { 0x3040, 0xA4CF }, { 0xAC00, 0xD7A3 }, { 0xF900, 0xFAFF },
2041 { 0xFE10, 0xFE19 }, { 0xFE30, 0xFE6F }, { 0xFF00, 0xFF60 }, 2041 { 0xFE10, 0xFE19 }, { 0xFE30, 0xFE6F }, { 0xFF00, 0xFF60 },
2042 { 0xFFE0, 0xFFE6 }, { 0x20000, 0x2FFFD }, { 0x30000, 0x3FFFD } 2042 { 0xFFE0, 0xFFE6 }, { 0x20000, 0x2FFFD }, { 0x30000, 0x3FFFD }
2043 }; 2043 };
2044 return bisearch(ucs, double_width, ARRAY_SIZE(double_width) - 1); 2044 return bisearch(ucs, double_width, ARRAY_SIZE(double_width) - 1);
2045 } 2045 }
2046 2046
2047 /* acquires console_sem */ 2047 /* acquires console_sem */
2048 static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int count) 2048 static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int count)
2049 { 2049 {
2050 #ifdef VT_BUF_VRAM_ONLY 2050 #ifdef VT_BUF_VRAM_ONLY
2051 #define FLUSH do { } while(0); 2051 #define FLUSH do { } while(0);
2052 #else 2052 #else
2053 #define FLUSH if (draw_x >= 0) { \ 2053 #define FLUSH if (draw_x >= 0) { \
2054 vc->vc_sw->con_putcs(vc, (u16 *)draw_from, (u16 *)draw_to - (u16 *)draw_from, vc->vc_y, draw_x); \ 2054 vc->vc_sw->con_putcs(vc, (u16 *)draw_from, (u16 *)draw_to - (u16 *)draw_from, vc->vc_y, draw_x); \
2055 draw_x = -1; \ 2055 draw_x = -1; \
2056 } 2056 }
2057 #endif 2057 #endif
2058 2058
2059 int c, tc, ok, n = 0, draw_x = -1; 2059 int c, tc, ok, n = 0, draw_x = -1;
2060 unsigned int currcons; 2060 unsigned int currcons;
2061 unsigned long draw_from = 0, draw_to = 0; 2061 unsigned long draw_from = 0, draw_to = 0;
2062 struct vc_data *vc; 2062 struct vc_data *vc;
2063 unsigned char vc_attr; 2063 unsigned char vc_attr;
2064 struct vt_notifier_param param; 2064 struct vt_notifier_param param;
2065 uint8_t rescan; 2065 uint8_t rescan;
2066 uint8_t inverse; 2066 uint8_t inverse;
2067 uint8_t width; 2067 uint8_t width;
2068 u16 himask, charmask; 2068 u16 himask, charmask;
2069 const unsigned char *orig_buf = NULL; 2069 const unsigned char *orig_buf = NULL;
2070 int orig_count; 2070 int orig_count;
2071 2071
2072 if (in_interrupt()) 2072 if (in_interrupt())
2073 return count; 2073 return count;
2074 2074
2075 might_sleep(); 2075 might_sleep();
2076 2076
2077 acquire_console_sem(); 2077 acquire_console_sem();
2078 vc = tty->driver_data; 2078 vc = tty->driver_data;
2079 if (vc == NULL) { 2079 if (vc == NULL) {
2080 printk(KERN_ERR "vt: argh, driver_data is NULL !\n"); 2080 printk(KERN_ERR "vt: argh, driver_data is NULL !\n");
2081 release_console_sem(); 2081 release_console_sem();
2082 return 0; 2082 return 0;
2083 } 2083 }
2084 2084
2085 currcons = vc->vc_num; 2085 currcons = vc->vc_num;
2086 if (!vc_cons_allocated(currcons)) { 2086 if (!vc_cons_allocated(currcons)) {
2087 /* could this happen? */ 2087 /* could this happen? */
2088 static int error = 0; 2088 static int error = 0;
2089 if (!error) { 2089 if (!error) {
2090 error = 1; 2090 error = 1;
2091 printk("con_write: tty %d not allocated\n", currcons+1); 2091 printk("con_write: tty %d not allocated\n", currcons+1);
2092 } 2092 }
2093 release_console_sem(); 2093 release_console_sem();
2094 return 0; 2094 return 0;
2095 } 2095 }
2096 release_console_sem(); 2096 release_console_sem();
2097 2097
2098 orig_buf = buf; 2098 orig_buf = buf;
2099 orig_count = count; 2099 orig_count = count;
2100 2100
2101 /* At this point 'buf' is guaranteed to be a kernel buffer 2101 /* At this point 'buf' is guaranteed to be a kernel buffer
2102 * and therefore no access to userspace (and therefore sleeping) 2102 * and therefore no access to userspace (and therefore sleeping)
2103 * will be needed. The con_buf_mtx serializes all tty based 2103 * will be needed. The con_buf_mtx serializes all tty based
2104 * console rendering and vcs write/read operations. We hold 2104 * console rendering and vcs write/read operations. We hold
2105 * the console spinlock during the entire write. 2105 * the console spinlock during the entire write.
2106 */ 2106 */
2107 2107
2108 acquire_console_sem(); 2108 acquire_console_sem();
2109 2109
2110 vc = tty->driver_data; 2110 vc = tty->driver_data;
2111 if (vc == NULL) { 2111 if (vc == NULL) {
2112 printk(KERN_ERR "vt: argh, driver_data _became_ NULL !\n"); 2112 printk(KERN_ERR "vt: argh, driver_data _became_ NULL !\n");
2113 release_console_sem(); 2113 release_console_sem();
2114 goto out; 2114 goto out;
2115 } 2115 }
2116 2116
2117 himask = vc->vc_hi_font_mask; 2117 himask = vc->vc_hi_font_mask;
2118 charmask = himask ? 0x1ff : 0xff; 2118 charmask = himask ? 0x1ff : 0xff;
2119 2119
2120 /* undraw cursor first */ 2120 /* undraw cursor first */
2121 if (IS_FG(vc)) 2121 if (IS_FG(vc))
2122 hide_cursor(vc); 2122 hide_cursor(vc);
2123 2123
2124 param.vc = vc; 2124 param.vc = vc;
2125 2125
2126 while (!tty->stopped && count) { 2126 while (!tty->stopped && count) {
2127 int orig = *buf; 2127 int orig = *buf;
2128 c = orig; 2128 c = orig;
2129 buf++; 2129 buf++;
2130 n++; 2130 n++;
2131 count--; 2131 count--;
2132 rescan = 0; 2132 rescan = 0;
2133 inverse = 0; 2133 inverse = 0;
2134 width = 1; 2134 width = 1;
2135 2135
2136 /* Do no translation at all in control states */ 2136 /* Do no translation at all in control states */
2137 if (vc->vc_state != ESnormal) { 2137 if (vc->vc_state != ESnormal) {
2138 tc = c; 2138 tc = c;
2139 } else if (vc->vc_utf && !vc->vc_disp_ctrl) { 2139 } else if (vc->vc_utf && !vc->vc_disp_ctrl) {
2140 /* Combine UTF-8 into Unicode in vc_utf_char. 2140 /* Combine UTF-8 into Unicode in vc_utf_char.
2141 * vc_utf_count is the number of continuation bytes still 2141 * vc_utf_count is the number of continuation bytes still
2142 * expected to arrive. 2142 * expected to arrive.
2143 * vc_npar is the number of continuation bytes arrived so 2143 * vc_npar is the number of continuation bytes arrived so
2144 * far 2144 * far
2145 */ 2145 */
2146 rescan_last_byte: 2146 rescan_last_byte:
2147 if ((c & 0xc0) == 0x80) { 2147 if ((c & 0xc0) == 0x80) {
2148 /* Continuation byte received */ 2148 /* Continuation byte received */
2149 static const uint32_t utf8_length_changes[] = { 0x0000007f, 0x000007ff, 0x0000ffff, 0x001fffff, 0x03ffffff, 0x7fffffff }; 2149 static const uint32_t utf8_length_changes[] = { 0x0000007f, 0x000007ff, 0x0000ffff, 0x001fffff, 0x03ffffff, 0x7fffffff };
2150 if (vc->vc_utf_count) { 2150 if (vc->vc_utf_count) {
2151 vc->vc_utf_char = (vc->vc_utf_char << 6) | (c & 0x3f); 2151 vc->vc_utf_char = (vc->vc_utf_char << 6) | (c & 0x3f);
2152 vc->vc_npar++; 2152 vc->vc_npar++;
2153 if (--vc->vc_utf_count) { 2153 if (--vc->vc_utf_count) {
2154 /* Still need some bytes */ 2154 /* Still need some bytes */
2155 continue; 2155 continue;
2156 } 2156 }
2157 /* Got a whole character */ 2157 /* Got a whole character */
2158 c = vc->vc_utf_char; 2158 c = vc->vc_utf_char;
2159 /* Reject overlong sequences */ 2159 /* Reject overlong sequences */
2160 if (c <= utf8_length_changes[vc->vc_npar - 1] || 2160 if (c <= utf8_length_changes[vc->vc_npar - 1] ||
2161 c > utf8_length_changes[vc->vc_npar]) 2161 c > utf8_length_changes[vc->vc_npar])
2162 c = 0xfffd; 2162 c = 0xfffd;
2163 } else { 2163 } else {
2164 /* Unexpected continuation byte */ 2164 /* Unexpected continuation byte */
2165 vc->vc_utf_count = 0; 2165 vc->vc_utf_count = 0;
2166 c = 0xfffd; 2166 c = 0xfffd;
2167 } 2167 }
2168 } else { 2168 } else {
2169 /* Single ASCII byte or first byte of a sequence received */ 2169 /* Single ASCII byte or first byte of a sequence received */
2170 if (vc->vc_utf_count) { 2170 if (vc->vc_utf_count) {
2171 /* Continuation byte expected */ 2171 /* Continuation byte expected */
2172 rescan = 1; 2172 rescan = 1;
2173 vc->vc_utf_count = 0; 2173 vc->vc_utf_count = 0;
2174 c = 0xfffd; 2174 c = 0xfffd;
2175 } else if (c > 0x7f) { 2175 } else if (c > 0x7f) {
2176 /* First byte of a multibyte sequence received */ 2176 /* First byte of a multibyte sequence received */
2177 vc->vc_npar = 0; 2177 vc->vc_npar = 0;
2178 if ((c & 0xe0) == 0xc0) { 2178 if ((c & 0xe0) == 0xc0) {
2179 vc->vc_utf_count = 1; 2179 vc->vc_utf_count = 1;
2180 vc->vc_utf_char = (c & 0x1f); 2180 vc->vc_utf_char = (c & 0x1f);
2181 } else if ((c & 0xf0) == 0xe0) { 2181 } else if ((c & 0xf0) == 0xe0) {
2182 vc->vc_utf_count = 2; 2182 vc->vc_utf_count = 2;
2183 vc->vc_utf_char = (c & 0x0f); 2183 vc->vc_utf_char = (c & 0x0f);
2184 } else if ((c & 0xf8) == 0xf0) { 2184 } else if ((c & 0xf8) == 0xf0) {
2185 vc->vc_utf_count = 3; 2185 vc->vc_utf_count = 3;
2186 vc->vc_utf_char = (c & 0x07); 2186 vc->vc_utf_char = (c & 0x07);
2187 } else if ((c & 0xfc) == 0xf8) { 2187 } else if ((c & 0xfc) == 0xf8) {
2188 vc->vc_utf_count = 4; 2188 vc->vc_utf_count = 4;
2189 vc->vc_utf_char = (c & 0x03); 2189 vc->vc_utf_char = (c & 0x03);
2190 } else if ((c & 0xfe) == 0xfc) { 2190 } else if ((c & 0xfe) == 0xfc) {
2191 vc->vc_utf_count = 5; 2191 vc->vc_utf_count = 5;
2192 vc->vc_utf_char = (c & 0x01); 2192 vc->vc_utf_char = (c & 0x01);
2193 } else { 2193 } else {
2194 /* 254 and 255 are invalid */ 2194 /* 254 and 255 are invalid */
2195 c = 0xfffd; 2195 c = 0xfffd;
2196 } 2196 }
2197 if (vc->vc_utf_count) { 2197 if (vc->vc_utf_count) {
2198 /* Still need some bytes */ 2198 /* Still need some bytes */
2199 continue; 2199 continue;
2200 } 2200 }
2201 } 2201 }
2202 /* Nothing to do if an ASCII byte was received */ 2202 /* Nothing to do if an ASCII byte was received */
2203 } 2203 }
2204 /* End of UTF-8 decoding. */ 2204 /* End of UTF-8 decoding. */
2205 /* c is the received character, or U+FFFD for invalid sequences. */ 2205 /* c is the received character, or U+FFFD for invalid sequences. */
2206 /* Replace invalid Unicode code points with U+FFFD too */ 2206 /* Replace invalid Unicode code points with U+FFFD too */
2207 if ((c >= 0xd800 && c <= 0xdfff) || c == 0xfffe || c == 0xffff) 2207 if ((c >= 0xd800 && c <= 0xdfff) || c == 0xfffe || c == 0xffff)
2208 c = 0xfffd; 2208 c = 0xfffd;
2209 tc = c; 2209 tc = c;
2210 } else { /* no utf or alternate charset mode */ 2210 } else { /* no utf or alternate charset mode */
2211 tc = vc->vc_translate[vc->vc_toggle_meta ? (c | 0x80) : c]; 2211 tc = vc_translate(vc, c);
2212 } 2212 }
2213 2213
2214 param.c = tc; 2214 param.c = tc;
2215 if (atomic_notifier_call_chain(&vt_notifier_list, VT_PREWRITE, 2215 if (atomic_notifier_call_chain(&vt_notifier_list, VT_PREWRITE,
2216 &param) == NOTIFY_STOP) 2216 &param) == NOTIFY_STOP)
2217 continue; 2217 continue;
2218 2218
2219 /* If the original code was a control character we 2219 /* If the original code was a control character we
2220 * only allow a glyph to be displayed if the code is 2220 * only allow a glyph to be displayed if the code is
2221 * not normally used (such as for cursor movement) or 2221 * not normally used (such as for cursor movement) or
2222 * if the disp_ctrl mode has been explicitly enabled. 2222 * if the disp_ctrl mode has been explicitly enabled.
2223 * Certain characters (as given by the CTRL_ALWAYS 2223 * Certain characters (as given by the CTRL_ALWAYS
2224 * bitmap) are always displayed as control characters, 2224 * bitmap) are always displayed as control characters,
2225 * as the console would be pretty useless without 2225 * as the console would be pretty useless without
2226 * them; to display an arbitrary font position use the 2226 * them; to display an arbitrary font position use the
2227 * direct-to-font zone in UTF-8 mode. 2227 * direct-to-font zone in UTF-8 mode.
2228 */ 2228 */
2229 ok = tc && (c >= 32 || 2229 ok = tc && (c >= 32 ||
2230 !(vc->vc_disp_ctrl ? (CTRL_ALWAYS >> c) & 1 : 2230 !(vc->vc_disp_ctrl ? (CTRL_ALWAYS >> c) & 1 :
2231 vc->vc_utf || ((CTRL_ACTION >> c) & 1))) 2231 vc->vc_utf || ((CTRL_ACTION >> c) & 1)))
2232 && (c != 127 || vc->vc_disp_ctrl) 2232 && (c != 127 || vc->vc_disp_ctrl)
2233 && (c != 128+27); 2233 && (c != 128+27);
2234 2234
2235 if (vc->vc_state == ESnormal && ok) { 2235 if (vc->vc_state == ESnormal && ok) {
2236 if (vc->vc_utf && !vc->vc_disp_ctrl) { 2236 if (vc->vc_utf && !vc->vc_disp_ctrl) {
2237 if (is_double_width(c)) 2237 if (is_double_width(c))
2238 width = 2; 2238 width = 2;
2239 } 2239 }
2240 /* Now try to find out how to display it */ 2240 /* Now try to find out how to display it */
2241 tc = conv_uni_to_pc(vc, tc); 2241 tc = conv_uni_to_pc(vc, tc);
2242 if (tc & ~charmask) { 2242 if (tc & ~charmask) {
2243 if (tc == -1 || tc == -2) { 2243 if (tc == -1 || tc == -2) {
2244 continue; /* nothing to display */ 2244 continue; /* nothing to display */
2245 } 2245 }
2246 /* Glyph not found */ 2246 /* Glyph not found */
2247 if ((!(vc->vc_utf && !vc->vc_disp_ctrl) || c < 128) && !(c & ~charmask)) { 2247 if ((!(vc->vc_utf && !vc->vc_disp_ctrl) || c < 128) && !(c & ~charmask)) {
2248 /* In legacy mode use the glyph we get by a 1:1 mapping. 2248 /* In legacy mode use the glyph we get by a 1:1 mapping.
2249 This would make absolutely no sense with Unicode in mind, 2249 This would make absolutely no sense with Unicode in mind,
2250 but do this for ASCII characters since a font may lack 2250 but do this for ASCII characters since a font may lack
2251 Unicode mapping info and we don't want to end up with 2251 Unicode mapping info and we don't want to end up with
2252 having question marks only. */ 2252 having question marks only. */
2253 tc = c; 2253 tc = c;
2254 } else { 2254 } else {
2255 /* Display U+FFFD. If it's not found, display an inverse question mark. */ 2255 /* Display U+FFFD. If it's not found, display an inverse question mark. */
2256 tc = conv_uni_to_pc(vc, 0xfffd); 2256 tc = conv_uni_to_pc(vc, 0xfffd);
2257 if (tc < 0) { 2257 if (tc < 0) {
2258 inverse = 1; 2258 inverse = 1;
2259 tc = conv_uni_to_pc(vc, '?'); 2259 tc = conv_uni_to_pc(vc, '?');
2260 if (tc < 0) tc = '?'; 2260 if (tc < 0) tc = '?';
2261 } 2261 }
2262 } 2262 }
2263 } 2263 }
2264 2264
2265 if (!inverse) { 2265 if (!inverse) {
2266 vc_attr = vc->vc_attr; 2266 vc_attr = vc->vc_attr;
2267 } else { 2267 } else {
2268 /* invert vc_attr */ 2268 /* invert vc_attr */
2269 if (!vc->vc_can_do_color) { 2269 if (!vc->vc_can_do_color) {
2270 vc_attr = (vc->vc_attr) ^ 0x08; 2270 vc_attr = (vc->vc_attr) ^ 0x08;
2271 } else if (vc->vc_hi_font_mask == 0x100) { 2271 } else if (vc->vc_hi_font_mask == 0x100) {
2272 vc_attr = ((vc->vc_attr) & 0x11) | (((vc->vc_attr) & 0xe0) >> 4) | (((vc->vc_attr) & 0x0e) << 4); 2272 vc_attr = ((vc->vc_attr) & 0x11) | (((vc->vc_attr) & 0xe0) >> 4) | (((vc->vc_attr) & 0x0e) << 4);
2273 } else { 2273 } else {
2274 vc_attr = ((vc->vc_attr) & 0x88) | (((vc->vc_attr) & 0x70) >> 4) | (((vc->vc_attr) & 0x07) << 4); 2274 vc_attr = ((vc->vc_attr) & 0x88) | (((vc->vc_attr) & 0x70) >> 4) | (((vc->vc_attr) & 0x07) << 4);
2275 } 2275 }
2276 FLUSH 2276 FLUSH
2277 } 2277 }
2278 2278
2279 while (1) { 2279 while (1) {
2280 if (vc->vc_need_wrap || vc->vc_decim) 2280 if (vc->vc_need_wrap || vc->vc_decim)
2281 FLUSH 2281 FLUSH
2282 if (vc->vc_need_wrap) { 2282 if (vc->vc_need_wrap) {
2283 cr(vc); 2283 cr(vc);
2284 lf(vc); 2284 lf(vc);
2285 } 2285 }
2286 if (vc->vc_decim) 2286 if (vc->vc_decim)
2287 insert_char(vc, 1); 2287 insert_char(vc, 1);
2288 scr_writew(himask ? 2288 scr_writew(himask ?
2289 ((vc_attr << 8) & ~himask) + ((tc & 0x100) ? himask : 0) + (tc & 0xff) : 2289 ((vc_attr << 8) & ~himask) + ((tc & 0x100) ? himask : 0) + (tc & 0xff) :
2290 (vc_attr << 8) + tc, 2290 (vc_attr << 8) + tc,
2291 (u16 *) vc->vc_pos); 2291 (u16 *) vc->vc_pos);
2292 if (DO_UPDATE(vc) && draw_x < 0) { 2292 if (DO_UPDATE(vc) && draw_x < 0) {
2293 draw_x = vc->vc_x; 2293 draw_x = vc->vc_x;
2294 draw_from = vc->vc_pos; 2294 draw_from = vc->vc_pos;
2295 } 2295 }
2296 if (vc->vc_x == vc->vc_cols - 1) { 2296 if (vc->vc_x == vc->vc_cols - 1) {
2297 vc->vc_need_wrap = vc->vc_decawm; 2297 vc->vc_need_wrap = vc->vc_decawm;
2298 draw_to = vc->vc_pos + 2; 2298 draw_to = vc->vc_pos + 2;
2299 } else { 2299 } else {
2300 vc->vc_x++; 2300 vc->vc_x++;
2301 draw_to = (vc->vc_pos += 2); 2301 draw_to = (vc->vc_pos += 2);
2302 } 2302 }
2303 2303
2304 if (!--width) break; 2304 if (!--width) break;
2305 2305
2306 tc = conv_uni_to_pc(vc, ' '); /* A space is printed in the second column */ 2306 tc = conv_uni_to_pc(vc, ' '); /* A space is printed in the second column */
2307 if (tc < 0) tc = ' '; 2307 if (tc < 0) tc = ' ';
2308 } 2308 }
2309 notify_write(vc, c); 2309 notify_write(vc, c);
2310 2310
2311 if (inverse) { 2311 if (inverse) {
2312 FLUSH 2312 FLUSH
2313 } 2313 }
2314 2314
2315 if (rescan) { 2315 if (rescan) {
2316 rescan = 0; 2316 rescan = 0;
2317 inverse = 0; 2317 inverse = 0;
2318 width = 1; 2318 width = 1;
2319 c = orig; 2319 c = orig;
2320 goto rescan_last_byte; 2320 goto rescan_last_byte;
2321 } 2321 }
2322 continue; 2322 continue;
2323 } 2323 }
2324 FLUSH 2324 FLUSH
2325 do_con_trol(tty, vc, orig); 2325 do_con_trol(tty, vc, orig);
2326 } 2326 }
2327 FLUSH 2327 FLUSH
2328 console_conditional_schedule(); 2328 console_conditional_schedule();
2329 release_console_sem(); 2329 release_console_sem();
2330 2330
2331 out: 2331 out:
2332 notify_update(vc); 2332 notify_update(vc);
2333 return n; 2333 return n;
2334 #undef FLUSH 2334 #undef FLUSH
2335 } 2335 }
2336 2336
2337 /* 2337 /*
2338 * This is the console switching callback. 2338 * This is the console switching callback.
2339 * 2339 *
2340 * Doing console switching in a process context allows 2340 * Doing console switching in a process context allows
2341 * us to do the switches asynchronously (needed when we want 2341 * us to do the switches asynchronously (needed when we want
2342 * to switch due to a keyboard interrupt). Synchronization 2342 * to switch due to a keyboard interrupt). Synchronization
2343 * with other console code and prevention of re-entrancy is 2343 * with other console code and prevention of re-entrancy is
2344 * ensured with console_sem. 2344 * ensured with console_sem.
2345 */ 2345 */
2346 static void console_callback(struct work_struct *ignored) 2346 static void console_callback(struct work_struct *ignored)
2347 { 2347 {
2348 acquire_console_sem(); 2348 acquire_console_sem();
2349 2349
2350 if (want_console >= 0) { 2350 if (want_console >= 0) {
2351 if (want_console != fg_console && 2351 if (want_console != fg_console &&
2352 vc_cons_allocated(want_console)) { 2352 vc_cons_allocated(want_console)) {
2353 hide_cursor(vc_cons[fg_console].d); 2353 hide_cursor(vc_cons[fg_console].d);
2354 change_console(vc_cons[want_console].d); 2354 change_console(vc_cons[want_console].d);
2355 /* we only changed when the console had already 2355 /* we only changed when the console had already
2356 been allocated - a new console is not created 2356 been allocated - a new console is not created
2357 in an interrupt routine */ 2357 in an interrupt routine */
2358 } 2358 }
2359 want_console = -1; 2359 want_console = -1;
2360 } 2360 }
2361 if (do_poke_blanked_console) { /* do not unblank for a LED change */ 2361 if (do_poke_blanked_console) { /* do not unblank for a LED change */
2362 do_poke_blanked_console = 0; 2362 do_poke_blanked_console = 0;
2363 poke_blanked_console(); 2363 poke_blanked_console();
2364 } 2364 }
2365 if (scrollback_delta) { 2365 if (scrollback_delta) {
2366 struct vc_data *vc = vc_cons[fg_console].d; 2366 struct vc_data *vc = vc_cons[fg_console].d;
2367 clear_selection(); 2367 clear_selection();
2368 if (vc->vc_mode == KD_TEXT) 2368 if (vc->vc_mode == KD_TEXT)
2369 vc->vc_sw->con_scrolldelta(vc, scrollback_delta); 2369 vc->vc_sw->con_scrolldelta(vc, scrollback_delta);
2370 scrollback_delta = 0; 2370 scrollback_delta = 0;
2371 } 2371 }
2372 if (blank_timer_expired) { 2372 if (blank_timer_expired) {
2373 do_blank_screen(0); 2373 do_blank_screen(0);
2374 blank_timer_expired = 0; 2374 blank_timer_expired = 0;
2375 } 2375 }
2376 notify_update(vc_cons[fg_console].d); 2376 notify_update(vc_cons[fg_console].d);
2377 2377
2378 release_console_sem(); 2378 release_console_sem();
2379 } 2379 }
2380 2380
2381 int set_console(int nr) 2381 int set_console(int nr)
2382 { 2382 {
2383 struct vc_data *vc = vc_cons[fg_console].d; 2383 struct vc_data *vc = vc_cons[fg_console].d;
2384 2384
2385 if (!vc_cons_allocated(nr) || vt_dont_switch || 2385 if (!vc_cons_allocated(nr) || vt_dont_switch ||
2386 (vc->vt_mode.mode == VT_AUTO && vc->vc_mode == KD_GRAPHICS)) { 2386 (vc->vt_mode.mode == VT_AUTO && vc->vc_mode == KD_GRAPHICS)) {
2387 2387
2388 /* 2388 /*
2389 * Console switch will fail in console_callback() or 2389 * Console switch will fail in console_callback() or
2390 * change_console() so there is no point scheduling 2390 * change_console() so there is no point scheduling
2391 * the callback 2391 * the callback
2392 * 2392 *
2393 * Existing set_console() users don't check the return 2393 * Existing set_console() users don't check the return
2394 * value so this shouldn't break anything 2394 * value so this shouldn't break anything
2395 */ 2395 */
2396 return -EINVAL; 2396 return -EINVAL;
2397 } 2397 }
2398 2398
2399 want_console = nr; 2399 want_console = nr;
2400 schedule_console_callback(); 2400 schedule_console_callback();
2401 2401
2402 return 0; 2402 return 0;
2403 } 2403 }
2404 2404
2405 struct tty_driver *console_driver; 2405 struct tty_driver *console_driver;
2406 2406
2407 #ifdef CONFIG_VT_CONSOLE 2407 #ifdef CONFIG_VT_CONSOLE
2408 2408
2409 /* 2409 /*
2410 * Console on virtual terminal 2410 * Console on virtual terminal
2411 * 2411 *
2412 * The console must be locked when we get here. 2412 * The console must be locked when we get here.
2413 */ 2413 */
2414 2414
2415 static void vt_console_print(struct console *co, const char *b, unsigned count) 2415 static void vt_console_print(struct console *co, const char *b, unsigned count)
2416 { 2416 {
2417 struct vc_data *vc = vc_cons[fg_console].d; 2417 struct vc_data *vc = vc_cons[fg_console].d;
2418 unsigned char c; 2418 unsigned char c;
2419 static DEFINE_SPINLOCK(printing_lock); 2419 static DEFINE_SPINLOCK(printing_lock);
2420 const ushort *start; 2420 const ushort *start;
2421 ushort cnt = 0; 2421 ushort cnt = 0;
2422 ushort myx; 2422 ushort myx;
2423 2423
2424 /* console busy or not yet initialized */ 2424 /* console busy or not yet initialized */
2425 if (!printable) 2425 if (!printable)
2426 return; 2426 return;
2427 if (!spin_trylock(&printing_lock)) 2427 if (!spin_trylock(&printing_lock))
2428 return; 2428 return;
2429 2429
2430 if (kmsg_redirect && vc_cons_allocated(kmsg_redirect - 1)) 2430 if (kmsg_redirect && vc_cons_allocated(kmsg_redirect - 1))
2431 vc = vc_cons[kmsg_redirect - 1].d; 2431 vc = vc_cons[kmsg_redirect - 1].d;
2432 2432
2433 /* read `x' only after setting currcons properly (otherwise 2433 /* read `x' only after setting currcons properly (otherwise
2434 the `x' macro will read the x of the foreground console). */ 2434 the `x' macro will read the x of the foreground console). */
2435 myx = vc->vc_x; 2435 myx = vc->vc_x;
2436 2436
2437 if (!vc_cons_allocated(fg_console)) { 2437 if (!vc_cons_allocated(fg_console)) {
2438 /* impossible */ 2438 /* impossible */
2439 /* printk("vt_console_print: tty %d not allocated ??\n", currcons+1); */ 2439 /* printk("vt_console_print: tty %d not allocated ??\n", currcons+1); */
2440 goto quit; 2440 goto quit;
2441 } 2441 }
2442 2442
2443 if (vc->vc_mode != KD_TEXT) 2443 if (vc->vc_mode != KD_TEXT)
2444 goto quit; 2444 goto quit;
2445 2445
2446 /* undraw cursor first */ 2446 /* undraw cursor first */
2447 if (IS_FG(vc)) 2447 if (IS_FG(vc))
2448 hide_cursor(vc); 2448 hide_cursor(vc);
2449 2449
2450 start = (ushort *)vc->vc_pos; 2450 start = (ushort *)vc->vc_pos;
2451 2451
2452 /* Contrived structure to try to emulate original need_wrap behaviour 2452 /* Contrived structure to try to emulate original need_wrap behaviour
2453 * Problems caused when we have need_wrap set on '\n' character */ 2453 * Problems caused when we have need_wrap set on '\n' character */
2454 while (count--) { 2454 while (count--) {
2455 c = *b++; 2455 c = *b++;
2456 if (c == 10 || c == 13 || c == 8 || vc->vc_need_wrap) { 2456 if (c == 10 || c == 13 || c == 8 || vc->vc_need_wrap) {
2457 if (cnt > 0) { 2457 if (cnt > 0) {
2458 if (CON_IS_VISIBLE(vc)) 2458 if (CON_IS_VISIBLE(vc))
2459 vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, vc->vc_x); 2459 vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, vc->vc_x);
2460 vc->vc_x += cnt; 2460 vc->vc_x += cnt;
2461 if (vc->vc_need_wrap) 2461 if (vc->vc_need_wrap)
2462 vc->vc_x--; 2462 vc->vc_x--;
2463 cnt = 0; 2463 cnt = 0;
2464 } 2464 }
2465 if (c == 8) { /* backspace */ 2465 if (c == 8) { /* backspace */
2466 bs(vc); 2466 bs(vc);
2467 start = (ushort *)vc->vc_pos; 2467 start = (ushort *)vc->vc_pos;
2468 myx = vc->vc_x; 2468 myx = vc->vc_x;
2469 continue; 2469 continue;
2470 } 2470 }
2471 if (c != 13) 2471 if (c != 13)
2472 lf(vc); 2472 lf(vc);
2473 cr(vc); 2473 cr(vc);
2474 start = (ushort *)vc->vc_pos; 2474 start = (ushort *)vc->vc_pos;
2475 myx = vc->vc_x; 2475 myx = vc->vc_x;
2476 if (c == 10 || c == 13) 2476 if (c == 10 || c == 13)
2477 continue; 2477 continue;
2478 } 2478 }
2479 scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos); 2479 scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos);
2480 notify_write(vc, c); 2480 notify_write(vc, c);
2481 cnt++; 2481 cnt++;
2482 if (myx == vc->vc_cols - 1) { 2482 if (myx == vc->vc_cols - 1) {
2483 vc->vc_need_wrap = 1; 2483 vc->vc_need_wrap = 1;
2484 continue; 2484 continue;
2485 } 2485 }
2486 vc->vc_pos += 2; 2486 vc->vc_pos += 2;
2487 myx++; 2487 myx++;
2488 } 2488 }
2489 if (cnt > 0) { 2489 if (cnt > 0) {
2490 if (CON_IS_VISIBLE(vc)) 2490 if (CON_IS_VISIBLE(vc))
2491 vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, vc->vc_x); 2491 vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, vc->vc_x);
2492 vc->vc_x += cnt; 2492 vc->vc_x += cnt;
2493 if (vc->vc_x == vc->vc_cols) { 2493 if (vc->vc_x == vc->vc_cols) {
2494 vc->vc_x--; 2494 vc->vc_x--;
2495 vc->vc_need_wrap = 1; 2495 vc->vc_need_wrap = 1;
2496 } 2496 }
2497 } 2497 }
2498 set_cursor(vc); 2498 set_cursor(vc);
2499 notify_update(vc); 2499 notify_update(vc);
2500 2500
2501 quit: 2501 quit:
2502 spin_unlock(&printing_lock); 2502 spin_unlock(&printing_lock);
2503 } 2503 }
2504 2504
2505 static struct tty_driver *vt_console_device(struct console *c, int *index) 2505 static struct tty_driver *vt_console_device(struct console *c, int *index)
2506 { 2506 {
2507 *index = c->index ? c->index-1 : fg_console; 2507 *index = c->index ? c->index-1 : fg_console;
2508 return console_driver; 2508 return console_driver;
2509 } 2509 }
2510 2510
2511 static struct console vt_console_driver = { 2511 static struct console vt_console_driver = {
2512 .name = "tty", 2512 .name = "tty",
2513 .write = vt_console_print, 2513 .write = vt_console_print,
2514 .device = vt_console_device, 2514 .device = vt_console_device,
2515 .unblank = unblank_screen, 2515 .unblank = unblank_screen,
2516 .flags = CON_PRINTBUFFER, 2516 .flags = CON_PRINTBUFFER,
2517 .index = -1, 2517 .index = -1,
2518 }; 2518 };
2519 #endif 2519 #endif
2520 2520
2521 /* 2521 /*
2522 * Handling of Linux-specific VC ioctls 2522 * Handling of Linux-specific VC ioctls
2523 */ 2523 */
2524 2524
2525 /* 2525 /*
2526 * Generally a bit racy with respect to console_sem(). 2526 * Generally a bit racy with respect to console_sem().
2527 * 2527 *
2528 * There are some functions which don't need it. 2528 * There are some functions which don't need it.
2529 * 2529 *
2530 * There are some functions which can sleep for arbitrary periods 2530 * There are some functions which can sleep for arbitrary periods
2531 * (paste_selection) but we don't need the lock there anyway. 2531 * (paste_selection) but we don't need the lock there anyway.
2532 * 2532 *
2533 * set_selection has locking, and definitely needs it 2533 * set_selection has locking, and definitely needs it
2534 */ 2534 */
2535 2535
2536 int tioclinux(struct tty_struct *tty, unsigned long arg) 2536 int tioclinux(struct tty_struct *tty, unsigned long arg)
2537 { 2537 {
2538 char type, data; 2538 char type, data;
2539 char __user *p = (char __user *)arg; 2539 char __user *p = (char __user *)arg;
2540 int lines; 2540 int lines;
2541 int ret; 2541 int ret;
2542 2542
2543 if (tty->driver->type != TTY_DRIVER_TYPE_CONSOLE) 2543 if (tty->driver->type != TTY_DRIVER_TYPE_CONSOLE)
2544 return -EINVAL; 2544 return -EINVAL;
2545 if (current->signal->tty != tty && !capable(CAP_SYS_ADMIN)) 2545 if (current->signal->tty != tty && !capable(CAP_SYS_ADMIN))
2546 return -EPERM; 2546 return -EPERM;
2547 if (get_user(type, p)) 2547 if (get_user(type, p))
2548 return -EFAULT; 2548 return -EFAULT;
2549 ret = 0; 2549 ret = 0;
2550 2550
2551 lock_kernel(); 2551 lock_kernel();
2552 2552
2553 switch (type) 2553 switch (type)
2554 { 2554 {
2555 case TIOCL_SETSEL: 2555 case TIOCL_SETSEL:
2556 acquire_console_sem(); 2556 acquire_console_sem();
2557 ret = set_selection((struct tiocl_selection __user *)(p+1), tty); 2557 ret = set_selection((struct tiocl_selection __user *)(p+1), tty);
2558 release_console_sem(); 2558 release_console_sem();
2559 break; 2559 break;
2560 case TIOCL_PASTESEL: 2560 case TIOCL_PASTESEL:
2561 ret = paste_selection(tty); 2561 ret = paste_selection(tty);
2562 break; 2562 break;
2563 case TIOCL_UNBLANKSCREEN: 2563 case TIOCL_UNBLANKSCREEN:
2564 acquire_console_sem(); 2564 acquire_console_sem();
2565 unblank_screen(); 2565 unblank_screen();
2566 release_console_sem(); 2566 release_console_sem();
2567 break; 2567 break;
2568 case TIOCL_SELLOADLUT: 2568 case TIOCL_SELLOADLUT:
2569 ret = sel_loadlut(p); 2569 ret = sel_loadlut(p);
2570 break; 2570 break;
2571 case TIOCL_GETSHIFTSTATE: 2571 case TIOCL_GETSHIFTSTATE:
2572 2572
2573 /* 2573 /*
2574 * Make it possible to react to Shift+Mousebutton. 2574 * Make it possible to react to Shift+Mousebutton.
2575 * Note that 'shift_state' is an undocumented 2575 * Note that 'shift_state' is an undocumented
2576 * kernel-internal variable; programs not closely 2576 * kernel-internal variable; programs not closely
2577 * related to the kernel should not use this. 2577 * related to the kernel should not use this.
2578 */ 2578 */
2579 data = shift_state; 2579 data = shift_state;
2580 ret = __put_user(data, p); 2580 ret = __put_user(data, p);
2581 break; 2581 break;
2582 case TIOCL_GETMOUSEREPORTING: 2582 case TIOCL_GETMOUSEREPORTING:
2583 data = mouse_reporting(); 2583 data = mouse_reporting();
2584 ret = __put_user(data, p); 2584 ret = __put_user(data, p);
2585 break; 2585 break;
2586 case TIOCL_SETVESABLANK: 2586 case TIOCL_SETVESABLANK:
2587 ret = set_vesa_blanking(p); 2587 ret = set_vesa_blanking(p);
2588 break; 2588 break;
2589 case TIOCL_GETKMSGREDIRECT: 2589 case TIOCL_GETKMSGREDIRECT:
2590 data = kmsg_redirect; 2590 data = kmsg_redirect;
2591 ret = __put_user(data, p); 2591 ret = __put_user(data, p);
2592 break; 2592 break;
2593 case TIOCL_SETKMSGREDIRECT: 2593 case TIOCL_SETKMSGREDIRECT:
2594 if (!capable(CAP_SYS_ADMIN)) { 2594 if (!capable(CAP_SYS_ADMIN)) {
2595 ret = -EPERM; 2595 ret = -EPERM;
2596 } else { 2596 } else {
2597 if (get_user(data, p+1)) 2597 if (get_user(data, p+1))
2598 ret = -EFAULT; 2598 ret = -EFAULT;
2599 else 2599 else
2600 kmsg_redirect = data; 2600 kmsg_redirect = data;
2601 } 2601 }
2602 break; 2602 break;
2603 case TIOCL_GETFGCONSOLE: 2603 case TIOCL_GETFGCONSOLE:
2604 ret = fg_console; 2604 ret = fg_console;
2605 break; 2605 break;
2606 case TIOCL_SCROLLCONSOLE: 2606 case TIOCL_SCROLLCONSOLE:
2607 if (get_user(lines, (s32 __user *)(p+4))) { 2607 if (get_user(lines, (s32 __user *)(p+4))) {
2608 ret = -EFAULT; 2608 ret = -EFAULT;
2609 } else { 2609 } else {
2610 scrollfront(vc_cons[fg_console].d, lines); 2610 scrollfront(vc_cons[fg_console].d, lines);
2611 ret = 0; 2611 ret = 0;
2612 } 2612 }
2613 break; 2613 break;
2614 case TIOCL_BLANKSCREEN: /* until explicitly unblanked, not only poked */ 2614 case TIOCL_BLANKSCREEN: /* until explicitly unblanked, not only poked */
2615 acquire_console_sem(); 2615 acquire_console_sem();
2616 ignore_poke = 1; 2616 ignore_poke = 1;
2617 do_blank_screen(0); 2617 do_blank_screen(0);
2618 release_console_sem(); 2618 release_console_sem();
2619 break; 2619 break;
2620 case TIOCL_BLANKEDSCREEN: 2620 case TIOCL_BLANKEDSCREEN:
2621 ret = console_blanked; 2621 ret = console_blanked;
2622 break; 2622 break;
2623 default: 2623 default:
2624 ret = -EINVAL; 2624 ret = -EINVAL;
2625 break; 2625 break;
2626 } 2626 }
2627 unlock_kernel(); 2627 unlock_kernel();
2628 return ret; 2628 return ret;
2629 } 2629 }
2630 2630
2631 /* 2631 /*
2632 * /dev/ttyN handling 2632 * /dev/ttyN handling
2633 */ 2633 */
2634 2634
2635 static int con_write(struct tty_struct *tty, const unsigned char *buf, int count) 2635 static int con_write(struct tty_struct *tty, const unsigned char *buf, int count)
2636 { 2636 {
2637 int retval; 2637 int retval;
2638 2638
2639 retval = do_con_write(tty, buf, count); 2639 retval = do_con_write(tty, buf, count);
2640 con_flush_chars(tty); 2640 con_flush_chars(tty);
2641 2641
2642 return retval; 2642 return retval;
2643 } 2643 }
2644 2644
2645 static int con_put_char(struct tty_struct *tty, unsigned char ch) 2645 static int con_put_char(struct tty_struct *tty, unsigned char ch)
2646 { 2646 {
2647 if (in_interrupt()) 2647 if (in_interrupt())
2648 return 0; /* n_r3964 calls put_char() from interrupt context */ 2648 return 0; /* n_r3964 calls put_char() from interrupt context */
2649 return do_con_write(tty, &ch, 1); 2649 return do_con_write(tty, &ch, 1);
2650 } 2650 }
2651 2651
2652 static int con_write_room(struct tty_struct *tty) 2652 static int con_write_room(struct tty_struct *tty)
2653 { 2653 {
2654 if (tty->stopped) 2654 if (tty->stopped)
2655 return 0; 2655 return 0;
2656 return 4096; /* No limit, really; we're not buffering */ 2656 return 4096; /* No limit, really; we're not buffering */
2657 } 2657 }
2658 2658
2659 static int con_chars_in_buffer(struct tty_struct *tty) 2659 static int con_chars_in_buffer(struct tty_struct *tty)
2660 { 2660 {
2661 return 0; /* we're not buffering */ 2661 return 0; /* we're not buffering */
2662 } 2662 }
2663 2663
2664 /* 2664 /*
2665 * con_throttle and con_unthrottle are only used for 2665 * con_throttle and con_unthrottle are only used for
2666 * paste_selection(), which has to stuff in a large number of 2666 * paste_selection(), which has to stuff in a large number of
2667 * characters... 2667 * characters...
2668 */ 2668 */
2669 static void con_throttle(struct tty_struct *tty) 2669 static void con_throttle(struct tty_struct *tty)
2670 { 2670 {
2671 } 2671 }
2672 2672
2673 static void con_unthrottle(struct tty_struct *tty) 2673 static void con_unthrottle(struct tty_struct *tty)
2674 { 2674 {
2675 struct vc_data *vc = tty->driver_data; 2675 struct vc_data *vc = tty->driver_data;
2676 2676
2677 wake_up_interruptible(&vc->paste_wait); 2677 wake_up_interruptible(&vc->paste_wait);
2678 } 2678 }
2679 2679
2680 /* 2680 /*
2681 * Turn the Scroll-Lock LED on when the tty is stopped 2681 * Turn the Scroll-Lock LED on when the tty is stopped
2682 */ 2682 */
2683 static void con_stop(struct tty_struct *tty) 2683 static void con_stop(struct tty_struct *tty)
2684 { 2684 {
2685 int console_num; 2685 int console_num;
2686 if (!tty) 2686 if (!tty)
2687 return; 2687 return;
2688 console_num = tty->index; 2688 console_num = tty->index;
2689 if (!vc_cons_allocated(console_num)) 2689 if (!vc_cons_allocated(console_num))
2690 return; 2690 return;
2691 set_vc_kbd_led(kbd_table + console_num, VC_SCROLLOCK); 2691 set_vc_kbd_led(kbd_table + console_num, VC_SCROLLOCK);
2692 set_leds(); 2692 set_leds();
2693 } 2693 }
2694 2694
2695 /* 2695 /*
2696 * Turn the Scroll-Lock LED off when the console is started 2696 * Turn the Scroll-Lock LED off when the console is started
2697 */ 2697 */
2698 static void con_start(struct tty_struct *tty) 2698 static void con_start(struct tty_struct *tty)
2699 { 2699 {
2700 int console_num; 2700 int console_num;
2701 if (!tty) 2701 if (!tty)
2702 return; 2702 return;
2703 console_num = tty->index; 2703 console_num = tty->index;
2704 if (!vc_cons_allocated(console_num)) 2704 if (!vc_cons_allocated(console_num))
2705 return; 2705 return;
2706 clr_vc_kbd_led(kbd_table + console_num, VC_SCROLLOCK); 2706 clr_vc_kbd_led(kbd_table + console_num, VC_SCROLLOCK);
2707 set_leds(); 2707 set_leds();
2708 } 2708 }
2709 2709
2710 static void con_flush_chars(struct tty_struct *tty) 2710 static void con_flush_chars(struct tty_struct *tty)
2711 { 2711 {
2712 struct vc_data *vc; 2712 struct vc_data *vc;
2713 2713
2714 if (in_interrupt()) /* from flush_to_ldisc */ 2714 if (in_interrupt()) /* from flush_to_ldisc */
2715 return; 2715 return;
2716 2716
2717 /* if we race with con_close(), vt may be null */ 2717 /* if we race with con_close(), vt may be null */
2718 acquire_console_sem(); 2718 acquire_console_sem();
2719 vc = tty->driver_data; 2719 vc = tty->driver_data;
2720 if (vc) 2720 if (vc)
2721 set_cursor(vc); 2721 set_cursor(vc);
2722 release_console_sem(); 2722 release_console_sem();
2723 } 2723 }
2724 2724
2725 /* 2725 /*
2726 * Allocate the console screen memory. 2726 * Allocate the console screen memory.
2727 */ 2727 */
2728 static int con_open(struct tty_struct *tty, struct file *filp) 2728 static int con_open(struct tty_struct *tty, struct file *filp)
2729 { 2729 {
2730 unsigned int currcons = tty->index; 2730 unsigned int currcons = tty->index;
2731 int ret = 0; 2731 int ret = 0;
2732 2732
2733 acquire_console_sem(); 2733 acquire_console_sem();
2734 if (tty->driver_data == NULL) { 2734 if (tty->driver_data == NULL) {
2735 ret = vc_allocate(currcons); 2735 ret = vc_allocate(currcons);
2736 if (ret == 0) { 2736 if (ret == 0) {
2737 struct vc_data *vc = vc_cons[currcons].d; 2737 struct vc_data *vc = vc_cons[currcons].d;
2738 tty->driver_data = vc; 2738 tty->driver_data = vc;
2739 vc->vc_tty = tty; 2739 vc->vc_tty = tty;
2740 2740
2741 if (!tty->winsize.ws_row && !tty->winsize.ws_col) { 2741 if (!tty->winsize.ws_row && !tty->winsize.ws_col) {
2742 tty->winsize.ws_row = vc_cons[currcons].d->vc_rows; 2742 tty->winsize.ws_row = vc_cons[currcons].d->vc_rows;
2743 tty->winsize.ws_col = vc_cons[currcons].d->vc_cols; 2743 tty->winsize.ws_col = vc_cons[currcons].d->vc_cols;
2744 } 2744 }
2745 if (vc->vc_utf) 2745 if (vc->vc_utf)
2746 tty->termios->c_iflag |= IUTF8; 2746 tty->termios->c_iflag |= IUTF8;
2747 else 2747 else
2748 tty->termios->c_iflag &= ~IUTF8; 2748 tty->termios->c_iflag &= ~IUTF8;
2749 release_console_sem(); 2749 release_console_sem();
2750 vcs_make_sysfs(tty); 2750 vcs_make_sysfs(tty);
2751 return ret; 2751 return ret;
2752 } 2752 }
2753 } 2753 }
2754 release_console_sem(); 2754 release_console_sem();
2755 return ret; 2755 return ret;
2756 } 2756 }
2757 2757
2758 /* 2758 /*
2759 * We take tty_mutex in here to prevent another thread from coming in via init_dev 2759 * We take tty_mutex in here to prevent another thread from coming in via init_dev
2760 * and taking a ref against the tty while we're in the process of forgetting 2760 * and taking a ref against the tty while we're in the process of forgetting
2761 * about it and cleaning things up. 2761 * about it and cleaning things up.
2762 * 2762 *
2763 * This is because vcs_remove_sysfs() can sleep and will drop the BKL. 2763 * This is because vcs_remove_sysfs() can sleep and will drop the BKL.
2764 */ 2764 */
2765 static void con_close(struct tty_struct *tty, struct file *filp) 2765 static void con_close(struct tty_struct *tty, struct file *filp)
2766 { 2766 {
2767 mutex_lock(&tty_mutex); 2767 mutex_lock(&tty_mutex);
2768 acquire_console_sem(); 2768 acquire_console_sem();
2769 if (tty && tty->count == 1) { 2769 if (tty && tty->count == 1) {
2770 struct vc_data *vc = tty->driver_data; 2770 struct vc_data *vc = tty->driver_data;
2771 2771
2772 if (vc) 2772 if (vc)
2773 vc->vc_tty = NULL; 2773 vc->vc_tty = NULL;
2774 tty->driver_data = NULL; 2774 tty->driver_data = NULL;
2775 release_console_sem(); 2775 release_console_sem();
2776 vcs_remove_sysfs(tty); 2776 vcs_remove_sysfs(tty);
2777 mutex_unlock(&tty_mutex); 2777 mutex_unlock(&tty_mutex);
2778 /* 2778 /*
2779 * tty_mutex is released, but we still hold BKL, so there is 2779 * tty_mutex is released, but we still hold BKL, so there is
2780 * still exclusion against init_dev() 2780 * still exclusion against init_dev()
2781 */ 2781 */
2782 return; 2782 return;
2783 } 2783 }
2784 release_console_sem(); 2784 release_console_sem();
2785 mutex_unlock(&tty_mutex); 2785 mutex_unlock(&tty_mutex);
2786 } 2786 }
2787 2787
2788 static int default_italic_color = 2; // green (ASCII) 2788 static int default_italic_color = 2; // green (ASCII)
2789 static int default_underline_color = 3; // cyan (ASCII) 2789 static int default_underline_color = 3; // cyan (ASCII)
2790 module_param_named(italic, default_italic_color, int, S_IRUGO | S_IWUSR); 2790 module_param_named(italic, default_italic_color, int, S_IRUGO | S_IWUSR);
2791 module_param_named(underline, default_underline_color, int, S_IRUGO | S_IWUSR); 2791 module_param_named(underline, default_underline_color, int, S_IRUGO | S_IWUSR);
2792 2792
2793 static void vc_init(struct vc_data *vc, unsigned int rows, 2793 static void vc_init(struct vc_data *vc, unsigned int rows,
2794 unsigned int cols, int do_clear) 2794 unsigned int cols, int do_clear)
2795 { 2795 {
2796 int j, k ; 2796 int j, k ;
2797 2797
2798 vc->vc_cols = cols; 2798 vc->vc_cols = cols;
2799 vc->vc_rows = rows; 2799 vc->vc_rows = rows;
2800 vc->vc_size_row = cols << 1; 2800 vc->vc_size_row = cols << 1;
2801 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row; 2801 vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row;
2802 2802
2803 set_origin(vc); 2803 set_origin(vc);
2804 vc->vc_pos = vc->vc_origin; 2804 vc->vc_pos = vc->vc_origin;
2805 reset_vc(vc); 2805 reset_vc(vc);
2806 for (j=k=0; j<16; j++) { 2806 for (j=k=0; j<16; j++) {
2807 vc->vc_palette[k++] = default_red[j] ; 2807 vc->vc_palette[k++] = default_red[j] ;
2808 vc->vc_palette[k++] = default_grn[j] ; 2808 vc->vc_palette[k++] = default_grn[j] ;
2809 vc->vc_palette[k++] = default_blu[j] ; 2809 vc->vc_palette[k++] = default_blu[j] ;
2810 } 2810 }
2811 vc->vc_def_color = 0x07; /* white */ 2811 vc->vc_def_color = 0x07; /* white */
2812 vc->vc_ulcolor = default_underline_color; 2812 vc->vc_ulcolor = default_underline_color;
2813 vc->vc_itcolor = default_italic_color; 2813 vc->vc_itcolor = default_italic_color;
2814 vc->vc_halfcolor = 0x08; /* grey */ 2814 vc->vc_halfcolor = 0x08; /* grey */
2815 init_waitqueue_head(&vc->paste_wait); 2815 init_waitqueue_head(&vc->paste_wait);
2816 reset_terminal(vc, do_clear); 2816 reset_terminal(vc, do_clear);
2817 } 2817 }
2818 2818
2819 /* 2819 /*
2820 * This routine initializes console interrupts, and does nothing 2820 * This routine initializes console interrupts, and does nothing
2821 * else. If you want the screen to clear, call tty_write with 2821 * else. If you want the screen to clear, call tty_write with
2822 * the appropriate escape-sequence. 2822 * the appropriate escape-sequence.
2823 */ 2823 */
2824 2824
2825 static int __init con_init(void) 2825 static int __init con_init(void)
2826 { 2826 {
2827 const char *display_desc = NULL; 2827 const char *display_desc = NULL;
2828 struct vc_data *vc; 2828 struct vc_data *vc;
2829 unsigned int currcons = 0, i; 2829 unsigned int currcons = 0, i;
2830 2830
2831 acquire_console_sem(); 2831 acquire_console_sem();
2832 2832
2833 if (conswitchp) 2833 if (conswitchp)
2834 display_desc = conswitchp->con_startup(); 2834 display_desc = conswitchp->con_startup();
2835 if (!display_desc) { 2835 if (!display_desc) {
2836 fg_console = 0; 2836 fg_console = 0;
2837 release_console_sem(); 2837 release_console_sem();
2838 return 0; 2838 return 0;
2839 } 2839 }
2840 2840
2841 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 2841 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
2842 struct con_driver *con_driver = &registered_con_driver[i]; 2842 struct con_driver *con_driver = &registered_con_driver[i];
2843 2843
2844 if (con_driver->con == NULL) { 2844 if (con_driver->con == NULL) {
2845 con_driver->con = conswitchp; 2845 con_driver->con = conswitchp;
2846 con_driver->desc = display_desc; 2846 con_driver->desc = display_desc;
2847 con_driver->flag = CON_DRIVER_FLAG_INIT; 2847 con_driver->flag = CON_DRIVER_FLAG_INIT;
2848 con_driver->first = 0; 2848 con_driver->first = 0;
2849 con_driver->last = MAX_NR_CONSOLES - 1; 2849 con_driver->last = MAX_NR_CONSOLES - 1;
2850 break; 2850 break;
2851 } 2851 }
2852 } 2852 }
2853 2853
2854 for (i = 0; i < MAX_NR_CONSOLES; i++) 2854 for (i = 0; i < MAX_NR_CONSOLES; i++)
2855 con_driver_map[i] = conswitchp; 2855 con_driver_map[i] = conswitchp;
2856 2856
2857 if (blankinterval) { 2857 if (blankinterval) {
2858 blank_state = blank_normal_wait; 2858 blank_state = blank_normal_wait;
2859 mod_timer(&console_timer, jiffies + blankinterval); 2859 mod_timer(&console_timer, jiffies + blankinterval);
2860 } 2860 }
2861 2861
2862 /* 2862 /*
2863 * kmalloc is not running yet - we use the bootmem allocator. 2863 * kmalloc is not running yet - we use the bootmem allocator.
2864 */ 2864 */
2865 for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) { 2865 for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) {
2866 vc_cons[currcons].d = vc = alloc_bootmem(sizeof(struct vc_data)); 2866 vc_cons[currcons].d = vc = alloc_bootmem(sizeof(struct vc_data));
2867 INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK); 2867 INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK);
2868 visual_init(vc, currcons, 1); 2868 visual_init(vc, currcons, 1);
2869 vc->vc_screenbuf = (unsigned short *)alloc_bootmem(vc->vc_screenbuf_size); 2869 vc->vc_screenbuf = (unsigned short *)alloc_bootmem(vc->vc_screenbuf_size);
2870 vc->vc_kmalloced = 0; 2870 vc->vc_kmalloced = 0;
2871 vc_init(vc, vc->vc_rows, vc->vc_cols, 2871 vc_init(vc, vc->vc_rows, vc->vc_cols,
2872 currcons || !vc->vc_sw->con_save_screen); 2872 currcons || !vc->vc_sw->con_save_screen);
2873 } 2873 }
2874 currcons = fg_console = 0; 2874 currcons = fg_console = 0;
2875 master_display_fg = vc = vc_cons[currcons].d; 2875 master_display_fg = vc = vc_cons[currcons].d;
2876 set_origin(vc); 2876 set_origin(vc);
2877 save_screen(vc); 2877 save_screen(vc);
2878 gotoxy(vc, vc->vc_x, vc->vc_y); 2878 gotoxy(vc, vc->vc_x, vc->vc_y);
2879 csi_J(vc, 0); 2879 csi_J(vc, 0);
2880 update_screen(vc); 2880 update_screen(vc);
2881 printk("Console: %s %s %dx%d", 2881 printk("Console: %s %s %dx%d",
2882 vc->vc_can_do_color ? "colour" : "mono", 2882 vc->vc_can_do_color ? "colour" : "mono",
2883 display_desc, vc->vc_cols, vc->vc_rows); 2883 display_desc, vc->vc_cols, vc->vc_rows);
2884 printable = 1; 2884 printable = 1;
2885 printk("\n"); 2885 printk("\n");
2886 2886
2887 release_console_sem(); 2887 release_console_sem();
2888 2888
2889 #ifdef CONFIG_VT_CONSOLE 2889 #ifdef CONFIG_VT_CONSOLE
2890 register_console(&vt_console_driver); 2890 register_console(&vt_console_driver);
2891 #endif 2891 #endif
2892 return 0; 2892 return 0;
2893 } 2893 }
2894 console_initcall(con_init); 2894 console_initcall(con_init);
2895 2895
2896 static const struct tty_operations con_ops = { 2896 static const struct tty_operations con_ops = {
2897 .open = con_open, 2897 .open = con_open,
2898 .close = con_close, 2898 .close = con_close,
2899 .write = con_write, 2899 .write = con_write,
2900 .write_room = con_write_room, 2900 .write_room = con_write_room,
2901 .put_char = con_put_char, 2901 .put_char = con_put_char,
2902 .flush_chars = con_flush_chars, 2902 .flush_chars = con_flush_chars,
2903 .chars_in_buffer = con_chars_in_buffer, 2903 .chars_in_buffer = con_chars_in_buffer,
2904 .ioctl = vt_ioctl, 2904 .ioctl = vt_ioctl,
2905 .stop = con_stop, 2905 .stop = con_stop,
2906 .start = con_start, 2906 .start = con_start,
2907 .throttle = con_throttle, 2907 .throttle = con_throttle,
2908 .unthrottle = con_unthrottle, 2908 .unthrottle = con_unthrottle,
2909 }; 2909 };
2910 2910
2911 int __init vty_init(void) 2911 int __init vty_init(void)
2912 { 2912 {
2913 vcs_init(); 2913 vcs_init();
2914 2914
2915 console_driver = alloc_tty_driver(MAX_NR_CONSOLES); 2915 console_driver = alloc_tty_driver(MAX_NR_CONSOLES);
2916 if (!console_driver) 2916 if (!console_driver)
2917 panic("Couldn't allocate console driver\n"); 2917 panic("Couldn't allocate console driver\n");
2918 console_driver->owner = THIS_MODULE; 2918 console_driver->owner = THIS_MODULE;
2919 console_driver->name = "tty"; 2919 console_driver->name = "tty";
2920 console_driver->name_base = 1; 2920 console_driver->name_base = 1;
2921 console_driver->major = TTY_MAJOR; 2921 console_driver->major = TTY_MAJOR;
2922 console_driver->minor_start = 1; 2922 console_driver->minor_start = 1;
2923 console_driver->type = TTY_DRIVER_TYPE_CONSOLE; 2923 console_driver->type = TTY_DRIVER_TYPE_CONSOLE;
2924 console_driver->init_termios = tty_std_termios; 2924 console_driver->init_termios = tty_std_termios;
2925 if (default_utf8) 2925 if (default_utf8)
2926 console_driver->init_termios.c_iflag |= IUTF8; 2926 console_driver->init_termios.c_iflag |= IUTF8;
2927 console_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS; 2927 console_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS;
2928 tty_set_operations(console_driver, &con_ops); 2928 tty_set_operations(console_driver, &con_ops);
2929 if (tty_register_driver(console_driver)) 2929 if (tty_register_driver(console_driver))
2930 panic("Couldn't register console driver\n"); 2930 panic("Couldn't register console driver\n");
2931 2931
2932 kbd_init(); 2932 kbd_init();
2933 console_map_init(); 2933 console_map_init();
2934 #ifdef CONFIG_PROM_CONSOLE 2934 #ifdef CONFIG_PROM_CONSOLE
2935 prom_con_init(); 2935 prom_con_init();
2936 #endif 2936 #endif
2937 #ifdef CONFIG_MDA_CONSOLE 2937 #ifdef CONFIG_MDA_CONSOLE
2938 mda_console_init(); 2938 mda_console_init();
2939 #endif 2939 #endif
2940 return 0; 2940 return 0;
2941 } 2941 }
2942 2942
2943 #ifndef VT_SINGLE_DRIVER 2943 #ifndef VT_SINGLE_DRIVER
2944 #include <linux/device.h> 2944 #include <linux/device.h>
2945 2945
2946 static struct class *vtconsole_class; 2946 static struct class *vtconsole_class;
2947 2947
2948 static int bind_con_driver(const struct consw *csw, int first, int last, 2948 static int bind_con_driver(const struct consw *csw, int first, int last,
2949 int deflt) 2949 int deflt)
2950 { 2950 {
2951 struct module *owner = csw->owner; 2951 struct module *owner = csw->owner;
2952 const char *desc = NULL; 2952 const char *desc = NULL;
2953 struct con_driver *con_driver; 2953 struct con_driver *con_driver;
2954 int i, j = -1, k = -1, retval = -ENODEV; 2954 int i, j = -1, k = -1, retval = -ENODEV;
2955 2955
2956 if (!try_module_get(owner)) 2956 if (!try_module_get(owner))
2957 return -ENODEV; 2957 return -ENODEV;
2958 2958
2959 acquire_console_sem(); 2959 acquire_console_sem();
2960 2960
2961 /* check if driver is registered */ 2961 /* check if driver is registered */
2962 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 2962 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
2963 con_driver = &registered_con_driver[i]; 2963 con_driver = &registered_con_driver[i];
2964 2964
2965 if (con_driver->con == csw) { 2965 if (con_driver->con == csw) {
2966 desc = con_driver->desc; 2966 desc = con_driver->desc;
2967 retval = 0; 2967 retval = 0;
2968 break; 2968 break;
2969 } 2969 }
2970 } 2970 }
2971 2971
2972 if (retval) 2972 if (retval)
2973 goto err; 2973 goto err;
2974 2974
2975 if (!(con_driver->flag & CON_DRIVER_FLAG_INIT)) { 2975 if (!(con_driver->flag & CON_DRIVER_FLAG_INIT)) {
2976 csw->con_startup(); 2976 csw->con_startup();
2977 con_driver->flag |= CON_DRIVER_FLAG_INIT; 2977 con_driver->flag |= CON_DRIVER_FLAG_INIT;
2978 } 2978 }
2979 2979
2980 if (deflt) { 2980 if (deflt) {
2981 if (conswitchp) 2981 if (conswitchp)
2982 module_put(conswitchp->owner); 2982 module_put(conswitchp->owner);
2983 2983
2984 __module_get(owner); 2984 __module_get(owner);
2985 conswitchp = csw; 2985 conswitchp = csw;
2986 } 2986 }
2987 2987
2988 first = max(first, con_driver->first); 2988 first = max(first, con_driver->first);
2989 last = min(last, con_driver->last); 2989 last = min(last, con_driver->last);
2990 2990
2991 for (i = first; i <= last; i++) { 2991 for (i = first; i <= last; i++) {
2992 int old_was_color; 2992 int old_was_color;
2993 struct vc_data *vc = vc_cons[i].d; 2993 struct vc_data *vc = vc_cons[i].d;
2994 2994
2995 if (con_driver_map[i]) 2995 if (con_driver_map[i])
2996 module_put(con_driver_map[i]->owner); 2996 module_put(con_driver_map[i]->owner);
2997 __module_get(owner); 2997 __module_get(owner);
2998 con_driver_map[i] = csw; 2998 con_driver_map[i] = csw;
2999 2999
3000 if (!vc || !vc->vc_sw) 3000 if (!vc || !vc->vc_sw)
3001 continue; 3001 continue;
3002 3002
3003 j = i; 3003 j = i;
3004 3004
3005 if (CON_IS_VISIBLE(vc)) { 3005 if (CON_IS_VISIBLE(vc)) {
3006 k = i; 3006 k = i;
3007 save_screen(vc); 3007 save_screen(vc);
3008 } 3008 }
3009 3009
3010 old_was_color = vc->vc_can_do_color; 3010 old_was_color = vc->vc_can_do_color;
3011 vc->vc_sw->con_deinit(vc); 3011 vc->vc_sw->con_deinit(vc);
3012 vc->vc_origin = (unsigned long)vc->vc_screenbuf; 3012 vc->vc_origin = (unsigned long)vc->vc_screenbuf;
3013 visual_init(vc, i, 0); 3013 visual_init(vc, i, 0);
3014 set_origin(vc); 3014 set_origin(vc);
3015 update_attr(vc); 3015 update_attr(vc);
3016 3016
3017 /* If the console changed between mono <-> color, then 3017 /* If the console changed between mono <-> color, then
3018 * the attributes in the screenbuf will be wrong. The 3018 * the attributes in the screenbuf will be wrong. The
3019 * following resets all attributes to something sane. 3019 * following resets all attributes to something sane.
3020 */ 3020 */
3021 if (old_was_color != vc->vc_can_do_color) 3021 if (old_was_color != vc->vc_can_do_color)
3022 clear_buffer_attributes(vc); 3022 clear_buffer_attributes(vc);
3023 } 3023 }
3024 3024
3025 printk("Console: switching "); 3025 printk("Console: switching ");
3026 if (!deflt) 3026 if (!deflt)
3027 printk("consoles %d-%d ", first+1, last+1); 3027 printk("consoles %d-%d ", first+1, last+1);
3028 if (j >= 0) { 3028 if (j >= 0) {
3029 struct vc_data *vc = vc_cons[j].d; 3029 struct vc_data *vc = vc_cons[j].d;
3030 3030
3031 printk("to %s %s %dx%d\n", 3031 printk("to %s %s %dx%d\n",
3032 vc->vc_can_do_color ? "colour" : "mono", 3032 vc->vc_can_do_color ? "colour" : "mono",
3033 desc, vc->vc_cols, vc->vc_rows); 3033 desc, vc->vc_cols, vc->vc_rows);
3034 3034
3035 if (k >= 0) { 3035 if (k >= 0) {
3036 vc = vc_cons[k].d; 3036 vc = vc_cons[k].d;
3037 update_screen(vc); 3037 update_screen(vc);
3038 } 3038 }
3039 } else 3039 } else
3040 printk("to %s\n", desc); 3040 printk("to %s\n", desc);
3041 3041
3042 retval = 0; 3042 retval = 0;
3043 err: 3043 err:
3044 release_console_sem(); 3044 release_console_sem();
3045 module_put(owner); 3045 module_put(owner);
3046 return retval; 3046 return retval;
3047 }; 3047 };
3048 3048
3049 #ifdef CONFIG_VT_HW_CONSOLE_BINDING 3049 #ifdef CONFIG_VT_HW_CONSOLE_BINDING
3050 static int con_is_graphics(const struct consw *csw, int first, int last) 3050 static int con_is_graphics(const struct consw *csw, int first, int last)
3051 { 3051 {
3052 int i, retval = 0; 3052 int i, retval = 0;
3053 3053
3054 for (i = first; i <= last; i++) { 3054 for (i = first; i <= last; i++) {
3055 struct vc_data *vc = vc_cons[i].d; 3055 struct vc_data *vc = vc_cons[i].d;
3056 3056
3057 if (vc && vc->vc_mode == KD_GRAPHICS) { 3057 if (vc && vc->vc_mode == KD_GRAPHICS) {
3058 retval = 1; 3058 retval = 1;
3059 break; 3059 break;
3060 } 3060 }
3061 } 3061 }
3062 3062
3063 return retval; 3063 return retval;
3064 } 3064 }
3065 3065
3066 /** 3066 /**
3067 * unbind_con_driver - unbind a console driver 3067 * unbind_con_driver - unbind a console driver
3068 * @csw: pointer to console driver to unregister 3068 * @csw: pointer to console driver to unregister
3069 * @first: first in range of consoles that @csw should be unbound from 3069 * @first: first in range of consoles that @csw should be unbound from
3070 * @last: last in range of consoles that @csw should be unbound from 3070 * @last: last in range of consoles that @csw should be unbound from
3071 * @deflt: should next bound console driver be default after @csw is unbound? 3071 * @deflt: should next bound console driver be default after @csw is unbound?
3072 * 3072 *
3073 * To unbind a driver from all possible consoles, pass 0 as @first and 3073 * To unbind a driver from all possible consoles, pass 0 as @first and
3074 * %MAX_NR_CONSOLES as @last. 3074 * %MAX_NR_CONSOLES as @last.
3075 * 3075 *
3076 * @deflt controls whether the console that ends up replacing @csw should be 3076 * @deflt controls whether the console that ends up replacing @csw should be
3077 * the default console. 3077 * the default console.
3078 * 3078 *
3079 * RETURNS: 3079 * RETURNS:
3080 * -ENODEV if @csw isn't a registered console driver or can't be unregistered 3080 * -ENODEV if @csw isn't a registered console driver or can't be unregistered
3081 * or 0 on success. 3081 * or 0 on success.
3082 */ 3082 */
3083 int unbind_con_driver(const struct consw *csw, int first, int last, int deflt) 3083 int unbind_con_driver(const struct consw *csw, int first, int last, int deflt)
3084 { 3084 {
3085 struct module *owner = csw->owner; 3085 struct module *owner = csw->owner;
3086 const struct consw *defcsw = NULL; 3086 const struct consw *defcsw = NULL;
3087 struct con_driver *con_driver = NULL, *con_back = NULL; 3087 struct con_driver *con_driver = NULL, *con_back = NULL;
3088 int i, retval = -ENODEV; 3088 int i, retval = -ENODEV;
3089 3089
3090 if (!try_module_get(owner)) 3090 if (!try_module_get(owner))
3091 return -ENODEV; 3091 return -ENODEV;
3092 3092
3093 acquire_console_sem(); 3093 acquire_console_sem();
3094 3094
3095 /* check if driver is registered and if it is unbindable */ 3095 /* check if driver is registered and if it is unbindable */
3096 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3096 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
3097 con_driver = &registered_con_driver[i]; 3097 con_driver = &registered_con_driver[i];
3098 3098
3099 if (con_driver->con == csw && 3099 if (con_driver->con == csw &&
3100 con_driver->flag & CON_DRIVER_FLAG_MODULE) { 3100 con_driver->flag & CON_DRIVER_FLAG_MODULE) {
3101 retval = 0; 3101 retval = 0;
3102 break; 3102 break;
3103 } 3103 }
3104 } 3104 }
3105 3105
3106 if (retval) { 3106 if (retval) {
3107 release_console_sem(); 3107 release_console_sem();
3108 goto err; 3108 goto err;
3109 } 3109 }
3110 3110
3111 retval = -ENODEV; 3111 retval = -ENODEV;
3112 3112
3113 /* check if backup driver exists */ 3113 /* check if backup driver exists */
3114 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3114 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
3115 con_back = &registered_con_driver[i]; 3115 con_back = &registered_con_driver[i];
3116 3116
3117 if (con_back->con && 3117 if (con_back->con &&
3118 !(con_back->flag & CON_DRIVER_FLAG_MODULE)) { 3118 !(con_back->flag & CON_DRIVER_FLAG_MODULE)) {
3119 defcsw = con_back->con; 3119 defcsw = con_back->con;
3120 retval = 0; 3120 retval = 0;
3121 break; 3121 break;
3122 } 3122 }
3123 } 3123 }
3124 3124
3125 if (retval) { 3125 if (retval) {
3126 release_console_sem(); 3126 release_console_sem();
3127 goto err; 3127 goto err;
3128 } 3128 }
3129 3129
3130 if (!con_is_bound(csw)) { 3130 if (!con_is_bound(csw)) {
3131 release_console_sem(); 3131 release_console_sem();
3132 goto err; 3132 goto err;
3133 } 3133 }
3134 3134
3135 first = max(first, con_driver->first); 3135 first = max(first, con_driver->first);
3136 last = min(last, con_driver->last); 3136 last = min(last, con_driver->last);
3137 3137
3138 for (i = first; i <= last; i++) { 3138 for (i = first; i <= last; i++) {
3139 if (con_driver_map[i] == csw) { 3139 if (con_driver_map[i] == csw) {
3140 module_put(csw->owner); 3140 module_put(csw->owner);
3141 con_driver_map[i] = NULL; 3141 con_driver_map[i] = NULL;
3142 } 3142 }
3143 } 3143 }
3144 3144
3145 if (!con_is_bound(defcsw)) { 3145 if (!con_is_bound(defcsw)) {
3146 const struct consw *defconsw = conswitchp; 3146 const struct consw *defconsw = conswitchp;
3147 3147
3148 defcsw->con_startup(); 3148 defcsw->con_startup();
3149 con_back->flag |= CON_DRIVER_FLAG_INIT; 3149 con_back->flag |= CON_DRIVER_FLAG_INIT;
3150 /* 3150 /*
3151 * vgacon may change the default driver to point 3151 * vgacon may change the default driver to point
3152 * to dummycon, we restore it here... 3152 * to dummycon, we restore it here...
3153 */ 3153 */
3154 conswitchp = defconsw; 3154 conswitchp = defconsw;
3155 } 3155 }
3156 3156
3157 if (!con_is_bound(csw)) 3157 if (!con_is_bound(csw))
3158 con_driver->flag &= ~CON_DRIVER_FLAG_INIT; 3158 con_driver->flag &= ~CON_DRIVER_FLAG_INIT;
3159 3159
3160 release_console_sem(); 3160 release_console_sem();
3161 /* ignore return value, binding should not fail */ 3161 /* ignore return value, binding should not fail */
3162 bind_con_driver(defcsw, first, last, deflt); 3162 bind_con_driver(defcsw, first, last, deflt);
3163 err: 3163 err:
3164 module_put(owner); 3164 module_put(owner);
3165 return retval; 3165 return retval;
3166 3166
3167 } 3167 }
3168 EXPORT_SYMBOL(unbind_con_driver); 3168 EXPORT_SYMBOL(unbind_con_driver);
3169 3169
3170 static int vt_bind(struct con_driver *con) 3170 static int vt_bind(struct con_driver *con)
3171 { 3171 {
3172 const struct consw *defcsw = NULL, *csw = NULL; 3172 const struct consw *defcsw = NULL, *csw = NULL;
3173 int i, more = 1, first = -1, last = -1, deflt = 0; 3173 int i, more = 1, first = -1, last = -1, deflt = 0;
3174 3174
3175 if (!con->con || !(con->flag & CON_DRIVER_FLAG_MODULE) || 3175 if (!con->con || !(con->flag & CON_DRIVER_FLAG_MODULE) ||
3176 con_is_graphics(con->con, con->first, con->last)) 3176 con_is_graphics(con->con, con->first, con->last))
3177 goto err; 3177 goto err;
3178 3178
3179 csw = con->con; 3179 csw = con->con;
3180 3180
3181 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3181 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
3182 struct con_driver *con = &registered_con_driver[i]; 3182 struct con_driver *con = &registered_con_driver[i];
3183 3183
3184 if (con->con && !(con->flag & CON_DRIVER_FLAG_MODULE)) { 3184 if (con->con && !(con->flag & CON_DRIVER_FLAG_MODULE)) {
3185 defcsw = con->con; 3185 defcsw = con->con;
3186 break; 3186 break;
3187 } 3187 }
3188 } 3188 }
3189 3189
3190 if (!defcsw) 3190 if (!defcsw)
3191 goto err; 3191 goto err;
3192 3192
3193 while (more) { 3193 while (more) {
3194 more = 0; 3194 more = 0;
3195 3195
3196 for (i = con->first; i <= con->last; i++) { 3196 for (i = con->first; i <= con->last; i++) {
3197 if (con_driver_map[i] == defcsw) { 3197 if (con_driver_map[i] == defcsw) {
3198 if (first == -1) 3198 if (first == -1)
3199 first = i; 3199 first = i;
3200 last = i; 3200 last = i;
3201 more = 1; 3201 more = 1;
3202 } else if (first != -1) 3202 } else if (first != -1)
3203 break; 3203 break;
3204 } 3204 }
3205 3205
3206 if (first == 0 && last == MAX_NR_CONSOLES -1) 3206 if (first == 0 && last == MAX_NR_CONSOLES -1)
3207 deflt = 1; 3207 deflt = 1;
3208 3208
3209 if (first != -1) 3209 if (first != -1)
3210 bind_con_driver(csw, first, last, deflt); 3210 bind_con_driver(csw, first, last, deflt);
3211 3211
3212 first = -1; 3212 first = -1;
3213 last = -1; 3213 last = -1;
3214 deflt = 0; 3214 deflt = 0;
3215 } 3215 }
3216 3216
3217 err: 3217 err:
3218 return 0; 3218 return 0;
3219 } 3219 }
3220 3220
3221 static int vt_unbind(struct con_driver *con) 3221 static int vt_unbind(struct con_driver *con)
3222 { 3222 {
3223 const struct consw *csw = NULL; 3223 const struct consw *csw = NULL;
3224 int i, more = 1, first = -1, last = -1, deflt = 0; 3224 int i, more = 1, first = -1, last = -1, deflt = 0;
3225 3225
3226 if (!con->con || !(con->flag & CON_DRIVER_FLAG_MODULE) || 3226 if (!con->con || !(con->flag & CON_DRIVER_FLAG_MODULE) ||
3227 con_is_graphics(con->con, con->first, con->last)) 3227 con_is_graphics(con->con, con->first, con->last))
3228 goto err; 3228 goto err;
3229 3229
3230 csw = con->con; 3230 csw = con->con;
3231 3231
3232 while (more) { 3232 while (more) {
3233 more = 0; 3233 more = 0;
3234 3234
3235 for (i = con->first; i <= con->last; i++) { 3235 for (i = con->first; i <= con->last; i++) {
3236 if (con_driver_map[i] == csw) { 3236 if (con_driver_map[i] == csw) {
3237 if (first == -1) 3237 if (first == -1)
3238 first = i; 3238 first = i;
3239 last = i; 3239 last = i;
3240 more = 1; 3240 more = 1;
3241 } else if (first != -1) 3241 } else if (first != -1)
3242 break; 3242 break;
3243 } 3243 }
3244 3244
3245 if (first == 0 && last == MAX_NR_CONSOLES -1) 3245 if (first == 0 && last == MAX_NR_CONSOLES -1)
3246 deflt = 1; 3246 deflt = 1;
3247 3247
3248 if (first != -1) 3248 if (first != -1)
3249 unbind_con_driver(csw, first, last, deflt); 3249 unbind_con_driver(csw, first, last, deflt);
3250 3250
3251 first = -1; 3251 first = -1;
3252 last = -1; 3252 last = -1;
3253 deflt = 0; 3253 deflt = 0;
3254 } 3254 }
3255 3255
3256 err: 3256 err:
3257 return 0; 3257 return 0;
3258 } 3258 }
3259 #else 3259 #else
3260 static inline int vt_bind(struct con_driver *con) 3260 static inline int vt_bind(struct con_driver *con)
3261 { 3261 {
3262 return 0; 3262 return 0;
3263 } 3263 }
3264 static inline int vt_unbind(struct con_driver *con) 3264 static inline int vt_unbind(struct con_driver *con)
3265 { 3265 {
3266 return 0; 3266 return 0;
3267 } 3267 }
3268 #endif /* CONFIG_VT_HW_CONSOLE_BINDING */ 3268 #endif /* CONFIG_VT_HW_CONSOLE_BINDING */
3269 3269
3270 static ssize_t store_bind(struct device *dev, struct device_attribute *attr, 3270 static ssize_t store_bind(struct device *dev, struct device_attribute *attr,
3271 const char *buf, size_t count) 3271 const char *buf, size_t count)
3272 { 3272 {
3273 struct con_driver *con = dev_get_drvdata(dev); 3273 struct con_driver *con = dev_get_drvdata(dev);
3274 int bind = simple_strtoul(buf, NULL, 0); 3274 int bind = simple_strtoul(buf, NULL, 0);
3275 3275
3276 if (bind) 3276 if (bind)
3277 vt_bind(con); 3277 vt_bind(con);
3278 else 3278 else
3279 vt_unbind(con); 3279 vt_unbind(con);
3280 3280
3281 return count; 3281 return count;
3282 } 3282 }
3283 3283
3284 static ssize_t show_bind(struct device *dev, struct device_attribute *attr, 3284 static ssize_t show_bind(struct device *dev, struct device_attribute *attr,
3285 char *buf) 3285 char *buf)
3286 { 3286 {
3287 struct con_driver *con = dev_get_drvdata(dev); 3287 struct con_driver *con = dev_get_drvdata(dev);
3288 int bind = con_is_bound(con->con); 3288 int bind = con_is_bound(con->con);
3289 3289
3290 return snprintf(buf, PAGE_SIZE, "%i\n", bind); 3290 return snprintf(buf, PAGE_SIZE, "%i\n", bind);
3291 } 3291 }
3292 3292
3293 static ssize_t show_name(struct device *dev, struct device_attribute *attr, 3293 static ssize_t show_name(struct device *dev, struct device_attribute *attr,
3294 char *buf) 3294 char *buf)
3295 { 3295 {
3296 struct con_driver *con = dev_get_drvdata(dev); 3296 struct con_driver *con = dev_get_drvdata(dev);
3297 3297
3298 return snprintf(buf, PAGE_SIZE, "%s %s\n", 3298 return snprintf(buf, PAGE_SIZE, "%s %s\n",
3299 (con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)", 3299 (con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)",
3300 con->desc); 3300 con->desc);
3301 3301
3302 } 3302 }
3303 3303
3304 static struct device_attribute device_attrs[] = { 3304 static struct device_attribute device_attrs[] = {
3305 __ATTR(bind, S_IRUGO|S_IWUSR, show_bind, store_bind), 3305 __ATTR(bind, S_IRUGO|S_IWUSR, show_bind, store_bind),
3306 __ATTR(name, S_IRUGO, show_name, NULL), 3306 __ATTR(name, S_IRUGO, show_name, NULL),
3307 }; 3307 };
3308 3308
3309 static int vtconsole_init_device(struct con_driver *con) 3309 static int vtconsole_init_device(struct con_driver *con)
3310 { 3310 {
3311 int i; 3311 int i;
3312 int error = 0; 3312 int error = 0;
3313 3313
3314 con->flag |= CON_DRIVER_FLAG_ATTR; 3314 con->flag |= CON_DRIVER_FLAG_ATTR;
3315 dev_set_drvdata(con->dev, con); 3315 dev_set_drvdata(con->dev, con);
3316 for (i = 0; i < ARRAY_SIZE(device_attrs); i++) { 3316 for (i = 0; i < ARRAY_SIZE(device_attrs); i++) {
3317 error = device_create_file(con->dev, &device_attrs[i]); 3317 error = device_create_file(con->dev, &device_attrs[i]);
3318 if (error) 3318 if (error)
3319 break; 3319 break;
3320 } 3320 }
3321 3321
3322 if (error) { 3322 if (error) {
3323 while (--i >= 0) 3323 while (--i >= 0)
3324 device_remove_file(con->dev, &device_attrs[i]); 3324 device_remove_file(con->dev, &device_attrs[i]);
3325 con->flag &= ~CON_DRIVER_FLAG_ATTR; 3325 con->flag &= ~CON_DRIVER_FLAG_ATTR;
3326 } 3326 }
3327 3327
3328 return error; 3328 return error;
3329 } 3329 }
3330 3330
3331 static void vtconsole_deinit_device(struct con_driver *con) 3331 static void vtconsole_deinit_device(struct con_driver *con)
3332 { 3332 {
3333 int i; 3333 int i;
3334 3334
3335 if (con->flag & CON_DRIVER_FLAG_ATTR) { 3335 if (con->flag & CON_DRIVER_FLAG_ATTR) {
3336 for (i = 0; i < ARRAY_SIZE(device_attrs); i++) 3336 for (i = 0; i < ARRAY_SIZE(device_attrs); i++)
3337 device_remove_file(con->dev, &device_attrs[i]); 3337 device_remove_file(con->dev, &device_attrs[i]);
3338 con->flag &= ~CON_DRIVER_FLAG_ATTR; 3338 con->flag &= ~CON_DRIVER_FLAG_ATTR;
3339 } 3339 }
3340 } 3340 }
3341 3341
3342 /** 3342 /**
3343 * con_is_bound - checks if driver is bound to the console 3343 * con_is_bound - checks if driver is bound to the console
3344 * @csw: console driver 3344 * @csw: console driver
3345 * 3345 *
3346 * RETURNS: zero if unbound, nonzero if bound 3346 * RETURNS: zero if unbound, nonzero if bound
3347 * 3347 *
3348 * Drivers can call this and if zero, they should release 3348 * Drivers can call this and if zero, they should release
3349 * all resources allocated on con_startup() 3349 * all resources allocated on con_startup()
3350 */ 3350 */
3351 int con_is_bound(const struct consw *csw) 3351 int con_is_bound(const struct consw *csw)
3352 { 3352 {
3353 int i, bound = 0; 3353 int i, bound = 0;
3354 3354
3355 for (i = 0; i < MAX_NR_CONSOLES; i++) { 3355 for (i = 0; i < MAX_NR_CONSOLES; i++) {
3356 if (con_driver_map[i] == csw) { 3356 if (con_driver_map[i] == csw) {
3357 bound = 1; 3357 bound = 1;
3358 break; 3358 break;
3359 } 3359 }
3360 } 3360 }
3361 3361
3362 return bound; 3362 return bound;
3363 } 3363 }
3364 EXPORT_SYMBOL(con_is_bound); 3364 EXPORT_SYMBOL(con_is_bound);
3365 3365
3366 /** 3366 /**
3367 * register_con_driver - register console driver to console layer 3367 * register_con_driver - register console driver to console layer
3368 * @csw: console driver 3368 * @csw: console driver
3369 * @first: the first console to take over, minimum value is 0 3369 * @first: the first console to take over, minimum value is 0
3370 * @last: the last console to take over, maximum value is MAX_NR_CONSOLES -1 3370 * @last: the last console to take over, maximum value is MAX_NR_CONSOLES -1
3371 * 3371 *
3372 * DESCRIPTION: This function registers a console driver which can later 3372 * DESCRIPTION: This function registers a console driver which can later
3373 * bind to a range of consoles specified by @first and @last. It will 3373 * bind to a range of consoles specified by @first and @last. It will
3374 * also initialize the console driver by calling con_startup(). 3374 * also initialize the console driver by calling con_startup().
3375 */ 3375 */
3376 int register_con_driver(const struct consw *csw, int first, int last) 3376 int register_con_driver(const struct consw *csw, int first, int last)
3377 { 3377 {
3378 struct module *owner = csw->owner; 3378 struct module *owner = csw->owner;
3379 struct con_driver *con_driver; 3379 struct con_driver *con_driver;
3380 const char *desc; 3380 const char *desc;
3381 int i, retval = 0; 3381 int i, retval = 0;
3382 3382
3383 if (!try_module_get(owner)) 3383 if (!try_module_get(owner))
3384 return -ENODEV; 3384 return -ENODEV;
3385 3385
3386 acquire_console_sem(); 3386 acquire_console_sem();
3387 3387
3388 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3388 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
3389 con_driver = &registered_con_driver[i]; 3389 con_driver = &registered_con_driver[i];
3390 3390
3391 /* already registered */ 3391 /* already registered */
3392 if (con_driver->con == csw) 3392 if (con_driver->con == csw)
3393 retval = -EINVAL; 3393 retval = -EINVAL;
3394 } 3394 }
3395 3395
3396 if (retval) 3396 if (retval)
3397 goto err; 3397 goto err;
3398 3398
3399 desc = csw->con_startup(); 3399 desc = csw->con_startup();
3400 3400
3401 if (!desc) 3401 if (!desc)
3402 goto err; 3402 goto err;
3403 3403
3404 retval = -EINVAL; 3404 retval = -EINVAL;
3405 3405
3406 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3406 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
3407 con_driver = &registered_con_driver[i]; 3407 con_driver = &registered_con_driver[i];
3408 3408
3409 if (con_driver->con == NULL) { 3409 if (con_driver->con == NULL) {
3410 con_driver->con = csw; 3410 con_driver->con = csw;
3411 con_driver->desc = desc; 3411 con_driver->desc = desc;
3412 con_driver->node = i; 3412 con_driver->node = i;
3413 con_driver->flag = CON_DRIVER_FLAG_MODULE | 3413 con_driver->flag = CON_DRIVER_FLAG_MODULE |
3414 CON_DRIVER_FLAG_INIT; 3414 CON_DRIVER_FLAG_INIT;
3415 con_driver->first = first; 3415 con_driver->first = first;
3416 con_driver->last = last; 3416 con_driver->last = last;
3417 retval = 0; 3417 retval = 0;
3418 break; 3418 break;
3419 } 3419 }
3420 } 3420 }
3421 3421
3422 if (retval) 3422 if (retval)
3423 goto err; 3423 goto err;
3424 3424
3425 con_driver->dev = device_create(vtconsole_class, NULL, 3425 con_driver->dev = device_create(vtconsole_class, NULL,
3426 MKDEV(0, con_driver->node), 3426 MKDEV(0, con_driver->node),
3427 "vtcon%i", con_driver->node); 3427 "vtcon%i", con_driver->node);
3428 3428
3429 if (IS_ERR(con_driver->dev)) { 3429 if (IS_ERR(con_driver->dev)) {
3430 printk(KERN_WARNING "Unable to create device for %s; " 3430 printk(KERN_WARNING "Unable to create device for %s; "
3431 "errno = %ld\n", con_driver->desc, 3431 "errno = %ld\n", con_driver->desc,
3432 PTR_ERR(con_driver->dev)); 3432 PTR_ERR(con_driver->dev));
3433 con_driver->dev = NULL; 3433 con_driver->dev = NULL;
3434 } else { 3434 } else {
3435 vtconsole_init_device(con_driver); 3435 vtconsole_init_device(con_driver);
3436 } 3436 }
3437 3437
3438 err: 3438 err:
3439 release_console_sem(); 3439 release_console_sem();
3440 module_put(owner); 3440 module_put(owner);
3441 return retval; 3441 return retval;
3442 } 3442 }
3443 EXPORT_SYMBOL(register_con_driver); 3443 EXPORT_SYMBOL(register_con_driver);
3444 3444
3445 /** 3445 /**
3446 * unregister_con_driver - unregister console driver from console layer 3446 * unregister_con_driver - unregister console driver from console layer
3447 * @csw: console driver 3447 * @csw: console driver
3448 * 3448 *
3449 * DESCRIPTION: All drivers that registers to the console layer must 3449 * DESCRIPTION: All drivers that registers to the console layer must
3450 * call this function upon exit, or if the console driver is in a state 3450 * call this function upon exit, or if the console driver is in a state
3451 * where it won't be able to handle console services, such as the 3451 * where it won't be able to handle console services, such as the
3452 * framebuffer console without loaded framebuffer drivers. 3452 * framebuffer console without loaded framebuffer drivers.
3453 * 3453 *
3454 * The driver must unbind first prior to unregistration. 3454 * The driver must unbind first prior to unregistration.
3455 */ 3455 */
3456 int unregister_con_driver(const struct consw *csw) 3456 int unregister_con_driver(const struct consw *csw)
3457 { 3457 {
3458 int i, retval = -ENODEV; 3458 int i, retval = -ENODEV;
3459 3459
3460 acquire_console_sem(); 3460 acquire_console_sem();
3461 3461
3462 /* cannot unregister a bound driver */ 3462 /* cannot unregister a bound driver */
3463 if (con_is_bound(csw)) 3463 if (con_is_bound(csw))
3464 goto err; 3464 goto err;
3465 3465
3466 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3466 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
3467 struct con_driver *con_driver = &registered_con_driver[i]; 3467 struct con_driver *con_driver = &registered_con_driver[i];
3468 3468
3469 if (con_driver->con == csw && 3469 if (con_driver->con == csw &&
3470 con_driver->flag & CON_DRIVER_FLAG_MODULE) { 3470 con_driver->flag & CON_DRIVER_FLAG_MODULE) {
3471 vtconsole_deinit_device(con_driver); 3471 vtconsole_deinit_device(con_driver);
3472 device_destroy(vtconsole_class, 3472 device_destroy(vtconsole_class,
3473 MKDEV(0, con_driver->node)); 3473 MKDEV(0, con_driver->node));
3474 con_driver->con = NULL; 3474 con_driver->con = NULL;
3475 con_driver->desc = NULL; 3475 con_driver->desc = NULL;
3476 con_driver->dev = NULL; 3476 con_driver->dev = NULL;
3477 con_driver->node = 0; 3477 con_driver->node = 0;
3478 con_driver->flag = 0; 3478 con_driver->flag = 0;
3479 con_driver->first = 0; 3479 con_driver->first = 0;
3480 con_driver->last = 0; 3480 con_driver->last = 0;
3481 retval = 0; 3481 retval = 0;
3482 break; 3482 break;
3483 } 3483 }
3484 } 3484 }
3485 err: 3485 err:
3486 release_console_sem(); 3486 release_console_sem();
3487 return retval; 3487 return retval;
3488 } 3488 }
3489 EXPORT_SYMBOL(unregister_con_driver); 3489 EXPORT_SYMBOL(unregister_con_driver);
3490 3490
3491 /* 3491 /*
3492 * If we support more console drivers, this function is used 3492 * If we support more console drivers, this function is used
3493 * when a driver wants to take over some existing consoles 3493 * when a driver wants to take over some existing consoles
3494 * and become default driver for newly opened ones. 3494 * and become default driver for newly opened ones.
3495 * 3495 *
3496 * take_over_console is basically a register followed by unbind 3496 * take_over_console is basically a register followed by unbind
3497 */ 3497 */
3498 int take_over_console(const struct consw *csw, int first, int last, int deflt) 3498 int take_over_console(const struct consw *csw, int first, int last, int deflt)
3499 { 3499 {
3500 int err; 3500 int err;
3501 3501
3502 err = register_con_driver(csw, first, last); 3502 err = register_con_driver(csw, first, last);
3503 3503
3504 if (!err) 3504 if (!err)
3505 bind_con_driver(csw, first, last, deflt); 3505 bind_con_driver(csw, first, last, deflt);
3506 3506
3507 return err; 3507 return err;
3508 } 3508 }
3509 3509
3510 /* 3510 /*
3511 * give_up_console is a wrapper to unregister_con_driver. It will only 3511 * give_up_console is a wrapper to unregister_con_driver. It will only
3512 * work if driver is fully unbound. 3512 * work if driver is fully unbound.
3513 */ 3513 */
3514 void give_up_console(const struct consw *csw) 3514 void give_up_console(const struct consw *csw)
3515 { 3515 {
3516 unregister_con_driver(csw); 3516 unregister_con_driver(csw);
3517 } 3517 }
3518 3518
3519 static int __init vtconsole_class_init(void) 3519 static int __init vtconsole_class_init(void)
3520 { 3520 {
3521 int i; 3521 int i;
3522 3522
3523 vtconsole_class = class_create(THIS_MODULE, "vtconsole"); 3523 vtconsole_class = class_create(THIS_MODULE, "vtconsole");
3524 if (IS_ERR(vtconsole_class)) { 3524 if (IS_ERR(vtconsole_class)) {
3525 printk(KERN_WARNING "Unable to create vt console class; " 3525 printk(KERN_WARNING "Unable to create vt console class; "
3526 "errno = %ld\n", PTR_ERR(vtconsole_class)); 3526 "errno = %ld\n", PTR_ERR(vtconsole_class));
3527 vtconsole_class = NULL; 3527 vtconsole_class = NULL;
3528 } 3528 }
3529 3529
3530 /* Add system drivers to sysfs */ 3530 /* Add system drivers to sysfs */
3531 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3531 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
3532 struct con_driver *con = &registered_con_driver[i]; 3532 struct con_driver *con = &registered_con_driver[i];
3533 3533
3534 if (con->con && !con->dev) { 3534 if (con->con && !con->dev) {
3535 con->dev = device_create(vtconsole_class, NULL, 3535 con->dev = device_create(vtconsole_class, NULL,
3536 MKDEV(0, con->node), 3536 MKDEV(0, con->node),
3537 "vtcon%i", con->node); 3537 "vtcon%i", con->node);
3538 3538
3539 if (IS_ERR(con->dev)) { 3539 if (IS_ERR(con->dev)) {
3540 printk(KERN_WARNING "Unable to create " 3540 printk(KERN_WARNING "Unable to create "
3541 "device for %s; errno = %ld\n", 3541 "device for %s; errno = %ld\n",
3542 con->desc, PTR_ERR(con->dev)); 3542 con->desc, PTR_ERR(con->dev));
3543 con->dev = NULL; 3543 con->dev = NULL;
3544 } else { 3544 } else {
3545 vtconsole_init_device(con); 3545 vtconsole_init_device(con);
3546 } 3546 }
3547 } 3547 }
3548 } 3548 }
3549 3549
3550 return 0; 3550 return 0;
3551 } 3551 }
3552 postcore_initcall(vtconsole_class_init); 3552 postcore_initcall(vtconsole_class_init);
3553 3553
3554 #endif 3554 #endif
3555 3555
3556 /* 3556 /*
3557 * Screen blanking 3557 * Screen blanking
3558 */ 3558 */
3559 3559
3560 static int set_vesa_blanking(char __user *p) 3560 static int set_vesa_blanking(char __user *p)
3561 { 3561 {
3562 unsigned int mode; 3562 unsigned int mode;
3563 3563
3564 if (get_user(mode, p + 1)) 3564 if (get_user(mode, p + 1))
3565 return -EFAULT; 3565 return -EFAULT;
3566 3566
3567 vesa_blank_mode = (mode < 4) ? mode : 0; 3567 vesa_blank_mode = (mode < 4) ? mode : 0;
3568 return 0; 3568 return 0;
3569 } 3569 }
3570 3570
3571 void do_blank_screen(int entering_gfx) 3571 void do_blank_screen(int entering_gfx)
3572 { 3572 {
3573 struct vc_data *vc = vc_cons[fg_console].d; 3573 struct vc_data *vc = vc_cons[fg_console].d;
3574 int i; 3574 int i;
3575 3575
3576 WARN_CONSOLE_UNLOCKED(); 3576 WARN_CONSOLE_UNLOCKED();
3577 3577
3578 if (console_blanked) { 3578 if (console_blanked) {
3579 if (blank_state == blank_vesa_wait) { 3579 if (blank_state == blank_vesa_wait) {
3580 blank_state = blank_off; 3580 blank_state = blank_off;
3581 vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0); 3581 vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0);
3582 } 3582 }
3583 return; 3583 return;
3584 } 3584 }
3585 3585
3586 /* entering graphics mode? */ 3586 /* entering graphics mode? */
3587 if (entering_gfx) { 3587 if (entering_gfx) {
3588 hide_cursor(vc); 3588 hide_cursor(vc);
3589 save_screen(vc); 3589 save_screen(vc);
3590 vc->vc_sw->con_blank(vc, -1, 1); 3590 vc->vc_sw->con_blank(vc, -1, 1);
3591 console_blanked = fg_console + 1; 3591 console_blanked = fg_console + 1;
3592 blank_state = blank_off; 3592 blank_state = blank_off;
3593 set_origin(vc); 3593 set_origin(vc);
3594 return; 3594 return;
3595 } 3595 }
3596 3596
3597 if (blank_state != blank_normal_wait) 3597 if (blank_state != blank_normal_wait)
3598 return; 3598 return;
3599 blank_state = blank_off; 3599 blank_state = blank_off;
3600 3600
3601 /* don't blank graphics */ 3601 /* don't blank graphics */
3602 if (vc->vc_mode != KD_TEXT) { 3602 if (vc->vc_mode != KD_TEXT) {
3603 console_blanked = fg_console + 1; 3603 console_blanked = fg_console + 1;
3604 return; 3604 return;
3605 } 3605 }
3606 3606
3607 hide_cursor(vc); 3607 hide_cursor(vc);
3608 del_timer_sync(&console_timer); 3608 del_timer_sync(&console_timer);
3609 blank_timer_expired = 0; 3609 blank_timer_expired = 0;
3610 3610
3611 save_screen(vc); 3611 save_screen(vc);
3612 /* In case we need to reset origin, blanking hook returns 1 */ 3612 /* In case we need to reset origin, blanking hook returns 1 */
3613 i = vc->vc_sw->con_blank(vc, vesa_off_interval ? 1 : (vesa_blank_mode + 1), 0); 3613 i = vc->vc_sw->con_blank(vc, vesa_off_interval ? 1 : (vesa_blank_mode + 1), 0);
3614 console_blanked = fg_console + 1; 3614 console_blanked = fg_console + 1;
3615 if (i) 3615 if (i)
3616 set_origin(vc); 3616 set_origin(vc);
3617 3617
3618 if (console_blank_hook && console_blank_hook(1)) 3618 if (console_blank_hook && console_blank_hook(1))
3619 return; 3619 return;
3620 3620
3621 if (vesa_off_interval && vesa_blank_mode) { 3621 if (vesa_off_interval && vesa_blank_mode) {
3622 blank_state = blank_vesa_wait; 3622 blank_state = blank_vesa_wait;
3623 mod_timer(&console_timer, jiffies + vesa_off_interval); 3623 mod_timer(&console_timer, jiffies + vesa_off_interval);
3624 } 3624 }
3625 } 3625 }
3626 EXPORT_SYMBOL(do_blank_screen); 3626 EXPORT_SYMBOL(do_blank_screen);
3627 3627
3628 /* 3628 /*
3629 * Called by timer as well as from vt_console_driver 3629 * Called by timer as well as from vt_console_driver
3630 */ 3630 */
3631 void do_unblank_screen(int leaving_gfx) 3631 void do_unblank_screen(int leaving_gfx)
3632 { 3632 {
3633 struct vc_data *vc; 3633 struct vc_data *vc;
3634 3634
3635 /* This should now always be called from a "sane" (read: can schedule) 3635 /* This should now always be called from a "sane" (read: can schedule)
3636 * context for the sake of the low level drivers, except in the special 3636 * context for the sake of the low level drivers, except in the special
3637 * case of oops_in_progress 3637 * case of oops_in_progress
3638 */ 3638 */
3639 if (!oops_in_progress) 3639 if (!oops_in_progress)
3640 might_sleep(); 3640 might_sleep();
3641 3641
3642 WARN_CONSOLE_UNLOCKED(); 3642 WARN_CONSOLE_UNLOCKED();
3643 3643
3644 ignore_poke = 0; 3644 ignore_poke = 0;
3645 if (!console_blanked) 3645 if (!console_blanked)
3646 return; 3646 return;
3647 if (!vc_cons_allocated(fg_console)) { 3647 if (!vc_cons_allocated(fg_console)) {
3648 /* impossible */ 3648 /* impossible */
3649 printk("unblank_screen: tty %d not allocated ??\n", fg_console+1); 3649 printk("unblank_screen: tty %d not allocated ??\n", fg_console+1);
3650 return; 3650 return;
3651 } 3651 }
3652 vc = vc_cons[fg_console].d; 3652 vc = vc_cons[fg_console].d;
3653 if (vc->vc_mode != KD_TEXT) 3653 if (vc->vc_mode != KD_TEXT)
3654 return; /* but leave console_blanked != 0 */ 3654 return; /* but leave console_blanked != 0 */
3655 3655
3656 if (blankinterval) { 3656 if (blankinterval) {
3657 mod_timer(&console_timer, jiffies + blankinterval); 3657 mod_timer(&console_timer, jiffies + blankinterval);
3658 blank_state = blank_normal_wait; 3658 blank_state = blank_normal_wait;
3659 } 3659 }
3660 3660
3661 console_blanked = 0; 3661 console_blanked = 0;
3662 if (vc->vc_sw->con_blank(vc, 0, leaving_gfx)) 3662 if (vc->vc_sw->con_blank(vc, 0, leaving_gfx))
3663 /* Low-level driver cannot restore -> do it ourselves */ 3663 /* Low-level driver cannot restore -> do it ourselves */
3664 update_screen(vc); 3664 update_screen(vc);
3665 if (console_blank_hook) 3665 if (console_blank_hook)
3666 console_blank_hook(0); 3666 console_blank_hook(0);
3667 set_palette(vc); 3667 set_palette(vc);
3668 set_cursor(vc); 3668 set_cursor(vc);
3669 } 3669 }
3670 EXPORT_SYMBOL(do_unblank_screen); 3670 EXPORT_SYMBOL(do_unblank_screen);
3671 3671
3672 /* 3672 /*
3673 * This is called by the outside world to cause a forced unblank, mostly for 3673 * This is called by the outside world to cause a forced unblank, mostly for
3674 * oopses. Currently, I just call do_unblank_screen(0), but we could eventually 3674 * oopses. Currently, I just call do_unblank_screen(0), but we could eventually
3675 * call it with 1 as an argument and so force a mode restore... that may kill 3675 * call it with 1 as an argument and so force a mode restore... that may kill
3676 * X or at least garbage the screen but would also make the Oops visible... 3676 * X or at least garbage the screen but would also make the Oops visible...
3677 */ 3677 */
3678 void unblank_screen(void) 3678 void unblank_screen(void)
3679 { 3679 {
3680 do_unblank_screen(0); 3680 do_unblank_screen(0);
3681 } 3681 }
3682 3682
3683 /* 3683 /*
3684 * We defer the timer blanking to work queue so it can take the console mutex 3684 * We defer the timer blanking to work queue so it can take the console mutex
3685 * (console operations can still happen at irq time, but only from printk which 3685 * (console operations can still happen at irq time, but only from printk which
3686 * has the console mutex. Not perfect yet, but better than no locking 3686 * has the console mutex. Not perfect yet, but better than no locking
3687 */ 3687 */
3688 static void blank_screen_t(unsigned long dummy) 3688 static void blank_screen_t(unsigned long dummy)
3689 { 3689 {
3690 if (unlikely(!keventd_up())) { 3690 if (unlikely(!keventd_up())) {
3691 mod_timer(&console_timer, jiffies + blankinterval); 3691 mod_timer(&console_timer, jiffies + blankinterval);
3692 return; 3692 return;
3693 } 3693 }
3694 blank_timer_expired = 1; 3694 blank_timer_expired = 1;
3695 schedule_work(&console_work); 3695 schedule_work(&console_work);
3696 } 3696 }
3697 3697
3698 void poke_blanked_console(void) 3698 void poke_blanked_console(void)
3699 { 3699 {
3700 WARN_CONSOLE_UNLOCKED(); 3700 WARN_CONSOLE_UNLOCKED();
3701 3701
3702 /* Add this so we quickly catch whoever might call us in a non 3702 /* Add this so we quickly catch whoever might call us in a non
3703 * safe context. Nowadays, unblank_screen() isn't to be called in 3703 * safe context. Nowadays, unblank_screen() isn't to be called in
3704 * atomic contexts and is allowed to schedule (with the special case 3704 * atomic contexts and is allowed to schedule (with the special case
3705 * of oops_in_progress, but that isn't of any concern for this 3705 * of oops_in_progress, but that isn't of any concern for this
3706 * function. --BenH. 3706 * function. --BenH.
3707 */ 3707 */
3708 might_sleep(); 3708 might_sleep();
3709 3709
3710 /* This isn't perfectly race free, but a race here would be mostly harmless, 3710 /* This isn't perfectly race free, but a race here would be mostly harmless,
3711 * at worse, we'll do a spurrious blank and it's unlikely 3711 * at worse, we'll do a spurrious blank and it's unlikely
3712 */ 3712 */
3713 del_timer(&console_timer); 3713 del_timer(&console_timer);
3714 blank_timer_expired = 0; 3714 blank_timer_expired = 0;
3715 3715
3716 if (ignore_poke || !vc_cons[fg_console].d || vc_cons[fg_console].d->vc_mode == KD_GRAPHICS) 3716 if (ignore_poke || !vc_cons[fg_console].d || vc_cons[fg_console].d->vc_mode == KD_GRAPHICS)
3717 return; 3717 return;
3718 if (console_blanked) 3718 if (console_blanked)
3719 unblank_screen(); 3719 unblank_screen();
3720 else if (blankinterval) { 3720 else if (blankinterval) {
3721 mod_timer(&console_timer, jiffies + blankinterval); 3721 mod_timer(&console_timer, jiffies + blankinterval);
3722 blank_state = blank_normal_wait; 3722 blank_state = blank_normal_wait;
3723 } 3723 }
3724 } 3724 }
3725 3725
3726 /* 3726 /*
3727 * Palettes 3727 * Palettes
3728 */ 3728 */
3729 3729
3730 static void set_palette(struct vc_data *vc) 3730 static void set_palette(struct vc_data *vc)
3731 { 3731 {
3732 WARN_CONSOLE_UNLOCKED(); 3732 WARN_CONSOLE_UNLOCKED();
3733 3733
3734 if (vc->vc_mode != KD_GRAPHICS) 3734 if (vc->vc_mode != KD_GRAPHICS)
3735 vc->vc_sw->con_set_palette(vc, color_table); 3735 vc->vc_sw->con_set_palette(vc, color_table);
3736 } 3736 }
3737 3737
3738 static int set_get_cmap(unsigned char __user *arg, int set) 3738 static int set_get_cmap(unsigned char __user *arg, int set)
3739 { 3739 {
3740 int i, j, k; 3740 int i, j, k;
3741 3741
3742 WARN_CONSOLE_UNLOCKED(); 3742 WARN_CONSOLE_UNLOCKED();
3743 3743
3744 for (i = 0; i < 16; i++) 3744 for (i = 0; i < 16; i++)
3745 if (set) { 3745 if (set) {
3746 get_user(default_red[i], arg++); 3746 get_user(default_red[i], arg++);
3747 get_user(default_grn[i], arg++); 3747 get_user(default_grn[i], arg++);
3748 get_user(default_blu[i], arg++); 3748 get_user(default_blu[i], arg++);
3749 } else { 3749 } else {
3750 put_user(default_red[i], arg++); 3750 put_user(default_red[i], arg++);
3751 put_user(default_grn[i], arg++); 3751 put_user(default_grn[i], arg++);
3752 put_user(default_blu[i], arg++); 3752 put_user(default_blu[i], arg++);
3753 } 3753 }
3754 if (set) { 3754 if (set) {
3755 for (i = 0; i < MAX_NR_CONSOLES; i++) 3755 for (i = 0; i < MAX_NR_CONSOLES; i++)
3756 if (vc_cons_allocated(i)) { 3756 if (vc_cons_allocated(i)) {
3757 for (j = k = 0; j < 16; j++) { 3757 for (j = k = 0; j < 16; j++) {
3758 vc_cons[i].d->vc_palette[k++] = default_red[j]; 3758 vc_cons[i].d->vc_palette[k++] = default_red[j];
3759 vc_cons[i].d->vc_palette[k++] = default_grn[j]; 3759 vc_cons[i].d->vc_palette[k++] = default_grn[j];
3760 vc_cons[i].d->vc_palette[k++] = default_blu[j]; 3760 vc_cons[i].d->vc_palette[k++] = default_blu[j];
3761 } 3761 }
3762 set_palette(vc_cons[i].d); 3762 set_palette(vc_cons[i].d);
3763 } 3763 }
3764 } 3764 }
3765 return 0; 3765 return 0;
3766 } 3766 }
3767 3767
3768 /* 3768 /*
3769 * Load palette into the DAC registers. arg points to a colour 3769 * Load palette into the DAC registers. arg points to a colour
3770 * map, 3 bytes per colour, 16 colours, range from 0 to 255. 3770 * map, 3 bytes per colour, 16 colours, range from 0 to 255.
3771 */ 3771 */
3772 3772
3773 int con_set_cmap(unsigned char __user *arg) 3773 int con_set_cmap(unsigned char __user *arg)
3774 { 3774 {
3775 int rc; 3775 int rc;
3776 3776
3777 acquire_console_sem(); 3777 acquire_console_sem();
3778 rc = set_get_cmap (arg,1); 3778 rc = set_get_cmap (arg,1);
3779 release_console_sem(); 3779 release_console_sem();
3780 3780
3781 return rc; 3781 return rc;
3782 } 3782 }
3783 3783
3784 int con_get_cmap(unsigned char __user *arg) 3784 int con_get_cmap(unsigned char __user *arg)
3785 { 3785 {
3786 int rc; 3786 int rc;
3787 3787
3788 acquire_console_sem(); 3788 acquire_console_sem();
3789 rc = set_get_cmap (arg,0); 3789 rc = set_get_cmap (arg,0);
3790 release_console_sem(); 3790 release_console_sem();
3791 3791
3792 return rc; 3792 return rc;
3793 } 3793 }
3794 3794
3795 void reset_palette(struct vc_data *vc) 3795 void reset_palette(struct vc_data *vc)
3796 { 3796 {
3797 int j, k; 3797 int j, k;
3798 for (j=k=0; j<16; j++) { 3798 for (j=k=0; j<16; j++) {
3799 vc->vc_palette[k++] = default_red[j]; 3799 vc->vc_palette[k++] = default_red[j];
3800 vc->vc_palette[k++] = default_grn[j]; 3800 vc->vc_palette[k++] = default_grn[j];
3801 vc->vc_palette[k++] = default_blu[j]; 3801 vc->vc_palette[k++] = default_blu[j];
3802 } 3802 }
3803 set_palette(vc); 3803 set_palette(vc);
3804 } 3804 }
3805 3805
3806 /* 3806 /*
3807 * Font switching 3807 * Font switching
3808 * 3808 *
3809 * Currently we only support fonts up to 32 pixels wide, at a maximum height 3809 * Currently we only support fonts up to 32 pixels wide, at a maximum height
3810 * of 32 pixels. Userspace fontdata is stored with 32 bytes (shorts/ints, 3810 * of 32 pixels. Userspace fontdata is stored with 32 bytes (shorts/ints,
3811 * depending on width) reserved for each character which is kinda wasty, but 3811 * depending on width) reserved for each character which is kinda wasty, but
3812 * this is done in order to maintain compatibility with the EGA/VGA fonts. It 3812 * this is done in order to maintain compatibility with the EGA/VGA fonts. It
3813 * is upto the actual low-level console-driver convert data into its favorite 3813 * is upto the actual low-level console-driver convert data into its favorite
3814 * format (maybe we should add a `fontoffset' field to the `display' 3814 * format (maybe we should add a `fontoffset' field to the `display'
3815 * structure so we won't have to convert the fontdata all the time. 3815 * structure so we won't have to convert the fontdata all the time.
3816 * /Jes 3816 * /Jes
3817 */ 3817 */
3818 3818
3819 #define max_font_size 65536 3819 #define max_font_size 65536
3820 3820
3821 static int con_font_get(struct vc_data *vc, struct console_font_op *op) 3821 static int con_font_get(struct vc_data *vc, struct console_font_op *op)
3822 { 3822 {
3823 struct console_font font; 3823 struct console_font font;
3824 int rc = -EINVAL; 3824 int rc = -EINVAL;
3825 int c; 3825 int c;
3826 3826
3827 if (vc->vc_mode != KD_TEXT) 3827 if (vc->vc_mode != KD_TEXT)
3828 return -EINVAL; 3828 return -EINVAL;
3829 3829
3830 if (op->data) { 3830 if (op->data) {
3831 font.data = kmalloc(max_font_size, GFP_KERNEL); 3831 font.data = kmalloc(max_font_size, GFP_KERNEL);
3832 if (!font.data) 3832 if (!font.data)
3833 return -ENOMEM; 3833 return -ENOMEM;
3834 } else 3834 } else
3835 font.data = NULL; 3835 font.data = NULL;
3836 3836
3837 acquire_console_sem(); 3837 acquire_console_sem();
3838 if (vc->vc_sw->con_font_get) 3838 if (vc->vc_sw->con_font_get)
3839 rc = vc->vc_sw->con_font_get(vc, &font); 3839 rc = vc->vc_sw->con_font_get(vc, &font);
3840 else 3840 else
3841 rc = -ENOSYS; 3841 rc = -ENOSYS;
3842 release_console_sem(); 3842 release_console_sem();
3843 3843
3844 if (rc) 3844 if (rc)
3845 goto out; 3845 goto out;
3846 3846
3847 c = (font.width+7)/8 * 32 * font.charcount; 3847 c = (font.width+7)/8 * 32 * font.charcount;
3848 3848
3849 if (op->data && font.charcount > op->charcount) 3849 if (op->data && font.charcount > op->charcount)
3850 rc = -ENOSPC; 3850 rc = -ENOSPC;
3851 if (!(op->flags & KD_FONT_FLAG_OLD)) { 3851 if (!(op->flags & KD_FONT_FLAG_OLD)) {
3852 if (font.width > op->width || font.height > op->height) 3852 if (font.width > op->width || font.height > op->height)
3853 rc = -ENOSPC; 3853 rc = -ENOSPC;
3854 } else { 3854 } else {
3855 if (font.width != 8) 3855 if (font.width != 8)
3856 rc = -EIO; 3856 rc = -EIO;
3857 else if ((op->height && font.height > op->height) || 3857 else if ((op->height && font.height > op->height) ||
3858 font.height > 32) 3858 font.height > 32)
3859 rc = -ENOSPC; 3859 rc = -ENOSPC;
3860 } 3860 }
3861 if (rc) 3861 if (rc)
3862 goto out; 3862 goto out;
3863 3863
3864 op->height = font.height; 3864 op->height = font.height;
3865 op->width = font.width; 3865 op->width = font.width;
3866 op->charcount = font.charcount; 3866 op->charcount = font.charcount;
3867 3867
3868 if (op->data && copy_to_user(op->data, font.data, c)) 3868 if (op->data && copy_to_user(op->data, font.data, c))
3869 rc = -EFAULT; 3869 rc = -EFAULT;
3870 3870
3871 out: 3871 out:
3872 kfree(font.data); 3872 kfree(font.data);
3873 return rc; 3873 return rc;
3874 } 3874 }
3875 3875
3876 static int con_font_set(struct vc_data *vc, struct console_font_op *op) 3876 static int con_font_set(struct vc_data *vc, struct console_font_op *op)
3877 { 3877 {
3878 struct console_font font; 3878 struct console_font font;
3879 int rc = -EINVAL; 3879 int rc = -EINVAL;
3880 int size; 3880 int size;
3881 3881
3882 if (vc->vc_mode != KD_TEXT) 3882 if (vc->vc_mode != KD_TEXT)
3883 return -EINVAL; 3883 return -EINVAL;
3884 if (!op->data) 3884 if (!op->data)
3885 return -EINVAL; 3885 return -EINVAL;
3886 if (op->charcount > 512) 3886 if (op->charcount > 512)
3887 return -EINVAL; 3887 return -EINVAL;
3888 if (!op->height) { /* Need to guess font height [compat] */ 3888 if (!op->height) { /* Need to guess font height [compat] */
3889 int h, i; 3889 int h, i;
3890 u8 __user *charmap = op->data; 3890 u8 __user *charmap = op->data;
3891 u8 tmp; 3891 u8 tmp;
3892 3892
3893 /* If from KDFONTOP ioctl, don't allow things which can be done in userland, 3893 /* If from KDFONTOP ioctl, don't allow things which can be done in userland,
3894 so that we can get rid of this soon */ 3894 so that we can get rid of this soon */
3895 if (!(op->flags & KD_FONT_FLAG_OLD)) 3895 if (!(op->flags & KD_FONT_FLAG_OLD))
3896 return -EINVAL; 3896 return -EINVAL;
3897 for (h = 32; h > 0; h--) 3897 for (h = 32; h > 0; h--)
3898 for (i = 0; i < op->charcount; i++) { 3898 for (i = 0; i < op->charcount; i++) {
3899 if (get_user(tmp, &charmap[32*i+h-1])) 3899 if (get_user(tmp, &charmap[32*i+h-1]))
3900 return -EFAULT; 3900 return -EFAULT;
3901 if (tmp) 3901 if (tmp)
3902 goto nonzero; 3902 goto nonzero;
3903 } 3903 }
3904 return -EINVAL; 3904 return -EINVAL;
3905 nonzero: 3905 nonzero:
3906 op->height = h; 3906 op->height = h;
3907 } 3907 }
3908 if (op->width <= 0 || op->width > 32 || op->height > 32) 3908 if (op->width <= 0 || op->width > 32 || op->height > 32)
3909 return -EINVAL; 3909 return -EINVAL;
3910 size = (op->width+7)/8 * 32 * op->charcount; 3910 size = (op->width+7)/8 * 32 * op->charcount;
3911 if (size > max_font_size) 3911 if (size > max_font_size)
3912 return -ENOSPC; 3912 return -ENOSPC;
3913 font.charcount = op->charcount; 3913 font.charcount = op->charcount;
3914 font.height = op->height; 3914 font.height = op->height;
3915 font.width = op->width; 3915 font.width = op->width;
3916 font.data = kmalloc(size, GFP_KERNEL); 3916 font.data = kmalloc(size, GFP_KERNEL);
3917 if (!font.data) 3917 if (!font.data)
3918 return -ENOMEM; 3918 return -ENOMEM;
3919 if (copy_from_user(font.data, op->data, size)) { 3919 if (copy_from_user(font.data, op->data, size)) {
3920 kfree(font.data); 3920 kfree(font.data);
3921 return -EFAULT; 3921 return -EFAULT;
3922 } 3922 }
3923 acquire_console_sem(); 3923 acquire_console_sem();
3924 if (vc->vc_sw->con_font_set) 3924 if (vc->vc_sw->con_font_set)
3925 rc = vc->vc_sw->con_font_set(vc, &font, op->flags); 3925 rc = vc->vc_sw->con_font_set(vc, &font, op->flags);
3926 else 3926 else
3927 rc = -ENOSYS; 3927 rc = -ENOSYS;
3928 release_console_sem(); 3928 release_console_sem();
3929 kfree(font.data); 3929 kfree(font.data);
3930 return rc; 3930 return rc;
3931 } 3931 }
3932 3932
3933 static int con_font_default(struct vc_data *vc, struct console_font_op *op) 3933 static int con_font_default(struct vc_data *vc, struct console_font_op *op)
3934 { 3934 {
3935 struct console_font font = {.width = op->width, .height = op->height}; 3935 struct console_font font = {.width = op->width, .height = op->height};
3936 char name[MAX_FONT_NAME]; 3936 char name[MAX_FONT_NAME];
3937 char *s = name; 3937 char *s = name;
3938 int rc; 3938 int rc;
3939 3939
3940 if (vc->vc_mode != KD_TEXT) 3940 if (vc->vc_mode != KD_TEXT)
3941 return -EINVAL; 3941 return -EINVAL;
3942 3942
3943 if (!op->data) 3943 if (!op->data)
3944 s = NULL; 3944 s = NULL;
3945 else if (strncpy_from_user(name, op->data, MAX_FONT_NAME - 1) < 0) 3945 else if (strncpy_from_user(name, op->data, MAX_FONT_NAME - 1) < 0)
3946 return -EFAULT; 3946 return -EFAULT;
3947 else 3947 else
3948 name[MAX_FONT_NAME - 1] = 0; 3948 name[MAX_FONT_NAME - 1] = 0;
3949 3949
3950 acquire_console_sem(); 3950 acquire_console_sem();
3951 if (vc->vc_sw->con_font_default) 3951 if (vc->vc_sw->con_font_default)
3952 rc = vc->vc_sw->con_font_default(vc, &font, s); 3952 rc = vc->vc_sw->con_font_default(vc, &font, s);
3953 else 3953 else
3954 rc = -ENOSYS; 3954 rc = -ENOSYS;
3955 release_console_sem(); 3955 release_console_sem();
3956 if (!rc) { 3956 if (!rc) {
3957 op->width = font.width; 3957 op->width = font.width;
3958 op->height = font.height; 3958 op->height = font.height;
3959 } 3959 }
3960 return rc; 3960 return rc;
3961 } 3961 }
3962 3962
3963 static int con_font_copy(struct vc_data *vc, struct console_font_op *op) 3963 static int con_font_copy(struct vc_data *vc, struct console_font_op *op)
3964 { 3964 {
3965 int con = op->height; 3965 int con = op->height;
3966 int rc; 3966 int rc;
3967 3967
3968 if (vc->vc_mode != KD_TEXT) 3968 if (vc->vc_mode != KD_TEXT)
3969 return -EINVAL; 3969 return -EINVAL;
3970 3970
3971 acquire_console_sem(); 3971 acquire_console_sem();
3972 if (!vc->vc_sw->con_font_copy) 3972 if (!vc->vc_sw->con_font_copy)
3973 rc = -ENOSYS; 3973 rc = -ENOSYS;
3974 else if (con < 0 || !vc_cons_allocated(con)) 3974 else if (con < 0 || !vc_cons_allocated(con))
3975 rc = -ENOTTY; 3975 rc = -ENOTTY;
3976 else if (con == vc->vc_num) /* nothing to do */ 3976 else if (con == vc->vc_num) /* nothing to do */
3977 rc = 0; 3977 rc = 0;
3978 else 3978 else
3979 rc = vc->vc_sw->con_font_copy(vc, con); 3979 rc = vc->vc_sw->con_font_copy(vc, con);
3980 release_console_sem(); 3980 release_console_sem();
3981 return rc; 3981 return rc;
3982 } 3982 }
3983 3983
3984 int con_font_op(struct vc_data *vc, struct console_font_op *op) 3984 int con_font_op(struct vc_data *vc, struct console_font_op *op)
3985 { 3985 {
3986 switch (op->op) { 3986 switch (op->op) {
3987 case KD_FONT_OP_SET: 3987 case KD_FONT_OP_SET:
3988 return con_font_set(vc, op); 3988 return con_font_set(vc, op);
3989 case KD_FONT_OP_GET: 3989 case KD_FONT_OP_GET:
3990 return con_font_get(vc, op); 3990 return con_font_get(vc, op);
3991 case KD_FONT_OP_SET_DEFAULT: 3991 case KD_FONT_OP_SET_DEFAULT:
3992 return con_font_default(vc, op); 3992 return con_font_default(vc, op);
3993 case KD_FONT_OP_COPY: 3993 case KD_FONT_OP_COPY:
3994 return con_font_copy(vc, op); 3994 return con_font_copy(vc, op);
3995 } 3995 }
3996 return -ENOSYS; 3996 return -ENOSYS;
3997 } 3997 }
3998 3998
3999 /* 3999 /*
4000 * Interface exported to selection and vcs. 4000 * Interface exported to selection and vcs.
4001 */ 4001 */
4002 4002
4003 /* used by selection */ 4003 /* used by selection */
4004 u16 screen_glyph(struct vc_data *vc, int offset) 4004 u16 screen_glyph(struct vc_data *vc, int offset)
4005 { 4005 {
4006 u16 w = scr_readw(screenpos(vc, offset, 1)); 4006 u16 w = scr_readw(screenpos(vc, offset, 1));
4007 u16 c = w & 0xff; 4007 u16 c = w & 0xff;
4008 4008
4009 if (w & vc->vc_hi_font_mask) 4009 if (w & vc->vc_hi_font_mask)
4010 c |= 0x100; 4010 c |= 0x100;
4011 return c; 4011 return c;
4012 } 4012 }
4013 EXPORT_SYMBOL_GPL(screen_glyph); 4013 EXPORT_SYMBOL_GPL(screen_glyph);
4014 4014
4015 /* used by vcs - note the word offset */ 4015 /* used by vcs - note the word offset */
4016 unsigned short *screen_pos(struct vc_data *vc, int w_offset, int viewed) 4016 unsigned short *screen_pos(struct vc_data *vc, int w_offset, int viewed)
4017 { 4017 {
4018 return screenpos(vc, 2 * w_offset, viewed); 4018 return screenpos(vc, 2 * w_offset, viewed);
4019 } 4019 }
4020 4020
4021 void getconsxy(struct vc_data *vc, unsigned char *p) 4021 void getconsxy(struct vc_data *vc, unsigned char *p)
4022 { 4022 {
4023 p[0] = vc->vc_x; 4023 p[0] = vc->vc_x;
4024 p[1] = vc->vc_y; 4024 p[1] = vc->vc_y;
4025 } 4025 }
4026 4026
4027 void putconsxy(struct vc_data *vc, unsigned char *p) 4027 void putconsxy(struct vc_data *vc, unsigned char *p)
4028 { 4028 {
4029 hide_cursor(vc); 4029 hide_cursor(vc);
4030 gotoxy(vc, p[0], p[1]); 4030 gotoxy(vc, p[0], p[1]);
4031 set_cursor(vc); 4031 set_cursor(vc);
4032 } 4032 }
4033 4033
4034 u16 vcs_scr_readw(struct vc_data *vc, const u16 *org) 4034 u16 vcs_scr_readw(struct vc_data *vc, const u16 *org)
4035 { 4035 {
4036 if ((unsigned long)org == vc->vc_pos && softcursor_original != -1) 4036 if ((unsigned long)org == vc->vc_pos && softcursor_original != -1)
4037 return softcursor_original; 4037 return softcursor_original;
4038 return scr_readw(org); 4038 return scr_readw(org);
4039 } 4039 }
4040 4040
4041 void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org) 4041 void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org)
4042 { 4042 {
4043 scr_writew(val, org); 4043 scr_writew(val, org);
4044 if ((unsigned long)org == vc->vc_pos) { 4044 if ((unsigned long)org == vc->vc_pos) {
4045 softcursor_original = -1; 4045 softcursor_original = -1;
4046 add_softcursor(vc); 4046 add_softcursor(vc);
4047 } 4047 }
4048 } 4048 }
4049 4049
4050 /* 4050 /*
4051 * Visible symbols for modules 4051 * Visible symbols for modules
4052 */ 4052 */
4053 4053
4054 EXPORT_SYMBOL(color_table); 4054 EXPORT_SYMBOL(color_table);
4055 EXPORT_SYMBOL(default_red); 4055 EXPORT_SYMBOL(default_red);
4056 EXPORT_SYMBOL(default_grn); 4056 EXPORT_SYMBOL(default_grn);
4057 EXPORT_SYMBOL(default_blu); 4057 EXPORT_SYMBOL(default_blu);
4058 EXPORT_SYMBOL(update_region); 4058 EXPORT_SYMBOL(update_region);
4059 EXPORT_SYMBOL(redraw_screen); 4059 EXPORT_SYMBOL(redraw_screen);
4060 EXPORT_SYMBOL(vc_resize); 4060 EXPORT_SYMBOL(vc_resize);
4061 EXPORT_SYMBOL(vc_lock_resize); 4061 EXPORT_SYMBOL(vc_lock_resize);
4062 EXPORT_SYMBOL(fg_console); 4062 EXPORT_SYMBOL(fg_console);
4063 EXPORT_SYMBOL(console_blank_hook); 4063 EXPORT_SYMBOL(console_blank_hook);
4064 EXPORT_SYMBOL(console_blanked); 4064 EXPORT_SYMBOL(console_blanked);
4065 EXPORT_SYMBOL(vc_cons); 4065 EXPORT_SYMBOL(vc_cons);
4066 #ifndef VT_SINGLE_DRIVER 4066 #ifndef VT_SINGLE_DRIVER
4067 EXPORT_SYMBOL(take_over_console); 4067 EXPORT_SYMBOL(take_over_console);
4068 EXPORT_SYMBOL(give_up_console); 4068 EXPORT_SYMBOL(give_up_console);
4069 #endif 4069 #endif
4070 4070
include/linux/consolemap.h
1 /* 1 /*
2 * consolemap.h 2 * consolemap.h
3 * 3 *
4 * Interface between console.c, selection.c and consolemap.c 4 * Interface between console.c, selection.c and consolemap.c
5 */ 5 */
6 #ifndef __LINUX_CONSOLEMAP_H__
7 #define __LINUX_CONSOLEMAP_H__
8
6 #define LAT1_MAP 0 9 #define LAT1_MAP 0
7 #define GRAF_MAP 1 10 #define GRAF_MAP 1
8 #define IBMPC_MAP 2 11 #define IBMPC_MAP 2
9 #define USER_MAP 3 12 #define USER_MAP 3
10 13
11 #include <linux/types.h> 14 #include <linux/types.h>
12 15
16 #ifdef CONFIG_CONSOLE_TRANSLATIONS
13 struct vc_data; 17 struct vc_data;
14 18
15 extern u16 inverse_translate(struct vc_data *conp, int glyph, int use_unicode); 19 extern u16 inverse_translate(struct vc_data *conp, int glyph, int use_unicode);
16 extern unsigned short *set_translate(int m, struct vc_data *vc); 20 extern unsigned short *set_translate(int m, struct vc_data *vc);
17 extern int conv_uni_to_pc(struct vc_data *conp, long ucs); 21 extern int conv_uni_to_pc(struct vc_data *conp, long ucs);
18 extern u32 conv_8bit_to_uni(unsigned char c); 22 extern u32 conv_8bit_to_uni(unsigned char c);
19 extern int conv_uni_to_8bit(u32 uni); 23 extern int conv_uni_to_8bit(u32 uni);
20 void console_map_init(void); 24 void console_map_init(void);
25 #else
26 #define inverse_translate(conp, glyph, uni) ((uint16_t)glyph)
27 #define set_translate(m, vc) ((unsigned short *)NULL)
28 #define conv_uni_to_pc(conp, ucs) ((int) (ucs > 0xff ? -1: ucs))
29 #define conv_8bit_to_uni(c) ((uint32_t)(c))
30 #define conv_uni_to_8bit(c) ((int) ((c) & 0xff))
31 #define console_map_init(c) do { ; } while (0)
32 #endif /* CONFIG_CONSOLE_TRANSLATIONS */
33
34 #endif /* __LINUX_CONSOLEMAP_H__ */
21 35
include/linux/vt_kern.h
1 #ifndef _VT_KERN_H 1 #ifndef _VT_KERN_H
2 #define _VT_KERN_H 2 #define _VT_KERN_H
3 3
4 /* 4 /*
5 * this really is an extension of the vc_cons structure in console.c, but 5 * this really is an extension of the vc_cons structure in console.c, but
6 * with information needed by the vt package 6 * with information needed by the vt package
7 */ 7 */
8 8
9 #include <linux/vt.h> 9 #include <linux/vt.h>
10 #include <linux/kd.h> 10 #include <linux/kd.h>
11 #include <linux/tty.h> 11 #include <linux/tty.h>
12 #include <linux/mutex.h> 12 #include <linux/mutex.h>
13 #include <linux/console_struct.h> 13 #include <linux/console_struct.h>
14 #include <linux/mm.h> 14 #include <linux/mm.h>
15 #include <linux/consolemap.h>
15 16
16 /* 17 /*
17 * Presently, a lot of graphics programs do not restore the contents of 18 * Presently, a lot of graphics programs do not restore the contents of
18 * the higher font pages. Defining this flag will avoid use of them, but 19 * the higher font pages. Defining this flag will avoid use of them, but
19 * will lose support for PIO_FONTRESET. Note that many font operations are 20 * will lose support for PIO_FONTRESET. Note that many font operations are
20 * not likely to work with these programs anyway; they need to be 21 * not likely to work with these programs anyway; they need to be
21 * fixed. The linux/Documentation directory includes a code snippet 22 * fixed. The linux/Documentation directory includes a code snippet
22 * to save and restore the text font. 23 * to save and restore the text font.
23 */ 24 */
24 #ifdef CONFIG_VGA_CONSOLE 25 #ifdef CONFIG_VGA_CONSOLE
25 #define BROKEN_GRAPHICS_PROGRAMS 1 26 #define BROKEN_GRAPHICS_PROGRAMS 1
26 #endif 27 #endif
27 28
28 extern void kd_mksound(unsigned int hz, unsigned int ticks); 29 extern void kd_mksound(unsigned int hz, unsigned int ticks);
29 extern int kbd_rate(struct kbd_repeat *rep); 30 extern int kbd_rate(struct kbd_repeat *rep);
30 extern int fg_console, last_console, want_console; 31 extern int fg_console, last_console, want_console;
31 32
32 /* console.c */ 33 /* console.c */
33 34
34 int vc_allocate(unsigned int console); 35 int vc_allocate(unsigned int console);
35 int vc_cons_allocated(unsigned int console); 36 int vc_cons_allocated(unsigned int console);
36 int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines); 37 int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines);
37 int vc_lock_resize(struct vc_data *vc, unsigned int cols, unsigned int lines); 38 int vc_lock_resize(struct vc_data *vc, unsigned int cols, unsigned int lines);
38 void vc_deallocate(unsigned int console); 39 void vc_deallocate(unsigned int console);
39 void reset_palette(struct vc_data *vc); 40 void reset_palette(struct vc_data *vc);
40 void do_blank_screen(int entering_gfx); 41 void do_blank_screen(int entering_gfx);
41 void do_unblank_screen(int leaving_gfx); 42 void do_unblank_screen(int leaving_gfx);
42 void unblank_screen(void); 43 void unblank_screen(void);
43 void poke_blanked_console(void); 44 void poke_blanked_console(void);
44 int con_font_op(struct vc_data *vc, struct console_font_op *op); 45 int con_font_op(struct vc_data *vc, struct console_font_op *op);
45 int con_set_cmap(unsigned char __user *cmap); 46 int con_set_cmap(unsigned char __user *cmap);
46 int con_get_cmap(unsigned char __user *cmap); 47 int con_get_cmap(unsigned char __user *cmap);
47 void scrollback(struct vc_data *vc, int lines); 48 void scrollback(struct vc_data *vc, int lines);
48 void scrollfront(struct vc_data *vc, int lines); 49 void scrollfront(struct vc_data *vc, int lines);
49 void update_region(struct vc_data *vc, unsigned long start, int count); 50 void update_region(struct vc_data *vc, unsigned long start, int count);
50 void redraw_screen(struct vc_data *vc, int is_switch); 51 void redraw_screen(struct vc_data *vc, int is_switch);
51 #define update_screen(x) redraw_screen(x, 0) 52 #define update_screen(x) redraw_screen(x, 0)
52 #define switch_screen(x) redraw_screen(x, 1) 53 #define switch_screen(x) redraw_screen(x, 1)
53 54
54 struct tty_struct; 55 struct tty_struct;
55 int tioclinux(struct tty_struct *tty, unsigned long arg); 56 int tioclinux(struct tty_struct *tty, unsigned long arg);
56 57
58 #ifdef CONFIG_CONSOLE_TRANSLATIONS
57 /* consolemap.c */ 59 /* consolemap.c */
58 60
59 struct unimapinit; 61 struct unimapinit;
60 struct unipair; 62 struct unipair;
61 63
62 int con_set_trans_old(unsigned char __user * table); 64 int con_set_trans_old(unsigned char __user * table);
63 int con_get_trans_old(unsigned char __user * table); 65 int con_get_trans_old(unsigned char __user * table);
64 int con_set_trans_new(unsigned short __user * table); 66 int con_set_trans_new(unsigned short __user * table);
65 int con_get_trans_new(unsigned short __user * table); 67 int con_get_trans_new(unsigned short __user * table);
66 int con_clear_unimap(struct vc_data *vc, struct unimapinit *ui); 68 int con_clear_unimap(struct vc_data *vc, struct unimapinit *ui);
67 int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list); 69 int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list);
68 int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct unipair __user *list); 70 int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct unipair __user *list);
69 int con_set_default_unimap(struct vc_data *vc); 71 int con_set_default_unimap(struct vc_data *vc);
70 void con_free_unimap(struct vc_data *vc); 72 void con_free_unimap(struct vc_data *vc);
71 void con_protect_unimap(struct vc_data *vc, int rdonly); 73 void con_protect_unimap(struct vc_data *vc, int rdonly);
72 int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc); 74 int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc);
75
76 #define vc_translate(vc, c) ((vc)->vc_translate[(c) | \
77 (vc)->vc_toggle_meta ? 0x80 : 0])
78 #else
79 #define con_set_trans_old(arg) (0)
80 #define con_get_trans_old(arg) (-EINVAL)
81 #define con_set_trans_new(arg) (0)
82 #define con_get_trans_new(arg) (-EINVAL)
83 #define con_clear_unimap(vc, ui) (0)
84 #define con_set_unimap(vc, ct, list) (0)
85 #define con_set_default_unimap(vc) (0)
86 #define con_copy_unimap(d, s) (0)
87 #define con_get_unimap(vc, ct, uct, list) (-EINVAL)
88 #define con_free_unimap(vc) do { ; } while (0)
89
90 #define vc_translate(vc, c) (c)
91 #endif
73 92
74 /* vt.c */ 93 /* vt.c */
75 int vt_waitactive(int vt); 94 int vt_waitactive(int vt);
76 void change_console(struct vc_data *new_vc); 95 void change_console(struct vc_data *new_vc);
77 void reset_vc(struct vc_data *vc); 96 void reset_vc(struct vc_data *vc);
78 extern int unbind_con_driver(const struct consw *csw, int first, int last, 97 extern int unbind_con_driver(const struct consw *csw, int first, int last,
79 int deflt); 98 int deflt);
80 int vty_init(void); 99 int vty_init(void);
81 100
82 /* 101 /*
83 * vc_screen.c shares this temporary buffer with the console write code so that 102 * vc_screen.c shares this temporary buffer with the console write code so that
84 * we can easily avoid touching user space while holding the console spinlock. 103 * we can easily avoid touching user space while holding the console spinlock.
85 */ 104 */
86 105
87 #define CON_BUF_SIZE (CONFIG_BASE_SMALL ? 256 : PAGE_SIZE) 106 #define CON_BUF_SIZE (CONFIG_BASE_SMALL ? 256 : PAGE_SIZE)
88 extern char con_buf[CON_BUF_SIZE]; 107 extern char con_buf[CON_BUF_SIZE];
89 extern struct mutex con_buf_mtx; 108 extern struct mutex con_buf_mtx;
90 extern char vt_dont_switch; 109 extern char vt_dont_switch;
91 extern int default_utf8; 110 extern int default_utf8;
92 111
93 struct vt_spawn_console { 112 struct vt_spawn_console {
94 spinlock_t lock; 113 spinlock_t lock;
95 struct pid *pid; 114 struct pid *pid;
96 int sig; 115 int sig;
97 }; 116 };
98 extern struct vt_spawn_console vt_spawn_con; 117 extern struct vt_spawn_console vt_spawn_con;
99 118
100 #endif /* _VT_KERN_H */ 119 #endif /* _VT_KERN_H */
101 120