/[linux-patches]/genpatches-2.6/tags/2.6.15-2/4505_vesafb-tng-1.0-rc1-r3.patch
Gentoo

Contents of /genpatches-2.6/tags/2.6.15-2/4505_vesafb-tng-1.0-rc1-r3.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 259 - (show annotations) (download)
Wed Jan 11 21:46:01 2006 UTC (8 years, 8 months ago) by dsd
File size: 85908 byte(s)
2.6.15-2 release
1 diff --git a/Documentation/fb/vesafb.txt b/Documentation/fb/vesafb.txt
2 index ee277dd..60f797e 100644
3 --- a/Documentation/fb/vesafb.txt
4 +++ b/Documentation/fb/vesafb.txt
5 @@ -2,16 +2,18 @@
6 What is vesafb?
7 ===============
8
9 -This is a generic driver for a graphic framebuffer on intel boxes.
10 +Vesafb is a generic framebuffer driver for x86 and x86_64 boxes.
11
12 -The idea is simple: Turn on graphics mode at boot time with the help
13 -of the BIOS, and use this as framebuffer device /dev/fb0, like the m68k
14 -(and other) ports do.
15 -
16 -This means we decide at boot time whenever we want to run in text or
17 -graphics mode. Switching mode later on (in protected mode) is
18 -impossible; BIOS calls work in real mode only. VESA BIOS Extensions
19 -Version 2.0 are required, because we need a linear frame buffer.
20 +VESA BIOS Extensions Version 2.0 are required, because we need access to
21 +a linear frame buffer. VBE 3.0 is required if you want to use modes with a
22 +higher (than the standard 60Hz) refresh rate.
23 +
24 +The VESA framebuffer driver comes in two flavors - the standard 'vesafb'
25 +and 'vesafb-tng'. Vesafb-tng is available only on 32-bit x86 due to the
26 +technology it uses (vm86). Vesafb-tng has more features than vesafb
27 +(adjusting the refresh rate on VBE3.0-compliant boards, switching the
28 +video mode without rebooting, selecting a mode by providing its
29 +modedb name, and more).
30
31 Advantages:
32
33 @@ -29,26 +31,35 @@ Disadvantages:
34 How to use it?
35 ==============
36
37 -Switching modes is done using the vga=... boot parameter. Read
38 -Documentation/svga.txt for details.
39 -
40 -You should compile in both vgacon (for text mode) and vesafb (for
41 -graphics mode). Which of them takes over the console depends on
42 -whenever the specified mode is text or graphics.
43 -
44 -The graphic modes are NOT in the list which you get if you boot with
45 -vga=ask and hit return. The mode you wish to use is derived from the
46 -VESA mode number. Here are those VESA mode numbers:
47 +If you are running a 32-bit x86 system and you decide to use vesafb-tng,
48 +you can either compile the driver into the kernel or use it as a module.
49 +The graphics mode you want to use is in both cases specified using the
50 +standard modedb format.
51 +
52 +If your system doesn't support vm86 calls, things get a little more tricky.
53 +Since on such systems you can't do BIOS calls from protected mode in which
54 +kernel runs, you have to decide at boot time whenever you want to run in text
55 +or in graphics mode. Switching mode later on is impossible. Switching modes
56 +is done using the vga=... boot parameter. Read Documentation/svga.txt for
57 +details. Below is a more detailed description of what to do on systems using
58 +the standard vesafb driver.
59 +
60 +You should compile in both vgacon (for text mode) and vesafb (for graphics
61 +mode). Which of them takes over the console depends on whenever the
62 +specified mode is text or graphics.
63 +
64 +The graphic modes are NOT in the list which you get if you boot with vga=ask
65 +and hit return. The mode you wish to use is derived from the VESA mode number.
66 +Here are those VESA mode numbers:
67
68 | 640x480 800x600 1024x768 1280x1024
69 ----+-------------------------------------
70 -256 | 0x101 0x103 0x105 0x107
71 -32k | 0x110 0x113 0x116 0x119
72 -64k | 0x111 0x114 0x117 0x11A
73 -16M | 0x112 0x115 0x118 0x11B
74 +256 | 0x101 0x103 0x105 0x107
75 +32k | 0x110 0x113 0x116 0x119
76 +64k | 0x111 0x114 0x117 0x11A
77 +16M | 0x112 0x115 0x118 0x11B
78
79 -The video mode number of the Linux kernel is the VESA mode number plus
80 -0x200.
81 +The video mode number of the Linux kernel is the VESA mode number plus 0x200.
82
83 Linux_kernel_mode_number = VESA_mode_number + 0x200
84
85 @@ -56,15 +67,15 @@ So the table for the Kernel mode numbers
86
87 | 640x480 800x600 1024x768 1280x1024
88 ----+-------------------------------------
89 -256 | 0x301 0x303 0x305 0x307
90 -32k | 0x310 0x313 0x316 0x319
91 -64k | 0x311 0x314 0x317 0x31A
92 -16M | 0x312 0x315 0x318 0x31B
93 -
94 -To enable one of those modes you have to specify "vga=ask" in the
95 -lilo.conf file and rerun LILO. Then you can type in the desired
96 -mode at the "vga=ask" prompt. For example if you like to use
97 -1024x768x256 colors you have to say "305" at this prompt.
98 +256 | 0x301 0x303 0x305 0x307
99 +32k | 0x310 0x313 0x316 0x319
100 +64k | 0x311 0x314 0x317 0x31A
101 +16M | 0x312 0x315 0x318 0x31B
102 +
103 +To enable one of those modes you have to specify "vga=ask" in the lilo.conf
104 +file and rerun LILO. Then you can type in the desired mode at the "vga=ask"
105 +prompt. For example if you like to use 1024x768x256 colors you have to say
106 +"305" at this prompt.
107
108 If this does not work, this might be because your BIOS does not support
109 linear framebuffers or because it does not support this mode at all.
110 @@ -72,11 +83,12 @@ Even if your board does, it might be the
111 Extensions v2.0 are required, 1.2 is NOT sufficient. You will get a
112 "bad mode number" message if something goes wrong.
113
114 -1. Note: LILO cannot handle hex, for booting directly with
115 +1. Note: LILO cannot handle hex, for booting directly with
116 "vga=mode-number" you have to transform the numbers to decimal.
117 2. Note: Some newer versions of LILO appear to work with those hex values,
118 if you set the 0x in front of the numbers.
119
120 +
121 X11
122 ===
123
124 @@ -84,98 +96,162 @@ XF68_FBDev should work just fine, but it
125 another (accelerated) X-Server like XF86_SVGA might or might not work.
126 It depends on X-Server and graphics board.
127
128 -The X-Server must restore the video mode correctly, else you end up
129 +The X-Server must restore the video mode correctly, or else you end up
130 with a broken console (and vesafb cannot do anything about this).
131 +With vesafb-tng chances are that the console will be restored properly
132 +even if the X server messes up the video mode.
133
134
135 Refresh rates
136 =============
137
138 -There is no way to change the vesafb video mode and/or timings after
139 -booting linux. If you are not happy with the 60 Hz refresh rate, you
140 -have these options:
141 +With VBE3.0 compatible BIOSes and vesafb-tng it is possible to change
142 +the refresh rate either at boot time (by specifying the @<rr> part of
143 +the mode name) or later, using the fbset utility.
144 +
145 +If you want to use the default BIOS refresh rate while switching modes
146 +on a running system, set pixclock to 0.
147 +
148 +With VBE2.0 there is no way to change the mode timings after booting
149 +Linux. If you are not happy with the 60 Hz refresh rate, you have
150 +these options:
151
152 - * configure and load the DOS-Tools for your the graphics board (if
153 - available) and boot linux with loadlin.
154 + * configure and load the DOS tools for your the graphics board (if
155 + available) and boot Linux with loadlin.
156 * use a native driver (matroxfb/atyfb) instead if vesafb. If none
157 is available, write a new one!
158 - * VBE 3.0 might work too. I have neither a gfx board with VBE 3.0
159 - support nor the specs, so I have not checked this yet.
160 + * use a BIOS editor to change the default refresh rate (such an
161 + editor does exist at least for ATI Radeon BIOSes).
162 + * if you're running a non-vm86 and VBE3.0-compatible system, you can
163 + use a kernel patch (vesafb-rrc) to hard-code some mode timings in
164 + the kernel and use these while setting the graphic mode at boot time.
165 +
166 +Note that there are some boards (nVidia 59**, 57** and newer models)
167 +claiming that their Video BIOS is VBE3.0 compliant, while ignoring the
168 +CRTC values provided by software such as vesafb-tng. You'll not be able
169 +to change the refresh rate if you're using one of these boards.
170
171
172 Configuration
173 =============
174
175 -The VESA BIOS provides protected mode interface for changing
176 -some parameters. vesafb can use it for palette changes and
177 -to pan the display. It is turned off by default because it
178 -seems not to work with some BIOS versions, but there are options
179 -to turn it on.
180 -
181 -You can pass options to vesafb using "video=vesafb:option" on
182 -the kernel command line. Multiple options should be separated
183 -by comma, like this: "video=vesafb:ypan,invers"
184 -
185 -Accepted options:
186 -
187 -invers no comment...
188 -
189 -ypan enable display panning using the VESA protected mode
190 - interface. The visible screen is just a window of the
191 - video memory, console scrolling is done by changing the
192 - start of the window.
193 - pro: * scrolling (fullscreen) is fast, because there is
194 - no need to copy around data.
195 - * You'll get scrollback (the Shift-PgUp thing),
196 - the video memory can be used as scrollback buffer
197 - kontra: * scrolling only parts of the screen causes some
198 - ugly flicker effects (boot logo flickers for
199 - example).
200 -
201 -ywrap Same as ypan, but assumes your gfx board can wrap-around
202 - the video memory (i.e. starts reading from top if it
203 - reaches the end of video memory). Faster than ypan.
204 -
205 -redraw scroll by redrawing the affected part of the screen, this
206 - is the safe (and slow) default.
207 -
208 -
209 -vgapal Use the standard vga registers for palette changes.
210 - This is the default.
211 -pmipal Use the protected mode interface for palette changes.
212 -
213 -mtrr:n setup memory type range registers for the vesafb framebuffer
214 - where n:
215 - 0 - disabled (equivalent to nomtrr) (default)
216 - 1 - uncachable
217 - 2 - write-back
218 - 3 - write-combining
219 - 4 - write-through
220 +The VESA BIOS provides protected mode interface for changing some parameters.
221 +vesafb can use it for palette changes and to pan the display. It is turned
222 +off by default because it seems not to work with some BIOS versions, but
223 +there are options to turn it on.
224 +
225 +You can pass options to vesafb using "video=vesafb:option" on the kernel
226 +command line. Multiple options should be separated by comma, like this:
227 +"video=vesafb:ypan,1024x768-32@85"
228 +
229 +Note that vesafb-tng still uses the "video=vesafb:option" format of the
230 +kernel command line video parameter. "video=vesafb-tng:xxx" is incorrect.
231 +
232 +Accepted options (both vesafb and vesafb-tng):
233 +
234 +ypan Enable display panning using the VESA protected mode interface
235 + The visible screen is just a window of the video memory,
236 + console scrolling is done by changing the start of the window.
237 + pro: * scrolling (fullscreen) is fast, because there is
238 + no need to copy around data.
239 + * you'll get scrollback (the Shift-PgUp thing),
240 + the video memory can be used as scrollback buffer
241 + con: * scrolling only parts of the screen causes some
242 + ugly flicker effects (boot logo flickers for
243 + example).
244 +
245 +ywrap Same as ypan, but assumes your gfx board can wrap-around the video
246 + memory (i.e. starts reading from top if it reaches the end of
247 + video memory). Faster than ypan.
248 +
249 +redraw Scroll by redrawing the affected part of the screen, this is the
250 + safe (and slow) default.
251 +
252 +vgapal Use the standard VGA registers for palette changes.
253 + This is the default.
254 +
255 +pmipal Use the protected mode interface for palette changes.
256 +
257 +mtrr:n Setup memory type range registers for the vesafb framebuffer
258 + where n:
259 + 0 - disabled (equivalent to nomtrr) (default)
260 + 1 - uncachable
261 + 2 - write-back
262 + 3 - write-combining
263 + 4 - write-through
264
265 - If you see the following in dmesg, choose the type that matches the
266 - old one. In this example, use "mtrr:2".
267 + If you see the following in dmesg, choose the type that matches
268 + the old one. In this example, use "mtrr:2".
269 ...
270 mtrr: type mismatch for e0000000,8000000 old: write-back new: write-combining
271 ...
272
273 -nomtrr disable mtrr
274 +nomtrr Do not use memory type range registers for vesafb.
275
276 vremap:n
277 remap 'n' MiB of video RAM. If 0 or not specified, remap memory
278 - according to video mode. (2.5.66 patch/idea by Antonino Daplas
279 - reversed to give override possibility (allocate more fb memory
280 - than the kernel would) to 2.4 by tmb@iki.fi)
281 + according to video mode. (2.5.66 patch/idea by Antonino Daplas
282 + reversed to give override possibility (allocate more fb memory
283 + than the kernel would) to 2.4 by tmb@iki.fi)
284
285 vtotal:n
286 if the video BIOS of your card incorrectly determines the total
287 amount of video RAM, use this option to override the BIOS (in MiB).
288
289 -Have fun!
290 +Options accepted only by vesafb-tng:
291
292 - Gerd
293 +<mode> The mode you want to set, in the standard modedb format. Refer to
294 + modedb.txt for detailed description. If you specify a mode that is
295 + not supported by your board's BIOS, vesafb will attempt to set a
296 + similar mode. The list of supported modes can be found in
297 + /proc/fbx/modes, where x is the framebuffer number (usually 0).
298 + When vesafb is compiled as a module, the mode string should be
299 + provided as a value of the parameter 'mode'.
300 +
301 +vbemode:x
302 + Force the use of VBE mode x. The mode will only be set if it's
303 + found in VBE-provided list of supported modes.
304 + NOTE: The mode number 'x' should be specified in VESA mode number
305 + notation, not the Linux kernel one (ie. 257 instead of 769).
306 + HINT: If you use this option because normal <mode> parameter does
307 + not work for you and you use a X server, you'll probably want to
308 + set the 'nocrtc' option to ensure that the video mode is properly
309 + restored after console <-> X switches.
310 +
311 +nocrtc Do not use CRTC timings while setting the graphic mode. This option
312 + makes sence only with VBE3.0 compliant systems. Use it if you have
313 + problems with the modes set in the standard way. Note that specifying
314 + this option means the refresh rate will be ignored and will stay at
315 + your BIOS default (60 Hz).
316 +
317 +noedid Do not try to fetch and use EDID-provided modes.
318 +
319 +gtf Force the use of VESA's GTF (Generalized Timing Formula). Specifying
320 + this will cause vesafb to skip it's internal modedb and EDID-modedb
321 + and jump straight to the GTF part of the code (normally used only if
322 + everything else failed). This can be useful if you want to get as
323 + much as possible from you graphics board but your BIOS doesn't
324 + support modes with refresh rates you require. Note that you may need
325 + to specify the maxhf, maxvf and maxclk parameters if they are not
326 + provided by EDID.
327 +
328 +Additionally, the following parameters may be provided. They all override the
329 +EDID-provided values and BIOS defaults. Refer to your monitor's specs to get
330 +the correct values for maxhf, maxvf and maxclk for your hardware.
331 +
332 +maxhf:n Maximum horizontal frequency (in kHz).
333 +maxvf:n Maximum vertical frequency (in Hz).
334 +maxclk:n Maximum pixel clock (in MHz).
335 +
336 +Have fun!
337
338 --
339 +Original document for the vesafb driver by
340 Gerd Knorr <kraxel@goldbach.in-berlin.de>
341
342 -Minor (mostly typo) changes
343 -by Nico Schmoigl <schmoigl@rumms.uni-mannheim.de>
344 +Minor (mostly typo) changes by
345 +Nico Schmoigl <schmoigl@rumms.uni-mannheim.de>
346 +
347 +Extended documentation for vm86, VBE3.0 and vesafb-tng by
348 +Michal Januszewski <spock@gentoo.org>
349 +
350 diff --git a/arch/i386/boot/video.S b/arch/i386/boot/video.S
351 index 92f6694..c4b29b0 100644
352 --- a/arch/i386/boot/video.S
353 +++ b/arch/i386/boot/video.S
354 @@ -165,10 +165,12 @@ basret: ret
355 # parameters in the default 80x25 mode -- these are set directly,
356 # because some very obscure BIOSes supply insane values.
357 mode_params:
358 +#ifdef CONFIG_FB_VESA_STD
359 #ifdef CONFIG_VIDEO_SELECT
360 cmpb $0, graphic_mode
361 jnz mopar_gr
362 #endif
363 +#endif
364 movb $0x03, %ah # Read cursor position
365 xorb %bh, %bh
366 int $0x10
367 @@ -201,6 +203,7 @@ mopar2: movb %al, %fs:(PARAM_VIDEO_LINES
368 ret
369
370 #ifdef CONFIG_VIDEO_SELECT
371 +#ifdef CONFIG_FB_VESA_STD
372 # Fetching of VESA frame buffer parameters
373 mopar_gr:
374 leaw modelist+1024, %di
375 @@ -283,6 +286,7 @@ dac_done:
376 movw %es, %fs:(PARAM_VESAPM_SEG)
377 movw %di, %fs:(PARAM_VESAPM_OFF)
378 no_pm: ret
379 +#endif
380
381 # The video mode menu
382 mode_menu:
383 @@ -497,10 +501,12 @@ mode_set:
384
385 cmpb $VIDEO_FIRST_V7>>8, %ah
386 jz setv7
387 -
388 +
389 +#ifdef CONFIG_FB_VESA_STD
390 cmpb $VIDEO_FIRST_VESA>>8, %ah
391 jnc check_vesa
392 -
393 +#endif
394 +
395 orb %ah, %ah
396 jz setmenu
397
398 @@ -572,6 +578,7 @@ setr1: lodsw
399 movw -4(%si), %ax # Fetch mode ID
400 jmp _m_s
401
402 +#ifdef CONFIG_FB_VESA_STD
403 check_vesa:
404 leaw modelist+1024, %di
405 subb $VIDEO_FIRST_VESA>>8, %bh
406 @@ -605,6 +612,7 @@ check_vesa:
407 ret
408
409 _setbad: jmp setbad # Ugly...
410 +#endif
411
412 # Recalculate vertical display end registers -- this fixes various
413 # inconsistencies of extended modes on many adapters. Called when
414 diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
415 index 25b6ca6..768fb08 100644
416 --- a/drivers/video/Kconfig
417 +++ b/drivers/video/Kconfig
418 @@ -454,8 +454,8 @@ config FB_TGA
419 cards. Say Y if you have one of those.
420
421 config FB_VESA
422 - bool "VESA VGA graphics support"
423 - depends on (FB = y) && X86
424 + tristate "VESA VGA graphics support"
425 + depends on (FB = y) && (X86 || X86_64)
426 select FB_CFB_FILLRECT
427 select FB_CFB_COPYAREA
428 select FB_CFB_IMAGEBLIT
429 @@ -465,6 +465,48 @@ config FB_VESA
430 You will get a boot time penguin logo at no additional cost. Please
431 read <file:Documentation/fb/vesafb.txt>. If unsure, say Y.
432
433 +choice
434 + prompt "VESA driver type"
435 + depends on FB_VESA
436 + default FB_VESA_STD if X86_64
437 + default FB_VESA_TNG if X86
438 +
439 +config FB_VESA_STD
440 + bool "vesafb"
441 + help
442 + This is the frame buffer device driver for generic VESA 2.0
443 + compliant graphic cards. The older VESA 1.2 cards are not supported.
444 + You will get a boot time penguin logo at no additional cost. Please
445 + read <file:Documentation/fb/vesafb.txt>. Choose this driver if you
446 + are experiencing problems with vesafb-tng or if you own a 64-bit system.
447 +
448 + Note that this driver cannot be compiled as a module.
449 +
450 +config FB_VESA_TNG
451 + bool "vesafb-tng"
452 + depends on !X86_64
453 + select FB_MODE_HELPERS
454 + help
455 + This is the frame buffer device driver for generic VESA 2.0
456 + compliant graphic cards. It is capable of taking advantage of
457 + VBE 3.0 features. With this driver you will be able to adjust
458 + the refresh rate (VBE 3.0 compliant boards only) and change
459 + the graphic mode on-the-fly.
460 +
461 + You will also get a boot time penguin logo at no additional cost. Please
462 + read <file:Documentation/fb/vesafb.txt>.
463 +
464 +endchoice
465 +
466 +config FB_VESA_DEFAULT_MODE
467 + string "VESA default mode"
468 + depends on FB_VESA_TNG
469 + default "640x480@60"
470 + help
471 + This option is used to determine the default mode vesafb is
472 + supposed to switch to in case no mode is provided as a kernel
473 + command line parameter.
474 +
475 config VIDEO_SELECT
476 bool
477 depends on FB_VESA
478 diff --git a/drivers/video/Makefile b/drivers/video/Makefile
479 index aa434e7..247cfb3 100644
480 --- a/drivers/video/Makefile
481 +++ b/drivers/video/Makefile
482 @@ -96,7 +96,11 @@ obj-$(CONFIG_FB_IMX) += imx
483 obj-$(CONFIG_FB_S3C2410) += s3c2410fb.o
484
485 # Platform or fallback drivers go here
486 -obj-$(CONFIG_FB_VESA) += vesafb.o
487 +ifeq ($(CONFIG_FB_VESA_STD),y)
488 + obj-y += vesafb.o
489 +else
490 + obj-$(CONFIG_FB_VESA) += vesafb-thread.o vesafb-tng.o
491 +endif
492 obj-$(CONFIG_FB_VGA16) += vga16fb.o vgastate.o
493 obj-$(CONFIG_FB_OF) += offb.o
494
495 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
496 index 9f18009..e3e5271 100644
497 --- a/drivers/video/fbmem.c
498 +++ b/drivers/video/fbmem.c
499 @@ -1403,6 +1403,7 @@ fbmem_init(void)
500 printk(KERN_WARNING "Unable to create fb class; errno = %ld\n", PTR_ERR(fb_class));
501 fb_class = NULL;
502 }
503 +
504 return 0;
505 }
506
507 diff --git a/drivers/video/modedb.c b/drivers/video/modedb.c
508 index 1da2f84..6755cb2 100644
509 --- a/drivers/video/modedb.c
510 +++ b/drivers/video/modedb.c
511 @@ -667,6 +667,7 @@ void fb_var_to_videomode(struct fb_video
512 {
513 u32 pixclock, hfreq, htotal, vtotal;
514
515 + mode->refresh = 0;
516 mode->name = NULL;
517 mode->xres = var->xres;
518 mode->yres = var->yres;
519 diff --git a/drivers/video/vesafb-thread.c b/drivers/video/vesafb-thread.c
520 new file mode 100644
521 index 0000000..249d794
522 --- /dev/null
523 +++ b/drivers/video/vesafb-thread.c
524 @@ -0,0 +1,722 @@
525 +/*
526 + * Framebuffer driver for VBE 2.0+ compliant graphic boards.
527 + * Kernel thread and vm86 routines.
528 + *
529 + * (c) 2004-2005 Michal Januszewski <spock@gentoo.org>
530 + *
531 + */
532 +
533 +#include <linux/config.h>
534 +#include <linux/slab.h>
535 +#include <linux/workqueue.h>
536 +#include <linux/completion.h>
537 +#include <linux/module.h>
538 +#include <linux/kernel.h>
539 +#include <linux/errno.h>
540 +#include <linux/mm.h>
541 +#include <linux/delay.h>
542 +#include <linux/signal.h>
543 +#include <linux/suspend.h>
544 +#include <linux/unistd.h>
545 +#include <video/vesa.h>
546 +#include <video/edid.h>
547 +#include <asm/mman.h>
548 +#include <asm/page.h>
549 +#include <asm/vm86.h>
550 +#include <asm/thread_info.h>
551 +#include <asm/uaccess.h>
552 +#include <asm/mmu_context.h>
553 +#include "edid.h"
554 +
555 +#ifdef MODULE
556 +int errno;
557 +#endif
558 +
559 +static DECLARE_COMPLETION(vesafb_th_completion);
560 +static DECLARE_MUTEX(vesafb_task_list_sem);
561 +static LIST_HEAD(vesafb_task_list);
562 +static DECLARE_WAIT_QUEUE_HEAD(vesafb_wait);
563 +
564 +static struct vm86_struct vm86;
565 +static int vesafb_pid = 0;
566 +
567 +_syscall3(int,ioperm,unsigned long, a, unsigned long, b, unsigned long, c);
568 +_syscall1(int,vm86old,struct vm86_struct __user*, v86);
569 +
570 +#define DEFAULT_VM86_FLAGS (IF_MASK | IOPL_MASK)
571 +#define VM86_PUSHW(x) \
572 +do { \
573 + vm86.regs.esp -= 2; \
574 + *(u16*)(STACK_ADDR + vm86.regs.esp) = x; \
575 +} while(0);
576 +
577 +/* Stack, the return code and buffers will be put into
578 + * one contiguous memory chunk:
579 + *
580 + * [ STACK | RET_CODE | BUFFER ]
581 + *
582 + * We only need a buffer that is ca. 0x2000 bytes in size.
583 + * Some video BIOSes (sis6326) try to store data somewhere
584 + * in 0x7000-0x7fff, so we zeromap more memory to be safe.
585 + */
586 +#define IVTBDA_SIZE PAGE_SIZE
587 +#define RET_CODE_SIZE 0x0010
588 +#define STACK_SIZE 0x0500
589 +#define BUFFER_SIZE 0x10000
590 +
591 +/* The amount of memory that will be allocated should be a multiple
592 + * of PAGE_SIZE. */
593 +#define __MEM_SIZE (RET_CODE_SIZE + STACK_SIZE + BUFFER_SIZE)
594 +#define REAL_MEM_SIZE (((__MEM_SIZE / PAGE_SIZE) + 1) * PAGE_SIZE)
595 +
596 +#define IVTBDA_ADDR 0x00000
597 +#define STACK_ADDR (IVTBDA_ADDR + IVTBDA_SIZE)
598 +#define RET_CODE_ADDR (STACK_ADDR + STACK_SIZE)
599 +#define BUF_ADDR (RET_CODE_ADDR + RET_CODE_SIZE)
600 +
601 +#define FLAG_D (1 << 10)
602 +
603 +/* Segment prefix opcodes */
604 +enum {
605 + P_CS = 0x2e,
606 + P_SS = 0x36,
607 + P_DS = 0x3e,
608 + P_ES = 0x26,
609 + P_FS = 0x64,
610 + P_GS = 0x65
611 +};
612 +
613 +/* Emulated vm86 ins instruction */
614 +static void vm86_ins(int size)
615 +{
616 + u32 edx, edi;
617 + edx = vm86.regs.edx & 0xffff;
618 + edi = (vm86.regs.edi & 0xffff) + (u32)(vm86.regs.es << 4);
619 +
620 + if (vm86.regs.eflags & FLAG_D)
621 + asm volatile ("std\n");
622 + else
623 + asm volatile ("cld\n");
624 +
625 + switch (size) {
626 + case 4:
627 + asm volatile ("insl\n" : "=D" (edi) : "d" (edx), "0" (edi));
628 + break;
629 + case 2:
630 + asm volatile ("insw\n" : "=D" (edi) : "d" (edx), "0" (edi));
631 + break;
632 + case 1:
633 + asm volatile ("insb\n" : "=D" (edi) : "d" (edx), "0" (edi));
634 + break;
635 + }
636 +
637 + if (vm86.regs.eflags & FLAG_D)
638 + asm volatile ("cld\n");
639 +
640 + edi -= (u32)(vm86.regs.es << 4);
641 +
642 + vm86.regs.edi &= 0xffff0000;
643 + vm86.regs.edi |= edi & 0xffff;
644 +}
645 +
646 +static void vm86_rep_ins(int size)
647 +{
648 + u16 cx = vm86.regs.ecx;
649 + while (cx--)
650 + vm86_ins(size);
651 +
652 + vm86.regs.ecx &= 0xffff0000;
653 +}
654 +
655 +/* Emulated vm86 outs instruction */
656 +static void vm86_outs(int size, int segment)
657 +{
658 + u32 edx, esi, base;
659 +
660 + edx = vm86.regs.edx & 0xffff;
661 + esi = vm86.regs.esi & 0xffff;
662 +
663 + switch (segment) {
664 + case P_CS: base = vm86.regs.cs; break;
665 + case P_SS: base = vm86.regs.ss; break;
666 + case P_ES: base = vm86.regs.es; break;
667 + case P_FS: base = vm86.regs.fs; break;
668 + case P_GS: base = vm86.regs.gs; break;
669 + default: base = vm86.regs.ds; break;
670 + }
671 +
672 + esi += base << 4;
673 +
674 + if (vm86.regs.eflags & FLAG_D)
675 + asm volatile ("std\n");
676 + else
677 + asm volatile ("cld\n");
678 +
679 + switch (size) {
680 + case 4:
681 + asm volatile ("outsl\n" : "=S" (esi) : "d" (edx), "0" (esi));
682 + break;
683 + case 2:
684 + asm volatile ("outsw\n" : "=S" (esi) : "d" (edx), "0" (esi));
685 + break;
686 + case 1:
687 + asm volatile ("outsb\n" : "=S" (esi) : "d" (edx), "0" (esi));
688 + break;
689 + }
690 +
691 + if (vm86.regs.eflags & FLAG_D)
692 + asm volatile ("cld");
693 +
694 + esi -= base << 4;
695 + vm86.regs.esi &= 0xffff0000;
696 + vm86.regs.esi |= (esi & 0xffff);
697 +}
698 +
699 +static void vm86_rep_outs(int size, int segment)
700 +{
701 + u16 cx = vm86.regs.ecx;
702 + while (cx--)
703 + vm86_outs(size, segment);
704 +
705 + vm86.regs.ecx &= 0xffff0000;
706 +}
707 +
708 +static int vm86_do_unknown(void)
709 +{
710 + u8 data32 = 0, segment = P_DS, rep = 0;
711 + u8 *instr;
712 + int ret = 0, i = 0;
713 +
714 + instr = (u8*)((vm86.regs.cs << 4) + vm86.regs.eip);
715 +
716 + while (1) {
717 + switch(instr[i]) {
718 + case 0x66: /* operand size prefix */
719 + data32 = 1 - data32;
720 + i++;
721 + break;
722 + case 0xf2: /* repnz */
723 + case 0xf3: /* rep */
724 + rep = 1;
725 + i++;
726 + break;
727 + case P_CS: /* segment prefix */
728 + case P_SS:
729 + case P_DS:
730 + case P_ES:
731 + case P_FS:
732 + case P_GS:
733 + segment = instr[i];
734 + i++;
735 + break;
736 + case 0xf0: /* LOCK - ignored */
737 + case 0x67: /* address size prefix - ignored */
738 + i++;
739 + break;
740 + case 0x6c: /* insb */
741 + if (rep)
742 + vm86_rep_ins(1);
743 + else
744 + vm86_ins(1);
745 + i++;
746 + goto out;
747 + case 0x6d: /* insw / insd */
748 + if (rep) {
749 + if (data32)
750 + vm86_rep_ins(4);
751 + else
752 + vm86_rep_ins(2);
753 + } else {
754 + if (data32)
755 + vm86_ins(4);
756 + else
757 + vm86_ins(2);
758 + }
759 + i++;
760 + goto out;
761 + case 0x6e: /* outsb */
762 + if (rep)
763 + vm86_rep_outs(1, segment);
764 + else
765 + vm86_outs(1, segment);
766 + i++;
767 + goto out;
768 + case 0x6f: /* outsw / outsd */
769 + if (rep) {
770 + if (data32)
771 + vm86_rep_outs(4, segment);
772 + else
773 + vm86_rep_outs(2, segment);
774 + } else {
775 + if (data32)
776 + vm86_outs(4, segment);
777 + else
778 + vm86_outs(2, segment);
779 + }
780 + i++;
781 + goto out;
782 + case 0xe4: /* inb xx */
783 + asm volatile (
784 + "inb %w1, %b0"
785 + : "=a" (vm86.regs.eax)
786 + : "d" (instr[i+1]), "0" (vm86.regs.eax));
787 + i += 2;
788 + goto out;
789 + case 0xe5: /* inw xx / ind xx */
790 + if (data32) {
791 + asm volatile (
792 + "inl %w1, %0"
793 + : "=a" (vm86.regs.eax)
794 + : "d" (instr[i+1]),
795 + "0" (vm86.regs.eax));
796 + } else {
797 + asm volatile (
798 + "inw %w1, %w0"
799 + : "=a" (vm86.regs.eax)
800 + : "d" (instr[i+1]),
801 + "0" (vm86.regs.eax));
802 + }
803 + i += 2;
804 + goto out;
805 +
806 + case 0xec: /* inb dx */
807 + asm volatile (
808 + "inb %w1, %b0"
809 + : "=a" (vm86.regs.eax)
810 + : "d" (vm86.regs.edx), "0" (vm86.regs.eax));
811 + i++;
812 + goto out;
813 + case 0xed: /* inw dx / ind dx */
814 + if (data32) {
815 + asm volatile (
816 + "inl %w1, %0"
817 + : "=a" (vm86.regs.eax)
818 + : "d" (vm86.regs.edx));
819 + } else {
820 + asm volatile (
821 + "inw %w1, %w0"
822 + : "=a" (vm86.regs.eax)
823 + : "d" (vm86.regs.edx));
824 + }
825 + i++;
826 + goto out;
827 + case 0xe6: /* outb xx */
828 + asm volatile (
829 + "outb %b0, %w1"
830 + : /* no return value */
831 + : "a" (vm86.regs.eax), "d" (instr[i+1]));
832 + i += 2;
833 + goto out;
834 + case 0xe7: /* outw xx / outd xx */
835 + if (data32) {
836 + asm volatile (
837 + "outl %0, %w1"
838 + : /* no return value */
839 + : "a" (vm86.regs.eax),
840 + "d" (instr[i+1]));
841 + } else {
842 + asm volatile (
843 + "outw %w0, %w1"
844 + : /* no return value */
845 + : "a" (vm86.regs.eax),
846 + "d" (instr[i+1]));
847 + }
848 + i += 2;
849 + goto out;
850 + case 0xee: /* outb dx */
851 + asm volatile (
852 + "outb %b0, %w1"
853 + : /* no return value */
854 + : "a" (vm86.regs.eax), "d" (vm86.regs.edx));
855 + i++;
856 + goto out;
857 + case 0xef: /* outw dx / outd dx */
858 + if (data32) {
859 + asm volatile (
860 + "outl %0, %w1"
861 + : /* no return value */
862 + : "a" (vm86.regs.eax),
863 + "d" (vm86.regs.edx));
864 + } else {
865 + asm volatile (
866 + "outw %w0, %w1"
867 + : /* no return value */
868 + : "a" (vm86.regs.eax),
869 + "d" (vm86.regs.edx));
870 + }
871 + i++;
872 + goto out;
873 + default:
874 + printk(KERN_ERR "vesafb: BUG, opcode 0x%x emulation "
875 + "not supported (EIP: 0x%lx)\n",
876 + instr[i], (u32)(vm86.regs.cs << 4) +
877 + vm86.regs.eip);
878 + ret = 1;
879 + goto out;
880 + }
881 + }
882 +out: vm86.regs.eip += i;
883 + return ret;
884 +}
885 +
886 +void vesafb_do_vm86(struct vm86_regs *regs)
887 +{
888 + unsigned int ret;
889 + u8 *retcode = (void*)RET_CODE_ADDR;
890 +
891 + memset(&vm86,0,sizeof(vm86));
892 + memcpy(&vm86.regs, regs, sizeof(struct vm86_regs));
893 +
894 + /* The return code */
895 + retcode[0] = 0xcd; /* int opcode */
896 + retcode[1] = 0xff; /* int number (255) */
897 +
898 + /* We use int 0xff to get back to protected mode */
899 + memset(&vm86.int_revectored, 0, sizeof(vm86.int_revectored));
900 + ((unsigned char *)&vm86.int_revectored)[0xff / 8] |= (1 << (0xff % 8));
901 +
902 + /*
903 + * We want to call int 0x10, so we set:
904 + * CS = 0x42 = 0x10 * 4 + 2
905 + * IP = 0x40 = 0x10 * 4
906 + * and SS:ESP. It's up to the caller to set the rest of the registers.
907 + */
908 + vm86.regs.eflags = DEFAULT_VM86_FLAGS;
909 + vm86.regs.cs = *(unsigned short *)0x42;
910 + vm86.regs.eip = *(unsigned short *)0x40;
911 + vm86.regs.ss = (STACK_ADDR >> 4);
912 + vm86.regs.esp = ((STACK_ADDR & 0x0000f) + STACK_SIZE);
913 +
914 + /* These will be fetched off the stack when we come to an iret in the
915 + * int's 0x10 code. */
916 + VM86_PUSHW(DEFAULT_VM86_FLAGS);
917 + VM86_PUSHW((RET_CODE_ADDR >> 4)); /* return code segment */
918 + VM86_PUSHW((RET_CODE_ADDR & 0x0000f)); /* return code offset */
919 +
920 + while(1) {
921 + ret = vm86old(&vm86);
922 +
923 + if (VM86_TYPE(ret) == VM86_INTx) {
924 + int vint = VM86_ARG(ret);
925 +
926 + /* If exit from vm86 was caused by int 0xff, then
927 + * we're done.. */
928 + if (vint == 0xff)
929 + goto out;
930 +
931 + /* .. otherwise, we have to call the int handler
932 + * manually */
933 + VM86_PUSHW(vm86.regs.eflags);
934 + VM86_PUSHW(vm86.regs.cs);
935 + VM86_PUSHW(vm86.regs.eip);
936 +
937 + vm86.regs.cs = *(u16 *)((vint << 2) + 2);
938 + vm86.regs.eip = *(u16 *)(vint << 2);
939 + vm86.regs.eflags &= ~(VIF_MASK | TF_MASK);
940 + } else if (VM86_TYPE(ret) == VM86_UNKNOWN) {
941 + if (vm86_do_unknown())
942 + goto out;
943 + } else {
944 + printk(KERN_ERR "vesafb: BUG, returned from "
945 + "vm86 with %x (EIP: 0x%lx)\n",
946 + ret, (u32)(vm86.regs.cs << 4) +
947 + vm86.regs.eip);
948 + goto out;
949 + }
950 + }
951 +
952 +out: /* copy the registers' state back to the caller's struct */
953 + memcpy(regs, &vm86.regs, sizeof(struct vm86_regs));
954 +}
955 +
956 +static int vesafb_remap_pfn_range(unsigned long start, unsigned long end,
957 + unsigned long pgoff, unsigned long prot,
958 + int type)
959 +{
960 + struct vm_area_struct *vma;
961 + struct mm_struct *mm = current->mm;
962 + int ret = 0;
963 +
964 + vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
965 + if (!vma)
966 + return -ENOMEM;
967 + memset(vma, 0, sizeof(*vma));
968 + down_write(&mm->mmap_sem);
969 + vma->vm_mm = mm;
970 + vma->vm_start = start;
971 + vma->vm_end = end;
972 + vma->vm_flags = VM_READ | VM_WRITE | VM_EXEC;
973 + vma->vm_flags |= mm->def_flags;
974 + vma->vm_page_prot.pgprot = prot;
975 + vma->vm_pgoff = pgoff;
976 +
977 + if ((ret = insert_vm_struct(mm, vma))) {
978 + up_write(&mm->mmap_sem);
979 + kmem_cache_free(vm_area_cachep, vma);
980 + return ret;
981 + }
982 +
983 + if (type) {
984 + vma->vm_flags |= VM_SHARED;
985 + ret = zeromap_page_range(vma,
986 + vma->vm_start,
987 + vma->vm_end - vma->vm_start,
988 + vma->vm_page_prot);
989 + } else {
990 + ret = remap_pfn_range(vma,
991 + vma->vm_start,
992 + vma->vm_pgoff,
993 + vma->vm_end - vma->vm_start,
994 + vma->vm_page_prot);
995 + }
996 + up_write(&mm->mmap_sem);
997 + return ret;
998 +}
999 +
1000 +static inline int vesafb_init_mem(void)
1001 +{
1002 + int ret = 0;
1003 +
1004 + /* The memory chunks we're remapping here should be multiples
1005 + * of PAGE_SIZE. */
1006 + ret += vesafb_remap_pfn_range(0x00000, IVTBDA_SIZE, 0,
1007 + PROT_READ | PROT_EXEC | PROT_WRITE, 0);
1008 + ret += vesafb_remap_pfn_range(IVTBDA_SIZE, REAL_MEM_SIZE, 0,
1009 + PROT_READ | PROT_EXEC | PROT_WRITE, 1);
1010 + ret += vesafb_remap_pfn_range(0x9f000, 0x100000,
1011 + 0x9f000 >> PAGE_SHIFT,
1012 + PROT_READ | PROT_EXEC | PROT_WRITE, 0);
1013 + if (ret)
1014 + printk(KERN_ERR "vesafb thread: memory remapping failed\n");
1015 +
1016 + return ret;
1017 +}
1018 +
1019 +#define vesafb_get_string(str) \
1020 +{ \
1021 + /* The address is in the form ssssoooo, where oooo = offset, \
1022 + * ssss = segment */ \
1023 + addr = ((p_vbe(tsk->buf)->str & 0xffff0000) >> 12) + \
1024 + (p_vbe(tsk->buf)->str & 0x0000ffff); \
1025 + \
1026 + /* The data is in ROM which is shared between processes, so we \
1027 + * just translate the real mode address into one visible from \
1028 + * kernel space */ \
1029 + if (addr >= 0xa0000) { \
1030 + p_vbe(tsk->buf)->str = (u32) __va(addr); \
1031 + \
1032 + /* The data is in the buffer, we just have to convert the \
1033 + * address so that it points into the buffer user provided. */ \
1034 + } else if (addr > BUF_ADDR && addr < BUF_ADDR + \
1035 + sizeof(struct vesafb_vbe_ib)) { \
1036 + addr -= BUF_ADDR; \
1037 + p_vbe(tsk->buf)->str = (u32) (tsk->buf + addr); \
1038 + \
1039 + /* This should never happen: someone was insane enough to put \
1040 + * the data somewhere in RAM.. */ \
1041 + } else { \
1042 + p_vbe(tsk->buf)->str = (u32) ""; \
1043 + } \
1044 +}
1045 +
1046 +void vesafb_handle_getvbeib(struct vesafb_task *tsk)
1047 +{
1048 + int addr, res;
1049 +
1050 + tsk->regs.es = (BUF_ADDR >> 4);
1051 + tsk->regs.edi = (BUF_ADDR & 0x000f);
1052 + strncpy(p_vbe(BUF_ADDR)->vbe_signature, "VBE2", 4);
1053 +
1054 + vesafb_do_vm86(&tsk->regs);
1055 + memcpy(tsk->buf, (void*)(BUF_ADDR), sizeof(struct vesafb_vbe_ib));
1056 +
1057 + /* The OEM fields were not defined prior to VBE 2.0 */
1058 + if (p_vbe(tsk->buf)->vbe_version >= 0x200) {
1059 + vesafb_get_string(oem_string_ptr);
1060 + vesafb_get_string(oem_vendor_name_ptr);
1061 + vesafb_get_string(oem_product_name_ptr);
1062 + vesafb_get_string(oem_product_rev_ptr);
1063 + }
1064 +
1065 + /* This is basically the same as vesafb_get_string() */
1066 + addr = ((p_vbe(tsk->buf)->mode_list_ptr & 0xffff0000) >> 12) +
1067 + (p_vbe(tsk->buf)->mode_list_ptr & 0x0000ffff);
1068 +
1069 + if (addr >= 0xa0000) {
1070 + p_vbe(tsk->buf)->mode_list_ptr = (u32) __va(addr);
1071 + } else if (addr > BUF_ADDR && addr < BUF_ADDR +
1072 + sizeof(struct vesafb_vbe_ib)) {
1073 + addr -= BUF_ADDR;
1074 + p_vbe(tsk->buf)->mode_list_ptr = (u32) (tsk->buf + addr);
1075 + } else {
1076 + res = 0;
1077 + printk(KERN_WARNING "vesafb: warning, copying modelist "
1078 + "from somewhere in RAM!\n");
1079 + while (*(u16*)(addr+res) != 0xffff &&
1080 + res < (sizeof(p_vbe(tsk->buf)->reserved) - 2)) {
1081 + *(u16*) ((u32)&(p_vbe(tsk->buf)->reserved) + res) =
1082 + *(u16*)(addr+res);
1083 + res += 2;
1084 + }
1085 + *(u16*) ((u32)&(p_vbe(tsk->buf)->reserved) + res) = 0xffff;
1086 + }
1087 +}
1088 +
1089 +int vesafb_handle_tasks(void)
1090 +{
1091 + struct vesafb_task *tsk;
1092 + struct list_head *curr, *next;
1093 + int ret = 0;
1094 +
1095 + down(&vesafb_task_list_sem);
1096 + list_for_each_safe(curr, next, &vesafb_task_list) {
1097 + tsk = list_entry(curr, struct vesafb_task, node);
1098 +
1099 + if (tsk->flags & TF_EXIT) {
1100 + ret = 1;
1101 + goto task_done;
1102 + }
1103 + if (tsk->flags & TF_GETVBEIB) {
1104 + vesafb_handle_getvbeib(tsk);
1105 + goto task_done;
1106 + }
1107 + if (tsk->flags & TF_MASK_BUF) {
1108 + tsk->regs.es = (BUF_ADDR >> 4);
1109 + tsk->regs.edi = (BUF_ADDR & 0x000f);
1110 + }
1111 + if (tsk->flags & TF_USE_BUF)
1112 + memcpy((void*)BUF_ADDR, tsk->buf, tsk->buf_len);
1113 +
1114 + vesafb_do_vm86(&tsk->regs);
1115 +
1116 + if (tsk->flags & TF_RETURN_BUF)
1117 + memcpy(tsk->buf, (void*)BUF_ADDR, tsk->buf_len);
1118 +
1119 +task_done: list_del(curr);
1120 + complete(&tsk->done);
1121 + }
1122 +
1123 + /* If we're going to kill this thread, don't allow any elements
1124 + * to be added to the task list. */
1125 + if (!ret)
1126 + up(&vesafb_task_list_sem);
1127 +
1128 + return ret;
1129 +}
1130 +
1131 +/*
1132 + * This 'hybrid' thread serves as a backend for vesafb-tng, handling all vm86
1133 + * calls. It is started as a kernel thread. It then creates its own mm struct,
1134 + * thus separating itself from any userspace processes. At this moment, it
1135 + * stops being a kernel thread (kernel threads have mm = NULL) and becomes
1136 + * a 'hybrid' thread -- one that has full access to kernel space, yet runs
1137 + * with its own address space.
1138 + *
1139 + * This is necessary because in order to make vm86 calls some parts of the
1140 + * first 1MB of RAM have to be setup to mimic the real mode. These are:
1141 + * - interrupt vector table [0x00000-0x003ff]
1142 + * - BIOS data area [0x00400-0x004ff]
1143 + * - Extended BIOS data area [0x9fc00-0x9ffff]
1144 + * - the video RAM [0xa0000-0xbffff]
1145 + * - video BIOS [0xc0000-0xcffff]
1146 + * - motherboard BIOS [0xf0000-0xfffff]
1147 + */
1148 +int vesafb_thread(void *unused)
1149 +{
1150 + int err = 0;
1151 +
1152 + set_fs(KERNEL_DS);
1153 + daemonize("vesafb");
1154 +
1155 + if (set_new_mm()) {
1156 + err = -ENOMEM;
1157 + goto thr_end;
1158 + }
1159 + if (vesafb_init_mem()) {
1160 + err = -ENOMEM;
1161 + goto thr_end;
1162 + }
1163 +
1164 + DPRINTK("started vesafb thread\n");
1165 +
1166 + /* Having an IO bitmap makes things faster as we avoid GPFs
1167 + * when running vm86 code. We can live if it fails, though,
1168 + * so don't bother checking for errors. */
1169 + ioperm(0,1024,1);
1170 + set_user_nice(current, -10);
1171 +
1172 + complete(&vesafb_th_completion);
1173 +
1174 + while (1) {
1175 + if (vesafb_handle_tasks())
1176 + break;
1177 + wait_event_interruptible(vesafb_wait,
1178 + !list_empty(&vesafb_task_list));
1179 + try_to_freeze();
1180 + }
1181 +
1182 +out: DPRINTK("exiting the vesafb thread\n");
1183 + vesafb_pid = -1;
1184 +
1185 + /* Now that all callers know this thread is no longer running
1186 + * (pid < 0), allow them to continue. */
1187 + up(&vesafb_task_list_sem);
1188 + return err;
1189 +thr_end:
1190 + down(&vesafb_task_list_sem);
1191 + complete(&vesafb_th_completion);
1192 + goto out;
1193 +}
1194 +
1195 +int vesafb_queue_task(struct vesafb_task *tsk)
1196 +{
1197 + down(&vesafb_task_list_sem);
1198 + if (vesafb_pid < 0)
1199 + return -1;
1200 + list_add_tail(&tsk->node, &vesafb_task_list);
1201 + up(&vesafb_task_list_sem);
1202 + wake_up(&vesafb_wait);
1203 + return 0;
1204 +}
1205 +
1206 +int vesafb_wait_for_thread(void)
1207 +{
1208 + /* PID 0 means that the thread is still initializing. */
1209 + if (vesafb_pid < 0)
1210 + return -1;
1211 + wait_for_completion(&vesafb_th_completion);
1212 + return 0;
1213 +}
1214 +
1215 +int __init vesafb_init_thread(void)
1216 +{
1217 + vesafb_pid = kernel_thread(vesafb_thread,NULL,0);
1218 + return 0;
1219 +}
1220 +
1221 +#ifdef MODULE
1222 +void __exit vesafb_kill_thread(void)
1223 +{
1224 + struct vesafb_task *tsk;
1225 + if (vesafb_pid <= 0)
1226 + return;
1227 +
1228 + vesafb_create_task(tsk);
1229 + if (!tsk)
1230 + return;
1231 + tsk->flags |= TF_EXIT;
1232 + vesafb_queue_task(tsk);
1233 + vesafb_wait_for_task(tsk);
1234 + kfree(tsk);
1235 + return;
1236 +}
1237 +module_exit(vesafb_kill_thread);
1238 +#endif
1239 +module_init(vesafb_init_thread);
1240 +
1241 +EXPORT_SYMBOL_GPL(vesafb_queue_task);
1242 +EXPORT_SYMBOL_GPL(vesafb_wait_for_thread);
1243 +
1244 +MODULE_LICENSE("GPL");
1245 +MODULE_AUTHOR("Michal Januszewski");
1246 +
1247 diff --git a/drivers/video/vesafb-tng.c b/drivers/video/vesafb-tng.c
1248 new file mode 100644
1249 index 0000000..4f98aea
1250 --- /dev/null
1251 +++ b/drivers/video/vesafb-tng.c
1252 @@ -0,0 +1,1478 @@
1253 +/*
1254 + * Framebuffer driver for VBE 2.0+ compliant graphic boards
1255 + *
1256 + * (c) 2004-2005 Michal Januszewski <spock@gentoo.org
1257 + * Based upon vesafb code by Gerd Knorr <kraxel@goldbach.in-berlin.de
1258 + *
1259 + */
1260 +
1261 +#include <linux/module.h>
1262 +#include <linux/kernel.h>
1263 +#include <linux/errno.h>
1264 +#include <linux/string.h>
1265 +#include <linux/mm.h>
1266 +#include <linux/tty.h>
1267 +#include <linux/delay.h>
1268 +#include <linux/fb.h>
1269 +#include <linux/ioport.h>
1270 +#include <linux/init.h>
1271 +#include <linux/proc_fs.h>
1272 +#include <linux/completion.h>
1273 +#include <linux/platform_device.h>
1274 +#include <video/edid.h>
1275 +#include <video/vesa.h>
1276 +#include <video/vga.h>
1277 +#include <asm/io.h>
1278 +#include <asm/mtrr.h>
1279 +#include <asm/page.h>
1280 +#include <asm/pgtable.h>
1281 +#include "edid.h"
1282 +
1283 +#define dac_reg (0x3c8)
1284 +#define dac_val (0x3c9)
1285 +
1286 +#define VESAFB_NEED_EXACT_RES 1
1287 +#define VESAFB_NEED_EXACT_DEPTH 2
1288 +
1289 +/* --------------------------------------------------------------------- */
1290 +
1291 +static struct fb_var_screeninfo vesafb_defined __initdata = {
1292 + .activate = FB_ACTIVATE_NOW,
1293 + .height = 0,
1294 + .width = 0,
1295 + .right_margin = 32,
1296 + .upper_margin = 16,
1297 + .lower_margin = 4,
1298 + .vsync_len = 4,
1299 + .vmode = FB_VMODE_NONINTERLACED,
1300 +};
1301 +
1302 +static struct fb_fix_screeninfo vesafb_fix __initdata = {
1303 + .id = "VESA VGA",
1304 + .type = FB_TYPE_PACKED_PIXELS,
1305 + .accel = FB_ACCEL_NONE,
1306 +};
1307 +
1308 +static int mtrr = 0; /* disable mtrr by default */
1309 +static int ypan = 0; /* 0 - nothing, 1 - ypan, 2 - ywrap */
1310 +static int pmi_setpal = 0; /* pmi for palette changes */
1311 +static u16 *pmi_base = NULL; /* protected mode interface location */
1312 +static void (*pmi_start)(void) = NULL;
1313 +static void (*pmi_pal)(void) = NULL;
1314 +static struct vesafb_vbe_ib vbe_ib;
1315 +static struct vesafb_mode_ib *vbe_modes;
1316 +static int vbe_modes_cnt = 0;
1317 +static struct fb_info *vesafb_info = NULL;
1318 +static int nocrtc = 0; /* ignore CRTC settings */
1319 +static int noedid __initdata = 0; /* don't try DDC transfers */
1320 +static int vram_remap __initdata = 0; /* set amount of memory to be used */
1321 +static int vram_total __initdata = 0; /* set total amount of memory */
1322 +static u16 maxclk __initdata = 0; /* maximum pixel clock */
1323 +static u16 maxvf __initdata = 0; /* maximum vertical frequency */
1324 +static u16 maxhf __initdata = 0; /* maximum horizontal frequency */
1325 +static int gtf __initdata = 0; /* forces use of the GTF */
1326 +static char *mode_option __initdata = NULL;
1327 +static u16 vbemode __initdata = 0;
1328 +
1329 +/* --------------------------------------------------------------------- */
1330 +
1331 +static int vesafb_find_vbe_mode(int xres, int yres, int depth,
1332 + unsigned char flags)
1333 +{
1334 + int i, match = -1, h = 0, d = 0x7fffffff;
1335 +
1336 + for (i = 0; i < vbe_modes_cnt; i++) {
1337 + h = abs(vbe_modes[i].x_res - xres) +
1338 + abs(vbe_modes[i].y_res - yres) +
1339 + abs(depth - vbe_modes[i].depth);
1340 + if (h == 0)
1341 + return i;
1342 + if (h < d || (h == d && vbe_modes[i].depth > depth)) {
1343 + d = h;
1344 + match = i;
1345 + }
1346 + }
1347 + i = 1;
1348 +
1349 + if (flags & VESAFB_NEED_EXACT_DEPTH && vbe_modes[match].depth != depth)
1350 + i = 0;
1351 + if (flags & VESAFB_NEED_EXACT_RES && d > 24)
1352 + i = 0;
1353 + if (i != 0)
1354 + return match;
1355 + else
1356 + return -1;
1357 +}
1358 +
1359 +static int vesafb_pan_display(struct fb_var_screeninfo *var,
1360 + struct fb_info *info)
1361 +{
1362 + int offset;
1363 +
1364 + if (!ypan)
1365 + return -EINVAL;
1366 + if (var->xoffset)
1367 + return -EINVAL;
1368 + if (var->yoffset > var->yres_virtual)
1369 + return -EINVAL;
1370 + if ((ypan==1) && var->yoffset+var->yres > var->yres_virtual)
1371 + return -EINVAL;
1372 +
1373 + offset = (var->yoffset * info->fix.line_length + var->xoffset) / 4;
1374 +
1375 + /* It turns out it's not the best idea to do panning via vm86,
1376 + * so we only allow it if we have a PMI. */
1377 + if (pmi_start) {
1378 + __asm__ __volatile__(
1379 + "call *(%%edi)"
1380 + : /* no return value */
1381 + : "a" (0x4f07), /* EAX */
1382 + "b" (0), /* EBX */
1383 + "c" (offset), /* ECX */
1384 + "d" (offset >> 16), /* EDX */
1385 + "D" (&pmi_start)); /* EDI */
1386 + }
1387 + return 0;
1388 +}
1389 +
1390 +static int vesafb_blank(int blank, struct fb_info *info)
1391 +{
1392 + struct vesafb_task *tsk;
1393 + int err = 1;
1394 +
1395 + if (vbe_ib.capabilities & VBE_CAP_VGACOMPAT) {
1396 + int loop = 10000;
1397 + u8 seq = 0, crtc17 = 0;
1398 +
1399 + if (blank == FB_BLANK_POWERDOWN) {
1400 + seq = 0x20;
1401 + crtc17 = 0x00;
1402 + err = 0;
1403 + } else {
1404 + seq = 0x00;
1405 + crtc17 = 0x80;
1406 + err = (blank == FB_BLANK_UNBLANK) ? 0 : -EINVAL;
1407 + }
1408 +
1409 + vga_wseq(NULL, 0x00, 0x01);
1410 + seq |= vga_rseq(NULL, 0x01) & ~0x20;
1411 + vga_wseq(NULL, 0x00, seq);
1412 +
1413 + crtc17 |= vga_rcrt(NULL, 0x17) & ~0x80;
1414 + while (loop--);
1415 + vga_wcrt(NULL, 0x17, crtc17);
1416 + vga_wseq(NULL, 0x00, 0x03);
1417 + } else {
1418 + vesafb_create_task (tsk);
1419 + if (!tsk)
1420 + return -ENOMEM;
1421 + tsk->regs.eax = 0x4f10;
1422 + switch (blank) {
1423 + case FB_BLANK_UNBLANK:
1424 + tsk->regs.ebx = 0x0001;
1425 + break;
1426 + case FB_BLANK_NORMAL:
1427 + tsk->regs.ebx = 0x0101; /* standby */
1428 + break;
1429 + case FB_BLANK_POWERDOWN:
1430 + tsk->regs.ebx = 0x0401; /* powerdown */
1431 + break;
1432 + default:
1433 + goto out;
1434 + }
1435 + tsk->flags = TF_CALL;
1436 + if (!vesafb_queue_task (tsk))
1437 + vesafb_wait_for_task(tsk);
1438 +
1439 + if ((tsk->regs.eax & 0xffff) == 0x004f)
1440 + err = 0;
1441 +out: kfree(tsk);
1442 + }
1443 + return err;
1444 +}
1445 +
1446 +static int vesafb_setpalette(struct vesafb_pal_entry *entries, int count,
1447 + int start, struct fb_info *info)
1448 +{
1449 + struct vesafb_task *tsk;
1450 + int i = ((struct vesafb_par*)info->par)->mode_idx;
1451 + int ret = 0;
1452 +
1453 + /* We support palette modifications for 8 bpp modes only, so
1454 + * there can never be more than 256 entries. */
1455 + if (start + count > 256)
1456 + return -EINVAL;
1457 +
1458 + if (pmi_setpal) {
1459 + __asm__ __volatile__(
1460 + "call *(%%esi)"
1461 + : /* no return value */
1462 + : "a" (0x4f09), /* EAX */
1463 + "b" (0), /* EBX */
1464 + "c" (count), /* ECX */
1465 + "d" (start), /* EDX */
1466 + "D" (entries), /* EDI */
1467 + "S" (&pmi_pal)); /* ESI */
1468 + return 0;
1469 + }
1470 +
1471 + /* Use VGA registers if mode is VGA-compatible. */
1472 + if (i >= 0 && i < vbe_modes_cnt &&
1473 + vbe_modes[i].mode_attr & VBE_MODE_VGACOMPAT) {
1474 + for (i = 0; i < count; i++) {
1475 + outb_p(start + i, dac_reg);
1476 + outb_p(entries[i].red, dac_val);
1477 + outb_p(entries[i].green, dac_val);
1478 + outb_p(entries[i].blue, dac_val);
1479 + }
1480 + } else {
1481 + vesafb_create_task (tsk);
1482 + if (!tsk)
1483 + return -ENOMEM;
1484 + tsk->regs.eax = 0x4f09;
1485 + tsk->regs.ebx = 0x0;
1486 + tsk->regs.ecx = count;
1487 + tsk->regs.edx = start;
1488 + tsk->buf = entries;
1489 + tsk->buf_len = sizeof(struct vesafb_pal_entry) * count;
1490 + tsk->flags = TF_CALL | TF_USE_BUF;
1491 +
1492 + if (!vesafb_queue_task (tsk))
1493 + vesafb_wait_for_task(tsk);
1494 + if ((tsk->regs.eax & 0xffff) != 0x004f)
1495 + ret = 1;
1496 + kfree(tsk);
1497 + }
1498 + return ret;
1499 +}
1500 +
1501 +static int vesafb_setcolreg(unsigned regno, unsigned red, unsigned green,
1502 + unsigned blue, unsigned transp,
1503 + struct fb_info *info)
1504 +{
1505 + struct vesafb_pal_entry entry;
1506 + int shift = 16 - info->var.green.length;
1507 + int ret = 0;
1508 +
1509 + if (regno >= info->cmap.len)
1510 + return -EINVAL;
1511 +
1512 + if (info->var.bits_per_pixel == 8) {
1513 + entry.red = red >> shift;
1514 + entry.green = green >> shift;
1515 + entry.blue = blue >> shift;
1516 + entry.pad = 0;
1517 +
1518 + ret = vesafb_setpalette(&entry, 1, regno, info);
1519 + } else if (regno < 16) {
1520 + switch (info->var.bits_per_pixel) {
1521 + case 16:
1522 + if (info->var.red.offset == 10) {
1523 + /* 1:5:5:5 */
1524 + ((u32*) (info->pseudo_palette))[regno] =
1525 + ((red & 0xf800) >> 1) |
1526 + ((green & 0xf800) >> 6) |
1527 + ((blue & 0xf800) >> 11);
1528 + } else {
1529 + /* 0:5:6:5 */
1530 + ((u32*) (info->pseudo_palette))[regno] =
1531 + ((red & 0xf800) ) |
1532 + ((green & 0xfc00) >> 5) |
1533 + ((blue & 0xf800) >> 11);
1534 + }
1535 + break;
1536 +
1537 + case 24:
1538 + case 32:
1539 + red >>= 8;
1540 + green >>= 8;
1541 + blue >>= 8;
1542 + ((u32 *)(info->pseudo_palette))[regno] =
1543 + (red << info->var.red.offset) |
1544 + (green << info->var.green.offset) |
1545 + (blue << info->var.blue.offset);
1546 + break;
1547 + }
1548 + }
1549 + return ret;
1550 +}
1551 +
1552 +static int vesafb_setcmap(struct fb_cmap *cmap, struct fb_info *info)
1553 +{
1554 + struct vesafb_pal_entry *entries;
1555 + int shift = 16 - info->var.green.length;
1556 + int i, ret = 0;
1557 +
1558 + if (info->var.bits_per_pixel == 8) {
1559 + if (cmap->start + cmap->len > info->cmap.start +
1560 + info->cmap.len || cmap->start < info->cmap.start)
1561 + return -EINVAL;
1562 +
1563 + entries = vmalloc(sizeof(struct vesafb_pal_entry) * cmap->len);
1564 + if (!entries)
1565 + return -ENOMEM;
1566 + for (i = 0; i < cmap->len; i++) {
1567 + entries[i].red = cmap->red[i] >> shift;
1568 + entries[i].green = cmap->green[i] >> shift;
1569 + entries[i].blue = cmap->blue[i] >> shift;
1570 + entries[i].pad = 0;
1571 + }
1572 + ret = vesafb_setpalette(entries, cmap->len, cmap->start, info);
1573 + vfree(entries);
1574 + } else {
1575 + /* For modes with bpp > 8, we only set the pseudo palette in
1576 + * the fb_info struct. We rely on vesafb_setcolreg to do all
1577 + * sanity checking. */
1578 + for (i = 0; i < cmap->len; i++) {
1579 + ret += vesafb_setcolreg(cmap->start + i, cmap->red[i],
1580 + cmap->green[i], cmap->blue[i],
1581 + 0, info);
1582 + }
1583 + }
1584 + return ret;
1585 +}
1586 +
1587 +static int vesafb_set_par(struct fb_info *info)
1588 +{
1589 + struct vesafb_par *par = (struct vesafb_par *) info->par;
1590 + struct vesafb_task *tsk;
1591 + struct vesafb_crtc_ib *crtc = NULL;
1592 + struct vesafb_mode_ib *mode = NULL;
1593 + int i, err = 0, depth = info->var.bits_per_pixel;
1594 +
1595 + if (depth > 8 && depth != 32)
1596 + depth = info->var.red.length + info->var.green.length +
1597 + info->var.blue.length;
1598 +
1599 + i = vesafb_find_vbe_mode(info->var.xres, info->var.yres, depth,
1600 + VESAFB_NEED_EXACT_RES |
1601 + VESAFB_NEED_EXACT_DEPTH);
1602 + if (i >= 0)
1603 + mode = &vbe_modes[i];
1604 + else
1605 + return -EINVAL;
1606 +
1607 + vesafb_create_task (tsk);
1608 + if (!tsk)
1609 + return -ENOMEM;
1610 + tsk->regs.eax = 0x4f02;
1611 + tsk->regs.ebx = mode->mode_id | 0x4000; /* use LFB */
1612 + tsk->flags = TF_CALL;
1613 +
1614 + if (vbe_ib.vbe_version >= 0x0300 && !nocrtc &&
1615 + info->var.pixclock != 0) {
1616 + tsk->regs.ebx |= 0x0800; /* use CRTC data */
1617 + tsk->flags |= TF_USE_BUF;
1618 + crtc = kmalloc(sizeof(struct vesafb_crtc_ib), GFP_KERNEL);
1619 + if (!crtc) {
1620 + err = -ENOMEM;
1621 + goto out;
1622 + }
1623 + crtc->horiz_start = info->var.xres + info->var.right_margin;
1624 + crtc->horiz_end = crtc->horiz_start + info->var.hsync_len;
1625 + crtc->horiz_total = crtc->horiz_end + info->var.left_margin;
1626 +
1627 + crtc->vert_start = info->var.yres + info->var.lower_margin;
1628 + crtc->vert_end = crtc->vert_start + info->var.vsync_len;
1629 + crtc->vert_total = crtc->vert_end + info->var.upper_margin;
1630 +
1631 + crtc->pixel_clock = PICOS2KHZ(info->var.pixclock) * 1000;
1632 + crtc->refresh_rate = (u16)(100 * (crtc->pixel_clock /
1633 + (crtc->vert_total * crtc->horiz_total)));
1634 + crtc->flags = 0;
1635 +
1636 + if (info->var.vmode & FB_VMODE_DOUBLE)
1637 + crtc->flags |= 0x1;
1638 + if (info->var.vmode & FB_VMODE_INTERLACED)
1639 + crtc->flags |= 0x2;
1640 + if (!(info->var.sync & FB_SYNC_HOR_HIGH_ACT))
1641 + crtc->flags |= 0x4;
1642 + if (!(info->var.sync & FB_SYNC_VERT_HIGH_ACT))
1643 + crtc->flags |= 0x8;
1644 + memcpy(&par->crtc, crtc, sizeof(struct vesafb_crtc_ib));
1645 + } else
1646 + memset(&par->crtc, 0, sizeof(struct vesafb_crtc_ib));
1647 +
1648 + tsk->buf = (void*)crtc;
1649 + tsk->buf_len = sizeof(struct vesafb_crtc_ib);
1650 +
1651 + if (vesafb_queue_task (tsk)) {
1652 + err = -EINVAL;
1653 + goto out;
1654 + }
1655 + vesafb_wait_for_task(tsk);
1656 +
1657 + if ((tsk->regs.eax & 0xffff) != 0x004f) {
1658 + printk(KERN_ERR "vesafb: mode switch failed (eax: 0x%lx)\n",
1659 + tsk->regs.eax);
1660 + err = -EINVAL;
1661 + goto out;
1662 + }
1663 + par->mode_idx = i;
1664 +
1665 + /* For 8bpp modes, always try to set the DAC to 8 bits. */
1666 + if (vbe_ib.capabilities & VBE_CAP_CAN_SWITCH_DAC &&
1667 + mode->bits_per_pixel <= 8) {
1668 + vesafb_reset_task(tsk);
1669 + tsk->flags = TF_CALL;
1670 + tsk->regs.eax = 0x4f08;
1671 + tsk->regs.ebx = 0x0800;
1672 +
1673 + if (!vesafb_queue_task (tsk))
1674 + vesafb_wait_for_task(tsk);
1675 +
1676 + if ((tsk->regs.eax & 0xffff) != 0x004f ||
1677 + ((tsk->regs.ebx & 0xff00) >> 8) != 8) {
1678 + /* We've failed to set the DAC palette format -
1679 + * time to correct var. */
1680 + info->var.red.length = 6;
1681 + info->var.green.length = 6;
1682 + info->var.blue.length = 6;
1683 + }
1684 + }
1685 +
1686 + info->fix.visual = (info->var.bits_per_pixel == 8) ?
1687 + FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
1688 + info->fix.line_length = mode->bytes_per_scan_line;
1689 +
1690 + DPRINTK("set new mode %dx%d-%d (0x%x)\n",
1691 + info->var.xres, info->var.yres, info->var.bits_per_pixel,
1692 + mode->mode_id);
1693 +
1694 +out: if (crtc != NULL)
1695 + kfree(crtc);
1696 + kfree(tsk);
1697 +
1698 + return err;
1699 +}
1700 +
1701 +static void vesafb_setup_var(struct fb_var_screeninfo *var, struct fb_info *info,
1702 + struct vesafb_mode_ib *mode)
1703 +{
1704 + var->xres = mode->x_res;
1705 + var->yres = mode->y_res;
1706 + var->xres_virtual = mode->x_res;
1707 + var->yres_virtual = (ypan) ?
1708 + info->fix.smem_len / mode->bytes_per_scan_line :
1709 + mode->y_res;
1710 + var->xoffset = 0;
1711 + var->yoffset = 0;
1712 + var->bits_per_pixel = mode->bits_per_pixel;
1713 +
1714 + if (var->bits_per_pixel == 15)
1715 + var->bits_per_pixel = 16;
1716 +
1717 + if (var->bits_per_pixel > 8) {
1718 + var->red.offset = mode->red_off;
1719 + var->red.length = mode->red_len;
1720 + var->green.offset = mode->green_off;
1721 + var->green.length = mode->green_len;
1722 + var->blue.offset = mode->blue_off;
1723 + var->blue.length = mode->blue_len;
1724 + var->transp.offset = mode->rsvd_off;
1725 + var->transp.length = mode->rsvd_len;
1726 +
1727 + DPRINTK("directcolor: size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
1728 + mode->rsvd_len,
1729 + mode->red_len,
1730 + mode->green_len,
1731 + mode->blue_len,
1732 + mode->rsvd_off,
1733 + mode->red_off,
1734 + mode->green_off,
1735 + mode->blue_off);
1736 + } else {
1737 + var->red.offset = 0;
1738 + var->green.offset = 0;
1739 + var->blue.offset = 0;
1740 + var->transp.offset = 0;
1741 +
1742 + /* We're assuming that we can switch the DAC to 8 bits. If
1743 + * this proves to be incorrect, we'll update the fields
1744 + * later in set_par(). */
1745 + if (vbe_ib.capabilities & VBE_CAP_CAN_SWITCH_DAC) {
1746 + var->red.length = 8;
1747 + var->green.length = 8;
1748 + var->blue.length = 8;
1749 + var->transp.length = 0;
1750 + } else {
1751 + var->red.length = 6;
1752 + var->green.length = 6;
1753 + var->blue.length = 6;
1754 + var->transp.length = 0;
1755 + }
1756 + }
1757 +}
1758 +
1759 +static void inline vesafb_check_limits(struct fb_var_screeninfo *var,
1760 + struct fb_info *info)
1761 +{
1762 + struct fb_videomode *mode;
1763 +
1764 + if (!var->pixclock)
1765 + return;
1766 + if (vbe_ib.vbe_version < 0x0300) {
1767 + fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60, var, info);
1768 + return;
1769 + }
1770 + if (!fb_validate_mode(var, info))
1771 + return;
1772 + mode = fb_find_best_mode(var, &info->modelist);
1773 + if (mode) {
1774 + DPRINTK("find_best_mode: %d %d @ %d (vmode: %d)\n",
1775 + mode->xres, mode->yres, mode->refresh, mode->vmode);
1776 + if (mode->xres == var->xres && mode->yres == var->yres &&
1777 + !(mode->vmode & (FB_VMODE_INTERLACED | FB_VMODE_DOUBLE))) {
1778 + fb_videomode_to_var(var, mode);
1779 + return;
1780 + }
1781 + }
1782 + if (info->monspecs.gtf && !fb_get_mode(FB_MAXTIMINGS, 0, var, info))
1783 + return;
1784 + /* Use default refresh rate */
1785 + var->pixclock = 0;
1786 +}
1787 +
1788 +static int vesafb_check_var(struct fb_var_screeninfo *var,
1789 + struct fb_info *info)
1790 +{
1791 + int match = -1;
1792 + int depth = var->red.length + var->green.length + var->blue.length;
1793 +
1794 + /* Various apps will use bits_per_pixel to set the color depth,
1795 + * which is theoretically incorrect, but which we'll try to handle
1796 + * here. */
1797 + if (depth == 0 || abs(depth - var->bits_per_pixel) >= 8)
1798 + depth = var->bits_per_pixel;
1799 + match = vesafb_find_vbe_mode(var->xres, var->yres, depth,
1800 + VESAFB_NEED_EXACT_RES);
1801 +
1802 + if (match == -1) {
1803 + DPRINTK("vesafb: mode %dx%d-%d not found\n", var->xres,
1804 + var->yres, depth);
1805 + return -EINVAL;
1806 + }
1807 +
1808 + vesafb_setup_var(var, info, &vbe_modes[match]);
1809 + DPRINTK("found mode 0x%x (%dx%d-%dbpp)\n",
1810 + vbe_modes[match].mode_id, vbe_modes[match].x_res,
1811 + vbe_modes[match].y_res, vbe_modes[match].depth);
1812 +
1813 + /* Check whether we have remapped enough memory for this mode. */
1814 + if (var->yres * vbe_modes[match].bytes_per_scan_line >
1815 + info->fix.smem_len) {
1816 + return -EINVAL;
1817 + }
1818 +
1819 + if ((var->vmode & FB_VMODE_DOUBLE) &&
1820 + !(vbe_modes[match].mode_attr & 0x100))
1821 + var->vmode &= ~FB_VMODE_DOUBLE;
1822 + if ((var->vmode & FB_VMODE_INTERLACED) &&
1823 + !(vbe_modes[match].mode_attr & 0x200))
1824 + var->vmode &= ~FB_VMODE_INTERLACED;
1825 + vesafb_check_limits(var, info);
1826 + return 0;
1827 +}
1828 +
1829 +static void vesafb_platform_release(struct device *device)
1830 +{
1831 + return;
1832 +}
1833 +
1834 +static int __init vesafb_probe(struct platform_device *device);
1835 +
1836 +static struct fb_ops vesafb_ops = {
1837 + .owner = THIS_MODULE,
1838 + .fb_setcolreg = vesafb_setcolreg,
1839 + .fb_setcmap = vesafb_setcmap,
1840 + .fb_pan_display = vesafb_pan_display,
1841 + .fb_blank = vesafb_blank,
1842 + .fb_fillrect = cfb_fillrect,
1843 + .fb_copyarea = cfb_copyarea,
1844 + .fb_imageblit = cfb_imageblit,
1845 + .fb_check_var = vesafb_check_var,
1846 + .fb_set_par = vesafb_set_par
1847 +};
1848 +
1849 +static struct platform_driver vesafb_driver = {
1850 + .probe = vesafb_probe,
1851 + .driver = {
1852 + .name = "vesafb",
1853 + },
1854 +};
1855 +
1856 +static struct platform_device vesafb_device = {
1857 + .name = "vesafb",
1858 + .dev = {
1859 + .release = vesafb_platform_release,
1860 + }
1861 +};
1862 +
1863 +#ifndef MODULE
1864 +int __init vesafb_setup(char *options)
1865 +{
1866 + char *this_opt;
1867 +
1868 + if (!options || !*options)
1869 + return 0;
1870 +
1871 + DPRINTK("options %s\n",options);
1872 +
1873 + while ((this_opt = strsep(&options, ",")) != NULL) {
1874 + if (!*this_opt) continue;
1875 +
1876 + DPRINTK("this_opt: %s\n",this_opt);
1877 +
1878 + if (! strcmp(this_opt, "redraw"))
1879 + ypan=0;
1880 + else if (! strcmp(this_opt, "ypan"))
1881 + ypan=1;
1882 + else if (! strcmp(this_opt, "ywrap"))
1883 + ypan=2;
1884 + else if (! strcmp(this_opt, "vgapal"))
1885 + pmi_setpal=0;
1886 + else if (! strcmp(this_opt, "pmipal"))
1887 + pmi_setpal=1;
1888 + else if (! strncmp(this_opt, "mtrr:", 5))
1889 + mtrr = simple_strtoul(this_opt+5, NULL, 0);
1890 + else if (! strcmp(this_opt, "nomtrr"))
1891 + mtrr=0;
1892 + else if (! strcmp(this_opt, "nocrtc"))
1893 + nocrtc=1;
1894 + else if (! strcmp(this_opt, "noedid"))
1895 + noedid=1;
1896 + else if (! strcmp(this_opt, "gtf"))
1897 + gtf=1;
1898 + else if (! strncmp(this_opt, "vtotal:", 7))
1899 + vram_total = simple_strtoul(this_opt + 7, NULL, 0);
1900 + else if (! strncmp(this_opt, "vremap:", 7))
1901 + vram_remap = simple_strtoul(this_opt + 7, NULL, 0);
1902 + else if (! strncmp(this_opt, "maxhf:", 6))
1903 + maxhf = simple_strtoul(this_opt + 6, NULL, 0);
1904 + else if (! strncmp(this_opt, "maxvf:", 6))
1905 + maxvf = simple_strtoul(this_opt + 6, NULL, 0);
1906 + else if (! strncmp(this_opt, "maxclk:", 7))
1907 + maxclk = simple_strtoul(this_opt + 7, NULL, 0);
1908 + else if (! strncmp(this_opt, "vbemode:", 8))
1909 + vbemode = simple_strtoul(this_opt + 8, NULL,0);
1910 + else if (this_opt[0] >= '0' && this_opt[0] <= '9') {
1911 + DPRINTK("mode_option: %s\n",this_opt);
1912 + mode_option = this_opt;
1913 + } else {
1914 + printk(KERN_WARNING
1915 + "vesafb: unrecognized option %s\n", this_opt);
1916 + }
1917 + }
1918 +
1919 + return 0;
1920 +}
1921 +#endif /* !MODULE */
1922 +
1923 +static int vesafb_read_proc_modes(char *buf, char **start, off_t offset,
1924 + int len, int *eof, void *private)
1925 +{
1926 + int clen = 0, i;
1927 +
1928 + for (i = 0; i < vbe_modes_cnt; i++) {
1929 + clen += sprintf(buf + clen, "%dx%d-%d\n", vbe_modes[i].x_res,
1930 + vbe_modes[i].y_res, vbe_modes[i].depth);
1931 + }
1932 + *start = buf + offset;
1933 +
1934 + if (clen > offset) {
1935 + clen -= offset;
1936 + } else {
1937 + clen = 0;
1938 + }
1939 + return clen;
1940 +}
1941 +
1942 +static int vesafb_read_proc_vbe_info(char *buf, char **start, off_t offset,
1943 + int len, int *eof, void *private)
1944 +{
1945 + int clen = 0;
1946 +
1947 + clen += sprintf(buf + clen, "Version: %d.%d\n",
1948 + ((vbe_ib.vbe_version & 0xff00) >> 8),
1949 + vbe_ib.vbe_version & 0xff);
1950 + clen += sprintf(buf + clen, "Vendor: %s\n",
1951 + (char*)vbe_ib.oem_vendor_name_ptr);
1952 + clen += sprintf(buf + clen, "Product: %s\n",
1953 + (char*)vbe_ib.oem_product_name_ptr);
1954 + clen += sprintf(buf + clen, "OEM rev: %s\n",
1955 + (char*)vbe_ib.oem_product_rev_ptr);
1956 + clen += sprintf(buf + clen, "OEM string: %s\n",
1957 + (char*)vbe_ib.oem_string_ptr);
1958 +
1959 + *start = buf + offset;
1960 +
1961 + if (clen > offset) {
1962 + clen -= offset;
1963 + } else {
1964 + clen = 0;
1965 + }
1966 + return clen;
1967 +}
1968 +
1969 +static int __init inline vesafb_vbe_getinfo(struct vesafb_task *tsk)
1970 +{
1971 + tsk->regs.eax = 0x4f00;
1972 + tsk->flags = TF_CALL | TF_GETVBEIB;
1973 + tsk->buf = &vbe_ib;
1974 + tsk->buf_len = sizeof(vbe_ib);
1975 + if (vesafb_queue_task (tsk))
1976 + return -EINVAL;
1977 + vesafb_wait_for_task(tsk);
1978 +
1979 + if (vbe_ib.vbe_version < 0x0200) {
1980 + printk(KERN_ERR "vesafb: Sorry, pre-VBE 2.0 cards are "
1981 + "not supported.\n");
1982 + return -EINVAL;
1983 + }
1984 +
1985 + if ((tsk->regs.eax & 0xffff) != 0x004f) {
1986 + printk(KERN_ERR "vesafb: Getting mode info block failed "
1987 + "(eax=0x%x)\n", (u32)tsk->regs.eax);
1988 + return -EINVAL;
1989 + }
1990 +
1991 + printk(KERN_INFO "vesafb: %s, %s, %s (OEM: %s)\n",
1992 + (char*)vbe_ib.oem_vendor_name_ptr,
1993 + (char*)vbe_ib.oem_product_name_ptr,
1994 + (char*)vbe_ib.oem_product_rev_ptr,
1995 + (char*)vbe_ib.oem_string_ptr);
1996 +
1997 + printk(KERN_INFO "vesafb: VBE version: %d.%d\n",
1998 + ((vbe_ib.vbe_version & 0xff00) >> 8),
1999 + vbe_ib.vbe_version & 0xff);
2000 + return 0;
2001 +}
2002 +
2003 +static int __init inline vesafb_vbe_getmodes(struct vesafb_task *tsk)
2004 +{
2005 + u16 *mode = 0;
2006 + int off = 0;
2007 +
2008 + /* Count available modes. */
2009 + mode = (u16*)vbe_ib.mode_list_ptr;
2010 + while (*mode != 0xffff) {
2011 + vbe_modes_cnt++;
2012 + mode++;
2013 + }
2014 +
2015 + vbe_modes = kmalloc(sizeof(struct vesafb_mode_ib)*
2016 + vbe_modes_cnt, GFP_KERNEL);
2017 + if (!vbe_modes)
2018 + return -ENOMEM;
2019 +
2020 + /* Get mode info for all available modes. */
2021 + mode = (u16*)vbe_ib.mode_list_ptr;
2022 +
2023 + while (*mode != 0xffff) {
2024 + struct vesafb_mode_ib *mib;
2025 +
2026 + vesafb_reset_task(tsk);
2027 + tsk->regs.eax = 0x4f01;
2028 + tsk->regs.ecx = (u32) *mode;
2029 + tsk->flags = TF_CALL | TF_RETURN_BUF;
2030 + tsk->buf = vbe_modes+off;
2031 + tsk->buf_len = sizeof(struct vesafb_mode_ib);
2032 + if (vesafb_queue_task(tsk))
2033 + return -EINVAL;
2034 + vesafb_wait_for_task(tsk);
2035 + mib = p_mode(tsk->buf);
2036 + mib->mode_id = *mode;
2037 +
2038 + /* We only want modes that are supported with the currennt
2039 + * hardware configuration (D0), color (D3), graphics (D4)
2040 + * and that have support for the LFB (D7). */
2041 + if ((mib->mode_attr & 0x99) == 0x99 &&
2042 + mib->bits_per_pixel >= 8) {
2043 + off++;
2044 + } else {
2045 + vbe_modes_cnt--;
2046 + }
2047 + mode++;
2048 + mib->depth = mib->red_len + mib->green_len + mib->blue_len;
2049 + /* Handle 8bpp modes and modes with broken color component
2050 + * lengths. */
2051 + if (mib->depth == 0 ||
2052 + (mib->depth == 24 && mib->bits_per_pixel == 32))
2053 + mib->depth = mib->bits_per_pixel;
2054 + }
2055 +
2056 + return 0;
2057 +}
2058 +
2059 +static int __init inline vesafb_vbe_getpmi(struct vesafb_task *tsk)
2060 +{
2061 + int i;
2062 +
2063 + vesafb_reset_task(tsk);
2064 + tsk->regs.eax = 0x4f0a;
2065 + tsk->regs.ebx = 0x0;
2066 + tsk->flags = TF_CALL;
2067 + if (vesafb_queue_task(tsk))
2068 + return -EINVAL;
2069 + vesafb_wait_for_task(tsk);
2070 +
2071 + if ((tsk->regs.eax & 0xffff) != 0x004f || tsk->regs.es < 0xc000) {
2072 + pmi_setpal = ypan = 0;
2073 + } else {
2074 + pmi_base = (u16*)phys_to_virt(((u32)tsk->regs.es << 4) +
2075 + tsk->regs.edi);
2076 + pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
2077 + pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
2078 + printk(KERN_INFO "vesafb: protected mode interface info at "
2079 + "%04x:%04x\n",
2080 + (u16)tsk->regs.es, (u16)tsk->regs.edi);
2081 + printk(KERN_INFO "vesafb: pmi: set display start = %p, "
2082 + "set palette = %p\n", pmi_start, pmi_pal);
2083 +
2084 + if (pmi_base[3]) {
2085 + printk(KERN_INFO "vesafb: pmi: ports = ");
2086 + for (i = pmi_base[3]/2; pmi_base[i] != 0xffff; i++)
2087 + printk("%x ",pmi_base[i]);
2088 + printk("\n");
2089 +
2090 + /*
2091 + * memory areas not supported (yet?)
2092 + *
2093 + * Rules are: we have to set up a descriptor for the
2094 + * requested memory area and pass it in the ES register
2095 + * to the BIOS function.
2096 + */
2097 + if (pmi_base[i] != 0xffff) {
2098 + printk(KERN_INFO "vesafb: can't handle memory "
2099 + "requests, pmi disabled\n");
2100 + ypan = pmi_setpal = 0;
2101 + }
2102 + }
2103 + }
2104 + return 0;
2105 +}
2106 +
2107 +static int __init inline vesafb_vbe_getedid(struct vesafb_task *tsk,
2108 + struct fb_info *info)
2109 +{
2110 + int res = 0;
2111 +
2112 + if (noedid || vbe_ib.vbe_version < 0x0300)
2113 + return -EINVAL;
2114 +
2115 + vesafb_reset_task(tsk);
2116 + tsk->regs.eax = 0x4f15;
2117 + tsk->regs.ebx = 0;
2118 + tsk->regs.ecx = 0;
2119 + if (vesafb_queue_task(tsk))
2120 + return -EINVAL;
2121 + vesafb_wait_for_task(tsk);
2122 +
2123 + if ((tsk->regs.eax & 0xffff) != 0x004f)
2124 + return -EINVAL;
2125 +
2126 + if ((tsk->regs.ebx & 0x3) == 3) {
2127 + printk(KERN_INFO "vesafb: VBIOS/hardware supports both "
2128 + "DDC1 and DDC2 transfers\n");
2129 + } else if ((tsk->regs.ebx & 0x3) == 2) {
2130 + printk(KERN_INFO "vesafb: VBIOS/hardware supports DDC2 "
2131 + "transfers\n");
2132 + } else if ((tsk->regs.ebx & 0x3) == 1) {
2133 + printk(KERN_INFO "vesafb: VBIOS/hardware supports DDC1 "
2134 + "transfers\n");
2135 + } else {
2136 + printk(KERN_INFO "vesafb: VBIOS/hardware doesn't support "
2137 + "DDC transfers\n");
2138 + return -EINVAL;
2139 + }
2140 +
2141 + vesafb_reset_task(tsk);
2142 + tsk->regs.eax = 0x4f15;
2143 + tsk->regs.ebx = 1;
2144 + tsk->regs.ecx = tsk->regs.edx = 0;
2145 + tsk->flags = TF_CALL | TF_RETURN_BUF;
2146 + tsk->buf = kmalloc(EDID_LENGTH, GFP_KERNEL);
2147 + tsk->buf_len = EDID_LENGTH;
2148 +
2149 + if (vesafb_queue_task(tsk)) {
2150 + res = -EINVAL;
2151 + goto out;
2152 + }
2153 + vesafb_wait_for_task(tsk);
2154 +
2155 + if ((tsk->regs.eax & 0xffff) == 0x004f) {
2156 + fb_edid_to_monspecs(tsk->buf, &info->monspecs);
2157 + fb_videomode_to_modelist(info->monspecs.modedb,
2158 + info->monspecs.modedb_len, &info->modelist);
2159 + if (info->monspecs.vfmax && info->monspecs.hfmax) {
2160 + /* If the maximum pixel clock wasn't specified in
2161 + * the EDID block, set it to 300 MHz. */
2162 + if (info->monspecs.dclkmax == 0)
2163 + info->monspecs.dclkmax = 300 * 1000000;
2164 + info->monspecs.gtf = 1;
2165 + } else {
2166 + res = -EINVAL;
2167 + }
2168 + }
2169 +
2170 +out: kfree(tsk->buf);
2171 + return res;
2172 +}
2173 +
2174 +static void __init inline vesafb_vbe_getmonspecs(struct vesafb_task *tsk,
2175 + struct fb_info *info)
2176 +{
2177 + struct fb_var_screeninfo var;
2178 + int i;
2179 + memset(&info->monspecs, 0, sizeof(struct fb_monspecs));
2180 +
2181 + /* If we didn't get all necessary data from the EDID block,
2182 + * mark it as incompatible with the GTF. */
2183 + if (vesafb_vbe_getedid(tsk, info))
2184 + info->monspecs.gtf = 0;
2185 +
2186 + /* Kernel command line overrides. */
2187 + if (maxclk)
2188 + info->monspecs.dclkmax = maxclk * 1000000;
2189 + if (maxvf)
2190 + info->monspecs.vfmax = maxvf;
2191 + if (maxhf)
2192 + info->monspecs.hfmax = maxhf * 1000;
2193 +
2194 + /* In case DDC transfers are not supported the user can provide
2195 + * monitor limits manually. Lower limits are set to "safe" values. */
2196 + if (info->monspecs.gtf == 0 && maxclk && maxvf && maxhf) {
2197 + info->monspecs.dclkmin = 0;
2198 + info->monspecs.vfmin = 60;
2199 + info->monspecs.hfmin = 29000;
2200 + info->monspecs.gtf = 1;
2201 + }
2202 +
2203 + if (info->monspecs.gtf) {
2204 + printk(KERN_INFO
2205 + "vesafb: monitor limits: vf = %d Hz, hf = %d kHz, "
2206 + "clk = %d MHz\n", info->monspecs.vfmax,
2207 + (int)(info->monspecs.hfmax / 1000),
2208 + (int)(info->monspecs.dclkmax / 1000000));
2209 + /* Add valid VESA video modes to our modelist. */
2210 + for (i = 0; i < VESA_MODEDB_SIZE; i++) {
2211 + fb_videomode_to_var(&var, (struct fb_videomode *)
2212 + &vesa_modes[i]);
2213 + if (!fb_validate_mode(&var, info))
2214 + fb_add_videomode((struct fb_videomode *)
2215 + &vesa_modes[i],
2216 + &info->modelist);
2217 + }
2218 + } else {
2219 + /* Add all VESA video modes to our modelist. */
2220 + fb_videomode_to_modelist((struct fb_videomode *)vesa_modes,
2221 + VESA_MODEDB_SIZE, &info->modelist);
2222 + printk(KERN_INFO "vesafb: no monitor limits have been set\n");
2223 + }
2224 + return;
2225 +}
2226 +
2227 +static int __init inline vesafb_vbe_init(struct fb_info *info)
2228 +{
2229 + struct vesafb_task *tsk;
2230 + int res = 0;
2231 +
2232 + vesafb_create_task(tsk);
2233 + if (!tsk)
2234 + return -EINVAL;
2235 + if ((res = vesafb_vbe_getinfo(tsk)) != 0)
2236 + goto out;
2237 + if ((res = vesafb_vbe_getmodes(tsk)) != 0)
2238 + goto out;
2239 + if (pmi_setpal || ypan)
2240 + vesafb_vbe_getpmi(tsk);
2241 + vesafb_vbe_getmonspecs(tsk, info);
2242 +out: kfree(tsk);
2243 + return res;
2244 +}
2245 +
2246 +static int __init decode_mode(u32 *xres, u32 *yres, u32 *bpp, u32 *refresh)
2247 +{
2248 + int len = strlen(mode_option), i, err = 0;
2249 + u8 res_specified = 0, bpp_specified = 0, refresh_specified = 0,
2250 + yres_specified = 0;
2251 +
2252 + for (i = len-1; i >= 0; i--) {
2253 + switch (mode_option[i]) {
2254 + case '@':
2255 + len = i;
2256 + if (!refresh_specified && !bpp_specified &&
2257 + !yres_specified) {
2258 + *refresh = simple_strtoul(&mode_option[i+1],
2259 + NULL, 0);
2260 + refresh_specified = 1;
2261 + } else
2262 + goto out;
2263 + break;
2264 + case '-':
2265 + len = i;
2266 + if (!bpp_specified && !yres_specified) {
2267 + *bpp = simple_strtoul(&mode_option[i+1],
2268 + NULL, 0);
2269 + bpp_specified = 1;
2270 + } else
2271 + goto out;
2272 + break;
2273 + case 'x':
2274 + if (!yres_specified) {
2275 + *yres = simple_strtoul(&mode_option[i+1],
2276 + NULL, 0);
2277 + yres_specified = 1;
2278 + } else
2279 + goto out;
2280 + break;
2281 + case '0'...'9':
2282 + break;
2283 + default:
2284 + goto out;
2285 + }
2286 + }
2287 +
2288 + if (i < 0 && yres_specified) {
2289 + *xres = simple_strtoul(mode_option, NULL, 0);
2290 + res_specified = 1;
2291 + }
2292 +
2293 +out: if (!res_specified || !yres_specified) {
2294 + printk(KERN_ERR "vesafb: invalid resolution, "
2295 + "%s not specified\n",
2296 + (!res_specified) ? "width" : "height");
2297 + err = -EINVAL;
2298 + }
2299 +
2300 + return err;
2301 +}
2302 +
2303 +static int __init vesafb_init_set_mode(struct fb_info *info)
2304 +{
2305 + struct fb_videomode *fbmode;
2306 + struct fb_videomode mode;
2307 + int i, modeid, refresh = 0;
2308 + u8 refresh_specified = 0;
2309 +
2310 + if (!mode_option)
2311 + mode_option = CONFIG_FB_VESA_DEFAULT_MODE;
2312 +
2313 + if (vbemode > 0) {
2314 + for (i = 0; i < vbe_modes_cnt; i++) {
2315 + if (vbe_modes[i].mode_id == vbemode) {
2316 + info->var.vmode = FB_VMODE_NONINTERLACED;
2317 + info->var.sync = FB_SYNC_VERT_HIGH_ACT;
2318 + vesafb_setup_var(&info->var, info,
2319 + &vbe_modes[i]);
2320 + fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON,
2321 + 60, &info->var, info);
2322 + /* With pixclock set to 0, the default BIOS
2323 + * timings will be used in set_par(). */
2324 + info->var.pixclock = 0;
2325 + modeid = i;
2326 + goto out;
2327 + }
2328 + }
2329 + printk(KERN_INFO "specified VBE mode %d not found\n",
2330 + vbemode);
2331 + vbemode = 0;
2332 + }
2333 +
2334 + /* Decode the mode specified on the kernel command line. We save
2335 + * the depth into bits_per_pixel, which is wrong, but will work
2336 + * anyway. */
2337 + if (decode_mode(&info->var.xres, &info->var.yres,
2338 + &info->var.bits_per_pixel, &refresh))
2339 + return -EINVAL;
2340 + if (refresh)
2341 + refresh_specified = 1;
2342 + else
2343 + refresh = 60;
2344 +
2345 + /* Look for a matching VBE mode. We can live if an exact match
2346 + * cannot be found. */
2347 + modeid = vesafb_find_vbe_mode(info->var.xres, info->var.yres,
2348 + info->var.bits_per_pixel, 0);
2349 +
2350 + if (modeid == -1) {
2351 + return -EINVAL;
2352 + } else {
2353 + info->var.vmode = FB_VMODE_NONINTERLACED;
2354 + info->var.sync = FB_SYNC_VERT_HIGH_ACT;
2355 + vesafb_setup_var(&info->var, info, &vbe_modes[modeid]);
2356 + }
2357 + if (vbe_ib.vbe_version < 0x0300) {
2358 + fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60,
2359 + &info->var, info);
2360 + goto out;
2361 + }
2362 + if (!gtf) {
2363 + struct fb_videomode tmode;
2364 +
2365 + if (refresh_specified) {
2366 + fb_var_to_videomode(&tmode, &info->var);
2367 + tmode.refresh = refresh;
2368 + fbmode = fb_find_nearest_mode(&tmode,
2369 + &info->modelist);
2370 + } else
2371 + fbmode = fb_find_best_mode(&info->var,
2372 + &info->modelist);
2373 +
2374 + if (fbmode->xres == info->var.xres &&
2375 + fbmode->yres == info->var.yres &&
2376 + !(fbmode->vmode & (FB_VMODE_INTERLACED | FB_VMODE_DOUBLE))
2377 + && (!refresh_specified ||
2378 + abs(refresh - fbmode->refresh) <= 5)) {
2379 + fb_videomode_to_var(&info->var, fbmode);
2380 + return modeid;
2381 + }
2382 + }
2383 + i = FB_MAXTIMINGS;
2384 + if (!info->monspecs.gtf)
2385 + i = FB_IGNOREMON | FB_VSYNCTIMINGS;
2386 + else if (refresh_specified)
2387 + i = FB_VSYNCTIMINGS;
2388 + if (!fb_get_mode(i, refresh, &info->var, info))
2389 + goto out;
2390 + if (info->monspecs.gtf &&
2391 + !fb_get_mode(FB_MAXTIMINGS, 0, &info->var, info))
2392 + goto out;
2393 + /* Use default refresh rate */
2394 + printk(KERN_WARNING "vesafb: using default BIOS refresh rate\n");
2395 + info->var.pixclock = 0;
2396 +
2397 +out:
2398 + fb_var_to_videomode(&mode, &info->var);
2399 + fb_add_videomode(&mode, &info->modelist);
2400 + return modeid;
2401 +}
2402 +
2403 +static int __init vesafb_probe(struct platform_device *dev)
2404 +{
2405 + char entry[16];
2406 + struct fb_info *info;
2407 + struct vesafb_mode_ib *mode = NULL;
2408 + int err = 0, i, h;
2409 + unsigned int size_vmode;
2410 + unsigned int size_remap;
2411 + unsigned int size_total;
2412 +
2413 + vesafb_info = info = framebuffer_alloc(sizeof(struct vesafb_par) +
2414 + sizeof(u32) * 256, &dev->dev);
2415 + if (!info)
2416 + return -ENOMEM;
2417 +
2418 + if (vesafb_wait_for_thread()) {
2419 + printk(KERN_ERR "vesafb: vesafb thread not running\n");
2420 + framebuffer_release(info);
2421 + return -EINVAL;
2422 + }
2423 +
2424 + if (vesafb_vbe_init(info)) {
2425 + printk(KERN_ERR "vesafb: vbe_init failed\n");
2426 + err = -EINVAL;
2427 + goto out;
2428 + }
2429 +
2430 + vesafb_fix.ypanstep = ypan ? 1 : 0;
2431 + vesafb_fix.ywrapstep = (ypan>1) ? 1 : 0;
2432 +
2433 + info->pseudo_palette = ((u8*)info->par + sizeof(struct vesafb_par));
2434 + info->fbops = &vesafb_ops;
2435 + info->var = vesafb_defined;
2436 + info->fix = vesafb_fix;
2437 +
2438 + if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
2439 + err = -ENXIO;
2440 + goto out;
2441 + }
2442 +
2443 + i = vesafb_init_set_mode(info);
2444 + if (i < 0) {
2445 + err = -EINVAL;
2446 + goto out_cmap;
2447 + } else
2448 + mode = &vbe_modes[i];
2449 +
2450 + /* Find out how much IO memory is required for the mode with
2451 + * the highest resolution. */
2452 + size_remap = 0;
2453 + for (i = 0; i < vbe_modes_cnt; i++) {
2454 + h = vbe_modes[i].bytes_per_scan_line * vbe_modes[i].y_res;
2455 + if (h > size_remap)
2456 + size_remap = h;
2457 + }
2458 + size_remap *= 2;
2459 +
2460 + /* size_vmode -- that is the amount of memory needed for the
2461 + * used video mode, i.e. the minimum amount of
2462 + * memory we need. */
2463 + if (mode != NULL) {
2464 + size_vmode = info->var.yres * mode->bytes_per_scan_line;
2465 + } else {
2466 + size_vmode = info->var.yres * info->var.xres *
2467 + ((info->var.bits_per_pixel + 7) >> 3);
2468 + }
2469 +
2470 + /* size_total -- all video memory we have. Used for mtrr
2471 + * entries, ressource allocation and bounds
2472 + * checking. */
2473 + size_total = vbe_ib.total_memory * 65536;
2474 + if (vram_total)
2475 + size_total = vram_total * 1024 * 1024;
2476 + if (size_total < size_vmode)
2477 + size_total = size_vmode;
2478 + ((struct vesafb_par*)(info->par))->mem_total = size_total;
2479 +
2480 + /* size_remap -- the amount of video memory we are going to
2481 + * use for vesafb. With modern cards it is no
2482 + * option to simply use size_total as th
2483 + * wastes plenty of kernel address space. */
2484 + if (vram_remap)
2485 + size_remap = vram_remap * 1024 * 1024;
2486 + if (size_remap < size_vmode)
2487 + size_remap = size_vmode;
2488 + if (size_remap > size_total)
2489 + size_remap = size_total;
2490 +
2491 + info->fix.smem_len = size_remap;
2492 + info->fix.smem_start = mode->phys_base_ptr;
2493 +
2494 + /* We have to set it here, because when setup_var() was called,
2495 + * smem_len wasn't defined yet. */
2496 + info->var.yres_virtual = info->fix.smem_len /
2497 + mode->bytes_per_scan_line;
2498 +
2499 + if (ypan && info->var.yres_virtual > info->var.yres) {
2500 + printk(KERN_INFO "vesafb: scrolling: %s "
2501 + "using protected mode interface, "
2502 + "yres_virtual=%d\n",
2503 + (ypan > 1) ? "ywrap" : "ypan",info->var.yres_virtual);
2504 + } else {
2505 + printk(KERN_INFO "vesafb: scrolling: redraw\n");
2506 + info->var.yres_virtual = info->var.yres;
2507 + ypan = 0;
2508 + }
2509 +
2510 + info->flags = FBINFO_FLAG_DEFAULT |
2511 + (ypan) ? FBINFO_HWACCEL_YPAN : 0;
2512 +
2513 + if (!request_mem_region(info->fix.smem_start, size_total, "vesafb")) {
2514 + printk(KERN_WARNING "vesafb: cannot reserve video memory at "
2515 + "0x%lx\n", info->fix.smem_start);
2516 + /* We cannot make this fatal. Sometimes this comes from magic
2517 + spaces our resource handlers simply don't know about. */
2518 + }
2519 +
2520 + info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len);
2521 +
2522 + if (!info->screen_base) {
2523 + printk(KERN_ERR
2524 + "vesafb: abort, cannot ioremap video memory "
2525 + "0x%x @ 0x%lx\n",
2526 + info->fix.smem_len, info->fix.smem_start);
2527 + err = -EIO;
2528 + goto out_mem;
2529 + }
2530 +
2531 + /* Request failure does not faze us, as vgacon probably has this
2532 + region already (FIXME) */
2533 + request_region(0x3c0, 32, "vesafb");
2534 +
2535 + if (mtrr && !(info->fix.smem_start & (PAGE_SIZE - 1))) {
2536 + int temp_size = size_total;
2537 + unsigned int type = 0;
2538 +
2539 + switch (mtrr) {
2540 + case 1:
2541 + type = MTRR_TYPE_UNCACHABLE;
2542 + break;
2543 + case 2:
2544 + type = MTRR_TYPE_WRBACK;
2545 + break;
2546 + case 3:
2547 + type = MTRR_TYPE_WRCOMB;
2548 + break;
2549 + case 4:
2550 + type = MTRR_TYPE_WRTHROUGH;
2551 + break;
2552 + default:
2553 + type = 0;
2554 + break;
2555 + }
2556 +
2557 + if (type) {
2558 + int rc;
2559 +
2560 + /* Find the largest power-of-two */
2561 + while (temp_size & (temp_size - 1))
2562 + temp_size &= (temp_size - 1);
2563 +
2564 + /* Try and find a power of two to add */
2565 + do {
2566 + rc = mtrr_add(info->fix.smem_start,
2567 + temp_size, type, 1);
2568 + temp_size >>= 1;
2569 + } while (temp_size >= PAGE_SIZE && rc == -EINVAL);
2570 + }
2571 + }
2572 +
2573 + if (register_framebuffer(info) < 0) {
2574 + printk(KERN_ERR
2575 + "vesafb: failed to register framebuffer device\n");
2576 + err = -EINVAL;
2577 + goto out_mem;
2578 + }
2579 +
2580 + printk(KERN_INFO "vesafb: framebuffer at 0x%lx, mapped to 0x%p, "
2581 + "using %dk, total %dk\n", info->fix.smem_start,
2582 + info->screen_base, size_remap/1024, size_total/1024);
2583 + printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node,
2584 + info->fix.id);
2585 +
2586 + sprintf(entry, "fb%d", info->node);
2587 + proc_mkdir(entry, 0);
2588 +
2589 + sprintf(entry, "fb%d/modes", info->node);
2590 + create_proc_read_entry(entry, 0, 0, vesafb_read_proc_modes, NULL);
2591 +
2592 + sprintf(entry, "fb%d/vbe_info", info->node);
2593 + create_proc_read_entry(entry, 0, 0, vesafb_read_proc_vbe_info, NULL);
2594 + return 0;
2595 +
2596 +out_mem:
2597 + release_mem_region(info->fix.smem_start, size_total);
2598 + if (!list_empty(&info->modelist))
2599 + fb_destroy_modelist(&info->modelist);
2600 + fb_destroy_modedb(info->monspecs.modedb);
2601 +out_cmap:
2602 + fb_dealloc_cmap(&info->cmap);
2603 +out:
2604 + framebuffer_release(info);
2605 + vesafb_info = NULL;
2606 + kfree(vbe_modes);
2607 + vbe_modes = NULL;
2608 + return err;
2609 +}
2610 +
2611 +int __init vesafb_init(void)
2612 +{
2613 + int ret;
2614 +#ifndef MODULE
2615 + char *option = NULL;
2616 +
2617 + if (fb_get_options("vesafb", &option))
2618 + return -ENODEV;
2619 + vesafb_setup(option);
2620 +#endif
2621 + ret = platform_driver_register(&vesafb_driver);
2622 +
2623 + if (!ret) {
2624 + ret = platform_device_register(&vesafb_device);
2625 + if (ret)
2626 + platform_driver_unregister(&vesafb_driver);
2627 + }
2628 + return ret;
2629 +}
2630 +
2631 +module_init(vesafb_init);
2632 +
2633 +#ifdef MODULE
2634 +void __exit vesafb_exit(void)
2635 +{
2636 + char entry[16];
2637 +
2638 + if (vesafb_info)
2639 + unregister_framebuffer(vesafb_info);
2640 +
2641 + platform_device_unregister(&vesafb_device);
2642 + platform_driver_unregister(&vesafb_driver);
2643 +
2644 + if (vesafb_info) {
2645 + struct vesafb_par *par = (struct vesafb_par*)vesafb_info->par;
2646 +
2647 + sprintf(entry, "fb%d/modes", vesafb_info->node);
2648 + remove_proc_entry(entry, NULL);
2649 +
2650 + sprintf(entry, "fb%d/vbe_info", vesafb_info->node);
2651 + remove_proc_entry(entry, NULL);
2652 +
2653 + sprintf(entry, "fb%d", vesafb_info->node);
2654 + remove_proc_entry(entry, NULL);
2655 +
2656 + iounmap(vesafb_info->screen_base);
2657 + release_mem_region(vesafb_info->fix.smem_start,
2658 + par->mem_total);
2659 + fb_dealloc_cmap(&vesafb_info->cmap);
2660 + if (!list_empty(&vesafb_info->modelist))
2661 + fb_destroy_modelist(&vesafb_info->modelist);
2662 + fb_destroy_modedb(vesafb_info->monspecs.modedb);
2663 + framebuffer_release(vesafb_info);
2664 + }
2665 +
2666 + if (vbe_modes != NULL)
2667 + kfree(vbe_modes);
2668 +}
2669 +
2670 +module_exit(vesafb_exit);
2671 +
2672 +static inline int param_get_scroll(char *buffer, struct kernel_param *kp)
2673 +{
2674 + return 0;
2675 +}
2676 +static inline int param_set_scroll(const char *val, struct kernel_param *kp)
2677 +{
2678 + ypan = 0;
2679 +
2680 + if (! strcmp(val, "redraw"))
2681 + ypan = 0;
2682 + else if (! strcmp(val, "ypan"))
2683 + ypan = 1;
2684 + else if (! strcmp(val, "ywrap"))
2685 + ypan = 2;
2686 +
2687 + return 0;
2688 +}
2689 +
2690 +#define param_check_scroll(name, p) __param_check(name, p, void);
2691 +
2692 +module_param_named(scroll, ypan, scroll, 0);
2693 +MODULE_PARM_DESC(scroll,"Scrolling mode, set to 'redraw', 'ypan' or 'ywrap'");
2694 +module_param_named(vgapal, pmi_setpal, invbool, 0);
2695 +MODULE_PARM_DESC(vgapal,"bool: set palette using VGA registers");
2696 +module_param_named(pmipal, pmi_setpal, bool, 0);
2697 +MODULE_PARM_DESC(pmipal,"bool: set palette using PMI calls");
2698 +module_param_named(nomtrr, mtrr, invbool, 0);
2699 +MODULE_PARM_DESC(nomtrr,"bool: disable use of MTRR registers");
2700 +module_param(nocrtc, bool, 0);
2701 +MODULE_PARM_DESC(nocrtc,"bool: ignore CRTC timings when setting modes");
2702 +module_param(noedid, bool, 0);
2703 +MODULE_PARM_DESC(noedid,"bool: ignore EDID-provided monitor limits "
2704 + "when setting modes");
2705 +module_param(gtf, bool, 0);
2706 +MODULE_PARM_DESC(gtf,"bool: force use of VESA GTF to calculate mode timings");
2707 +module_param(vram_remap, uint, 0);
2708 +MODULE_PARM_DESC(vram_remap,"Set amount of video memory to be used [MiB]");
2709 +module_param(vram_total, uint, 0);
2710 +MODULE_PARM_DESC(vram_total,"Set total amount of video memoery [MiB]");
2711 +module_param(maxclk, ushort, 0);
2712 +MODULE_PARM_DESC(maxclk,"Maximum pixelclock [MHz], overrides EDID data");
2713 +module_param(maxhf, ushort, 0);
2714 +MODULE_PARM_DESC(maxhf,"Maximum horizontal frequency [kHz], "
2715 + "overrides EDID data");
2716 +module_param(maxvf, ushort, 0);
2717 +MODULE_PARM_DESC(maxvf,"Maximum vertical frequency [Hz], "
2718 + "overrides EDID data");
2719 +module_param_named(mode, mode_option, charp, 0);
2720 +MODULE_PARM_DESC(mode, "Specify resolution as "
2721 + "\"<xres>x<yres>[-<bpp>][@<refresh>]\"");
2722 +module_param(vbemode, ushort, 0);
2723 +MODULE_PARM_DESC(vbemode,"VBE mode number to set, overrides 'mode' setting");
2724 +
2725 +#endif /* MODULE */
2726 +
2727 +MODULE_LICENSE("GPL");
2728 +MODULE_AUTHOR("Michal Januszewski");
2729 +MODULE_DESCRIPTION("Framebuffer driver for VBE2.0+ compliant graphics boards");
2730 +
2731 diff --git a/include/linux/sched.h b/include/linux/sched.h
2732 index 2bbf968..0e263b7 100644
2733 --- a/include/linux/sched.h
2734 +++ b/include/linux/sched.h
2735 @@ -1137,6 +1137,8 @@ extern void mmput(struct mm_struct *);
2736 extern struct mm_struct *get_task_mm(struct task_struct *task);
2737 /* Remove the current tasks stale references to the old mm_struct */
2738 extern void mm_release(struct task_struct *, struct mm_struct *);
2739 +/* Create a new mm for a kernel thread */
2740 +extern int set_new_mm(void);
2741
2742 extern int copy_thread(int, unsigned long, unsigned long, unsigned long, struct task_struct *, struct pt_regs *);
2743 extern void flush_thread(void);
2744 diff --git a/include/video/vesa.h b/include/video/vesa.h
2745 new file mode 100644
2746 index 0000000..c274604
2747 --- /dev/null
2748 +++ b/include/video/vesa.h
2749 @@ -0,0 +1,146 @@
2750 +#if 0
2751 +#define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , \
2752 + ## args)
2753 +#else
2754 +#define DPRINTK(fmt, args...)
2755 +#endif
2756 +
2757 +#define p_crtc(arg) ((struct vesafb_crtc_ib*)(arg))
2758 +#define p_vbe(arg) ((struct vesafb_vbe_ib*)(arg))
2759 +#define p_mode(arg) ((struct vesafb_mode_ib*)(arg))
2760 +
2761 +struct vesafb_task {
2762 + u8 flags;
2763 + void *buf;
2764 + int buf_len;
2765 + struct vm86_regs regs;
2766 + struct list_head node;
2767 + struct completion done;
2768 +};
2769 +
2770 +/* Vesafb task flags and masks */
2771 +#define TF_CALL 0x00
2772 +#define TF_EXIT 0x01
2773 +#define TF_GETVBEIB 0x02
2774 +#define TF_USE_BUF 0x04
2775 +#define TF_RETURN_BUF 0x08
2776 +#define TF_MASK_BUF (TF_USE_BUF | TF_RETURN_BUF)
2777 +
2778 +/* Macros and functions for manipulating vesafb tasks */
2779 +#define vesafb_create_task(task) \
2780 +do { \
2781 + task = kmalloc(sizeof(struct vesafb_task), GFP_ATOMIC); \
2782 + if (task) \
2783 + memset(task, 0, sizeof(struct vesafb_task)); \
2784 + init_completion(&task->done); \
2785 +} while (0)
2786 +
2787 +#define vesafb_wait_for_task(task) wait_for_completion(&task->done);
2788 +#define vesafb_reset_task(task) init_completion(&task->done);
2789 +int vesafb_queue_task(struct vesafb_task *task);
2790 +
2791 +/* Functions for controlling the vesafb thread */
2792 +int vesafb_wait_for_thread(void);
2793 +
2794 +#define VBE_CAP_CAN_SWITCH_DAC 0x01
2795 +#define VBE_CAP_VGACOMPAT 0x02
2796 +
2797 +/* This struct is 512 bytes long */
2798 +struct vesafb_vbe_ib {
2799 + char vbe_signature[4];
2800 + u16 vbe_version;
2801 + u32 oem_string_ptr;
2802 + u32 capabilities;
2803 + u32 mode_list_ptr;
2804 + u16 total_memory;
2805 + u16 oem_software_rev;
2806 + u32 oem_vendor_name_ptr;
2807 + u32 oem_product_name_ptr;
2808 + u32 oem_product_rev_ptr;
2809 + u8 reserved[222];
2810 + char oem_data[256];
2811 +} __attribute__ ((packed));
2812 +
2813 +struct vesafb_crtc_ib {
2814 + u16 horiz_total;
2815 + u16 horiz_start;
2816 + u16 horiz_end;
2817 + u16 vert_total;
2818 + u16 vert_start;
2819 + u16 vert_end;
2820 + u8 flags;
2821 + u32 pixel_clock;
2822 + u16 refresh_rate;
2823 + u8 reserved[40];
2824 +} __attribute__ ((packed));
2825 +
2826 +#define VBE_MODE_VGACOMPAT 0x20
2827 +
2828 +struct vesafb_mode_ib {
2829 + /* for all VBE revisions */
2830 + u16 mode_attr;
2831 + u8 winA_attr;
2832 + u8 winB_attr;
2833 + u16 win_granularity;
2834 + u16 win_size;
2835 + u16 winA_seg;
2836 + u16 winB_seg;
2837 + u32 win_func_ptr;
2838 + u16 bytes_per_scan_line;
2839 +
2840 + /* for VBE 1.2+ */
2841 + u16 x_res;
2842 + u16 y_res;
2843 + u8 x_char_size;
2844 + u8 y_char_size;
2845 + u8 planes;
2846 + u8 bits_per_pixel;
2847 + u8 banks;
2848 + u8 memory_model;
2849 + u8 bank_size;
2850 + u8 image_pages;
2851 + u8 reserved1;
2852 +
2853 + /* Direct color fields for direct/6 and YUV/7 memory models. */
2854 + /* Offsets are bit positions of lsb in the mask. */
2855 + u8 red_len;
2856 + u8 red_off;
2857 + u8 green_len;
2858 + u8 green_off;
2859 + u8 blue_len;
2860 + u8 blue_off;
2861 + u8 rsvd_len;
2862 + u8 rsvd_off;
2863 + u8 direct_color_info; /* direct color mode attributes */
2864 +
2865 + /* for VBE 2.0+ */
2866 + u32 phys_base_ptr;
2867 + u8 reserved2[6];
2868 +
2869 + /* for VBE 3.0+ */
2870 + u16 lin_bytes_per_scan_line;
2871 + u8 bnk_image_pages;
2872 + u8 lin_image_pages;
2873 + u8 lin_red_len;
2874 + u8 lin_red_off;
2875 + u8 lin_green_len;
2876 + u8 lin_green_off;
2877 + u8 lin_blue_len;
2878 + u8 lin_blue_off;
2879 + u8 lin_rsvd_len;
2880 + u8 lin_rsvd_off;
2881 + u32 max_pixel_clock;
2882 + u16 mode_id;
2883 + u8 depth;
2884 +} __attribute__ ((packed));
2885 +
2886 +struct vesafb_pal_entry {
2887 + u_char blue, green, red, pad;
2888 +} __attribute__ ((packed));
2889 +
2890 +struct vesafb_par {
2891 + u32 mem_total;
2892 + int mode_idx;
2893 + struct vesafb_crtc_ib crtc;
2894 +};
2895 +
2896 diff --git a/kernel/fork.c b/kernel/fork.c
2897 index 158710d..557b253 100644
2898 --- a/kernel/fork.c
2899 +++ b/kernel/fork.c
2900 @@ -96,6 +96,7 @@ kmem_cache_t *fs_cachep;
2901
2902 /* SLAB cache for vm_area_struct structures */
2903 kmem_cache_t *vm_area_cachep;
2904 +EXPORT_SYMBOL_GPL(vm_area_cachep);
2905
2906 /* SLAB cache for mm_struct structures (tsk->mm) */
2907 static kmem_cache_t *mm_cachep;
2908 @@ -384,6 +385,40 @@ void mmput(struct mm_struct *mm)
2909 EXPORT_SYMBOL_GPL(mmput);
2910
2911 /**
2912 + * set_new_mm - allocate, init and activate a new mm for a kernel thread
2913 + */
2914 +int set_new_mm(void)
2915 +{
2916 + struct mm_struct *mm;
2917 + struct task_struct *tsk = current;
2918 + struct mm_struct *active_mm;
2919 +
2920 + mm = mm_alloc();
2921 + if (!mm)
2922 + goto fail_nomem;
2923 + if (init_new_context(current,mm))
2924 + goto fail_nocontext;
2925 +
2926 + task_lock(tsk);
2927 + tsk->flags |= PF_BORROWED_MM;
2928 + active_mm = tsk->active_mm;
2929 + current->mm = mm;
2930 + current->active_mm = mm;
2931 + activate_mm(active_mm, mm);
2932 + task_unlock(current);
2933 +
2934 + /* Drop the previous active_mm */
2935 + mmdrop(active_mm);
2936 + return 0;
2937 +
2938 +fail_nocontext:
2939 + mmdrop(mm);
2940 +fail_nomem:
2941 + return -EINVAL;
2942 +}
2943 +EXPORT_SYMBOL_GPL(set_new_mm);
2944 +
2945 +/**
2946 * get_task_mm - acquire a reference to the task's mm
2947 *
2948 * Returns %NULL if the task has no mm. Checks PF_BORROWED_MM (meaning
2949 diff --git a/mm/memory.c b/mm/memory.c
2950 index 0f60baf..df9f20d 100644
2951 --- a/mm/memory.c
2952 +++ b/mm/memory.c
2953 @@ -1090,6 +1090,7 @@ int zeromap_page_range(struct vm_area_st
2954 } while (pgd++, addr = next, addr != end);
2955 return err;
2956 }
2957 +EXPORT_SYMBOL_GPL(zeromap_page_range);
2958
2959 /*
2960 * maps a range of physical memory into the requested pages. the old
2961 diff --git a/mm/mmap.c b/mm/mmap.c
2962 index 6c997b1..aff02e8 100644
2963 --- a/mm/mmap.c
2964 +++ b/mm/mmap.c
2965 @@ -2001,6 +2001,7 @@ int insert_vm_struct(struct mm_struct *
2966 vma_link(mm, vma, prev, rb_link, rb_parent);
2967 return 0;
2968 }
2969 +EXPORT_SYMBOL_GPL(insert_vm_struct);
2970
2971 /*
2972 * Copy the vma structure to a new location in the same mm,

  ViewVC Help
Powered by ViewVC 1.1.20