/[linux-patches]/genpatches-2.6/trunk/2.6.16-pre/4505_vesafb-tng-1.0-rc1-r3.patch
Gentoo

Contents of /genpatches-2.6/trunk/2.6.16-pre/4505_vesafb-tng-1.0-rc1-r3.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 277 - (show annotations) (download) (as text)
Sun Jan 22 14:13:09 2006 UTC (14 years, 10 months ago) by phreak
File MIME type: text/x-diff
File size: 86471 byte(s)
Rediffing 4505_vesafb-tng-1.0-rc1-r3.patch
1 diff --git a/Documentation/fb/vesafb.txt b/Documentation/fb/vesafb.txt
2 index ee277dd..60f797e 100644
3 Index: linux-git/Documentation/fb/vesafb.txt
4 ===================================================================
5 --- linux-git.orig/Documentation/fb/vesafb.txt
6 +++ linux-git/Documentation/fb/vesafb.txt
7 @@ -2,16 +2,18 @@
8 What is vesafb?
9 ===============
10
11 -This is a generic driver for a graphic framebuffer on intel boxes.
12 +Vesafb is a generic framebuffer driver for x86 and x86_64 boxes.
13
14 -The idea is simple: Turn on graphics mode at boot time with the help
15 -of the BIOS, and use this as framebuffer device /dev/fb0, like the m68k
16 -(and other) ports do.
17 -
18 -This means we decide at boot time whenever we want to run in text or
19 -graphics mode. Switching mode later on (in protected mode) is
20 -impossible; BIOS calls work in real mode only. VESA BIOS Extensions
21 -Version 2.0 are required, because we need a linear frame buffer.
22 +VESA BIOS Extensions Version 2.0 are required, because we need access to
23 +a linear frame buffer. VBE 3.0 is required if you want to use modes with a
24 +higher (than the standard 60Hz) refresh rate.
25 +
26 +The VESA framebuffer driver comes in two flavors - the standard 'vesafb'
27 +and 'vesafb-tng'. Vesafb-tng is available only on 32-bit x86 due to the
28 +technology it uses (vm86). Vesafb-tng has more features than vesafb
29 +(adjusting the refresh rate on VBE3.0-compliant boards, switching the
30 +video mode without rebooting, selecting a mode by providing its
31 +modedb name, and more).
32
33 Advantages:
34
35 @@ -29,26 +31,35 @@ Disadvantages:
36 How to use it?
37 ==============
38
39 -Switching modes is done using the vga=... boot parameter. Read
40 -Documentation/svga.txt for details.
41 -
42 -You should compile in both vgacon (for text mode) and vesafb (for
43 -graphics mode). Which of them takes over the console depends on
44 -whenever the specified mode is text or graphics.
45 -
46 -The graphic modes are NOT in the list which you get if you boot with
47 -vga=ask and hit return. The mode you wish to use is derived from the
48 -VESA mode number. Here are those VESA mode numbers:
49 +If you are running a 32-bit x86 system and you decide to use vesafb-tng,
50 +you can either compile the driver into the kernel or use it as a module.
51 +The graphics mode you want to use is in both cases specified using the
52 +standard modedb format.
53 +
54 +If your system doesn't support vm86 calls, things get a little more tricky.
55 +Since on such systems you can't do BIOS calls from protected mode in which
56 +kernel runs, you have to decide at boot time whenever you want to run in text
57 +or in graphics mode. Switching mode later on is impossible. Switching modes
58 +is done using the vga=... boot parameter. Read Documentation/svga.txt for
59 +details. Below is a more detailed description of what to do on systems using
60 +the standard vesafb driver.
61 +
62 +You should compile in both vgacon (for text mode) and vesafb (for graphics
63 +mode). Which of them takes over the console depends on whenever the
64 +specified mode is text or graphics.
65 +
66 +The graphic modes are NOT in the list which you get if you boot with vga=ask
67 +and hit return. The mode you wish to use is derived from the VESA mode number.
68 +Here are those VESA mode numbers:
69
70 | 640x480 800x600 1024x768 1280x1024
71 ----+-------------------------------------
72 -256 | 0x101 0x103 0x105 0x107
73 -32k | 0x110 0x113 0x116 0x119
74 -64k | 0x111 0x114 0x117 0x11A
75 -16M | 0x112 0x115 0x118 0x11B
76 +256 | 0x101 0x103 0x105 0x107
77 +32k | 0x110 0x113 0x116 0x119
78 +64k | 0x111 0x114 0x117 0x11A
79 +16M | 0x112 0x115 0x118 0x11B
80
81 -The video mode number of the Linux kernel is the VESA mode number plus
82 -0x200.
83 +The video mode number of the Linux kernel is the VESA mode number plus 0x200.
84
85 Linux_kernel_mode_number = VESA_mode_number + 0x200
86
87 @@ -56,15 +67,15 @@ So the table for the Kernel mode numbers
88
89 | 640x480 800x600 1024x768 1280x1024
90 ----+-------------------------------------
91 -256 | 0x301 0x303 0x305 0x307
92 -32k | 0x310 0x313 0x316 0x319
93 -64k | 0x311 0x314 0x317 0x31A
94 -16M | 0x312 0x315 0x318 0x31B
95 -
96 -To enable one of those modes you have to specify "vga=ask" in the
97 -lilo.conf file and rerun LILO. Then you can type in the desired
98 -mode at the "vga=ask" prompt. For example if you like to use
99 -1024x768x256 colors you have to say "305" at this prompt.
100 +256 | 0x301 0x303 0x305 0x307
101 +32k | 0x310 0x313 0x316 0x319
102 +64k | 0x311 0x314 0x317 0x31A
103 +16M | 0x312 0x315 0x318 0x31B
104 +
105 +To enable one of those modes you have to specify "vga=ask" in the lilo.conf
106 +file and rerun LILO. Then you can type in the desired mode at the "vga=ask"
107 +prompt. For example if you like to use 1024x768x256 colors you have to say
108 +"305" at this prompt.
109
110 If this does not work, this might be because your BIOS does not support
111 linear framebuffers or because it does not support this mode at all.
112 @@ -72,11 +83,12 @@ Even if your board does, it might be the
113 Extensions v2.0 are required, 1.2 is NOT sufficient. You will get a
114 "bad mode number" message if something goes wrong.
115
116 -1. Note: LILO cannot handle hex, for booting directly with
117 +1. Note: LILO cannot handle hex, for booting directly with
118 "vga=mode-number" you have to transform the numbers to decimal.
119 2. Note: Some newer versions of LILO appear to work with those hex values,
120 if you set the 0x in front of the numbers.
121
122 +
123 X11
124 ===
125
126 @@ -84,98 +96,162 @@ XF68_FBDev should work just fine, but it
127 another (accelerated) X-Server like XF86_SVGA might or might not work.
128 It depends on X-Server and graphics board.
129
130 -The X-Server must restore the video mode correctly, else you end up
131 +The X-Server must restore the video mode correctly, or else you end up
132 with a broken console (and vesafb cannot do anything about this).
133 +With vesafb-tng chances are that the console will be restored properly
134 +even if the X server messes up the video mode.
135
136
137 Refresh rates
138 =============
139
140 -There is no way to change the vesafb video mode and/or timings after
141 -booting linux. If you are not happy with the 60 Hz refresh rate, you
142 -have these options:
143 +With VBE3.0 compatible BIOSes and vesafb-tng it is possible to change
144 +the refresh rate either at boot time (by specifying the @<rr> part of
145 +the mode name) or later, using the fbset utility.
146 +
147 +If you want to use the default BIOS refresh rate while switching modes
148 +on a running system, set pixclock to 0.
149 +
150 +With VBE2.0 there is no way to change the mode timings after booting
151 +Linux. If you are not happy with the 60 Hz refresh rate, you have
152 +these options:
153
154 - * configure and load the DOS-Tools for your the graphics board (if
155 - available) and boot linux with loadlin.
156 + * configure and load the DOS tools for your the graphics board (if
157 + available) and boot Linux with loadlin.
158 * use a native driver (matroxfb/atyfb) instead if vesafb. If none
159 is available, write a new one!
160 - * VBE 3.0 might work too. I have neither a gfx board with VBE 3.0
161 - support nor the specs, so I have not checked this yet.
162 + * use a BIOS editor to change the default refresh rate (such an
163 + editor does exist at least for ATI Radeon BIOSes).
164 + * if you're running a non-vm86 and VBE3.0-compatible system, you can
165 + use a kernel patch (vesafb-rrc) to hard-code some mode timings in
166 + the kernel and use these while setting the graphic mode at boot time.
167 +
168 +Note that there are some boards (nVidia 59**, 57** and newer models)
169 +claiming that their Video BIOS is VBE3.0 compliant, while ignoring the
170 +CRTC values provided by software such as vesafb-tng. You'll not be able
171 +to change the refresh rate if you're using one of these boards.
172
173
174 Configuration
175 =============
176
177 -The VESA BIOS provides protected mode interface for changing
178 -some parameters. vesafb can use it for palette changes and
179 -to pan the display. It is turned off by default because it
180 -seems not to work with some BIOS versions, but there are options
181 -to turn it on.
182 -
183 -You can pass options to vesafb using "video=vesafb:option" on
184 -the kernel command line. Multiple options should be separated
185 -by comma, like this: "video=vesafb:ypan,invers"
186 -
187 -Accepted options:
188 -
189 -invers no comment...
190 -
191 -ypan enable display panning using the VESA protected mode
192 - interface. The visible screen is just a window of the
193 - video memory, console scrolling is done by changing the
194 - start of the window.
195 - pro: * scrolling (fullscreen) is fast, because there is
196 - no need to copy around data.
197 - * You'll get scrollback (the Shift-PgUp thing),
198 - the video memory can be used as scrollback buffer
199 - kontra: * scrolling only parts of the screen causes some
200 - ugly flicker effects (boot logo flickers for
201 - example).
202 -
203 -ywrap Same as ypan, but assumes your gfx board can wrap-around
204 - the video memory (i.e. starts reading from top if it
205 - reaches the end of video memory). Faster than ypan.
206 -
207 -redraw scroll by redrawing the affected part of the screen, this
208 - is the safe (and slow) default.
209 -
210 -
211 -vgapal Use the standard vga registers for palette changes.
212 - This is the default.
213 -pmipal Use the protected mode interface for palette changes.
214 -
215 -mtrr:n setup memory type range registers for the vesafb framebuffer
216 - where n:
217 - 0 - disabled (equivalent to nomtrr) (default)
218 - 1 - uncachable
219 - 2 - write-back
220 - 3 - write-combining
221 - 4 - write-through
222 +The VESA BIOS provides protected mode interface for changing some parameters.
223 +vesafb can use it for palette changes and to pan the display. It is turned
224 +off by default because it seems not to work with some BIOS versions, but
225 +there are options to turn it on.
226 +
227 +You can pass options to vesafb using "video=vesafb:option" on the kernel
228 +command line. Multiple options should be separated by comma, like this:
229 +"video=vesafb:ypan,1024x768-32@85"
230 +
231 +Note that vesafb-tng still uses the "video=vesafb:option" format of the
232 +kernel command line video parameter. "video=vesafb-tng:xxx" is incorrect.
233 +
234 +Accepted options (both vesafb and vesafb-tng):
235 +
236 +ypan Enable display panning using the VESA protected mode interface
237 + The visible screen is just a window of the video memory,
238 + console scrolling is done by changing the start of the window.
239 + pro: * scrolling (fullscreen) is fast, because there is
240 + no need to copy around data.
241 + * you'll get scrollback (the Shift-PgUp thing),
242 + the video memory can be used as scrollback buffer
243 + con: * scrolling only parts of the screen causes some
244 + ugly flicker effects (boot logo flickers for
245 + example).
246 +
247 +ywrap Same as ypan, but assumes your gfx board can wrap-around the video
248 + memory (i.e. starts reading from top if it reaches the end of
249 + video memory). Faster than ypan.
250 +
251 +redraw Scroll by redrawing the affected part of the screen, this is the
252 + safe (and slow) default.
253 +
254 +vgapal Use the standard VGA registers for palette changes.
255 + This is the default.
256 +
257 +pmipal Use the protected mode interface for palette changes.
258 +
259 +mtrr:n Setup memory type range registers for the vesafb framebuffer
260 + where n:
261 + 0 - disabled (equivalent to nomtrr) (default)
262 + 1 - uncachable
263 + 2 - write-back
264 + 3 - write-combining
265 + 4 - write-through
266
267 - If you see the following in dmesg, choose the type that matches the
268 - old one. In this example, use "mtrr:2".
269 + If you see the following in dmesg, choose the type that matches
270 + the old one. In this example, use "mtrr:2".
271 ...
272 mtrr: type mismatch for e0000000,8000000 old: write-back new: write-combining
273 ...
274
275 -nomtrr disable mtrr
276 +nomtrr Do not use memory type range registers for vesafb.
277
278 vremap:n
279 remap 'n' MiB of video RAM. If 0 or not specified, remap memory
280 - according to video mode. (2.5.66 patch/idea by Antonino Daplas
281 - reversed to give override possibility (allocate more fb memory
282 - than the kernel would) to 2.4 by tmb@iki.fi)
283 + according to video mode. (2.5.66 patch/idea by Antonino Daplas
284 + reversed to give override possibility (allocate more fb memory
285 + than the kernel would) to 2.4 by tmb@iki.fi)
286
287 vtotal:n
288 if the video BIOS of your card incorrectly determines the total
289 amount of video RAM, use this option to override the BIOS (in MiB).
290
291 -Have fun!
292 +Options accepted only by vesafb-tng:
293
294 - Gerd
295 +<mode> The mode you want to set, in the standard modedb format. Refer to
296 + modedb.txt for detailed description. If you specify a mode that is
297 + not supported by your board's BIOS, vesafb will attempt to set a
298 + similar mode. The list of supported modes can be found in
299 + /proc/fbx/modes, where x is the framebuffer number (usually 0).
300 + When vesafb is compiled as a module, the mode string should be
301 + provided as a value of the parameter 'mode'.
302 +
303 +vbemode:x
304 + Force the use of VBE mode x. The mode will only be set if it's
305 + found in VBE-provided list of supported modes.
306 + NOTE: The mode number 'x' should be specified in VESA mode number
307 + notation, not the Linux kernel one (ie. 257 instead of 769).
308 + HINT: If you use this option because normal <mode> parameter does
309 + not work for you and you use a X server, you'll probably want to
310 + set the 'nocrtc' option to ensure that the video mode is properly
311 + restored after console <-> X switches.
312 +
313 +nocrtc Do not use CRTC timings while setting the graphic mode. This option
314 + makes sence only with VBE3.0 compliant systems. Use it if you have
315 + problems with the modes set in the standard way. Note that specifying
316 + this option means the refresh rate will be ignored and will stay at
317 + your BIOS default (60 Hz).
318 +
319 +noedid Do not try to fetch and use EDID-provided modes.
320 +
321 +gtf Force the use of VESA's GTF (Generalized Timing Formula). Specifying
322 + this will cause vesafb to skip it's internal modedb and EDID-modedb
323 + and jump straight to the GTF part of the code (normally used only if
324 + everything else failed). This can be useful if you want to get as
325 + much as possible from you graphics board but your BIOS doesn't
326 + support modes with refresh rates you require. Note that you may need
327 + to specify the maxhf, maxvf and maxclk parameters if they are not
328 + provided by EDID.
329 +
330 +Additionally, the following parameters may be provided. They all override the
331 +EDID-provided values and BIOS defaults. Refer to your monitor's specs to get
332 +the correct values for maxhf, maxvf and maxclk for your hardware.
333 +
334 +maxhf:n Maximum horizontal frequency (in kHz).
335 +maxvf:n Maximum vertical frequency (in Hz).
336 +maxclk:n Maximum pixel clock (in MHz).
337 +
338 +Have fun!
339
340 --
341 +Original document for the vesafb driver by
342 Gerd Knorr <kraxel@goldbach.in-berlin.de>
343
344 -Minor (mostly typo) changes
345 -by Nico Schmoigl <schmoigl@rumms.uni-mannheim.de>
346 +Minor (mostly typo) changes by
347 +Nico Schmoigl <schmoigl@rumms.uni-mannheim.de>
348 +
349 +Extended documentation for vm86, VBE3.0 and vesafb-tng by
350 +Michal Januszewski <spock@gentoo.org>
351 +
352 Index: linux-git/arch/i386/boot/video.S
353 ===================================================================
354 --- linux-git.orig/arch/i386/boot/video.S
355 +++ linux-git/arch/i386/boot/video.S
356 @@ -164,10 +164,12 @@ basret: ret
357 # parameters in the default 80x25 mode -- these are set directly,
358 # because some very obscure BIOSes supply insane values.
359 mode_params:
360 +#ifdef CONFIG_FB_VESA_STD
361 #ifdef CONFIG_VIDEO_SELECT
362 cmpb $0, graphic_mode
363 jnz mopar_gr
364 #endif
365 +#endif
366 movb $0x03, %ah # Read cursor position
367 xorb %bh, %bh
368 int $0x10
369 @@ -200,6 +202,7 @@ mopar2: movb %al, %fs:(PARAM_VIDEO_LINES
370 ret
371
372 #ifdef CONFIG_VIDEO_SELECT
373 +#ifdef CONFIG_FB_VESA_STD
374 # Fetching of VESA frame buffer parameters
375 mopar_gr:
376 leaw modelist+1024, %di
377 @@ -278,6 +281,7 @@ dac_done:
378 movw %es, %fs:(PARAM_VESAPM_SEG)
379 movw %di, %fs:(PARAM_VESAPM_OFF)
380 no_pm: ret
381 +#endif
382
383 # The video mode menu
384 mode_menu:
385 @@ -492,10 +496,12 @@ mode_set:
386
387 cmpb $VIDEO_FIRST_V7>>8, %ah
388 jz setv7
389 -
390 +
391 +#ifdef CONFIG_FB_VESA_STD
392 cmpb $VIDEO_FIRST_VESA>>8, %ah
393 jnc check_vesa
394 -
395 +#endif
396 +
397 orb %ah, %ah
398 jz setmenu
399
400 @@ -567,6 +573,7 @@ setr1: lodsw
401 movw -4(%si), %ax # Fetch mode ID
402 jmp _m_s
403
404 +#ifdef CONFIG_FB_VESA_STD
405 check_vesa:
406 leaw modelist+1024, %di
407 subb $VIDEO_FIRST_VESA>>8, %bh
408 @@ -600,6 +607,7 @@ check_vesa:
409 ret
410
411 _setbad: jmp setbad # Ugly...
412 +#endif
413
414 # Recalculate vertical display end registers -- this fixes various
415 # inconsistencies of extended modes on many adapters. Called when
416 Index: linux-git/drivers/video/Kconfig
417 ===================================================================
418 --- linux-git.orig/drivers/video/Kconfig
419 +++ linux-git/drivers/video/Kconfig
420 @@ -454,8 +454,8 @@ config FB_TGA
421 cards. Say Y if you have one of those.
422
423 config FB_VESA
424 - bool "VESA VGA graphics support"
425 - depends on (FB = y) && X86
426 + tristate "VESA VGA graphics support"
427 + depends on (FB = y) && (X86 || X86_64)
428 select FB_CFB_FILLRECT
429 select FB_CFB_COPYAREA
430 select FB_CFB_IMAGEBLIT
431 @@ -465,6 +465,48 @@ config FB_VESA
432 You will get a boot time penguin logo at no additional cost. Please
433 read <file:Documentation/fb/vesafb.txt>. If unsure, say Y.
434
435 +choice
436 + prompt "VESA driver type"
437 + depends on FB_VESA
438 + default FB_VESA_STD if X86_64
439 + default FB_VESA_TNG if X86
440 +
441 +config FB_VESA_STD
442 + bool "vesafb"
443 + help
444 + This is the frame buffer device driver for generic VESA 2.0
445 + compliant graphic cards. The older VESA 1.2 cards are not supported.
446 + You will get a boot time penguin logo at no additional cost. Please
447 + read <file:Documentation/fb/vesafb.txt>. Choose this driver if you
448 + are experiencing problems with vesafb-tng or if you own a 64-bit system.
449 +
450 + Note that this driver cannot be compiled as a module.
451 +
452 +config FB_VESA_TNG
453 + bool "vesafb-tng"
454 + depends on !X86_64
455 + select FB_MODE_HELPERS
456 + help
457 + This is the frame buffer device driver for generic VESA 2.0
458 + compliant graphic cards. It is capable of taking advantage of
459 + VBE 3.0 features. With this driver you will be able to adjust
460 + the refresh rate (VBE 3.0 compliant boards only) and change
461 + the graphic mode on-the-fly.
462 +
463 + You will also get a boot time penguin logo at no additional cost. Please
464 + read <file:Documentation/fb/vesafb.txt>.
465 +
466 +endchoice
467 +
468 +config FB_VESA_DEFAULT_MODE
469 + string "VESA default mode"
470 + depends on FB_VESA_TNG
471 + default "640x480@60"
472 + help
473 + This option is used to determine the default mode vesafb is
474 + supposed to switch to in case no mode is provided as a kernel
475 + command line parameter.
476 +
477 config VIDEO_SELECT
478 bool
479 depends on FB_VESA
480 Index: linux-git/drivers/video/Makefile
481 ===================================================================
482 --- linux-git.orig/drivers/video/Makefile
483 +++ linux-git/drivers/video/Makefile
484 @@ -97,7 +97,11 @@ obj-$(CONFIG_FB_IMX) += imx
485 obj-$(CONFIG_FB_S3C2410) += s3c2410fb.o
486
487 # Platform or fallback drivers go here
488 -obj-$(CONFIG_FB_VESA) += vesafb.o
489 +ifeq ($(CONFIG_FB_VESA_STD),y)
490 + obj-y += vesafb.o
491 +else
492 + obj-$(CONFIG_FB_VESA) += vesafb-thread.o vesafb-tng.o
493 +endif
494 obj-$(CONFIG_FB_VGA16) += vga16fb.o vgastate.o
495 obj-$(CONFIG_FB_OF) += offb.o
496
497 Index: linux-git/drivers/video/fbmem.c
498 ===================================================================
499 --- linux-git.orig/drivers/video/fbmem.c
500 +++ linux-git/drivers/video/fbmem.c
501 @@ -1430,6 +1430,7 @@ fbmem_init(void)
502 printk(KERN_WARNING "Unable to create fb class; errno = %ld\n", PTR_ERR(fb_class));
503 fb_class = NULL;
504 }
505 +
506 return 0;
507 }
508
509 Index: linux-git/drivers/video/modedb.c
510 ===================================================================
511 --- linux-git.orig/drivers/video/modedb.c
512 +++ linux-git/drivers/video/modedb.c
513 @@ -667,6 +667,7 @@ void fb_var_to_videomode(struct fb_video
514 {
515 u32 pixclock, hfreq, htotal, vtotal;
516
517 + mode->refresh = 0;
518 mode->name = NULL;
519 mode->xres = var->xres;
520 mode->yres = var->yres;
521 Index: linux-git/drivers/video/vesafb-thread.c
522 ===================================================================
523 --- /dev/null
524 +++ linux-git/drivers/video/vesafb-thread.c
525 @@ -0,0 +1,722 @@
526 +/*
527 + * Framebuffer driver for VBE 2.0+ compliant graphic boards.
528 + * Kernel thread and vm86 routines.
529 + *
530 + * (c) 2004-2005 Michal Januszewski <spock@gentoo.org>
531 + *
532 + */
533 +
534 +#include <linux/config.h>
535 +#include <linux/slab.h>
536 +#include <linux/workqueue.h>
537 +#include <linux/completion.h>
538 +#include <linux/module.h>
539 +#include <linux/kernel.h>
540 +#include <linux/errno.h>
541 +#include <linux/mm.h>
542 +#include <linux/delay.h>
543 +#include <linux/signal.h>
544 +#include <linux/suspend.h>
545 +#include <linux/unistd.h>
546 +#include <video/vesa.h>
547 +#include <video/edid.h>
548 +#include <asm/mman.h>
549 +#include <asm/page.h>
550 +#include <asm/vm86.h>
551 +#include <asm/thread_info.h>
552 +#include <asm/uaccess.h>
553 +#include <asm/mmu_context.h>
554 +#include "edid.h"
555 +
556 +#ifdef MODULE
557 +int errno;
558 +#endif
559 +
560 +static DECLARE_COMPLETION(vesafb_th_completion);
561 +static DECLARE_MUTEX(vesafb_task_list_sem);
562 +static LIST_HEAD(vesafb_task_list);
563 +static DECLARE_WAIT_QUEUE_HEAD(vesafb_wait);
564 +
565 +static struct vm86_struct vm86;
566 +static int vesafb_pid = 0;
567 +
568 +_syscall3(int,ioperm,unsigned long, a, unsigned long, b, unsigned long, c);
569 +_syscall1(int,vm86old,struct vm86_struct __user*, v86);
570 +
571 +#define DEFAULT_VM86_FLAGS (IF_MASK | IOPL_MASK)
572 +#define VM86_PUSHW(x) \
573 +do { \
574 + vm86.regs.esp -= 2; \
575 + *(u16*)(STACK_ADDR + vm86.regs.esp) = x; \
576 +} while(0);
577 +
578 +/* Stack, the return code and buffers will be put into
579 + * one contiguous memory chunk:
580 + *
581 + * [ STACK | RET_CODE | BUFFER ]
582 + *
583 + * We only need a buffer that is ca. 0x2000 bytes in size.
584 + * Some video BIOSes (sis6326) try to store data somewhere
585 + * in 0x7000-0x7fff, so we zeromap more memory to be safe.
586 + */
587 +#define IVTBDA_SIZE PAGE_SIZE
588 +#define RET_CODE_SIZE 0x0010
589 +#define STACK_SIZE 0x0500
590 +#define BUFFER_SIZE 0x10000
591 +
592 +/* The amount of memory that will be allocated should be a multiple
593 + * of PAGE_SIZE. */
594 +#define __MEM_SIZE (RET_CODE_SIZE + STACK_SIZE + BUFFER_SIZE)
595 +#define REAL_MEM_SIZE (((__MEM_SIZE / PAGE_SIZE) + 1) * PAGE_SIZE)
596 +
597 +#define IVTBDA_ADDR 0x00000
598 +#define STACK_ADDR (IVTBDA_ADDR + IVTBDA_SIZE)
599 +#define RET_CODE_ADDR (STACK_ADDR + STACK_SIZE)
600 +#define BUF_ADDR (RET_CODE_ADDR + RET_CODE_SIZE)
601 +
602 +#define FLAG_D (1 << 10)
603 +
604 +/* Segment prefix opcodes */
605 +enum {
606 + P_CS = 0x2e,
607 + P_SS = 0x36,
608 + P_DS = 0x3e,
609 + P_ES = 0x26,
610 + P_FS = 0x64,
611 + P_GS = 0x65
612 +};
613 +
614 +/* Emulated vm86 ins instruction */
615 +static void vm86_ins(int size)
616 +{
617 + u32 edx, edi;
618 + edx = vm86.regs.edx & 0xffff;
619 + edi = (vm86.regs.edi & 0xffff) + (u32)(vm86.regs.es << 4);
620 +
621 + if (vm86.regs.eflags & FLAG_D)
622 + asm volatile ("std\n");
623 + else
624 + asm volatile ("cld\n");
625 +
626 + switch (size) {
627 + case 4:
628 + asm volatile ("insl\n" : "=D" (edi) : "d" (edx), "0" (edi));
629 + break;
630 + case 2:
631 + asm volatile ("insw\n" : "=D" (edi) : "d" (edx), "0" (edi));
632 + break;
633 + case 1:
634 + asm volatile ("insb\n" : "=D" (edi) : "d" (edx), "0" (edi));
635 + break;
636 + }
637 +
638 + if (vm86.regs.eflags & FLAG_D)
639 + asm volatile ("cld\n");
640 +
641 + edi -= (u32)(vm86.regs.es << 4);
642 +
643 + vm86.regs.edi &= 0xffff0000;
644 + vm86.regs.edi |= edi & 0xffff;
645 +}
646 +
647 +static void vm86_rep_ins(int size)
648 +{
649 + u16 cx = vm86.regs.ecx;
650 + while (cx--)
651 + vm86_ins(size);
652 +
653 + vm86.regs.ecx &= 0xffff0000;
654 +}
655 +
656 +/* Emulated vm86 outs instruction */
657 +static void vm86_outs(int size, int segment)
658 +{
659 + u32 edx, esi, base;
660 +
661 + edx = vm86.regs.edx & 0xffff;
662 + esi = vm86.regs.esi & 0xffff;
663 +
664 + switch (segment) {
665 + case P_CS: base = vm86.regs.cs; break;
666 + case P_SS: base = vm86.regs.ss; break;
667 + case P_ES: base = vm86.regs.es; break;
668 + case P_FS: base = vm86.regs.fs; break;
669 + case P_GS: base = vm86.regs.gs; break;
670 + default: base = vm86.regs.ds; break;
671 + }
672 +
673 + esi += base << 4;
674 +
675 + if (vm86.regs.eflags & FLAG_D)
676 + asm volatile ("std\n");
677 + else
678 + asm volatile ("cld\n");
679 +
680 + switch (size) {
681 + case 4:
682 + asm volatile ("outsl\n" : "=S" (esi) : "d" (edx), "0" (esi));
683 + break;
684 + case 2:
685 + asm volatile ("outsw\n" : "=S" (esi) : "d" (edx), "0" (esi));
686 + break;
687 + case 1:
688 + asm volatile ("outsb\n" : "=S" (esi) : "d" (edx), "0" (esi));
689 + break;
690 + }
691 +
692 + if (vm86.regs.eflags & FLAG_D)
693 + asm volatile ("cld");
694 +
695 + esi -= base << 4;
696 + vm86.regs.esi &= 0xffff0000;
697 + vm86.regs.esi |= (esi & 0xffff);
698 +}
699 +
700 +static void vm86_rep_outs(int size, int segment)
701 +{
702 + u16 cx = vm86.regs.ecx;
703 + while (cx--)
704 + vm86_outs(size, segment);
705 +
706 + vm86.regs.ecx &= 0xffff0000;
707 +}
708 +
709 +static int vm86_do_unknown(void)
710 +{
711 + u8 data32 = 0, segment = P_DS, rep = 0;
712 + u8 *instr;
713 + int ret = 0, i = 0;
714 +
715 + instr = (u8*)((vm86.regs.cs << 4) + vm86.regs.eip);
716 +
717 + while (1) {
718 + switch(instr[i]) {
719 + case 0x66: /* operand size prefix */
720 + data32 = 1 - data32;
721 + i++;
722 + break;
723 + case 0xf2: /* repnz */
724 + case 0xf3: /* rep */
725 + rep = 1;
726 + i++;
727 + break;
728 + case P_CS: /* segment prefix */
729 + case P_SS:
730 + case P_DS:
731 + case P_ES:
732 + case P_FS:
733 + case P_GS:
734 + segment = instr[i];
735 + i++;
736 + break;
737 + case 0xf0: /* LOCK - ignored */
738 + case 0x67: /* address size prefix - ignored */
739 + i++;
740 + break;
741 + case 0x6c: /* insb */
742 + if (rep)
743 + vm86_rep_ins(1);
744 + else
745 + vm86_ins(1);
746 + i++;
747 + goto out;
748 + case 0x6d: /* insw / insd */
749 + if (rep) {
750 + if (data32)
751 + vm86_rep_ins(4);
752 + else
753 + vm86_rep_ins(2);
754 + } else {
755 + if (data32)
756 + vm86_ins(4);
757 + else
758 + vm86_ins(2);
759 + }
760 + i++;
761 + goto out;
762 + case 0x6e: /* outsb */
763 + if (rep)
764 + vm86_rep_outs(1, segment);
765 + else
766 + vm86_outs(1, segment);
767 + i++;
768 + goto out;
769 + case 0x6f: /* outsw / outsd */
770 + if (rep) {
771 + if (data32)
772 + vm86_rep_outs(4, segment);
773 + else
774 + vm86_rep_outs(2, segment);
775 + } else {
776 + if (data32)
777 + vm86_outs(4, segment);
778 + else
779 + vm86_outs(2, segment);
780 + }
781 + i++;
782 + goto out;
783 + case 0xe4: /* inb xx */
784 + asm volatile (
785 + "inb %w1, %b0"
786 + : "=a" (vm86.regs.eax)
787 + : "d" (instr[i+1]), "0" (vm86.regs.eax));
788 + i += 2;
789 + goto out;
790 + case 0xe5: /* inw xx / ind xx */
791 + if (data32) {
792 + asm volatile (
793 + "inl %w1, %0"
794 + : "=a" (vm86.regs.eax)
795 + : "d" (instr[i+1]),
796 + "0" (vm86.regs.eax));
797 + } else {
798 + asm volatile (
799 + "inw %w1, %w0"
800 + : "=a" (vm86.regs.eax)
801 + : "d" (instr[i+1]),
802 + "0" (vm86.regs.eax));
803 + }
804 + i += 2;
805 + goto out;
806 +
807 + case 0xec: /* inb dx */
808 + asm volatile (
809 + "inb %w1, %b0"
810 + : "=a" (vm86.regs.eax)
811 + : "d" (vm86.regs.edx), "0" (vm86.regs.eax));
812 + i++;
813 + goto out;
814 + case 0xed: /* inw dx / ind dx */
815 + if (data32) {
816 + asm volatile (
817 + "inl %w1, %0"
818 + : "=a" (vm86.regs.eax)
819 + : "d" (vm86.regs.edx));
820 + } else {
821 + asm volatile (
822 + "inw %w1, %w0"
823 + : "=a" (vm86.regs.eax)
824 + : "d" (vm86.regs.edx));
825 + }
826 + i++;
827 + goto out;
828 + case 0xe6: /* outb xx */
829 + asm volatile (
830 + "outb %b0, %w1"
831 + : /* no return value */
832 + : "a" (vm86.regs.eax), "d" (instr[i+1]));
833 + i += 2;
834 + goto out;
835 + case 0xe7: /* outw xx / outd xx */
836 + if (data32) {
837 + asm volatile (
838 + "outl %0, %w1"
839 + : /* no return value */
840 + : "a" (vm86.regs.eax),
841 + "d" (instr[i+1]));
842 + } else {
843 + asm volatile (
844 + "outw %w0, %w1"
845 + : /* no return value */
846 + : "a" (vm86.regs.eax),
847 + "d" (instr[i+1]));
848 + }
849 + i += 2;
850 + goto out;
851 + case 0xee: /* outb dx */
852 + asm volatile (
853 + "outb %b0, %w1"
854 + : /* no return value */
855 + : "a" (vm86.regs.eax), "d" (vm86.regs.edx));
856 + i++;
857 + goto out;
858 + case 0xef: /* outw dx / outd dx */
859 + if (data32) {
860 + asm volatile (
861 + "outl %0, %w1"
862 + : /* no return value */
863 + : "a" (vm86.regs.eax),
864 + "d" (vm86.regs.edx));
865 + } else {
866 + asm volatile (
867 + "outw %w0, %w1"
868 + : /* no return value */
869 + : "a" (vm86.regs.eax),
870 + "d" (vm86.regs.edx));
871 + }
872 + i++;
873 + goto out;
874 + default:
875 + printk(KERN_ERR "vesafb: BUG, opcode 0x%x emulation "
876 + "not supported (EIP: 0x%lx)\n",
877 + instr[i], (u32)(vm86.regs.cs << 4) +
878 + vm86.regs.eip);
879 + ret = 1;
880 + goto out;
881 + }
882 + }
883 +out: vm86.regs.eip += i;
884 + return ret;
885 +}
886 +
887 +void vesafb_do_vm86(struct vm86_regs *regs)
888 +{
889 + unsigned int ret;
890 + u8 *retcode = (void*)RET_CODE_ADDR;
891 +
892 + memset(&vm86,0,sizeof(vm86));
893 + memcpy(&vm86.regs, regs, sizeof(struct vm86_regs));
894 +
895 + /* The return code */
896 + retcode[0] = 0xcd; /* int opcode */
897 + retcode[1] = 0xff; /* int number (255) */
898 +
899 + /* We use int 0xff to get back to protected mode */
900 + memset(&vm86.int_revectored, 0, sizeof(vm86.int_revectored));
901 + ((unsigned char *)&vm86.int_revectored)[0xff / 8] |= (1 << (0xff % 8));
902 +
903 + /*
904 + * We want to call int 0x10, so we set:
905 + * CS = 0x42 = 0x10 * 4 + 2
906 + * IP = 0x40 = 0x10 * 4
907 + * and SS:ESP. It's up to the caller to set the rest of the registers.
908 + */
909 + vm86.regs.eflags = DEFAULT_VM86_FLAGS;
910 + vm86.regs.cs = *(unsigned short *)0x42;
911 + vm86.regs.eip = *(unsigned short *)0x40;
912 + vm86.regs.ss = (STACK_ADDR >> 4);
913 + vm86.regs.esp = ((STACK_ADDR & 0x0000f) + STACK_SIZE);
914 +
915 + /* These will be fetched off the stack when we come to an iret in the
916 + * int's 0x10 code. */
917 + VM86_PUSHW(DEFAULT_VM86_FLAGS);
918 + VM86_PUSHW((RET_CODE_ADDR >> 4)); /* return code segment */
919 + VM86_PUSHW((RET_CODE_ADDR & 0x0000f)); /* return code offset */
920 +
921 + while(1) {
922 + ret = vm86old(&vm86);
923 +
924 + if (VM86_TYPE(ret) == VM86_INTx) {
925 + int vint = VM86_ARG(ret);
926 +
927 + /* If exit from vm86 was caused by int 0xff, then
928 + * we're done.. */
929 + if (vint == 0xff)
930 + goto out;
931 +
932 + /* .. otherwise, we have to call the int handler
933 + * manually */
934 + VM86_PUSHW(vm86.regs.eflags);
935 + VM86_PUSHW(vm86.regs.cs);
936 + VM86_PUSHW(vm86.regs.eip);
937 +
938 + vm86.regs.cs = *(u16 *)((vint << 2) + 2);
939 + vm86.regs.eip = *(u16 *)(vint << 2);
940 + vm86.regs.eflags &= ~(VIF_MASK | TF_MASK);
941 + } else if (VM86_TYPE(ret) == VM86_UNKNOWN) {
942 + if (vm86_do_unknown())
943 + goto out;
944 + } else {
945 + printk(KERN_ERR "vesafb: BUG, returned from "
946 + "vm86 with %x (EIP: 0x%lx)\n",
947 + ret, (u32)(vm86.regs.cs << 4) +
948 + vm86.regs.eip);
949 + goto out;
950 + }
951 + }
952 +
953 +out: /* copy the registers' state back to the caller's struct */
954 + memcpy(regs, &vm86.regs, sizeof(struct vm86_regs));
955 +}
956 +
957 +static int vesafb_remap_pfn_range(unsigned long start, unsigned long end,
958 + unsigned long pgoff, unsigned long prot,
959 + int type)
960 +{
961 + struct vm_area_struct *vma;
962 + struct mm_struct *mm = current->mm;
963 + int ret = 0;
964 +
965 + vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
966 + if (!vma)
967 + return -ENOMEM;
968 + memset(vma, 0, sizeof(*vma));
969 + down_write(&mm->mmap_sem);
970 + vma->vm_mm = mm;
971 + vma->vm_start = start;
972 + vma->vm_end = end;
973 + vma->vm_flags = VM_READ | VM_WRITE | VM_EXEC;
974 + vma->vm_flags |= mm->def_flags;
975 + vma->vm_page_prot.pgprot = prot;
976 + vma->vm_pgoff = pgoff;
977 +
978 + if ((ret = insert_vm_struct(mm, vma))) {
979 + up_write(&mm->mmap_sem);
980 + kmem_cache_free(vm_area_cachep, vma);
981 + return ret;
982 + }
983 +
984 + if (type) {
985 + vma->vm_flags |= VM_SHARED;
986 + ret = zeromap_page_range(vma,
987 + vma->vm_start,
988 + vma->vm_end - vma->vm_start,
989 + vma->vm_page_prot);
990 + } else {
991 + ret = remap_pfn_range(vma,
992 + vma->vm_start,
993 + vma->vm_pgoff,
994 + vma->vm_end - vma->vm_start,
995 + vma->vm_page_prot);
996 + }
997 + up_write(&mm->mmap_sem);
998 + return ret;
999 +}
1000 +
1001 +static inline int vesafb_init_mem(void)
1002 +{
1003 + int ret = 0;
1004 +
1005 + /* The memory chunks we're remapping here should be multiples
1006 + * of PAGE_SIZE. */
1007 + ret += vesafb_remap_pfn_range(0x00000, IVTBDA_SIZE, 0,
1008 + PROT_READ | PROT_EXEC | PROT_WRITE, 0);
1009 + ret += vesafb_remap_pfn_range(IVTBDA_SIZE, REAL_MEM_SIZE, 0,
1010 + PROT_READ | PROT_EXEC | PROT_WRITE, 1);
1011 + ret += vesafb_remap_pfn_range(0x9f000, 0x100000,
1012 + 0x9f000 >> PAGE_SHIFT,
1013 + PROT_READ | PROT_EXEC | PROT_WRITE, 0);
1014 + if (ret)
1015 + printk(KERN_ERR "vesafb thread: memory remapping failed\n");
1016 +
1017 + return ret;
1018 +}
1019 +
1020 +#define vesafb_get_string(str) \
1021 +{ \
1022 + /* The address is in the form ssssoooo, where oooo = offset, \
1023 + * ssss = segment */ \
1024 + addr = ((p_vbe(tsk->buf)->str & 0xffff0000) >> 12) + \
1025 + (p_vbe(tsk->buf)->str & 0x0000ffff); \
1026 + \
1027 + /* The data is in ROM which is shared between processes, so we \
1028 + * just translate the real mode address into one visible from \
1029 + * kernel space */ \
1030 + if (addr >= 0xa0000) { \
1031 + p_vbe(tsk->buf)->str = (u32) __va(addr); \
1032 + \
1033 + /* The data is in the buffer, we just have to convert the \
1034 + * address so that it points into the buffer user provided. */ \
1035 + } else if (addr > BUF_ADDR && addr < BUF_ADDR + \
1036 + sizeof(struct vesafb_vbe_ib)) { \
1037 + addr -= BUF_ADDR; \
1038 + p_vbe(tsk->buf)->str = (u32) (tsk->buf + addr); \
1039 + \
1040 + /* This should never happen: someone was insane enough to put \
1041 + * the data somewhere in RAM.. */ \
1042 + } else { \
1043 + p_vbe(tsk->buf)->str = (u32) ""; \
1044 + } \
1045 +}
1046 +
1047 +void vesafb_handle_getvbeib(struct vesafb_task *tsk)
1048 +{
1049 + int addr, res;
1050 +
1051 + tsk->regs.es = (BUF_ADDR >> 4);
1052 + tsk->regs.edi = (BUF_ADDR & 0x000f);
1053 + strncpy(p_vbe(BUF_ADDR)->vbe_signature, "VBE2", 4);
1054 +
1055 + vesafb_do_vm86(&tsk->regs);
1056 + memcpy(tsk->buf, (void*)(BUF_ADDR), sizeof(struct vesafb_vbe_ib));
1057 +
1058 + /* The OEM fields were not defined prior to VBE 2.0 */
1059 + if (p_vbe(tsk->buf)->vbe_version >= 0x200) {
1060 + vesafb_get_string(oem_string_ptr);
1061 + vesafb_get_string(oem_vendor_name_ptr);
1062 + vesafb_get_string(oem_product_name_ptr);
1063 + vesafb_get_string(oem_product_rev_ptr);
1064 + }
1065 +
1066 + /* This is basically the same as vesafb_get_string() */
1067 + addr = ((p_vbe(tsk->buf)->mode_list_ptr & 0xffff0000) >> 12) +
1068 + (p_vbe(tsk->buf)->mode_list_ptr & 0x0000ffff);
1069 +
1070 + if (addr >= 0xa0000) {
1071 + p_vbe(tsk->buf)->mode_list_ptr = (u32) __va(addr);
1072 + } else if (addr > BUF_ADDR && addr < BUF_ADDR +
1073 + sizeof(struct vesafb_vbe_ib)) {
1074 + addr -= BUF_ADDR;
1075 + p_vbe(tsk->buf)->mode_list_ptr = (u32) (tsk->buf + addr);
1076 + } else {
1077 + res = 0;
1078 + printk(KERN_WARNING "vesafb: warning, copying modelist "
1079 + "from somewhere in RAM!\n");
1080 + while (*(u16*)(addr+res) != 0xffff &&
1081 + res < (sizeof(p_vbe(tsk->buf)->reserved) - 2)) {
1082 + *(u16*) ((u32)&(p_vbe(tsk->buf)->reserved) + res) =
1083 + *(u16*)(addr+res);
1084 + res += 2;
1085 + }
1086 + *(u16*) ((u32)&(p_vbe(tsk->buf)->reserved) + res) = 0xffff;
1087 + }
1088 +}
1089 +
1090 +int vesafb_handle_tasks(void)
1091 +{
1092 + struct vesafb_task *tsk;
1093 + struct list_head *curr, *next;
1094 + int ret = 0;
1095 +
1096 + down(&vesafb_task_list_sem);
1097 + list_for_each_safe(curr, next, &vesafb_task_list) {
1098 + tsk = list_entry(curr, struct vesafb_task, node);
1099 +
1100 + if (tsk->flags & TF_EXIT) {
1101 + ret = 1;
1102 + goto task_done;
1103 + }
1104 + if (tsk->flags & TF_GETVBEIB) {
1105 + vesafb_handle_getvbeib(tsk);
1106 + goto task_done;
1107 + }
1108 + if (tsk->flags & TF_MASK_BUF) {
1109 + tsk->regs.es = (BUF_ADDR >> 4);
1110 + tsk->regs.edi = (BUF_ADDR & 0x000f);
1111 + }
1112 + if (tsk->flags & TF_USE_BUF)
1113 + memcpy((void*)BUF_ADDR, tsk->buf, tsk->buf_len);
1114 +
1115 + vesafb_do_vm86(&tsk->regs);
1116 +
1117 + if (tsk->flags & TF_RETURN_BUF)
1118 + memcpy(tsk->buf, (void*)BUF_ADDR, tsk->buf_len);
1119 +
1120 +task_done: list_del(curr);
1121 + complete(&tsk->done);
1122 + }
1123 +
1124 + /* If we're going to kill this thread, don't allow any elements
1125 + * to be added to the task list. */
1126 + if (!ret)
1127 + up(&vesafb_task_list_sem);
1128 +
1129 + return ret;
1130 +}
1131 +
1132 +/*
1133 + * This 'hybrid' thread serves as a backend for vesafb-tng, handling all vm86
1134 + * calls. It is started as a kernel thread. It then creates its own mm struct,
1135 + * thus separating itself from any userspace processes. At this moment, it
1136 + * stops being a kernel thread (kernel threads have mm = NULL) and becomes
1137 + * a 'hybrid' thread -- one that has full access to kernel space, yet runs
1138 + * with its own address space.
1139 + *
1140 + * This is necessary because in order to make vm86 calls some parts of the
1141 + * first 1MB of RAM have to be setup to mimic the real mode. These are:
1142 + * - interrupt vector table [0x00000-0x003ff]
1143 + * - BIOS data area [0x00400-0x004ff]
1144 + * - Extended BIOS data area [0x9fc00-0x9ffff]
1145 + * - the video RAM [0xa0000-0xbffff]
1146 + * - video BIOS [0xc0000-0xcffff]
1147 + * - motherboard BIOS [0xf0000-0xfffff]
1148 + */
1149 +int vesafb_thread(void *unused)
1150 +{
1151 + int err = 0;
1152 +
1153 + set_fs(KERNEL_DS);
1154 + daemonize("vesafb");
1155 +
1156 + if (set_new_mm()) {
1157 + err = -ENOMEM;
1158 + goto thr_end;
1159 + }
1160 + if (vesafb_init_mem()) {
1161 + err = -ENOMEM;
1162 + goto thr_end;
1163 + }
1164 +
1165 + DPRINTK("started vesafb thread\n");
1166 +
1167 + /* Having an IO bitmap makes things faster as we avoid GPFs
1168 + * when running vm86 code. We can live if it fails, though,
1169 + * so don't bother checking for errors. */
1170 + ioperm(0,1024,1);
1171 + set_user_nice(current, -10);
1172 +
1173 + complete(&vesafb_th_completion);
1174 +
1175 + while (1) {
1176 + if (vesafb_handle_tasks())
1177 + break;
1178 + wait_event_interruptible(vesafb_wait,
1179 + !list_empty(&vesafb_task_list));
1180 + try_to_freeze();
1181 + }
1182 +
1183 +out: DPRINTK("exiting the vesafb thread\n");
1184 + vesafb_pid = -1;
1185 +
1186 + /* Now that all callers know this thread is no longer running
1187 + * (pid < 0), allow them to continue. */
1188 + up(&vesafb_task_list_sem);
1189 + return err;
1190 +thr_end:
1191 + down(&vesafb_task_list_sem);
1192 + complete(&vesafb_th_completion);
1193 + goto out;
1194 +}
1195 +
1196 +int vesafb_queue_task(struct vesafb_task *tsk)
1197 +{
1198 + down(&vesafb_task_list_sem);
1199 + if (vesafb_pid < 0)
1200 + return -1;
1201 + list_add_tail(&tsk->node, &vesafb_task_list);
1202 + up(&vesafb_task_list_sem);
1203 + wake_up(&vesafb_wait);
1204 + return 0;
1205 +}
1206 +
1207 +int vesafb_wait_for_thread(void)
1208 +{
1209 + /* PID 0 means that the thread is still initializing. */
1210 + if (vesafb_pid < 0)
1211 + return -1;
1212 + wait_for_completion(&vesafb_th_completion);
1213 + return 0;
1214 +}
1215 +
1216 +int __init vesafb_init_thread(void)
1217 +{
1218 + vesafb_pid = kernel_thread(vesafb_thread,NULL,0);
1219 + return 0;
1220 +}
1221 +
1222 +#ifdef MODULE
1223 +void __exit vesafb_kill_thread(void)
1224 +{
1225 + struct vesafb_task *tsk;
1226 + if (vesafb_pid <= 0)
1227 + return;
1228 +
1229 + vesafb_create_task(tsk);
1230 + if (!tsk)
1231 + return;
1232 + tsk->flags |= TF_EXIT;
1233 + vesafb_queue_task(tsk);
1234 + vesafb_wait_for_task(tsk);
1235 + kfree(tsk);
1236 + return;
1237 +}
1238 +module_exit(vesafb_kill_thread);
1239 +#endif
1240 +module_init(vesafb_init_thread);
1241 +
1242 +EXPORT_SYMBOL_GPL(vesafb_queue_task);
1243 +EXPORT_SYMBOL_GPL(vesafb_wait_for_thread);
1244 +
1245 +MODULE_LICENSE("GPL");
1246 +MODULE_AUTHOR("Michal Januszewski");
1247 +
1248 Index: linux-git/drivers/video/vesafb-tng.c
1249 ===================================================================
1250 --- /dev/null
1251 +++ linux-git/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 Index: linux-git/include/linux/sched.h
2732 ===================================================================
2733 --- linux-git.orig/include/linux/sched.h
2734 +++ linux-git/include/linux/sched.h
2735 @@ -1143,6 +1143,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 Index: linux-git/include/video/vesa.h
2745 ===================================================================
2746 --- /dev/null
2747 +++ linux-git/include/video/vesa.h
2748 @@ -0,0 +1,146 @@
2749 +#if 0
2750 +#define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , \
2751 + ## args)
2752 +#else
2753 +#define DPRINTK(fmt, args...)
2754 +#endif
2755 +
2756 +#define p_crtc(arg) ((struct vesafb_crtc_ib*)(arg))
2757 +#define p_vbe(arg) ((struct vesafb_vbe_ib*)(arg))
2758 +#define p_mode(arg) ((struct vesafb_mode_ib*)(arg))
2759 +
2760 +struct vesafb_task {
2761 + u8 flags;
2762 + void *buf;
2763 + int buf_len;
2764 + struct vm86_regs regs;
2765 + struct list_head node;
2766 + struct completion done;
2767 +};
2768 +
2769 +/* Vesafb task flags and masks */
2770 +#define TF_CALL 0x00
2771 +#define TF_EXIT 0x01
2772 +#define TF_GETVBEIB 0x02
2773 +#define TF_USE_BUF 0x04
2774 +#define TF_RETURN_BUF 0x08
2775 +#define TF_MASK_BUF (TF_USE_BUF | TF_RETURN_BUF)
2776 +
2777 +/* Macros and functions for manipulating vesafb tasks */
2778 +#define vesafb_create_task(task) \
2779 +do { \
2780 + task = kmalloc(sizeof(struct vesafb_task), GFP_ATOMIC); \
2781 + if (task) \
2782 + memset(task, 0, sizeof(struct vesafb_task)); \
2783 + init_completion(&task->done); \
2784 +} while (0)
2785 +
2786 +#define vesafb_wait_for_task(task) wait_for_completion(&task->done);
2787 +#define vesafb_reset_task(task) init_completion(&task->done);
2788 +int vesafb_queue_task(struct vesafb_task *task);
2789 +
2790 +/* Functions for controlling the vesafb thread */
2791 +int vesafb_wait_for_thread(void);
2792 +
2793 +#define VBE_CAP_CAN_SWITCH_DAC 0x01
2794 +#define VBE_CAP_VGACOMPAT 0x02
2795 +
2796 +/* This struct is 512 bytes long */
2797 +struct vesafb_vbe_ib {
2798 + char vbe_signature[4];
2799 + u16 vbe_version;
2800 + u32 oem_string_ptr;
2801 + u32 capabilities;
2802 + u32 mode_list_ptr;
2803 + u16 total_memory;
2804 + u16 oem_software_rev;
2805 + u32 oem_vendor_name_ptr;
2806 + u32 oem_product_name_ptr;
2807 + u32 oem_product_rev_ptr;
2808 + u8 reserved[222];
2809 + char oem_data[256];
2810 +} __attribute__ ((packed));
2811 +
2812 +struct vesafb_crtc_ib {
2813 + u16 horiz_total;
2814 + u16 horiz_start;
2815 + u16 horiz_end;
2816 + u16 vert_total;
2817 + u16 vert_start;
2818 + u16 vert_end;
2819 + u8 flags;
2820 + u32 pixel_clock;
2821 + u16 refresh_rate;
2822 + u8 reserved[40];
2823 +} __attribute__ ((packed));
2824 +
2825 +#define VBE_MODE_VGACOMPAT 0x20
2826 +
2827 +struct vesafb_mode_ib {
2828 + /* for all VBE revisions */
2829 + u16 mode_attr;
2830 + u8 winA_attr;
2831 + u8 winB_attr;
2832 + u16 win_granularity;
2833 + u16 win_size;
2834 + u16 winA_seg;
2835 + u16 winB_seg;
2836 + u32 win_func_ptr;
2837 + u16 bytes_per_scan_line;
2838 +
2839 + /* for VBE 1.2+ */
2840 + u16 x_res;
2841 + u16 y_res;
2842 + u8 x_char_size;
2843 + u8 y_char_size;
2844 + u8 planes;
2845 + u8 bits_per_pixel;
2846 + u8 banks;
2847 + u8 memory_model;
2848 + u8 bank_size;
2849 + u8 image_pages;
2850 + u8 reserved1;
2851 +
2852 + /* Direct color fields for direct/6 and YUV/7 memory models. */
2853 + /* Offsets are bit positions of lsb in the mask. */
2854 + u8 red_len;
2855 + u8 red_off;
2856 + u8 green_len;
2857 + u8 green_off;
2858 + u8 blue_len;
2859 + u8 blue_off;
2860 + u8 rsvd_len;
2861 + u8 rsvd_off;
2862 + u8 direct_color_info; /* direct color mode attributes */
2863 +
2864 + /* for VBE 2.0+ */
2865 + u32 phys_base_ptr;
2866 + u8 reserved2[6];
2867 +
2868 + /* for VBE 3.0+ */
2869 + u16 lin_bytes_per_scan_line;
2870 + u8 bnk_image_pages;
2871 + u8 lin_image_pages;
2872 + u8 lin_red_len;
2873 + u8 lin_red_off;
2874 + u8 lin_green_len;
2875 + u8 lin_green_off;
2876 + u8 lin_blue_len;
2877 + u8 lin_blue_off;
2878 + u8 lin_rsvd_len;
2879 + u8 lin_rsvd_off;
2880 + u32 max_pixel_clock;
2881 + u16 mode_id;
2882 + u8 depth;
2883 +} __attribute__ ((packed));
2884 +
2885 +struct vesafb_pal_entry {
2886 + u_char blue, green, red, pad;
2887 +} __attribute__ ((packed));
2888 +
2889 +struct vesafb_par {
2890 + u32 mem_total;
2891 + int mode_idx;
2892 + struct vesafb_crtc_ib crtc;
2893 +};
2894 +
2895 Index: linux-git/kernel/fork.c
2896 ===================================================================
2897 --- linux-git.orig/kernel/fork.c
2898 +++ linux-git/kernel/fork.c
2899 @@ -97,6 +97,7 @@ kmem_cache_t *fs_cachep;
2900
2901 /* SLAB cache for vm_area_struct structures */
2902 kmem_cache_t *vm_area_cachep;
2903 +EXPORT_SYMBOL_GPL(vm_area_cachep);
2904
2905 /* SLAB cache for mm_struct structures (tsk->mm) */
2906 static kmem_cache_t *mm_cachep;
2907 @@ -383,6 +384,40 @@ void mmput(struct mm_struct *mm)
2908 EXPORT_SYMBOL_GPL(mmput);
2909
2910 /**
2911 + * set_new_mm - allocate, init and activate a new mm for a kernel thread
2912 + */
2913 +int set_new_mm(void)
2914 +{
2915 + struct mm_struct *mm;
2916 + struct task_struct *tsk = current;
2917 + struct mm_struct *active_mm;
2918 +
2919 + mm = mm_alloc();
2920 + if (!mm)
2921 + goto fail_nomem;
2922 + if (init_new_context(current,mm))
2923 + goto fail_nocontext;
2924 +
2925 + task_lock(tsk);
2926 + tsk->flags |= PF_BORROWED_MM;
2927 + active_mm = tsk->active_mm;
2928 + current->mm = mm;
2929 + current->active_mm = mm;
2930 + activate_mm(active_mm, mm);
2931 + task_unlock(current);
2932 +
2933 + /* Drop the previous active_mm */
2934 + mmdrop(active_mm);
2935 + return 0;
2936 +
2937 +fail_nocontext:
2938 + mmdrop(mm);
2939 +fail_nomem:
2940 + return -EINVAL;
2941 +}
2942 +EXPORT_SYMBOL_GPL(set_new_mm);
2943 +
2944 +/**
2945 * get_task_mm - acquire a reference to the task's mm
2946 *
2947 * Returns %NULL if the task has no mm. Checks PF_BORROWED_MM (meaning
2948 Index: linux-git/mm/memory.c
2949 ===================================================================
2950 --- linux-git.orig/mm/memory.c
2951 +++ linux-git/mm/memory.c
2952 @@ -1097,6 +1097,7 @@ static int zeromap_pte_range(struct mm_s
2953 pte_unmap_unlock(pte - 1, ptl);
2954 return 0;
2955 }
2956 +EXPORT_SYMBOL_GPL(zeromap_page_range);
2957
2958 static inline int zeromap_pmd_range(struct mm_struct *mm, pud_t *pud,
2959 unsigned long addr, unsigned long end, pgprot_t prot)
2960 Index: linux-git/mm/mmap.c
2961 ===================================================================
2962 --- linux-git.orig/mm/mmap.c
2963 +++ linux-git/mm/mmap.c
2964 @@ -1991,6 +1991,7 @@ int insert_vm_struct(struct mm_struct *
2965 vma_link(mm, vma, prev, rb_link, rb_parent);
2966 return 0;
2967 }
2968 +EXPORT_SYMBOL_GPL(insert_vm_struct);
2969
2970 /*
2971 * Copy the vma structure to a new location in the same mm,

  ViewVC Help
Powered by ViewVC 1.1.20