Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:master commit in: /
Date: Tue, 23 Jun 2015 12:48:23
Message-Id: 1426720603.aca5f6281d96053a892f47fb707516f7df7d56a9.mpagano@gentoo
1 commit: aca5f6281d96053a892f47fb707516f7df7d56a9
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Wed Mar 18 23:16:43 2015 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Wed Mar 18 23:16:43 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=aca5f628
7
8 Patch to enable link security restrictions by default. Patch to disable Windows 8 compatibility for some Lenovo ThinkPads. Patch to ensure that /dev/root doesn't appear in /proc/mounts when bootint without an initramfs. Path to not not lock when UMH is waiting on current thread spawned by linuxrc. (bug #481344) fbcondecor bootsplash patch. Add Gentoo Linux support config settings and defaults. Kernel patch that enables gcc < v4.9 optimizations for additional CPUs. Kernel patch enables gcc >= v4.9 optimizations for additional CPUs.
9
10 0000_README | 28 +
11 ...ble-link-security-restrictions-by-default.patch | 22 +
12 2700_ThinkPad-30-brightness-control-fix.patch | 67 +
13 2900_dev-root-proc-mount-fix.patch | 30 +
14 2905_2disk-resume-image-fix.patch | 24 +
15 4200_fbcondecor-3.19.patch | 2119 ++++++++++++++++++++
16 ...able-additional-cpu-optimizations-for-gcc.patch | 327 +++
17 ...-additional-cpu-optimizations-for-gcc-4.9.patch | 387 ++++
18 8 files changed, 3004 insertions(+)
19
20 diff --git a/0000_README b/0000_README
21 index 36c2b96..ca06e06 100644
22 --- a/0000_README
23 +++ b/0000_README
24 @@ -47,6 +47,34 @@ Patch: 1500_XATTR_USER_PREFIX.patch
25 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
26 Desc: Support for namespace user.pax.* on tmpfs.
27
28 +Patch: 1510_fs-enable-link-security-restrictions-by-default.patch
29 +From: http://sources.debian.net/src/linux/3.16.7-ckt4-3/debian/patches/debian/fs-enable-link-security-restrictions-by-default.patch/
30 +Desc: Enable link security restrictions by default
31 +
32 +Patch: 2700_ThinkPad-30-brightness-control-fix.patch
33 +From: Seth Forshee <seth.forshee@×××××××××.com>
34 +Desc: ACPI: Disable Windows 8 compatibility for some Lenovo ThinkPads.
35 +
36 +Patch: 2900_dev-root-proc-mount-fix.patch
37 +From: https://bugs.gentoo.org/show_bug.cgi?id=438380
38 +Desc: Ensure that /dev/root doesn't appear in /proc/mounts when bootint without an initramfs.
39 +
40 +Patch: 2905_s2disk-resume-image-fix.patch
41 +From: Al Viro <viro <at> ZenIV.linux.org.uk>
42 +Desc: Do not lock when UMH is waiting on current thread spawned by linuxrc. (bug #481344)
43 +
44 +Patch: 4200_fbcondecor-3.19.patch
45 +From: http://www.mepiscommunity.org/fbcondecor
46 +Desc: Bootsplash ported by Marco. (Bug #539616)
47 +
48 Patch: 4567_distro-Gentoo-Kconfig.patch
49 From: Tom Wijsman <TomWij@g.o>
50 Desc: Add Gentoo Linux support config settings and defaults.
51 +
52 +Patch: 5000_enable-additional-cpu-optimizations-for-gcc.patch
53 +From: https://github.com/graysky2/kernel_gcc_patch/
54 +Desc: Kernel patch enables gcc < v4.9 optimizations for additional CPUs.
55 +
56 +Patch: 5010_enable-additional-cpu-optimizations-for-gcc-4.9.patch
57 +From: https://github.com/graysky2/kernel_gcc_patch/
58 +Desc: Kernel patch enables gcc >= v4.9 optimizations for additional CPUs.
59
60 diff --git a/1510_fs-enable-link-security-restrictions-by-default.patch b/1510_fs-enable-link-security-restrictions-by-default.patch
61 new file mode 100644
62 index 0000000..639fb3c
63 --- /dev/null
64 +++ b/1510_fs-enable-link-security-restrictions-by-default.patch
65 @@ -0,0 +1,22 @@
66 +From: Ben Hutchings <ben@××××××××××××.uk>
67 +Subject: fs: Enable link security restrictions by default
68 +Date: Fri, 02 Nov 2012 05:32:06 +0000
69 +Bug-Debian: https://bugs.debian.org/609455
70 +Forwarded: not-needed
71 +
72 +This reverts commit 561ec64ae67ef25cac8d72bb9c4bfc955edfd415
73 +('VFS: don't do protected {sym,hard}links by default').
74 +
75 +--- a/fs/namei.c
76 ++++ b/fs/namei.c
77 +@@ -651,8 +651,8 @@ static inline void put_link(struct namei
78 + path_put(link);
79 + }
80 +
81 +-int sysctl_protected_symlinks __read_mostly = 0;
82 +-int sysctl_protected_hardlinks __read_mostly = 0;
83 ++int sysctl_protected_symlinks __read_mostly = 1;
84 ++int sysctl_protected_hardlinks __read_mostly = 1;
85 +
86 + /**
87 + * may_follow_link - Check symlink following for unsafe situations
88
89 diff --git a/2700_ThinkPad-30-brightness-control-fix.patch b/2700_ThinkPad-30-brightness-control-fix.patch
90 new file mode 100644
91 index 0000000..b548c6d
92 --- /dev/null
93 +++ b/2700_ThinkPad-30-brightness-control-fix.patch
94 @@ -0,0 +1,67 @@
95 +diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
96 +index cb96296..6c242ed 100644
97 +--- a/drivers/acpi/blacklist.c
98 ++++ b/drivers/acpi/blacklist.c
99 +@@ -269,6 +276,61 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
100 + },
101 +
102 + /*
103 ++ * The following Lenovo models have a broken workaround in the
104 ++ * acpi_video backlight implementation to meet the Windows 8
105 ++ * requirement of 101 backlight levels. Reverting to pre-Win8
106 ++ * behavior fixes the problem.
107 ++ */
108 ++ {
109 ++ .callback = dmi_disable_osi_win8,
110 ++ .ident = "Lenovo ThinkPad L430",
111 ++ .matches = {
112 ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
113 ++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L430"),
114 ++ },
115 ++ },
116 ++ {
117 ++ .callback = dmi_disable_osi_win8,
118 ++ .ident = "Lenovo ThinkPad T430s",
119 ++ .matches = {
120 ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
121 ++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T430s"),
122 ++ },
123 ++ },
124 ++ {
125 ++ .callback = dmi_disable_osi_win8,
126 ++ .ident = "Lenovo ThinkPad T530",
127 ++ .matches = {
128 ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
129 ++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T530"),
130 ++ },
131 ++ },
132 ++ {
133 ++ .callback = dmi_disable_osi_win8,
134 ++ .ident = "Lenovo ThinkPad W530",
135 ++ .matches = {
136 ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
137 ++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad W530"),
138 ++ },
139 ++ },
140 ++ {
141 ++ .callback = dmi_disable_osi_win8,
142 ++ .ident = "Lenovo ThinkPad X1 Carbon",
143 ++ .matches = {
144 ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
145 ++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X1 Carbon"),
146 ++ },
147 ++ },
148 ++ {
149 ++ .callback = dmi_disable_osi_win8,
150 ++ .ident = "Lenovo ThinkPad X230",
151 ++ .matches = {
152 ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
153 ++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X230"),
154 ++ },
155 ++ },
156 ++
157 ++ /*
158 + * BIOS invocation of _OSI(Linux) is almost always a BIOS bug.
159 + * Linux ignores it, except for the machines enumerated below.
160 + */
161 +
162
163 diff --git a/2900_dev-root-proc-mount-fix.patch b/2900_dev-root-proc-mount-fix.patch
164 new file mode 100644
165 index 0000000..6ea86e2
166 --- /dev/null
167 +++ b/2900_dev-root-proc-mount-fix.patch
168 @@ -0,0 +1,30 @@
169 +--- a/init/do_mounts.c 2014-08-26 08:03:30.000013100 -0400
170 ++++ b/init/do_mounts.c 2014-08-26 08:11:19.720014712 -0400
171 +@@ -484,7 +484,10 @@ void __init change_floppy(char *fmt, ...
172 + va_start(args, fmt);
173 + vsprintf(buf, fmt, args);
174 + va_end(args);
175 +- fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
176 ++ if (saved_root_name[0])
177 ++ fd = sys_open(saved_root_name, O_RDWR | O_NDELAY, 0);
178 ++ else
179 ++ fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
180 + if (fd >= 0) {
181 + sys_ioctl(fd, FDEJECT, 0);
182 + sys_close(fd);
183 +@@ -527,8 +530,13 @@ void __init mount_root(void)
184 + }
185 + #endif
186 + #ifdef CONFIG_BLOCK
187 +- create_dev("/dev/root", ROOT_DEV);
188 +- mount_block_root("/dev/root", root_mountflags);
189 ++ if (saved_root_name[0]) {
190 ++ create_dev(saved_root_name, ROOT_DEV);
191 ++ mount_block_root(saved_root_name, root_mountflags);
192 ++ } else {
193 ++ create_dev("/dev/root", ROOT_DEV);
194 ++ mount_block_root("/dev/root", root_mountflags);
195 ++ }
196 + #endif
197 + }
198 +
199
200 diff --git a/2905_2disk-resume-image-fix.patch b/2905_2disk-resume-image-fix.patch
201 new file mode 100644
202 index 0000000..7e95d29
203 --- /dev/null
204 +++ b/2905_2disk-resume-image-fix.patch
205 @@ -0,0 +1,24 @@
206 +diff --git a/kernel/kmod.c b/kernel/kmod.c
207 +index fb32636..d968882 100644
208 +--- a/kernel/kmod.c
209 ++++ b/kernel/kmod.c
210 +@@ -575,7 +575,8 @@
211 + call_usermodehelper_freeinfo(sub_info);
212 + return -EINVAL;
213 + }
214 +- helper_lock();
215 ++ if (!(current->flags & PF_FREEZER_SKIP))
216 ++ helper_lock();
217 + if (!khelper_wq || usermodehelper_disabled) {
218 + retval = -EBUSY;
219 + goto out;
220 +@@ -611,7 +612,8 @@ wait_done:
221 + out:
222 + call_usermodehelper_freeinfo(sub_info);
223 + unlock:
224 +- helper_unlock();
225 ++ if (!(current->flags & PF_FREEZER_SKIP))
226 ++ helper_unlock();
227 + return retval;
228 + }
229 + EXPORT_SYMBOL(call_usermodehelper_exec);
230
231 diff --git a/4200_fbcondecor-3.19.patch b/4200_fbcondecor-3.19.patch
232 new file mode 100644
233 index 0000000..29c379f
234 --- /dev/null
235 +++ b/4200_fbcondecor-3.19.patch
236 @@ -0,0 +1,2119 @@
237 +diff --git a/Documentation/fb/00-INDEX b/Documentation/fb/00-INDEX
238 +index fe85e7c..2230930 100644
239 +--- a/Documentation/fb/00-INDEX
240 ++++ b/Documentation/fb/00-INDEX
241 +@@ -23,6 +23,8 @@ ep93xx-fb.txt
242 + - info on the driver for EP93xx LCD controller.
243 + fbcon.txt
244 + - intro to and usage guide for the framebuffer console (fbcon).
245 ++fbcondecor.txt
246 ++ - info on the Framebuffer Console Decoration
247 + framebuffer.txt
248 + - introduction to frame buffer devices.
249 + gxfb.txt
250 +diff --git a/Documentation/fb/fbcondecor.txt b/Documentation/fb/fbcondecor.txt
251 +new file mode 100644
252 +index 0000000..3388c61
253 +--- /dev/null
254 ++++ b/Documentation/fb/fbcondecor.txt
255 +@@ -0,0 +1,207 @@
256 ++What is it?
257 ++-----------
258 ++
259 ++The framebuffer decorations are a kernel feature which allows displaying a
260 ++background picture on selected consoles.
261 ++
262 ++What do I need to get it to work?
263 ++---------------------------------
264 ++
265 ++To get fbcondecor up-and-running you will have to:
266 ++ 1) get a copy of splashutils [1] or a similar program
267 ++ 2) get some fbcondecor themes
268 ++ 3) build the kernel helper program
269 ++ 4) build your kernel with the FB_CON_DECOR option enabled.
270 ++
271 ++To get fbcondecor operational right after fbcon initialization is finished, you
272 ++will have to include a theme and the kernel helper into your initramfs image.
273 ++Please refer to splashutils documentation for instructions on how to do that.
274 ++
275 ++[1] The splashutils package can be downloaded from:
276 ++ http://github.com/alanhaggai/fbsplash
277 ++
278 ++The userspace helper
279 ++--------------------
280 ++
281 ++The userspace fbcondecor helper (by default: /sbin/fbcondecor_helper) is called by the
282 ++kernel whenever an important event occurs and the kernel needs some kind of
283 ++job to be carried out. Important events include console switches and video
284 ++mode switches (the kernel requests background images and configuration
285 ++parameters for the current console). The fbcondecor helper must be accessible at
286 ++all times. If it's not, fbcondecor will be switched off automatically.
287 ++
288 ++It's possible to set path to the fbcondecor helper by writing it to
289 ++/proc/sys/kernel/fbcondecor.
290 ++
291 ++*****************************************************************************
292 ++
293 ++The information below is mostly technical stuff. There's probably no need to
294 ++read it unless you plan to develop a userspace helper.
295 ++
296 ++The fbcondecor protocol
297 ++-----------------------
298 ++
299 ++The fbcondecor protocol defines a communication interface between the kernel and
300 ++the userspace fbcondecor helper.
301 ++
302 ++The kernel side is responsible for:
303 ++
304 ++ * rendering console text, using an image as a background (instead of a
305 ++ standard solid color fbcon uses),
306 ++ * accepting commands from the user via ioctls on the fbcondecor device,
307 ++ * calling the userspace helper to set things up as soon as the fb subsystem
308 ++ is initialized.
309 ++
310 ++The userspace helper is responsible for everything else, including parsing
311 ++configuration files, decompressing the image files whenever the kernel needs
312 ++it, and communicating with the kernel if necessary.
313 ++
314 ++The fbcondecor protocol specifies how communication is done in both ways:
315 ++kernel->userspace and userspace->helper.
316 ++
317 ++Kernel -> Userspace
318 ++-------------------
319 ++
320 ++The kernel communicates with the userspace helper by calling it and specifying
321 ++the task to be done in a series of arguments.
322 ++
323 ++The arguments follow the pattern:
324 ++<fbcondecor protocol version> <command> <parameters>
325 ++
326 ++All commands defined in fbcondecor protocol v2 have the following parameters:
327 ++ virtual console
328 ++ framebuffer number
329 ++ theme
330 ++
331 ++Fbcondecor protocol v1 specified an additional 'fbcondecor mode' after the
332 ++framebuffer number. Fbcondecor protocol v1 is deprecated and should not be used.
333 ++
334 ++Fbcondecor protocol v2 specifies the following commands:
335 ++
336 ++getpic
337 ++------
338 ++ The kernel issues this command to request image data. It's up to the
339 ++ userspace helper to find a background image appropriate for the specified
340 ++ theme and the current resolution. The userspace helper should respond by
341 ++ issuing the FBIOCONDECOR_SETPIC ioctl.
342 ++
343 ++init
344 ++----
345 ++ The kernel issues this command after the fbcondecor device is created and
346 ++ the fbcondecor interface is initialized. Upon receiving 'init', the userspace
347 ++ helper should parse the kernel command line (/proc/cmdline) or otherwise
348 ++ decide whether fbcondecor is to be activated.
349 ++
350 ++ To activate fbcondecor on the first console the helper should issue the
351 ++ FBIOCONDECOR_SETCFG, FBIOCONDECOR_SETPIC and FBIOCONDECOR_SETSTATE commands,
352 ++ in the above-mentioned order.
353 ++
354 ++ When the userspace helper is called in an early phase of the boot process
355 ++ (right after the initialization of fbcon), no filesystems will be mounted.
356 ++ The helper program should mount sysfs and then create the appropriate
357 ++ framebuffer, fbcondecor and tty0 devices (if they don't already exist) to get
358 ++ current display settings and to be able to communicate with the kernel side.
359 ++ It should probably also mount the procfs to be able to parse the kernel
360 ++ command line parameters.
361 ++
362 ++ Note that the console sem is not held when the kernel calls fbcondecor_helper
363 ++ with the 'init' command. The fbcondecor helper should perform all ioctls with
364 ++ origin set to FBCON_DECOR_IO_ORIG_USER.
365 ++
366 ++modechange
367 ++----------
368 ++ The kernel issues this command on a mode change. The helper's response should
369 ++ be similar to the response to the 'init' command. Note that this time the
370 ++ console sem is held and all ioctls must be performed with origin set to
371 ++ FBCON_DECOR_IO_ORIG_KERNEL.
372 ++
373 ++
374 ++Userspace -> Kernel
375 ++-------------------
376 ++
377 ++Userspace programs can communicate with fbcondecor via ioctls on the
378 ++fbcondecor device. These ioctls are to be used by both the userspace helper
379 ++(called only by the kernel) and userspace configuration tools (run by the users).
380 ++
381 ++The fbcondecor helper should set the origin field to FBCON_DECOR_IO_ORIG_KERNEL
382 ++when doing the appropriate ioctls. All userspace configuration tools should
383 ++use FBCON_DECOR_IO_ORIG_USER. Failure to set the appropriate value in the origin
384 ++field when performing ioctls from the kernel helper will most likely result
385 ++in a console deadlock.
386 ++
387 ++FBCON_DECOR_IO_ORIG_KERNEL instructs fbcondecor not to try to acquire the console
388 ++semaphore. Not surprisingly, FBCON_DECOR_IO_ORIG_USER instructs it to acquire
389 ++the console sem.
390 ++
391 ++The framebuffer console decoration provides the following ioctls (all defined in
392 ++linux/fb.h):
393 ++
394 ++FBIOCONDECOR_SETPIC
395 ++description: loads a background picture for a virtual console
396 ++argument: struct fbcon_decor_iowrapper*; data: struct fb_image*
397 ++notes:
398 ++If called for consoles other than the current foreground one, the picture data
399 ++will be ignored.
400 ++
401 ++If the current virtual console is running in a 8-bpp mode, the cmap substruct
402 ++of fb_image has to be filled appropriately: start should be set to 16 (first
403 ++16 colors are reserved for fbcon), len to a value <= 240 and red, green and
404 ++blue should point to valid cmap data. The transp field is ingored. The fields
405 ++dx, dy, bg_color, fg_color in fb_image are ignored as well.
406 ++
407 ++FBIOCONDECOR_SETCFG
408 ++description: sets the fbcondecor config for a virtual console
409 ++argument: struct fbcon_decor_iowrapper*; data: struct vc_decor*
410 ++notes: The structure has to be filled with valid data.
411 ++
412 ++FBIOCONDECOR_GETCFG
413 ++description: gets the fbcondecor config for a virtual console
414 ++argument: struct fbcon_decor_iowrapper*; data: struct vc_decor*
415 ++
416 ++FBIOCONDECOR_SETSTATE
417 ++description: sets the fbcondecor state for a virtual console
418 ++argument: struct fbcon_decor_iowrapper*; data: unsigned int*
419 ++ values: 0 = disabled, 1 = enabled.
420 ++
421 ++FBIOCONDECOR_GETSTATE
422 ++description: gets the fbcondecor state for a virtual console
423 ++argument: struct fbcon_decor_iowrapper*; data: unsigned int*
424 ++ values: as in FBIOCONDECOR_SETSTATE
425 ++
426 ++Info on used structures:
427 ++
428 ++Definition of struct vc_decor can be found in linux/console_decor.h. It's
429 ++heavily commented. Note that the 'theme' field should point to a string
430 ++no longer than FBCON_DECOR_THEME_LEN. When FBIOCONDECOR_GETCFG call is
431 ++performed, the theme field should point to a char buffer of length
432 ++FBCON_DECOR_THEME_LEN.
433 ++
434 ++Definition of struct fbcon_decor_iowrapper can be found in linux/fb.h.
435 ++The fields in this struct have the following meaning:
436 ++
437 ++vc:
438 ++Virtual console number.
439 ++
440 ++origin:
441 ++Specifies if the ioctl is performed as a response to a kernel request. The
442 ++fbcondecor helper should set this field to FBCON_DECOR_IO_ORIG_KERNEL, userspace
443 ++programs should set it to FBCON_DECOR_IO_ORIG_USER. This field is necessary to
444 ++avoid console semaphore deadlocks.
445 ++
446 ++data:
447 ++Pointer to a data structure appropriate for the performed ioctl. Type of
448 ++the data struct is specified in the ioctls description.
449 ++
450 ++*****************************************************************************
451 ++
452 ++Credit
453 ++------
454 ++
455 ++Original 'bootsplash' project & implementation by:
456 ++ Volker Poplawski <volker@×××××××××.de>, Stefan Reinauer <stepan@××××.de>,
457 ++ Steffen Winterfeldt <snwint@××××.de>, Michael Schroeder <mls@××××.de>,
458 ++ Ken Wimer <wimer@××××.de>.
459 ++
460 ++Fbcondecor, fbcondecor protocol design, current implementation & docs by:
461 ++ Michal Januszewski <michalj+fbcondecor@×××××.com>
462 ++
463 +diff --git a/drivers/Makefile b/drivers/Makefile
464 +index 7183b6a..d576148 100644
465 +--- a/drivers/Makefile
466 ++++ b/drivers/Makefile
467 +@@ -17,6 +17,10 @@ obj-y += pwm/
468 + obj-$(CONFIG_PCI) += pci/
469 + obj-$(CONFIG_PARISC) += parisc/
470 + obj-$(CONFIG_RAPIDIO) += rapidio/
471 ++# tty/ comes before char/ so that the VT console is the boot-time
472 ++# default.
473 ++obj-y += tty/
474 ++obj-y += char/
475 + obj-y += video/
476 + obj-y += idle/
477 +
478 +@@ -42,11 +46,6 @@ obj-$(CONFIG_REGULATOR) += regulator/
479 + # reset controllers early, since gpu drivers might rely on them to initialize
480 + obj-$(CONFIG_RESET_CONTROLLER) += reset/
481 +
482 +-# tty/ comes before char/ so that the VT console is the boot-time
483 +-# default.
484 +-obj-y += tty/
485 +-obj-y += char/
486 +-
487 + # iommu/ comes before gpu as gpu are using iommu controllers
488 + obj-$(CONFIG_IOMMU_SUPPORT) += iommu/
489 +
490 +diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
491 +index fe1cd01..6d2e87a 100644
492 +--- a/drivers/video/console/Kconfig
493 ++++ b/drivers/video/console/Kconfig
494 +@@ -126,6 +126,19 @@ config FRAMEBUFFER_CONSOLE_ROTATION
495 + such that other users of the framebuffer will remain normally
496 + oriented.
497 +
498 ++config FB_CON_DECOR
499 ++ bool "Support for the Framebuffer Console Decorations"
500 ++ depends on FRAMEBUFFER_CONSOLE=y && !FB_TILEBLITTING
501 ++ default n
502 ++ ---help---
503 ++ This option enables support for framebuffer console decorations which
504 ++ makes it possible to display images in the background of the system
505 ++ consoles. Note that userspace utilities are necessary in order to take
506 ++ advantage of these features. Refer to Documentation/fb/fbcondecor.txt
507 ++ for more information.
508 ++
509 ++ If unsure, say N.
510 ++
511 + config STI_CONSOLE
512 + bool "STI text console"
513 + depends on PARISC
514 +diff --git a/drivers/video/console/Makefile b/drivers/video/console/Makefile
515 +index 43bfa48..cc104b6f 100644
516 +--- a/drivers/video/console/Makefile
517 ++++ b/drivers/video/console/Makefile
518 +@@ -16,4 +16,5 @@ obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += fbcon_rotate.o fbcon_cw.o fbcon_ud.o \
519 + fbcon_ccw.o
520 + endif
521 +
522 ++obj-$(CONFIG_FB_CON_DECOR) += fbcondecor.o cfbcondecor.o
523 + obj-$(CONFIG_FB_STI) += sticore.o
524 +diff --git a/drivers/video/console/bitblit.c b/drivers/video/console/bitblit.c
525 +index 61b182b..984384b 100644
526 +--- a/drivers/video/console/bitblit.c
527 ++++ b/drivers/video/console/bitblit.c
528 +@@ -18,6 +18,7 @@
529 + #include <linux/console.h>
530 + #include <asm/types.h>
531 + #include "fbcon.h"
532 ++#include "fbcondecor.h"
533 +
534 + /*
535 + * Accelerated handlers.
536 +@@ -55,6 +56,13 @@ static void bit_bmove(struct vc_data *vc, struct fb_info *info, int sy,
537 + area.height = height * vc->vc_font.height;
538 + area.width = width * vc->vc_font.width;
539 +
540 ++ if (fbcon_decor_active(info, vc)) {
541 ++ area.sx += vc->vc_decor.tx;
542 ++ area.sy += vc->vc_decor.ty;
543 ++ area.dx += vc->vc_decor.tx;
544 ++ area.dy += vc->vc_decor.ty;
545 ++ }
546 ++
547 + info->fbops->fb_copyarea(info, &area);
548 + }
549 +
550 +@@ -380,11 +388,15 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode,
551 + cursor.image.depth = 1;
552 + cursor.rop = ROP_XOR;
553 +
554 +- if (info->fbops->fb_cursor)
555 +- err = info->fbops->fb_cursor(info, &cursor);
556 ++ if (fbcon_decor_active(info, vc)) {
557 ++ fbcon_decor_cursor(info, &cursor);
558 ++ } else {
559 ++ if (info->fbops->fb_cursor)
560 ++ err = info->fbops->fb_cursor(info, &cursor);
561 +
562 +- if (err)
563 +- soft_cursor(info, &cursor);
564 ++ if (err)
565 ++ soft_cursor(info, &cursor);
566 ++ }
567 +
568 + ops->cursor_reset = 0;
569 + }
570 +diff --git a/drivers/video/console/cfbcondecor.c b/drivers/video/console/cfbcondecor.c
571 +new file mode 100644
572 +index 0000000..a2b4497
573 +--- /dev/null
574 ++++ b/drivers/video/console/cfbcondecor.c
575 +@@ -0,0 +1,471 @@
576 ++/*
577 ++ * linux/drivers/video/cfbcon_decor.c -- Framebuffer decor render functions
578 ++ *
579 ++ * Copyright (C) 2004 Michal Januszewski <michalj+fbcondecor@×××××.com>
580 ++ *
581 ++ * Code based upon "Bootdecor" (C) 2001-2003
582 ++ * Volker Poplawski <volker@×××××××××.de>,
583 ++ * Stefan Reinauer <stepan@××××.de>,
584 ++ * Steffen Winterfeldt <snwint@××××.de>,
585 ++ * Michael Schroeder <mls@××××.de>,
586 ++ * Ken Wimer <wimer@××××.de>.
587 ++ *
588 ++ * This file is subject to the terms and conditions of the GNU General Public
589 ++ * License. See the file COPYING in the main directory of this archive for
590 ++ * more details.
591 ++ */
592 ++#include <linux/module.h>
593 ++#include <linux/types.h>
594 ++#include <linux/fb.h>
595 ++#include <linux/selection.h>
596 ++#include <linux/slab.h>
597 ++#include <linux/vt_kern.h>
598 ++#include <asm/irq.h>
599 ++
600 ++#include "fbcon.h"
601 ++#include "fbcondecor.h"
602 ++
603 ++#define parse_pixel(shift,bpp,type) \
604 ++ do { \
605 ++ if (d & (0x80 >> (shift))) \
606 ++ dd2[(shift)] = fgx; \
607 ++ else \
608 ++ dd2[(shift)] = transparent ? *(type *)decor_src : bgx; \
609 ++ decor_src += (bpp); \
610 ++ } while (0) \
611 ++
612 ++extern int get_color(struct vc_data *vc, struct fb_info *info,
613 ++ u16 c, int is_fg);
614 ++
615 ++void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc)
616 ++{
617 ++ int i, j, k;
618 ++ int minlen = min(min(info->var.red.length, info->var.green.length),
619 ++ info->var.blue.length);
620 ++ u32 col;
621 ++
622 ++ for (j = i = 0; i < 16; i++) {
623 ++ k = color_table[i];
624 ++
625 ++ col = ((vc->vc_palette[j++] >> (8-minlen))
626 ++ << info->var.red.offset);
627 ++ col |= ((vc->vc_palette[j++] >> (8-minlen))
628 ++ << info->var.green.offset);
629 ++ col |= ((vc->vc_palette[j++] >> (8-minlen))
630 ++ << info->var.blue.offset);
631 ++ ((u32 *)info->pseudo_palette)[k] = col;
632 ++ }
633 ++}
634 ++
635 ++void fbcon_decor_renderc(struct fb_info *info, int ypos, int xpos, int height,
636 ++ int width, u8* src, u32 fgx, u32 bgx, u8 transparent)
637 ++{
638 ++ unsigned int x, y;
639 ++ u32 dd;
640 ++ int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
641 ++ unsigned int d = ypos * info->fix.line_length + xpos * bytespp;
642 ++ unsigned int ds = (ypos * info->var.xres + xpos) * bytespp;
643 ++ u16 dd2[4];
644 ++
645 ++ u8* decor_src = (u8 *)(info->bgdecor.data + ds);
646 ++ u8* dst = (u8 *)(info->screen_base + d);
647 ++
648 ++ if ((ypos + height) > info->var.yres || (xpos + width) > info->var.xres)
649 ++ return;
650 ++
651 ++ for (y = 0; y < height; y++) {
652 ++ switch (info->var.bits_per_pixel) {
653 ++
654 ++ case 32:
655 ++ for (x = 0; x < width; x++) {
656 ++
657 ++ if ((x & 7) == 0)
658 ++ d = *src++;
659 ++ if (d & 0x80)
660 ++ dd = fgx;
661 ++ else
662 ++ dd = transparent ?
663 ++ *(u32 *)decor_src : bgx;
664 ++
665 ++ d <<= 1;
666 ++ decor_src += 4;
667 ++ fb_writel(dd, dst);
668 ++ dst += 4;
669 ++ }
670 ++ break;
671 ++ case 24:
672 ++ for (x = 0; x < width; x++) {
673 ++
674 ++ if ((x & 7) == 0)
675 ++ d = *src++;
676 ++ if (d & 0x80)
677 ++ dd = fgx;
678 ++ else
679 ++ dd = transparent ?
680 ++ (*(u32 *)decor_src & 0xffffff) : bgx;
681 ++
682 ++ d <<= 1;
683 ++ decor_src += 3;
684 ++#ifdef __LITTLE_ENDIAN
685 ++ fb_writew(dd & 0xffff, dst);
686 ++ dst += 2;
687 ++ fb_writeb((dd >> 16), dst);
688 ++#else
689 ++ fb_writew(dd >> 8, dst);
690 ++ dst += 2;
691 ++ fb_writeb(dd & 0xff, dst);
692 ++#endif
693 ++ dst++;
694 ++ }
695 ++ break;
696 ++ case 16:
697 ++ for (x = 0; x < width; x += 2) {
698 ++ if ((x & 7) == 0)
699 ++ d = *src++;
700 ++
701 ++ parse_pixel(0, 2, u16);
702 ++ parse_pixel(1, 2, u16);
703 ++#ifdef __LITTLE_ENDIAN
704 ++ dd = dd2[0] | (dd2[1] << 16);
705 ++#else
706 ++ dd = dd2[1] | (dd2[0] << 16);
707 ++#endif
708 ++ d <<= 2;
709 ++ fb_writel(dd, dst);
710 ++ dst += 4;
711 ++ }
712 ++ break;
713 ++
714 ++ case 8:
715 ++ for (x = 0; x < width; x += 4) {
716 ++ if ((x & 7) == 0)
717 ++ d = *src++;
718 ++
719 ++ parse_pixel(0, 1, u8);
720 ++ parse_pixel(1, 1, u8);
721 ++ parse_pixel(2, 1, u8);
722 ++ parse_pixel(3, 1, u8);
723 ++
724 ++#ifdef __LITTLE_ENDIAN
725 ++ dd = dd2[0] | (dd2[1] << 8) | (dd2[2] << 16) | (dd2[3] << 24);
726 ++#else
727 ++ dd = dd2[3] | (dd2[2] << 8) | (dd2[1] << 16) | (dd2[0] << 24);
728 ++#endif
729 ++ d <<= 4;
730 ++ fb_writel(dd, dst);
731 ++ dst += 4;
732 ++ }
733 ++ }
734 ++
735 ++ dst += info->fix.line_length - width * bytespp;
736 ++ decor_src += (info->var.xres - width) * bytespp;
737 ++ }
738 ++}
739 ++
740 ++#define cc2cx(a) \
741 ++ ((info->fix.visual == FB_VISUAL_TRUECOLOR || \
742 ++ info->fix.visual == FB_VISUAL_DIRECTCOLOR) ? \
743 ++ ((u32*)info->pseudo_palette)[a] : a)
744 ++
745 ++void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info,
746 ++ const unsigned short *s, int count, int yy, int xx)
747 ++{
748 ++ unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
749 ++ struct fbcon_ops *ops = info->fbcon_par;
750 ++ int fg_color, bg_color, transparent;
751 ++ u8 *src;
752 ++ u32 bgx, fgx;
753 ++ u16 c = scr_readw(s);
754 ++
755 ++ fg_color = get_color(vc, info, c, 1);
756 ++ bg_color = get_color(vc, info, c, 0);
757 ++
758 ++ /* Don't paint the background image if console is blanked */
759 ++ transparent = ops->blank_state ? 0 :
760 ++ (vc->vc_decor.bg_color == bg_color);
761 ++
762 ++ xx = xx * vc->vc_font.width + vc->vc_decor.tx;
763 ++ yy = yy * vc->vc_font.height + vc->vc_decor.ty;
764 ++
765 ++ fgx = cc2cx(fg_color);
766 ++ bgx = cc2cx(bg_color);
767 ++
768 ++ while (count--) {
769 ++ c = scr_readw(s++);
770 ++ src = vc->vc_font.data + (c & charmask) * vc->vc_font.height *
771 ++ ((vc->vc_font.width + 7) >> 3);
772 ++
773 ++ fbcon_decor_renderc(info, yy, xx, vc->vc_font.height,
774 ++ vc->vc_font.width, src, fgx, bgx, transparent);
775 ++ xx += vc->vc_font.width;
776 ++ }
777 ++}
778 ++
779 ++void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor)
780 ++{
781 ++ int i;
782 ++ unsigned int dsize, s_pitch;
783 ++ struct fbcon_ops *ops = info->fbcon_par;
784 ++ struct vc_data* vc;
785 ++ u8 *src;
786 ++
787 ++ /* we really don't need any cursors while the console is blanked */
788 ++ if (info->state != FBINFO_STATE_RUNNING || ops->blank_state)
789 ++ return;
790 ++
791 ++ vc = vc_cons[ops->currcon].d;
792 ++
793 ++ src = kmalloc(64 + sizeof(struct fb_image), GFP_ATOMIC);
794 ++ if (!src)
795 ++ return;
796 ++
797 ++ s_pitch = (cursor->image.width + 7) >> 3;
798 ++ dsize = s_pitch * cursor->image.height;
799 ++ if (cursor->enable) {
800 ++ switch (cursor->rop) {
801 ++ case ROP_XOR:
802 ++ for (i = 0; i < dsize; i++)
803 ++ src[i] = cursor->image.data[i] ^ cursor->mask[i];
804 ++ break;
805 ++ case ROP_COPY:
806 ++ default:
807 ++ for (i = 0; i < dsize; i++)
808 ++ src[i] = cursor->image.data[i] & cursor->mask[i];
809 ++ break;
810 ++ }
811 ++ } else
812 ++ memcpy(src, cursor->image.data, dsize);
813 ++
814 ++ fbcon_decor_renderc(info,
815 ++ cursor->image.dy + vc->vc_decor.ty,
816 ++ cursor->image.dx + vc->vc_decor.tx,
817 ++ cursor->image.height,
818 ++ cursor->image.width,
819 ++ (u8*)src,
820 ++ cc2cx(cursor->image.fg_color),
821 ++ cc2cx(cursor->image.bg_color),
822 ++ cursor->image.bg_color == vc->vc_decor.bg_color);
823 ++
824 ++ kfree(src);
825 ++}
826 ++
827 ++static void decorset(u8 *dst, int height, int width, int dstbytes,
828 ++ u32 bgx, int bpp)
829 ++{
830 ++ int i;
831 ++
832 ++ if (bpp == 8)
833 ++ bgx |= bgx << 8;
834 ++ if (bpp == 16 || bpp == 8)
835 ++ bgx |= bgx << 16;
836 ++
837 ++ while (height-- > 0) {
838 ++ u8 *p = dst;
839 ++
840 ++ switch (bpp) {
841 ++
842 ++ case 32:
843 ++ for (i=0; i < width; i++) {
844 ++ fb_writel(bgx, p); p += 4;
845 ++ }
846 ++ break;
847 ++ case 24:
848 ++ for (i=0; i < width; i++) {
849 ++#ifdef __LITTLE_ENDIAN
850 ++ fb_writew((bgx & 0xffff),(u16*)p); p += 2;
851 ++ fb_writeb((bgx >> 16),p++);
852 ++#else
853 ++ fb_writew((bgx >> 8),(u16*)p); p += 2;
854 ++ fb_writeb((bgx & 0xff),p++);
855 ++#endif
856 ++ }
857 ++ case 16:
858 ++ for (i=0; i < width/4; i++) {
859 ++ fb_writel(bgx,p); p += 4;
860 ++ fb_writel(bgx,p); p += 4;
861 ++ }
862 ++ if (width & 2) {
863 ++ fb_writel(bgx,p); p += 4;
864 ++ }
865 ++ if (width & 1)
866 ++ fb_writew(bgx,(u16*)p);
867 ++ break;
868 ++ case 8:
869 ++ for (i=0; i < width/4; i++) {
870 ++ fb_writel(bgx,p); p += 4;
871 ++ }
872 ++
873 ++ if (width & 2) {
874 ++ fb_writew(bgx,p); p += 2;
875 ++ }
876 ++ if (width & 1)
877 ++ fb_writeb(bgx,(u8*)p);
878 ++ break;
879 ++
880 ++ }
881 ++ dst += dstbytes;
882 ++ }
883 ++}
884 ++
885 ++void fbcon_decor_copy(u8 *dst, u8 *src, int height, int width, int linebytes,
886 ++ int srclinebytes, int bpp)
887 ++{
888 ++ int i;
889 ++
890 ++ while (height-- > 0) {
891 ++ u32 *p = (u32 *)dst;
892 ++ u32 *q = (u32 *)src;
893 ++
894 ++ switch (bpp) {
895 ++
896 ++ case 32:
897 ++ for (i=0; i < width; i++)
898 ++ fb_writel(*q++, p++);
899 ++ break;
900 ++ case 24:
901 ++ for (i=0; i < (width*3/4); i++)
902 ++ fb_writel(*q++, p++);
903 ++ if ((width*3) % 4) {
904 ++ if (width & 2) {
905 ++ fb_writeb(*(u8*)q, (u8*)p);
906 ++ } else if (width & 1) {
907 ++ fb_writew(*(u16*)q, (u16*)p);
908 ++ fb_writeb(*(u8*)((u16*)q+1),(u8*)((u16*)p+2));
909 ++ }
910 ++ }
911 ++ break;
912 ++ case 16:
913 ++ for (i=0; i < width/4; i++) {
914 ++ fb_writel(*q++, p++);
915 ++ fb_writel(*q++, p++);
916 ++ }
917 ++ if (width & 2)
918 ++ fb_writel(*q++, p++);
919 ++ if (width & 1)
920 ++ fb_writew(*(u16*)q, (u16*)p);
921 ++ break;
922 ++ case 8:
923 ++ for (i=0; i < width/4; i++)
924 ++ fb_writel(*q++, p++);
925 ++
926 ++ if (width & 2) {
927 ++ fb_writew(*(u16*)q, (u16*)p);
928 ++ q = (u32*) ((u16*)q + 1);
929 ++ p = (u32*) ((u16*)p + 1);
930 ++ }
931 ++ if (width & 1)
932 ++ fb_writeb(*(u8*)q, (u8*)p);
933 ++ break;
934 ++ }
935 ++
936 ++ dst += linebytes;
937 ++ src += srclinebytes;
938 ++ }
939 ++}
940 ++
941 ++static void decorfill(struct fb_info *info, int sy, int sx, int height,
942 ++ int width)
943 ++{
944 ++ int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
945 ++ int d = sy * info->fix.line_length + sx * bytespp;
946 ++ int ds = (sy * info->var.xres + sx) * bytespp;
947 ++
948 ++ fbcon_decor_copy((u8 *)(info->screen_base + d), (u8 *)(info->bgdecor.data + ds),
949 ++ height, width, info->fix.line_length, info->var.xres * bytespp,
950 ++ info->var.bits_per_pixel);
951 ++}
952 ++
953 ++void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx,
954 ++ int height, int width)
955 ++{
956 ++ int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
957 ++ struct fbcon_ops *ops = info->fbcon_par;
958 ++ u8 *dst;
959 ++ int transparent, bg_color = attr_bgcol_ec(bgshift, vc, info);
960 ++
961 ++ transparent = (vc->vc_decor.bg_color == bg_color);
962 ++ sy = sy * vc->vc_font.height + vc->vc_decor.ty;
963 ++ sx = sx * vc->vc_font.width + vc->vc_decor.tx;
964 ++ height *= vc->vc_font.height;
965 ++ width *= vc->vc_font.width;
966 ++
967 ++ /* Don't paint the background image if console is blanked */
968 ++ if (transparent && !ops->blank_state) {
969 ++ decorfill(info, sy, sx, height, width);
970 ++ } else {
971 ++ dst = (u8 *)(info->screen_base + sy * info->fix.line_length +
972 ++ sx * ((info->var.bits_per_pixel + 7) >> 3));
973 ++ decorset(dst, height, width, info->fix.line_length, cc2cx(bg_color),
974 ++ info->var.bits_per_pixel);
975 ++ }
976 ++}
977 ++
978 ++void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info,
979 ++ int bottom_only)
980 ++{
981 ++ unsigned int tw = vc->vc_cols*vc->vc_font.width;
982 ++ unsigned int th = vc->vc_rows*vc->vc_font.height;
983 ++
984 ++ if (!bottom_only) {
985 ++ /* top margin */
986 ++ decorfill(info, 0, 0, vc->vc_decor.ty, info->var.xres);
987 ++ /* left margin */
988 ++ decorfill(info, vc->vc_decor.ty, 0, th, vc->vc_decor.tx);
989 ++ /* right margin */
990 ++ decorfill(info, vc->vc_decor.ty, vc->vc_decor.tx + tw, th,
991 ++ info->var.xres - vc->vc_decor.tx - tw);
992 ++ }
993 ++ decorfill(info, vc->vc_decor.ty + th, 0,
994 ++ info->var.yres - vc->vc_decor.ty - th, info->var.xres);
995 ++}
996 ++
997 ++void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y,
998 ++ int sx, int dx, int width)
999 ++{
1000 ++ u16 *d = (u16 *) (vc->vc_origin + vc->vc_size_row * y + dx * 2);
1001 ++ u16 *s = d + (dx - sx);
1002 ++ u16 *start = d;
1003 ++ u16 *ls = d;
1004 ++ u16 *le = d + width;
1005 ++ u16 c;
1006 ++ int x = dx;
1007 ++ u16 attr = 1;
1008 ++
1009 ++ do {
1010 ++ c = scr_readw(d);
1011 ++ if (attr != (c & 0xff00)) {
1012 ++ attr = c & 0xff00;
1013 ++ if (d > start) {
1014 ++ fbcon_decor_putcs(vc, info, start, d - start, y, x);
1015 ++ x += d - start;
1016 ++ start = d;
1017 ++ }
1018 ++ }
1019 ++ if (s >= ls && s < le && c == scr_readw(s)) {
1020 ++ if (d > start) {
1021 ++ fbcon_decor_putcs(vc, info, start, d - start, y, x);
1022 ++ x += d - start + 1;
1023 ++ start = d + 1;
1024 ++ } else {
1025 ++ x++;
1026 ++ start++;
1027 ++ }
1028 ++ }
1029 ++ s++;
1030 ++ d++;
1031 ++ } while (d < le);
1032 ++ if (d > start)
1033 ++ fbcon_decor_putcs(vc, info, start, d - start, y, x);
1034 ++}
1035 ++
1036 ++void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank)
1037 ++{
1038 ++ if (blank) {
1039 ++ decorset((u8 *)info->screen_base, info->var.yres, info->var.xres,
1040 ++ info->fix.line_length, 0, info->var.bits_per_pixel);
1041 ++ } else {
1042 ++ update_screen(vc);
1043 ++ fbcon_decor_clear_margins(vc, info, 0);
1044 ++ }
1045 ++}
1046 ++
1047 +diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
1048 +index f447734..da50d61 100644
1049 +--- a/drivers/video/console/fbcon.c
1050 ++++ b/drivers/video/console/fbcon.c
1051 +@@ -79,6 +79,7 @@
1052 + #include <asm/irq.h>
1053 +
1054 + #include "fbcon.h"
1055 ++#include "../console/fbcondecor.h"
1056 +
1057 + #ifdef FBCONDEBUG
1058 + # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
1059 +@@ -94,7 +95,7 @@ enum {
1060 +
1061 + static struct display fb_display[MAX_NR_CONSOLES];
1062 +
1063 +-static signed char con2fb_map[MAX_NR_CONSOLES];
1064 ++signed char con2fb_map[MAX_NR_CONSOLES];
1065 + static signed char con2fb_map_boot[MAX_NR_CONSOLES];
1066 +
1067 + static int logo_lines;
1068 +@@ -286,7 +287,7 @@ static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info)
1069 + !vt_force_oops_output(vc);
1070 + }
1071 +
1072 +-static int get_color(struct vc_data *vc, struct fb_info *info,
1073 ++int get_color(struct vc_data *vc, struct fb_info *info,
1074 + u16 c, int is_fg)
1075 + {
1076 + int depth = fb_get_color_depth(&info->var, &info->fix);
1077 +@@ -551,6 +552,9 @@ static int do_fbcon_takeover(int show_logo)
1078 + info_idx = -1;
1079 + } else {
1080 + fbcon_has_console_bind = 1;
1081 ++#ifdef CONFIG_FB_CON_DECOR
1082 ++ fbcon_decor_init();
1083 ++#endif
1084 + }
1085 +
1086 + return err;
1087 +@@ -1007,6 +1011,12 @@ static const char *fbcon_startup(void)
1088 + rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1089 + cols /= vc->vc_font.width;
1090 + rows /= vc->vc_font.height;
1091 ++
1092 ++ if (fbcon_decor_active(info, vc)) {
1093 ++ cols = vc->vc_decor.twidth / vc->vc_font.width;
1094 ++ rows = vc->vc_decor.theight / vc->vc_font.height;
1095 ++ }
1096 ++
1097 + vc_resize(vc, cols, rows);
1098 +
1099 + DPRINTK("mode: %s\n", info->fix.id);
1100 +@@ -1036,7 +1046,7 @@ static void fbcon_init(struct vc_data *vc, int init)
1101 + cap = info->flags;
1102 +
1103 + if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
1104 +- (info->fix.type == FB_TYPE_TEXT))
1105 ++ (info->fix.type == FB_TYPE_TEXT) || fbcon_decor_active(info, vc))
1106 + logo = 0;
1107 +
1108 + if (var_to_display(p, &info->var, info))
1109 +@@ -1260,6 +1270,11 @@ static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
1110 + fbcon_clear_margins(vc, 0);
1111 + }
1112 +
1113 ++ if (fbcon_decor_active(info, vc)) {
1114 ++ fbcon_decor_clear(vc, info, sy, sx, height, width);
1115 ++ return;
1116 ++ }
1117 ++
1118 + /* Split blits that cross physical y_wrap boundary */
1119 +
1120 + y_break = p->vrows - p->yscroll;
1121 +@@ -1279,10 +1294,15 @@ static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
1122 + struct display *p = &fb_display[vc->vc_num];
1123 + struct fbcon_ops *ops = info->fbcon_par;
1124 +
1125 +- if (!fbcon_is_inactive(vc, info))
1126 +- ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
1127 +- get_color(vc, info, scr_readw(s), 1),
1128 +- get_color(vc, info, scr_readw(s), 0));
1129 ++ if (!fbcon_is_inactive(vc, info)) {
1130 ++
1131 ++ if (fbcon_decor_active(info, vc))
1132 ++ fbcon_decor_putcs(vc, info, s, count, ypos, xpos);
1133 ++ else
1134 ++ ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
1135 ++ get_color(vc, info, scr_readw(s), 1),
1136 ++ get_color(vc, info, scr_readw(s), 0));
1137 ++ }
1138 + }
1139 +
1140 + static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
1141 +@@ -1298,8 +1318,13 @@ static void fbcon_clear_margins(struct vc_data *vc, int bottom_only)
1142 + struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1143 + struct fbcon_ops *ops = info->fbcon_par;
1144 +
1145 +- if (!fbcon_is_inactive(vc, info))
1146 +- ops->clear_margins(vc, info, bottom_only);
1147 ++ if (!fbcon_is_inactive(vc, info)) {
1148 ++ if (fbcon_decor_active(info, vc)) {
1149 ++ fbcon_decor_clear_margins(vc, info, bottom_only);
1150 ++ } else {
1151 ++ ops->clear_margins(vc, info, bottom_only);
1152 ++ }
1153 ++ }
1154 + }
1155 +
1156 + static void fbcon_cursor(struct vc_data *vc, int mode)
1157 +@@ -1819,7 +1844,7 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1158 + count = vc->vc_rows;
1159 + if (softback_top)
1160 + fbcon_softback_note(vc, t, count);
1161 +- if (logo_shown >= 0)
1162 ++ if (logo_shown >= 0 || fbcon_decor_active(info, vc))
1163 + goto redraw_up;
1164 + switch (p->scrollmode) {
1165 + case SCROLL_MOVE:
1166 +@@ -1912,6 +1937,8 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1167 + count = vc->vc_rows;
1168 + if (logo_shown >= 0)
1169 + goto redraw_down;
1170 ++ if (fbcon_decor_active(info, vc))
1171 ++ goto redraw_down;
1172 + switch (p->scrollmode) {
1173 + case SCROLL_MOVE:
1174 + fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
1175 +@@ -2060,6 +2087,13 @@ static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int s
1176 + }
1177 + return;
1178 + }
1179 ++
1180 ++ if (fbcon_decor_active(info, vc) && sy == dy && height == 1) {
1181 ++ /* must use slower redraw bmove to keep background pic intact */
1182 ++ fbcon_decor_bmove_redraw(vc, info, sy, sx, dx, width);
1183 ++ return;
1184 ++ }
1185 ++
1186 + ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
1187 + height, width);
1188 + }
1189 +@@ -2130,8 +2164,8 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width,
1190 + var.yres = virt_h * virt_fh;
1191 + x_diff = info->var.xres - var.xres;
1192 + y_diff = info->var.yres - var.yres;
1193 +- if (x_diff < 0 || x_diff > virt_fw ||
1194 +- y_diff < 0 || y_diff > virt_fh) {
1195 ++ if ((x_diff < 0 || x_diff > virt_fw ||
1196 ++ y_diff < 0 || y_diff > virt_fh) && !vc->vc_decor.state) {
1197 + const struct fb_videomode *mode;
1198 +
1199 + DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
1200 +@@ -2167,6 +2201,21 @@ static int fbcon_switch(struct vc_data *vc)
1201 +
1202 + info = registered_fb[con2fb_map[vc->vc_num]];
1203 + ops = info->fbcon_par;
1204 ++ prev_console = ops->currcon;
1205 ++ if (prev_console != -1)
1206 ++ old_info = registered_fb[con2fb_map[prev_console]];
1207 ++
1208 ++#ifdef CONFIG_FB_CON_DECOR
1209 ++ if (!fbcon_decor_active_vc(vc) && info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
1210 ++ struct vc_data *vc_curr = vc_cons[prev_console].d;
1211 ++ if (vc_curr && fbcon_decor_active_vc(vc_curr)) {
1212 ++ /* Clear the screen to avoid displaying funky colors during
1213 ++ * palette updates. */
1214 ++ memset((u8*)info->screen_base + info->fix.line_length * info->var.yoffset,
1215 ++ 0, info->var.yres * info->fix.line_length);
1216 ++ }
1217 ++ }
1218 ++#endif
1219 +
1220 + if (softback_top) {
1221 + if (softback_lines)
1222 +@@ -2185,9 +2234,6 @@ static int fbcon_switch(struct vc_data *vc)
1223 + logo_shown = FBCON_LOGO_CANSHOW;
1224 + }
1225 +
1226 +- prev_console = ops->currcon;
1227 +- if (prev_console != -1)
1228 +- old_info = registered_fb[con2fb_map[prev_console]];
1229 + /*
1230 + * FIXME: If we have multiple fbdev's loaded, we need to
1231 + * update all info->currcon. Perhaps, we can place this
1232 +@@ -2231,6 +2277,18 @@ static int fbcon_switch(struct vc_data *vc)
1233 + fbcon_del_cursor_timer(old_info);
1234 + }
1235 +
1236 ++ if (fbcon_decor_active_vc(vc)) {
1237 ++ struct vc_data *vc_curr = vc_cons[prev_console].d;
1238 ++
1239 ++ if (!vc_curr->vc_decor.theme ||
1240 ++ strcmp(vc->vc_decor.theme, vc_curr->vc_decor.theme) ||
1241 ++ (fbcon_decor_active_nores(info, vc_curr) &&
1242 ++ !fbcon_decor_active(info, vc_curr))) {
1243 ++ fbcon_decor_disable(vc, 0);
1244 ++ fbcon_decor_call_helper("modechange", vc->vc_num);
1245 ++ }
1246 ++ }
1247 ++
1248 + if (fbcon_is_inactive(vc, info) ||
1249 + ops->blank_state != FB_BLANK_UNBLANK)
1250 + fbcon_del_cursor_timer(info);
1251 +@@ -2339,15 +2397,20 @@ static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
1252 + }
1253 + }
1254 +
1255 +- if (!fbcon_is_inactive(vc, info)) {
1256 ++ if (!fbcon_is_inactive(vc, info)) {
1257 + if (ops->blank_state != blank) {
1258 + ops->blank_state = blank;
1259 + fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
1260 + ops->cursor_flash = (!blank);
1261 +
1262 +- if (!(info->flags & FBINFO_MISC_USEREVENT))
1263 +- if (fb_blank(info, blank))
1264 +- fbcon_generic_blank(vc, info, blank);
1265 ++ if (!(info->flags & FBINFO_MISC_USEREVENT)) {
1266 ++ if (fb_blank(info, blank)) {
1267 ++ if (fbcon_decor_active(info, vc))
1268 ++ fbcon_decor_blank(vc, info, blank);
1269 ++ else
1270 ++ fbcon_generic_blank(vc, info, blank);
1271 ++ }
1272 ++ }
1273 + }
1274 +
1275 + if (!blank)
1276 +@@ -2522,13 +2585,22 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
1277 + }
1278 +
1279 + if (resize) {
1280 ++ /* reset wrap/pan */
1281 + int cols, rows;
1282 +
1283 + cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
1284 + rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1285 ++
1286 ++ if (fbcon_decor_active(info, vc)) {
1287 ++ info->var.xoffset = info->var.yoffset = p->yscroll = 0;
1288 ++ cols = vc->vc_decor.twidth;
1289 ++ rows = vc->vc_decor.theight;
1290 ++ }
1291 + cols /= w;
1292 + rows /= h;
1293 ++
1294 + vc_resize(vc, cols, rows);
1295 ++
1296 + if (CON_IS_VISIBLE(vc) && softback_buf)
1297 + fbcon_update_softback(vc);
1298 + } else if (CON_IS_VISIBLE(vc)
1299 +@@ -2657,7 +2729,11 @@ static int fbcon_set_palette(struct vc_data *vc, unsigned char *table)
1300 + int i, j, k, depth;
1301 + u8 val;
1302 +
1303 +- if (fbcon_is_inactive(vc, info))
1304 ++ if (fbcon_is_inactive(vc, info)
1305 ++#ifdef CONFIG_FB_CON_DECOR
1306 ++ || vc->vc_num != fg_console
1307 ++#endif
1308 ++ )
1309 + return -EINVAL;
1310 +
1311 + if (!CON_IS_VISIBLE(vc))
1312 +@@ -2683,14 +2759,56 @@ static int fbcon_set_palette(struct vc_data *vc, unsigned char *table)
1313 + } else
1314 + fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
1315 +
1316 +- return fb_set_cmap(&palette_cmap, info);
1317 ++ if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1318 ++ info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
1319 ++
1320 ++ u16 *red, *green, *blue;
1321 ++ int minlen = min(min(info->var.red.length, info->var.green.length),
1322 ++ info->var.blue.length);
1323 ++ int h;
1324 ++
1325 ++ struct fb_cmap cmap = {
1326 ++ .start = 0,
1327 ++ .len = (1 << minlen),
1328 ++ .red = NULL,
1329 ++ .green = NULL,
1330 ++ .blue = NULL,
1331 ++ .transp = NULL
1332 ++ };
1333 ++
1334 ++ red = kmalloc(256 * sizeof(u16) * 3, GFP_KERNEL);
1335 ++
1336 ++ if (!red)
1337 ++ goto out;
1338 ++
1339 ++ green = red + 256;
1340 ++ blue = green + 256;
1341 ++ cmap.red = red;
1342 ++ cmap.green = green;
1343 ++ cmap.blue = blue;
1344 ++
1345 ++ for (i = 0; i < cmap.len; i++) {
1346 ++ red[i] = green[i] = blue[i] = (0xffff * i)/(cmap.len-1);
1347 ++ }
1348 ++
1349 ++ h = fb_set_cmap(&cmap, info);
1350 ++ fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
1351 ++ kfree(red);
1352 ++
1353 ++ return h;
1354 ++
1355 ++ } else if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1356 ++ info->var.bits_per_pixel == 8 && info->bgdecor.cmap.red != NULL)
1357 ++ fb_set_cmap(&info->bgdecor.cmap, info);
1358 ++
1359 ++out: return fb_set_cmap(&palette_cmap, info);
1360 + }
1361 +
1362 + static u16 *fbcon_screen_pos(struct vc_data *vc, int offset)
1363 + {
1364 + unsigned long p;
1365 + int line;
1366 +-
1367 ++
1368 + if (vc->vc_num != fg_console || !softback_lines)
1369 + return (u16 *) (vc->vc_origin + offset);
1370 + line = offset / vc->vc_size_row;
1371 +@@ -2909,7 +3027,14 @@ static void fbcon_modechanged(struct fb_info *info)
1372 + rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1373 + cols /= vc->vc_font.width;
1374 + rows /= vc->vc_font.height;
1375 +- vc_resize(vc, cols, rows);
1376 ++
1377 ++ if (!fbcon_decor_active_nores(info, vc)) {
1378 ++ vc_resize(vc, cols, rows);
1379 ++ } else {
1380 ++ fbcon_decor_disable(vc, 0);
1381 ++ fbcon_decor_call_helper("modechange", vc->vc_num);
1382 ++ }
1383 ++
1384 + updatescrollmode(p, info, vc);
1385 + scrollback_max = 0;
1386 + scrollback_current = 0;
1387 +@@ -2954,7 +3079,9 @@ static void fbcon_set_all_vcs(struct fb_info *info)
1388 + rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1389 + cols /= vc->vc_font.width;
1390 + rows /= vc->vc_font.height;
1391 +- vc_resize(vc, cols, rows);
1392 ++ if (!fbcon_decor_active_nores(info, vc)) {
1393 ++ vc_resize(vc, cols, rows);
1394 ++ }
1395 + }
1396 +
1397 + if (fg != -1)
1398 +@@ -3596,6 +3723,7 @@ static void fbcon_exit(void)
1399 + }
1400 + }
1401 +
1402 ++ fbcon_decor_exit();
1403 + fbcon_has_exited = 1;
1404 + }
1405 +
1406 +diff --git a/drivers/video/console/fbcondecor.c b/drivers/video/console/fbcondecor.c
1407 +new file mode 100644
1408 +index 0000000..babc8c5
1409 +--- /dev/null
1410 ++++ b/drivers/video/console/fbcondecor.c
1411 +@@ -0,0 +1,555 @@
1412 ++/*
1413 ++ * linux/drivers/video/console/fbcondecor.c -- Framebuffer console decorations
1414 ++ *
1415 ++ * Copyright (C) 2004-2009 Michal Januszewski <michalj+fbcondecor@×××××.com>
1416 ++ *
1417 ++ * Code based upon "Bootsplash" (C) 2001-2003
1418 ++ * Volker Poplawski <volker@×××××××××.de>,
1419 ++ * Stefan Reinauer <stepan@××××.de>,
1420 ++ * Steffen Winterfeldt <snwint@××××.de>,
1421 ++ * Michael Schroeder <mls@××××.de>,
1422 ++ * Ken Wimer <wimer@××××.de>.
1423 ++ *
1424 ++ * Compat ioctl support by Thorsten Klein <TK@××××××××××××××.de>.
1425 ++ *
1426 ++ * This file is subject to the terms and conditions of the GNU General Public
1427 ++ * License. See the file COPYING in the main directory of this archive for
1428 ++ * more details.
1429 ++ *
1430 ++ */
1431 ++#include <linux/module.h>
1432 ++#include <linux/kernel.h>
1433 ++#include <linux/string.h>
1434 ++#include <linux/types.h>
1435 ++#include <linux/fb.h>
1436 ++#include <linux/vt_kern.h>
1437 ++#include <linux/vmalloc.h>
1438 ++#include <linux/unistd.h>
1439 ++#include <linux/syscalls.h>
1440 ++#include <linux/init.h>
1441 ++#include <linux/proc_fs.h>
1442 ++#include <linux/workqueue.h>
1443 ++#include <linux/kmod.h>
1444 ++#include <linux/miscdevice.h>
1445 ++#include <linux/device.h>
1446 ++#include <linux/fs.h>
1447 ++#include <linux/compat.h>
1448 ++#include <linux/console.h>
1449 ++
1450 ++#include <asm/uaccess.h>
1451 ++#include <asm/irq.h>
1452 ++
1453 ++#include "fbcon.h"
1454 ++#include "fbcondecor.h"
1455 ++
1456 ++extern signed char con2fb_map[];
1457 ++static int fbcon_decor_enable(struct vc_data *vc);
1458 ++char fbcon_decor_path[KMOD_PATH_LEN] = "/sbin/fbcondecor_helper";
1459 ++static int initialized = 0;
1460 ++
1461 ++int fbcon_decor_call_helper(char* cmd, unsigned short vc)
1462 ++{
1463 ++ char *envp[] = {
1464 ++ "HOME=/",
1465 ++ "PATH=/sbin:/bin",
1466 ++ NULL
1467 ++ };
1468 ++
1469 ++ char tfb[5];
1470 ++ char tcons[5];
1471 ++ unsigned char fb = (int) con2fb_map[vc];
1472 ++
1473 ++ char *argv[] = {
1474 ++ fbcon_decor_path,
1475 ++ "2",
1476 ++ cmd,
1477 ++ tcons,
1478 ++ tfb,
1479 ++ vc_cons[vc].d->vc_decor.theme,
1480 ++ NULL
1481 ++ };
1482 ++
1483 ++ snprintf(tfb,5,"%d",fb);
1484 ++ snprintf(tcons,5,"%d",vc);
1485 ++
1486 ++ return call_usermodehelper(fbcon_decor_path, argv, envp, UMH_WAIT_EXEC);
1487 ++}
1488 ++
1489 ++/* Disables fbcondecor on a virtual console; called with console sem held. */
1490 ++int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw)
1491 ++{
1492 ++ struct fb_info* info;
1493 ++
1494 ++ if (!vc->vc_decor.state)
1495 ++ return -EINVAL;
1496 ++
1497 ++ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1498 ++
1499 ++ if (info == NULL)
1500 ++ return -EINVAL;
1501 ++
1502 ++ vc->vc_decor.state = 0;
1503 ++ vc_resize(vc, info->var.xres / vc->vc_font.width,
1504 ++ info->var.yres / vc->vc_font.height);
1505 ++
1506 ++ if (fg_console == vc->vc_num && redraw) {
1507 ++ redraw_screen(vc, 0);
1508 ++ update_region(vc, vc->vc_origin +
1509 ++ vc->vc_size_row * vc->vc_top,
1510 ++ vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1511 ++ }
1512 ++
1513 ++ printk(KERN_INFO "fbcondecor: switched decor state to 'off' on console %d\n",
1514 ++ vc->vc_num);
1515 ++
1516 ++ return 0;
1517 ++}
1518 ++
1519 ++/* Enables fbcondecor on a virtual console; called with console sem held. */
1520 ++static int fbcon_decor_enable(struct vc_data *vc)
1521 ++{
1522 ++ struct fb_info* info;
1523 ++
1524 ++ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1525 ++
1526 ++ if (vc->vc_decor.twidth == 0 || vc->vc_decor.theight == 0 ||
1527 ++ info == NULL || vc->vc_decor.state || (!info->bgdecor.data &&
1528 ++ vc->vc_num == fg_console))
1529 ++ return -EINVAL;
1530 ++
1531 ++ vc->vc_decor.state = 1;
1532 ++ vc_resize(vc, vc->vc_decor.twidth / vc->vc_font.width,
1533 ++ vc->vc_decor.theight / vc->vc_font.height);
1534 ++
1535 ++ if (fg_console == vc->vc_num) {
1536 ++ redraw_screen(vc, 0);
1537 ++ update_region(vc, vc->vc_origin +
1538 ++ vc->vc_size_row * vc->vc_top,
1539 ++ vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1540 ++ fbcon_decor_clear_margins(vc, info, 0);
1541 ++ }
1542 ++
1543 ++ printk(KERN_INFO "fbcondecor: switched decor state to 'on' on console %d\n",
1544 ++ vc->vc_num);
1545 ++
1546 ++ return 0;
1547 ++}
1548 ++
1549 ++static inline int fbcon_decor_ioctl_dosetstate(struct vc_data *vc, unsigned int state, unsigned char origin)
1550 ++{
1551 ++ int ret;
1552 ++
1553 ++// if (origin == FBCON_DECOR_IO_ORIG_USER)
1554 ++ console_lock();
1555 ++ if (!state)
1556 ++ ret = fbcon_decor_disable(vc, 1);
1557 ++ else
1558 ++ ret = fbcon_decor_enable(vc);
1559 ++// if (origin == FBCON_DECOR_IO_ORIG_USER)
1560 ++ console_unlock();
1561 ++
1562 ++ return ret;
1563 ++}
1564 ++
1565 ++static inline void fbcon_decor_ioctl_dogetstate(struct vc_data *vc, unsigned int *state)
1566 ++{
1567 ++ *state = vc->vc_decor.state;
1568 ++}
1569 ++
1570 ++static int fbcon_decor_ioctl_dosetcfg(struct vc_data *vc, struct vc_decor *cfg, unsigned char origin)
1571 ++{
1572 ++ struct fb_info *info;
1573 ++ int len;
1574 ++ char *tmp;
1575 ++
1576 ++ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1577 ++
1578 ++ if (info == NULL || !cfg->twidth || !cfg->theight ||
1579 ++ cfg->tx + cfg->twidth > info->var.xres ||
1580 ++ cfg->ty + cfg->theight > info->var.yres)
1581 ++ return -EINVAL;
1582 ++
1583 ++ len = strlen_user(cfg->theme);
1584 ++ if (!len || len > FBCON_DECOR_THEME_LEN)
1585 ++ return -EINVAL;
1586 ++ tmp = kmalloc(len, GFP_KERNEL);
1587 ++ if (!tmp)
1588 ++ return -ENOMEM;
1589 ++ if (copy_from_user(tmp, (void __user *)cfg->theme, len))
1590 ++ return -EFAULT;
1591 ++ cfg->theme = tmp;
1592 ++ cfg->state = 0;
1593 ++
1594 ++ /* If this ioctl is a response to a request from kernel, the console sem
1595 ++ * is already held; we also don't need to disable decor because either the
1596 ++ * new config and background picture will be successfully loaded, and the
1597 ++ * decor will stay on, or in case of a failure it'll be turned off in fbcon. */
1598 ++// if (origin == FBCON_DECOR_IO_ORIG_USER) {
1599 ++ console_lock();
1600 ++ if (vc->vc_decor.state)
1601 ++ fbcon_decor_disable(vc, 1);
1602 ++// }
1603 ++
1604 ++ if (vc->vc_decor.theme)
1605 ++ kfree(vc->vc_decor.theme);
1606 ++
1607 ++ vc->vc_decor = *cfg;
1608 ++
1609 ++// if (origin == FBCON_DECOR_IO_ORIG_USER)
1610 ++ console_unlock();
1611 ++
1612 ++ printk(KERN_INFO "fbcondecor: console %d using theme '%s'\n",
1613 ++ vc->vc_num, vc->vc_decor.theme);
1614 ++ return 0;
1615 ++}
1616 ++
1617 ++static int fbcon_decor_ioctl_dogetcfg(struct vc_data *vc, struct vc_decor *decor)
1618 ++{
1619 ++ char __user *tmp;
1620 ++
1621 ++ tmp = decor->theme;
1622 ++ *decor = vc->vc_decor;
1623 ++ decor->theme = tmp;
1624 ++
1625 ++ if (vc->vc_decor.theme) {
1626 ++ if (copy_to_user(tmp, vc->vc_decor.theme, strlen(vc->vc_decor.theme) + 1))
1627 ++ return -EFAULT;
1628 ++ } else
1629 ++ if (put_user(0, tmp))
1630 ++ return -EFAULT;
1631 ++
1632 ++ return 0;
1633 ++}
1634 ++
1635 ++static int fbcon_decor_ioctl_dosetpic(struct vc_data *vc, struct fb_image *img, unsigned char origin)
1636 ++{
1637 ++ struct fb_info *info;
1638 ++ int len;
1639 ++ u8 *tmp;
1640 ++
1641 ++ if (vc->vc_num != fg_console)
1642 ++ return -EINVAL;
1643 ++
1644 ++ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1645 ++
1646 ++ if (info == NULL)
1647 ++ return -EINVAL;
1648 ++
1649 ++ if (img->width != info->var.xres || img->height != info->var.yres) {
1650 ++ printk(KERN_ERR "fbcondecor: picture dimensions mismatch\n");
1651 ++ printk(KERN_ERR "%dx%d vs %dx%d\n", img->width, img->height, info->var.xres, info->var.yres);
1652 ++ return -EINVAL;
1653 ++ }
1654 ++
1655 ++ if (img->depth != info->var.bits_per_pixel) {
1656 ++ printk(KERN_ERR "fbcondecor: picture depth mismatch\n");
1657 ++ return -EINVAL;
1658 ++ }
1659 ++
1660 ++ if (img->depth == 8) {
1661 ++ if (!img->cmap.len || !img->cmap.red || !img->cmap.green ||
1662 ++ !img->cmap.blue)
1663 ++ return -EINVAL;
1664 ++
1665 ++ tmp = vmalloc(img->cmap.len * 3 * 2);
1666 ++ if (!tmp)
1667 ++ return -ENOMEM;
1668 ++
1669 ++ if (copy_from_user(tmp,
1670 ++ (void __user*)img->cmap.red, (img->cmap.len << 1)) ||
1671 ++ copy_from_user(tmp + (img->cmap.len << 1),
1672 ++ (void __user*)img->cmap.green, (img->cmap.len << 1)) ||
1673 ++ copy_from_user(tmp + (img->cmap.len << 2),
1674 ++ (void __user*)img->cmap.blue, (img->cmap.len << 1))) {
1675 ++ vfree(tmp);
1676 ++ return -EFAULT;
1677 ++ }
1678 ++
1679 ++ img->cmap.transp = NULL;
1680 ++ img->cmap.red = (u16*)tmp;
1681 ++ img->cmap.green = img->cmap.red + img->cmap.len;
1682 ++ img->cmap.blue = img->cmap.green + img->cmap.len;
1683 ++ } else {
1684 ++ img->cmap.red = NULL;
1685 ++ }
1686 ++
1687 ++ len = ((img->depth + 7) >> 3) * img->width * img->height;
1688 ++
1689 ++ /*
1690 ++ * Allocate an additional byte so that we never go outside of the
1691 ++ * buffer boundaries in the rendering functions in a 24 bpp mode.
1692 ++ */
1693 ++ tmp = vmalloc(len + 1);
1694 ++
1695 ++ if (!tmp)
1696 ++ goto out;
1697 ++
1698 ++ if (copy_from_user(tmp, (void __user*)img->data, len))
1699 ++ goto out;
1700 ++
1701 ++ img->data = tmp;
1702 ++
1703 ++ /* If this ioctl is a response to a request from kernel, the console sem
1704 ++ * is already held. */
1705 ++// if (origin == FBCON_DECOR_IO_ORIG_USER)
1706 ++ console_lock();
1707 ++
1708 ++ if (info->bgdecor.data)
1709 ++ vfree((u8*)info->bgdecor.data);
1710 ++ if (info->bgdecor.cmap.red)
1711 ++ vfree(info->bgdecor.cmap.red);
1712 ++
1713 ++ info->bgdecor = *img;
1714 ++
1715 ++ if (fbcon_decor_active_vc(vc) && fg_console == vc->vc_num) {
1716 ++ redraw_screen(vc, 0);
1717 ++ update_region(vc, vc->vc_origin +
1718 ++ vc->vc_size_row * vc->vc_top,
1719 ++ vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1720 ++ fbcon_decor_clear_margins(vc, info, 0);
1721 ++ }
1722 ++
1723 ++// if (origin == FBCON_DECOR_IO_ORIG_USER)
1724 ++ console_unlock();
1725 ++
1726 ++ return 0;
1727 ++
1728 ++out: if (img->cmap.red)
1729 ++ vfree(img->cmap.red);
1730 ++
1731 ++ if (tmp)
1732 ++ vfree(tmp);
1733 ++ return -ENOMEM;
1734 ++}
1735 ++
1736 ++static long fbcon_decor_ioctl(struct file *filp, u_int cmd, u_long arg)
1737 ++{
1738 ++ struct fbcon_decor_iowrapper __user *wrapper = (void __user*) arg;
1739 ++ struct vc_data *vc = NULL;
1740 ++ unsigned short vc_num = 0;
1741 ++ unsigned char origin = 0;
1742 ++ void __user *data = NULL;
1743 ++
1744 ++ if (!access_ok(VERIFY_READ, wrapper,
1745 ++ sizeof(struct fbcon_decor_iowrapper)))
1746 ++ return -EFAULT;
1747 ++
1748 ++ __get_user(vc_num, &wrapper->vc);
1749 ++ __get_user(origin, &wrapper->origin);
1750 ++ __get_user(data, &wrapper->data);
1751 ++
1752 ++ if (!vc_cons_allocated(vc_num))
1753 ++ return -EINVAL;
1754 ++
1755 ++ vc = vc_cons[vc_num].d;
1756 ++
1757 ++ switch (cmd) {
1758 ++ case FBIOCONDECOR_SETPIC:
1759 ++ {
1760 ++ struct fb_image img;
1761 ++ if (copy_from_user(&img, (struct fb_image __user *)data, sizeof(struct fb_image)))
1762 ++ return -EFAULT;
1763 ++
1764 ++ return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
1765 ++ }
1766 ++ case FBIOCONDECOR_SETCFG:
1767 ++ {
1768 ++ struct vc_decor cfg;
1769 ++ if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
1770 ++ return -EFAULT;
1771 ++
1772 ++ return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
1773 ++ }
1774 ++ case FBIOCONDECOR_GETCFG:
1775 ++ {
1776 ++ int rval;
1777 ++ struct vc_decor cfg;
1778 ++
1779 ++ if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
1780 ++ return -EFAULT;
1781 ++
1782 ++ rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
1783 ++
1784 ++ if (copy_to_user(data, &cfg, sizeof(struct vc_decor)))
1785 ++ return -EFAULT;
1786 ++ return rval;
1787 ++ }
1788 ++ case FBIOCONDECOR_SETSTATE:
1789 ++ {
1790 ++ unsigned int state = 0;
1791 ++ if (get_user(state, (unsigned int __user *)data))
1792 ++ return -EFAULT;
1793 ++ return fbcon_decor_ioctl_dosetstate(vc, state, origin);
1794 ++ }
1795 ++ case FBIOCONDECOR_GETSTATE:
1796 ++ {
1797 ++ unsigned int state = 0;
1798 ++ fbcon_decor_ioctl_dogetstate(vc, &state);
1799 ++ return put_user(state, (unsigned int __user *)data);
1800 ++ }
1801 ++
1802 ++ default:
1803 ++ return -ENOIOCTLCMD;
1804 ++ }
1805 ++}
1806 ++
1807 ++#ifdef CONFIG_COMPAT
1808 ++
1809 ++static long fbcon_decor_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) {
1810 ++
1811 ++ struct fbcon_decor_iowrapper32 __user *wrapper = (void __user *)arg;
1812 ++ struct vc_data *vc = NULL;
1813 ++ unsigned short vc_num = 0;
1814 ++ unsigned char origin = 0;
1815 ++ compat_uptr_t data_compat = 0;
1816 ++ void __user *data = NULL;
1817 ++
1818 ++ if (!access_ok(VERIFY_READ, wrapper,
1819 ++ sizeof(struct fbcon_decor_iowrapper32)))
1820 ++ return -EFAULT;
1821 ++
1822 ++ __get_user(vc_num, &wrapper->vc);
1823 ++ __get_user(origin, &wrapper->origin);
1824 ++ __get_user(data_compat, &wrapper->data);
1825 ++ data = compat_ptr(data_compat);
1826 ++
1827 ++ if (!vc_cons_allocated(vc_num))
1828 ++ return -EINVAL;
1829 ++
1830 ++ vc = vc_cons[vc_num].d;
1831 ++
1832 ++ switch (cmd) {
1833 ++ case FBIOCONDECOR_SETPIC32:
1834 ++ {
1835 ++ struct fb_image32 img_compat;
1836 ++ struct fb_image img;
1837 ++
1838 ++ if (copy_from_user(&img_compat, (struct fb_image32 __user *)data, sizeof(struct fb_image32)))
1839 ++ return -EFAULT;
1840 ++
1841 ++ fb_image_from_compat(img, img_compat);
1842 ++
1843 ++ return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
1844 ++ }
1845 ++
1846 ++ case FBIOCONDECOR_SETCFG32:
1847 ++ {
1848 ++ struct vc_decor32 cfg_compat;
1849 ++ struct vc_decor cfg;
1850 ++
1851 ++ if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
1852 ++ return -EFAULT;
1853 ++
1854 ++ vc_decor_from_compat(cfg, cfg_compat);
1855 ++
1856 ++ return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
1857 ++ }
1858 ++
1859 ++ case FBIOCONDECOR_GETCFG32:
1860 ++ {
1861 ++ int rval;
1862 ++ struct vc_decor32 cfg_compat;
1863 ++ struct vc_decor cfg;
1864 ++
1865 ++ if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
1866 ++ return -EFAULT;
1867 ++ cfg.theme = compat_ptr(cfg_compat.theme);
1868 ++
1869 ++ rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
1870 ++
1871 ++ vc_decor_to_compat(cfg_compat, cfg);
1872 ++
1873 ++ if (copy_to_user((struct vc_decor32 __user *)data, &cfg_compat, sizeof(struct vc_decor32)))
1874 ++ return -EFAULT;
1875 ++ return rval;
1876 ++ }
1877 ++
1878 ++ case FBIOCONDECOR_SETSTATE32:
1879 ++ {
1880 ++ compat_uint_t state_compat = 0;
1881 ++ unsigned int state = 0;
1882 ++
1883 ++ if (get_user(state_compat, (compat_uint_t __user *)data))
1884 ++ return -EFAULT;
1885 ++
1886 ++ state = (unsigned int)state_compat;
1887 ++
1888 ++ return fbcon_decor_ioctl_dosetstate(vc, state, origin);
1889 ++ }
1890 ++
1891 ++ case FBIOCONDECOR_GETSTATE32:
1892 ++ {
1893 ++ compat_uint_t state_compat = 0;
1894 ++ unsigned int state = 0;
1895 ++
1896 ++ fbcon_decor_ioctl_dogetstate(vc, &state);
1897 ++ state_compat = (compat_uint_t)state;
1898 ++
1899 ++ return put_user(state_compat, (compat_uint_t __user *)data);
1900 ++ }
1901 ++
1902 ++ default:
1903 ++ return -ENOIOCTLCMD;
1904 ++ }
1905 ++}
1906 ++#else
1907 ++ #define fbcon_decor_compat_ioctl NULL
1908 ++#endif
1909 ++
1910 ++static struct file_operations fbcon_decor_ops = {
1911 ++ .owner = THIS_MODULE,
1912 ++ .unlocked_ioctl = fbcon_decor_ioctl,
1913 ++ .compat_ioctl = fbcon_decor_compat_ioctl
1914 ++};
1915 ++
1916 ++static struct miscdevice fbcon_decor_dev = {
1917 ++ .minor = MISC_DYNAMIC_MINOR,
1918 ++ .name = "fbcondecor",
1919 ++ .fops = &fbcon_decor_ops
1920 ++};
1921 ++
1922 ++void fbcon_decor_reset(void)
1923 ++{
1924 ++ int i;
1925 ++
1926 ++ for (i = 0; i < num_registered_fb; i++) {
1927 ++ registered_fb[i]->bgdecor.data = NULL;
1928 ++ registered_fb[i]->bgdecor.cmap.red = NULL;
1929 ++ }
1930 ++
1931 ++ for (i = 0; i < MAX_NR_CONSOLES && vc_cons[i].d; i++) {
1932 ++ vc_cons[i].d->vc_decor.state = vc_cons[i].d->vc_decor.twidth =
1933 ++ vc_cons[i].d->vc_decor.theight = 0;
1934 ++ vc_cons[i].d->vc_decor.theme = NULL;
1935 ++ }
1936 ++
1937 ++ return;
1938 ++}
1939 ++
1940 ++int fbcon_decor_init(void)
1941 ++{
1942 ++ int i;
1943 ++
1944 ++ fbcon_decor_reset();
1945 ++
1946 ++ if (initialized)
1947 ++ return 0;
1948 ++
1949 ++ i = misc_register(&fbcon_decor_dev);
1950 ++ if (i) {
1951 ++ printk(KERN_ERR "fbcondecor: failed to register device\n");
1952 ++ return i;
1953 ++ }
1954 ++
1955 ++ fbcon_decor_call_helper("init", 0);
1956 ++ initialized = 1;
1957 ++ return 0;
1958 ++}
1959 ++
1960 ++int fbcon_decor_exit(void)
1961 ++{
1962 ++ fbcon_decor_reset();
1963 ++ return 0;
1964 ++}
1965 ++
1966 ++EXPORT_SYMBOL(fbcon_decor_path);
1967 +diff --git a/drivers/video/console/fbcondecor.h b/drivers/video/console/fbcondecor.h
1968 +new file mode 100644
1969 +index 0000000..3b3724b
1970 +--- /dev/null
1971 ++++ b/drivers/video/console/fbcondecor.h
1972 +@@ -0,0 +1,78 @@
1973 ++/*
1974 ++ * linux/drivers/video/console/fbcondecor.h -- Framebuffer Console Decoration headers
1975 ++ *
1976 ++ * Copyright (C) 2004 Michal Januszewski <michalj+fbcondecor@×××××.com>
1977 ++ *
1978 ++ */
1979 ++
1980 ++#ifndef __FBCON_DECOR_H
1981 ++#define __FBCON_DECOR_H
1982 ++
1983 ++#ifndef _LINUX_FB_H
1984 ++#include <linux/fb.h>
1985 ++#endif
1986 ++
1987 ++/* This is needed for vc_cons in fbcmap.c */
1988 ++#include <linux/vt_kern.h>
1989 ++
1990 ++struct fb_cursor;
1991 ++struct fb_info;
1992 ++struct vc_data;
1993 ++
1994 ++#ifdef CONFIG_FB_CON_DECOR
1995 ++/* fbcondecor.c */
1996 ++int fbcon_decor_init(void);
1997 ++int fbcon_decor_exit(void);
1998 ++int fbcon_decor_call_helper(char* cmd, unsigned short cons);
1999 ++int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw);
2000 ++
2001 ++/* cfbcondecor.c */
2002 ++void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx);
2003 ++void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor);
2004 ++void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width);
2005 ++void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only);
2006 ++void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank);
2007 ++void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width);
2008 ++void fbcon_decor_copy(u8 *dst, u8 *src, int height, int width, int linebytes, int srclinesbytes, int bpp);
2009 ++void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc);
2010 ++
2011 ++/* vt.c */
2012 ++void acquire_console_sem(void);
2013 ++void release_console_sem(void);
2014 ++void do_unblank_screen(int entering_gfx);
2015 ++
2016 ++/* struct vc_data *y */
2017 ++#define fbcon_decor_active_vc(y) (y->vc_decor.state && y->vc_decor.theme)
2018 ++
2019 ++/* struct fb_info *x, struct vc_data *y */
2020 ++#define fbcon_decor_active_nores(x,y) (x->bgdecor.data && fbcon_decor_active_vc(y))
2021 ++
2022 ++/* struct fb_info *x, struct vc_data *y */
2023 ++#define fbcon_decor_active(x,y) (fbcon_decor_active_nores(x,y) && \
2024 ++ x->bgdecor.width == x->var.xres && \
2025 ++ x->bgdecor.height == x->var.yres && \
2026 ++ x->bgdecor.depth == x->var.bits_per_pixel)
2027 ++
2028 ++
2029 ++#else /* CONFIG_FB_CON_DECOR */
2030 ++
2031 ++static inline void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx) {}
2032 ++static inline void fbcon_decor_putc(struct vc_data *vc, struct fb_info *info, int c, int ypos, int xpos) {}
2033 ++static inline void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor) {}
2034 ++static inline void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) {}
2035 ++static inline void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only) {}
2036 ++static inline void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank) {}
2037 ++static inline void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width) {}
2038 ++static inline void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc) {}
2039 ++static inline int fbcon_decor_call_helper(char* cmd, unsigned short cons) { return 0; }
2040 ++static inline int fbcon_decor_init(void) { return 0; }
2041 ++static inline int fbcon_decor_exit(void) { return 0; }
2042 ++static inline int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw) { return 0; }
2043 ++
2044 ++#define fbcon_decor_active_vc(y) (0)
2045 ++#define fbcon_decor_active_nores(x,y) (0)
2046 ++#define fbcon_decor_active(x,y) (0)
2047 ++
2048 ++#endif /* CONFIG_FB_CON_DECOR */
2049 ++
2050 ++#endif /* __FBCON_DECOR_H */
2051 +diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
2052 +index e1f4727..2952e33 100644
2053 +--- a/drivers/video/fbdev/Kconfig
2054 ++++ b/drivers/video/fbdev/Kconfig
2055 +@@ -1204,7 +1204,6 @@ config FB_MATROX
2056 + select FB_CFB_FILLRECT
2057 + select FB_CFB_COPYAREA
2058 + select FB_CFB_IMAGEBLIT
2059 +- select FB_TILEBLITTING
2060 + select FB_MACMODES if PPC_PMAC
2061 + ---help---
2062 + Say Y here if you have a Matrox Millennium, Matrox Millennium II,
2063 +diff --git a/drivers/video/fbdev/core/fbcmap.c b/drivers/video/fbdev/core/fbcmap.c
2064 +index f89245b..05e036c 100644
2065 +--- a/drivers/video/fbdev/core/fbcmap.c
2066 ++++ b/drivers/video/fbdev/core/fbcmap.c
2067 +@@ -17,6 +17,8 @@
2068 + #include <linux/slab.h>
2069 + #include <linux/uaccess.h>
2070 +
2071 ++#include "../../console/fbcondecor.h"
2072 ++
2073 + static u16 red2[] __read_mostly = {
2074 + 0x0000, 0xaaaa
2075 + };
2076 +@@ -249,14 +251,17 @@ int fb_set_cmap(struct fb_cmap *cmap, struct fb_info *info)
2077 + if (transp)
2078 + htransp = *transp++;
2079 + if (info->fbops->fb_setcolreg(start++,
2080 +- hred, hgreen, hblue,
2081 ++ hred, hgreen, hblue,
2082 + htransp, info))
2083 + break;
2084 + }
2085 + }
2086 +- if (rc == 0)
2087 ++ if (rc == 0) {
2088 + fb_copy_cmap(cmap, &info->cmap);
2089 +-
2090 ++ if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
2091 ++ info->fix.visual == FB_VISUAL_DIRECTCOLOR)
2092 ++ fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
2093 ++ }
2094 + return rc;
2095 + }
2096 +
2097 +diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
2098 +index b6d5008..d6703f2 100644
2099 +--- a/drivers/video/fbdev/core/fbmem.c
2100 ++++ b/drivers/video/fbdev/core/fbmem.c
2101 +@@ -1250,15 +1250,6 @@ struct fb_fix_screeninfo32 {
2102 + u16 reserved[3];
2103 + };
2104 +
2105 +-struct fb_cmap32 {
2106 +- u32 start;
2107 +- u32 len;
2108 +- compat_caddr_t red;
2109 +- compat_caddr_t green;
2110 +- compat_caddr_t blue;
2111 +- compat_caddr_t transp;
2112 +-};
2113 +-
2114 + static int fb_getput_cmap(struct fb_info *info, unsigned int cmd,
2115 + unsigned long arg)
2116 + {
2117 +diff --git a/include/linux/console_decor.h b/include/linux/console_decor.h
2118 +new file mode 100644
2119 +index 0000000..04b8d80
2120 +--- /dev/null
2121 ++++ b/include/linux/console_decor.h
2122 +@@ -0,0 +1,46 @@
2123 ++#ifndef _LINUX_CONSOLE_DECOR_H_
2124 ++#define _LINUX_CONSOLE_DECOR_H_ 1
2125 ++
2126 ++/* A structure used by the framebuffer console decorations (drivers/video/console/fbcondecor.c) */
2127 ++struct vc_decor {
2128 ++ __u8 bg_color; /* The color that is to be treated as transparent */
2129 ++ __u8 state; /* Current decor state: 0 = off, 1 = on */
2130 ++ __u16 tx, ty; /* Top left corner coordinates of the text field */
2131 ++ __u16 twidth, theight; /* Width and height of the text field */
2132 ++ char* theme;
2133 ++};
2134 ++
2135 ++#ifdef __KERNEL__
2136 ++#ifdef CONFIG_COMPAT
2137 ++#include <linux/compat.h>
2138 ++
2139 ++struct vc_decor32 {
2140 ++ __u8 bg_color; /* The color that is to be treated as transparent */
2141 ++ __u8 state; /* Current decor state: 0 = off, 1 = on */
2142 ++ __u16 tx, ty; /* Top left corner coordinates of the text field */
2143 ++ __u16 twidth, theight; /* Width and height of the text field */
2144 ++ compat_uptr_t theme;
2145 ++};
2146 ++
2147 ++#define vc_decor_from_compat(to, from) \
2148 ++ (to).bg_color = (from).bg_color; \
2149 ++ (to).state = (from).state; \
2150 ++ (to).tx = (from).tx; \
2151 ++ (to).ty = (from).ty; \
2152 ++ (to).twidth = (from).twidth; \
2153 ++ (to).theight = (from).theight; \
2154 ++ (to).theme = compat_ptr((from).theme)
2155 ++
2156 ++#define vc_decor_to_compat(to, from) \
2157 ++ (to).bg_color = (from).bg_color; \
2158 ++ (to).state = (from).state; \
2159 ++ (to).tx = (from).tx; \
2160 ++ (to).ty = (from).ty; \
2161 ++ (to).twidth = (from).twidth; \
2162 ++ (to).theight = (from).theight; \
2163 ++ (to).theme = ptr_to_compat((from).theme)
2164 ++
2165 ++#endif /* CONFIG_COMPAT */
2166 ++#endif /* __KERNEL__ */
2167 ++
2168 ++#endif
2169 +diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h
2170 +index 7f0c329..98f5d60 100644
2171 +--- a/include/linux/console_struct.h
2172 ++++ b/include/linux/console_struct.h
2173 +@@ -19,6 +19,7 @@
2174 + struct vt_struct;
2175 +
2176 + #define NPAR 16
2177 ++#include <linux/console_decor.h>
2178 +
2179 + struct vc_data {
2180 + struct tty_port port; /* Upper level data */
2181 +@@ -107,6 +108,8 @@ struct vc_data {
2182 + unsigned long vc_uni_pagedir;
2183 + unsigned long *vc_uni_pagedir_loc; /* [!] Location of uni_pagedir variable for this console */
2184 + bool vc_panic_force_write; /* when oops/panic this VC can accept forced output/blanking */
2185 ++
2186 ++ struct vc_decor vc_decor;
2187 + /* additional information is in vt_kern.h */
2188 + };
2189 +
2190 +diff --git a/include/linux/fb.h b/include/linux/fb.h
2191 +index fe6ac95..1e36b03 100644
2192 +--- a/include/linux/fb.h
2193 ++++ b/include/linux/fb.h
2194 +@@ -219,6 +219,34 @@ struct fb_deferred_io {
2195 + };
2196 + #endif
2197 +
2198 ++#ifdef __KERNEL__
2199 ++#ifdef CONFIG_COMPAT
2200 ++struct fb_image32 {
2201 ++ __u32 dx; /* Where to place image */
2202 ++ __u32 dy;
2203 ++ __u32 width; /* Size of image */
2204 ++ __u32 height;
2205 ++ __u32 fg_color; /* Only used when a mono bitmap */
2206 ++ __u32 bg_color;
2207 ++ __u8 depth; /* Depth of the image */
2208 ++ const compat_uptr_t data; /* Pointer to image data */
2209 ++ struct fb_cmap32 cmap; /* color map info */
2210 ++};
2211 ++
2212 ++#define fb_image_from_compat(to, from) \
2213 ++ (to).dx = (from).dx; \
2214 ++ (to).dy = (from).dy; \
2215 ++ (to).width = (from).width; \
2216 ++ (to).height = (from).height; \
2217 ++ (to).fg_color = (from).fg_color; \
2218 ++ (to).bg_color = (from).bg_color; \
2219 ++ (to).depth = (from).depth; \
2220 ++ (to).data = compat_ptr((from).data); \
2221 ++ fb_cmap_from_compat((to).cmap, (from).cmap)
2222 ++
2223 ++#endif /* CONFIG_COMPAT */
2224 ++#endif /* __KERNEL__ */
2225 ++
2226 + /*
2227 + * Frame buffer operations
2228 + *
2229 +@@ -489,6 +517,9 @@ struct fb_info {
2230 + #define FBINFO_STATE_SUSPENDED 1
2231 + u32 state; /* Hardware state i.e suspend */
2232 + void *fbcon_par; /* fbcon use-only private area */
2233 ++
2234 ++ struct fb_image bgdecor;
2235 ++
2236 + /* From here on everything is device dependent */
2237 + void *par;
2238 + /* we need the PCI or similar aperture base/size not
2239 +diff --git a/include/uapi/linux/fb.h b/include/uapi/linux/fb.h
2240 +index fb795c3..dc77a03 100644
2241 +--- a/include/uapi/linux/fb.h
2242 ++++ b/include/uapi/linux/fb.h
2243 +@@ -8,6 +8,25 @@
2244 +
2245 + #define FB_MAX 32 /* sufficient for now */
2246 +
2247 ++struct fbcon_decor_iowrapper
2248 ++{
2249 ++ unsigned short vc; /* Virtual console */
2250 ++ unsigned char origin; /* Point of origin of the request */
2251 ++ void *data;
2252 ++};
2253 ++
2254 ++#ifdef __KERNEL__
2255 ++#ifdef CONFIG_COMPAT
2256 ++#include <linux/compat.h>
2257 ++struct fbcon_decor_iowrapper32
2258 ++{
2259 ++ unsigned short vc; /* Virtual console */
2260 ++ unsigned char origin; /* Point of origin of the request */
2261 ++ compat_uptr_t data;
2262 ++};
2263 ++#endif /* CONFIG_COMPAT */
2264 ++#endif /* __KERNEL__ */
2265 ++
2266 + /* ioctls
2267 + 0x46 is 'F' */
2268 + #define FBIOGET_VSCREENINFO 0x4600
2269 +@@ -35,6 +54,25 @@
2270 + #define FBIOGET_DISPINFO 0x4618
2271 + #define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
2272 +
2273 ++#define FBIOCONDECOR_SETCFG _IOWR('F', 0x19, struct fbcon_decor_iowrapper)
2274 ++#define FBIOCONDECOR_GETCFG _IOR('F', 0x1A, struct fbcon_decor_iowrapper)
2275 ++#define FBIOCONDECOR_SETSTATE _IOWR('F', 0x1B, struct fbcon_decor_iowrapper)
2276 ++#define FBIOCONDECOR_GETSTATE _IOR('F', 0x1C, struct fbcon_decor_iowrapper)
2277 ++#define FBIOCONDECOR_SETPIC _IOWR('F', 0x1D, struct fbcon_decor_iowrapper)
2278 ++#ifdef __KERNEL__
2279 ++#ifdef CONFIG_COMPAT
2280 ++#define FBIOCONDECOR_SETCFG32 _IOWR('F', 0x19, struct fbcon_decor_iowrapper32)
2281 ++#define FBIOCONDECOR_GETCFG32 _IOR('F', 0x1A, struct fbcon_decor_iowrapper32)
2282 ++#define FBIOCONDECOR_SETSTATE32 _IOWR('F', 0x1B, struct fbcon_decor_iowrapper32)
2283 ++#define FBIOCONDECOR_GETSTATE32 _IOR('F', 0x1C, struct fbcon_decor_iowrapper32)
2284 ++#define FBIOCONDECOR_SETPIC32 _IOWR('F', 0x1D, struct fbcon_decor_iowrapper32)
2285 ++#endif /* CONFIG_COMPAT */
2286 ++#endif /* __KERNEL__ */
2287 ++
2288 ++#define FBCON_DECOR_THEME_LEN 128 /* Maximum lenght of a theme name */
2289 ++#define FBCON_DECOR_IO_ORIG_KERNEL 0 /* Kernel ioctl origin */
2290 ++#define FBCON_DECOR_IO_ORIG_USER 1 /* User ioctl origin */
2291 ++
2292 + #define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */
2293 + #define FB_TYPE_PLANES 1 /* Non interleaved planes */
2294 + #define FB_TYPE_INTERLEAVED_PLANES 2 /* Interleaved planes */
2295 +@@ -277,6 +315,29 @@ struct fb_var_screeninfo {
2296 + __u32 reserved[4]; /* Reserved for future compatibility */
2297 + };
2298 +
2299 ++#ifdef __KERNEL__
2300 ++#ifdef CONFIG_COMPAT
2301 ++struct fb_cmap32 {
2302 ++ __u32 start;
2303 ++ __u32 len; /* Number of entries */
2304 ++ compat_uptr_t red; /* Red values */
2305 ++ compat_uptr_t green;
2306 ++ compat_uptr_t blue;
2307 ++ compat_uptr_t transp; /* transparency, can be NULL */
2308 ++};
2309 ++
2310 ++#define fb_cmap_from_compat(to, from) \
2311 ++ (to).start = (from).start; \
2312 ++ (to).len = (from).len; \
2313 ++ (to).red = compat_ptr((from).red); \
2314 ++ (to).green = compat_ptr((from).green); \
2315 ++ (to).blue = compat_ptr((from).blue); \
2316 ++ (to).transp = compat_ptr((from).transp)
2317 ++
2318 ++#endif /* CONFIG_COMPAT */
2319 ++#endif /* __KERNEL__ */
2320 ++
2321 ++
2322 + struct fb_cmap {
2323 + __u32 start; /* First entry */
2324 + __u32 len; /* Number of entries */
2325 +diff --git a/kernel/sysctl.c b/kernel/sysctl.c
2326 +index 74f5b58..6386ab0 100644
2327 +--- a/kernel/sysctl.c
2328 ++++ b/kernel/sysctl.c
2329 +@@ -146,6 +146,10 @@ static const int cap_last_cap = CAP_LAST_CAP;
2330 + static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
2331 + #endif
2332 +
2333 ++#ifdef CONFIG_FB_CON_DECOR
2334 ++extern char fbcon_decor_path[];
2335 ++#endif
2336 ++
2337 + #ifdef CONFIG_INOTIFY_USER
2338 + #include <linux/inotify.h>
2339 + #endif
2340 +@@ -255,6 +259,15 @@ static struct ctl_table sysctl_base_table[] = {
2341 + .mode = 0555,
2342 + .child = dev_table,
2343 + },
2344 ++#ifdef CONFIG_FB_CON_DECOR
2345 ++ {
2346 ++ .procname = "fbcondecor",
2347 ++ .data = &fbcon_decor_path,
2348 ++ .maxlen = KMOD_PATH_LEN,
2349 ++ .mode = 0644,
2350 ++ .proc_handler = &proc_dostring,
2351 ++ },
2352 ++#endif
2353 + { }
2354 + };
2355 +
2356
2357 diff --git a/5000_enable-additional-cpu-optimizations-for-gcc.patch b/5000_enable-additional-cpu-optimizations-for-gcc.patch
2358 new file mode 100644
2359 index 0000000..f7ab6f0
2360 --- /dev/null
2361 +++ b/5000_enable-additional-cpu-optimizations-for-gcc.patch
2362 @@ -0,0 +1,327 @@
2363 +This patch has been tested on and known to work with kernel versions from 3.2
2364 +up to the latest git version (pulled on 12/14/2013).
2365 +
2366 +This patch will expand the number of microarchitectures to include new
2367 +processors including: AMD K10-family, AMD Family 10h (Barcelona), AMD Family
2368 +14h (Bobcat), AMD Family 15h (Bulldozer), AMD Family 15h (Piledriver), AMD
2369 +Family 16h (Jaguar), Intel 1st Gen Core i3/i5/i7 (Nehalem), Intel 2nd Gen Core
2370 +i3/i5/i7 (Sandybridge), Intel 3rd Gen Core i3/i5/i7 (Ivybridge), and Intel 4th
2371 +Gen Core i3/i5/i7 (Haswell). It also offers the compiler the 'native' flag.
2372 +
2373 +Small but real speed increases are measurable using a make endpoint comparing
2374 +a generic kernel to one built with one of the respective microarchs.
2375 +
2376 +See the following experimental evidence supporting this statement:
2377 +https://github.com/graysky2/kernel_gcc_patch
2378 +
2379 +REQUIREMENTS
2380 +linux version >=3.15
2381 +gcc version <4.9
2382 +
2383 +---
2384 +diff -uprN a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
2385 +--- a/arch/x86/include/asm/module.h 2013-11-03 18:41:51.000000000 -0500
2386 ++++ b/arch/x86/include/asm/module.h 2013-12-15 06:21:24.351122516 -0500
2387 +@@ -15,6 +15,16 @@
2388 + #define MODULE_PROC_FAMILY "586MMX "
2389 + #elif defined CONFIG_MCORE2
2390 + #define MODULE_PROC_FAMILY "CORE2 "
2391 ++#elif defined CONFIG_MNATIVE
2392 ++#define MODULE_PROC_FAMILY "NATIVE "
2393 ++#elif defined CONFIG_MCOREI7
2394 ++#define MODULE_PROC_FAMILY "COREI7 "
2395 ++#elif defined CONFIG_MCOREI7AVX
2396 ++#define MODULE_PROC_FAMILY "COREI7AVX "
2397 ++#elif defined CONFIG_MCOREAVXI
2398 ++#define MODULE_PROC_FAMILY "COREAVXI "
2399 ++#elif defined CONFIG_MCOREAVX2
2400 ++#define MODULE_PROC_FAMILY "COREAVX2 "
2401 + #elif defined CONFIG_MATOM
2402 + #define MODULE_PROC_FAMILY "ATOM "
2403 + #elif defined CONFIG_M686
2404 +@@ -33,6 +43,18 @@
2405 + #define MODULE_PROC_FAMILY "K7 "
2406 + #elif defined CONFIG_MK8
2407 + #define MODULE_PROC_FAMILY "K8 "
2408 ++#elif defined CONFIG_MK10
2409 ++#define MODULE_PROC_FAMILY "K10 "
2410 ++#elif defined CONFIG_MBARCELONA
2411 ++#define MODULE_PROC_FAMILY "BARCELONA "
2412 ++#elif defined CONFIG_MBOBCAT
2413 ++#define MODULE_PROC_FAMILY "BOBCAT "
2414 ++#elif defined CONFIG_MBULLDOZER
2415 ++#define MODULE_PROC_FAMILY "BULLDOZER "
2416 ++#elif defined CONFIG_MPILEDRIVER
2417 ++#define MODULE_PROC_FAMILY "PILEDRIVER "
2418 ++#elif defined CONFIG_MJAGUAR
2419 ++#define MODULE_PROC_FAMILY "JAGUAR "
2420 + #elif defined CONFIG_MELAN
2421 + #define MODULE_PROC_FAMILY "ELAN "
2422 + #elif defined CONFIG_MCRUSOE
2423 +diff -uprN a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
2424 +--- a/arch/x86/Kconfig.cpu 2013-11-03 18:41:51.000000000 -0500
2425 ++++ b/arch/x86/Kconfig.cpu 2013-12-15 06:21:24.351122516 -0500
2426 +@@ -139,7 +139,7 @@ config MPENTIUM4
2427 +
2428 +
2429 + config MK6
2430 +- bool "K6/K6-II/K6-III"
2431 ++ bool "AMD K6/K6-II/K6-III"
2432 + depends on X86_32
2433 + ---help---
2434 + Select this for an AMD K6-family processor. Enables use of
2435 +@@ -147,7 +147,7 @@ config MK6
2436 + flags to GCC.
2437 +
2438 + config MK7
2439 +- bool "Athlon/Duron/K7"
2440 ++ bool "AMD Athlon/Duron/K7"
2441 + depends on X86_32
2442 + ---help---
2443 + Select this for an AMD Athlon K7-family processor. Enables use of
2444 +@@ -155,12 +155,55 @@ config MK7
2445 + flags to GCC.
2446 +
2447 + config MK8
2448 +- bool "Opteron/Athlon64/Hammer/K8"
2449 ++ bool "AMD Opteron/Athlon64/Hammer/K8"
2450 + ---help---
2451 + Select this for an AMD Opteron or Athlon64 Hammer-family processor.
2452 + Enables use of some extended instructions, and passes appropriate
2453 + optimization flags to GCC.
2454 +
2455 ++config MK10
2456 ++ bool "AMD 61xx/7x50/PhenomX3/X4/II/K10"
2457 ++ ---help---
2458 ++ Select this for an AMD 61xx Eight-Core Magny-Cours, Athlon X2 7x50,
2459 ++ Phenom X3/X4/II, Athlon II X2/X3/X4, or Turion II-family processor.
2460 ++ Enables use of some extended instructions, and passes appropriate
2461 ++ optimization flags to GCC.
2462 ++
2463 ++config MBARCELONA
2464 ++ bool "AMD Barcelona"
2465 ++ ---help---
2466 ++ Select this for AMD Barcelona and newer processors.
2467 ++
2468 ++ Enables -march=barcelona
2469 ++
2470 ++config MBOBCAT
2471 ++ bool "AMD Bobcat"
2472 ++ ---help---
2473 ++ Select this for AMD Bobcat processors.
2474 ++
2475 ++ Enables -march=btver1
2476 ++
2477 ++config MBULLDOZER
2478 ++ bool "AMD Bulldozer"
2479 ++ ---help---
2480 ++ Select this for AMD Bulldozer processors.
2481 ++
2482 ++ Enables -march=bdver1
2483 ++
2484 ++config MPILEDRIVER
2485 ++ bool "AMD Piledriver"
2486 ++ ---help---
2487 ++ Select this for AMD Piledriver processors.
2488 ++
2489 ++ Enables -march=bdver2
2490 ++
2491 ++config MJAGUAR
2492 ++ bool "AMD Jaguar"
2493 ++ ---help---
2494 ++ Select this for AMD Jaguar processors.
2495 ++
2496 ++ Enables -march=btver2
2497 ++
2498 + config MCRUSOE
2499 + bool "Crusoe"
2500 + depends on X86_32
2501 +@@ -251,8 +294,17 @@ config MPSC
2502 + using the cpu family field
2503 + in /proc/cpuinfo. Family 15 is an older Xeon, Family 6 a newer one.
2504 +
2505 ++config MATOM
2506 ++ bool "Intel Atom"
2507 ++ ---help---
2508 ++
2509 ++ Select this for the Intel Atom platform. Intel Atom CPUs have an
2510 ++ in-order pipelining architecture and thus can benefit from
2511 ++ accordingly optimized code. Use a recent GCC with specific Atom
2512 ++ support in order to fully benefit from selecting this option.
2513 ++
2514 + config MCORE2
2515 +- bool "Core 2/newer Xeon"
2516 ++ bool "Intel Core 2"
2517 + ---help---
2518 +
2519 + Select this for Intel Core 2 and newer Core 2 Xeons (Xeon 51xx and
2520 +@@ -260,14 +312,40 @@ config MCORE2
2521 + family in /proc/cpuinfo. Newer ones have 6 and older ones 15
2522 + (not a typo)
2523 +
2524 +-config MATOM
2525 +- bool "Intel Atom"
2526 ++ Enables -march=core2
2527 ++
2528 ++config MCOREI7
2529 ++ bool "Intel Core i7"
2530 + ---help---
2531 +
2532 +- Select this for the Intel Atom platform. Intel Atom CPUs have an
2533 +- in-order pipelining architecture and thus can benefit from
2534 +- accordingly optimized code. Use a recent GCC with specific Atom
2535 +- support in order to fully benefit from selecting this option.
2536 ++ Select this for the Intel Nehalem platform. Intel Nehalem proecessors
2537 ++ include Core i3, i5, i7, Xeon: 34xx, 35xx, 55xx, 56xx, 75xx processors.
2538 ++
2539 ++ Enables -march=corei7
2540 ++
2541 ++config MCOREI7AVX
2542 ++ bool "Intel Core 2nd Gen AVX"
2543 ++ ---help---
2544 ++
2545 ++ Select this for 2nd Gen Core processors including Sandy Bridge.
2546 ++
2547 ++ Enables -march=corei7-avx
2548 ++
2549 ++config MCOREAVXI
2550 ++ bool "Intel Core 3rd Gen AVX"
2551 ++ ---help---
2552 ++
2553 ++ Select this for 3rd Gen Core processors including Ivy Bridge.
2554 ++
2555 ++ Enables -march=core-avx-i
2556 ++
2557 ++config MCOREAVX2
2558 ++ bool "Intel Core AVX2"
2559 ++ ---help---
2560 ++
2561 ++ Select this for AVX2 enabled processors including Haswell.
2562 ++
2563 ++ Enables -march=core-avx2
2564 +
2565 + config GENERIC_CPU
2566 + bool "Generic-x86-64"
2567 +@@ -276,6 +354,19 @@ config GENERIC_CPU
2568 + Generic x86-64 CPU.
2569 + Run equally well on all x86-64 CPUs.
2570 +
2571 ++config MNATIVE
2572 ++ bool "Native optimizations autodetected by GCC"
2573 ++ ---help---
2574 ++
2575 ++ GCC 4.2 and above support -march=native, which automatically detects
2576 ++ the optimum settings to use based on your processor. -march=native
2577 ++ also detects and applies additional settings beyond -march specific
2578 ++ to your CPU, (eg. -msse4). Unless you have a specific reason not to
2579 ++ (e.g. distcc cross-compiling), you should probably be using
2580 ++ -march=native rather than anything listed below.
2581 ++
2582 ++ Enables -march=native
2583 ++
2584 + endchoice
2585 +
2586 + config X86_GENERIC
2587 +@@ -300,7 +391,7 @@ config X86_INTERNODE_CACHE_SHIFT
2588 + config X86_L1_CACHE_SHIFT
2589 + int
2590 + default "7" if MPENTIUM4 || MPSC
2591 +- default "6" if MK7 || MK8 || MPENTIUMM || MCORE2 || MATOM || MVIAC7 || X86_GENERIC || GENERIC_CPU
2592 ++ default "6" if MK7 || MK8 || MK10 || MBARCELONA || MBOBCAT || MBULLDOZER || MPILEDRIVER || MJAGUAR || MPENTIUMM || MCORE2 || MCOREI7 || MCOREI7AVX || MCOREAVXI || MCOREAVX2 || MATOM || MVIAC7 || X86_GENERIC || MNATIVE || GENERIC_CPU
2593 + default "4" if MELAN || M486 || MGEODEGX1
2594 + default "5" if MWINCHIP3D || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE_LX
2595 +
2596 +@@ -331,11 +422,11 @@ config X86_ALIGNMENT_16
2597 +
2598 + config X86_INTEL_USERCOPY
2599 + def_bool y
2600 +- depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK7 || MEFFICEON || MCORE2
2601 ++ depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || MNATIVE || X86_GENERIC || MK8 || MK7 || MK10 || MBARCELONA || MEFFICEON || MCORE2 || MCOREI7 || MCOREI7AVX || MCOREAVXI || MCOREAVX2
2602 +
2603 + config X86_USE_PPRO_CHECKSUM
2604 + def_bool y
2605 +- depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 || MVIAC7 || MEFFICEON || MGEODE_LX || MCORE2 || MATOM
2606 ++ depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MK10 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 || MVIAC7 || MEFFICEON || MGEODE_LX || MCORE2 || MCOREI7 || MCOREI7AVX || MCOREAVXI || MCOREAVX2 || MATOM || MNATIVE
2607 +
2608 + config X86_USE_3DNOW
2609 + def_bool y
2610 +@@ -363,17 +454,17 @@ config X86_P6_NOP
2611 +
2612 + config X86_TSC
2613 + def_bool y
2614 +- depends on (MWINCHIP3D || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MCORE2 || MATOM) || X86_64
2615 ++ depends on (MWINCHIP3D || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MK10 || MBARCELONA || MBOBCAT || MBULLDOZER || MPILEDRIVER || MJAGUAR || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MCORE2 || MCOREI7 || MCOREI7-AVX || MATOM) || X86_64 || MNATIVE
2616 +
2617 + config X86_CMPXCHG64
2618 + def_bool y
2619 +- depends on X86_PAE || X86_64 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MATOM
2620 ++ depends on X86_PAE || X86_64 || MCORE2 || MCOREI7 || MCOREI7AVX || MCOREAVXI || MCOREAVX2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MATOM || MNATIVE
2621 +
2622 + # this should be set for all -march=.. options where the compiler
2623 + # generates cmov.
2624 + config X86_CMOV
2625 + def_bool y
2626 +- depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
2627 ++ depends on (MK8 || MK10 || MBARCELONA || MBOBCAT || MBULLDOZER || MPILEDRIVER || MJAGUAR || MK7 || MCORE2 || MCOREI7 || MCOREI7AVX || MCOREAVXI || MCOREAVX2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MNATIVE || MATOM || MGEODE_LX)
2628 +
2629 + config X86_MINIMUM_CPU_FAMILY
2630 + int
2631 +diff -uprN a/arch/x86/Makefile b/arch/x86/Makefile
2632 +--- a/arch/x86/Makefile 2013-11-03 18:41:51.000000000 -0500
2633 ++++ b/arch/x86/Makefile 2013-12-15 06:21:24.354455723 -0500
2634 +@@ -61,11 +61,26 @@ else
2635 + KBUILD_CFLAGS += $(call cc-option,-mno-sse -mpreferred-stack-boundary=3)
2636 +
2637 + # FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu)
2638 ++ cflags-$(CONFIG_MNATIVE) += $(call cc-option,-march=native)
2639 + cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
2640 ++ cflags-$(CONFIG_MK10) += $(call cc-option,-march=amdfam10)
2641 ++ cflags-$(CONFIG_MBARCELONA) += $(call cc-option,-march=barcelona)
2642 ++ cflags-$(CONFIG_MBOBCAT) += $(call cc-option,-march=btver1)
2643 ++ cflags-$(CONFIG_MBULLDOZER) += $(call cc-option,-march=bdver1)
2644 ++ cflags-$(CONFIG_MPILEDRIVER) += $(call cc-option,-march=bdver2)
2645 ++ cflags-$(CONFIG_MJAGUAR) += $(call cc-option,-march=btver2)
2646 + cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
2647 +
2648 + cflags-$(CONFIG_MCORE2) += \
2649 +- $(call cc-option,-march=core2,$(call cc-option,-mtune=generic))
2650 ++ $(call cc-option,-march=core2,$(call cc-option,-mtune=core2))
2651 ++ cflags-$(CONFIG_MCOREI7) += \
2652 ++ $(call cc-option,-march=corei7,$(call cc-option,-mtune=corei7))
2653 ++ cflags-$(CONFIG_MCOREI7AVX) += \
2654 ++ $(call cc-option,-march=corei7-avx,$(call cc-option,-mtune=corei7-avx))
2655 ++ cflags-$(CONFIG_MCOREAVXI) += \
2656 ++ $(call cc-option,-march=core-avx-i,$(call cc-option,-mtune=core-avx-i))
2657 ++ cflags-$(CONFIG_MCOREAVX2) += \
2658 ++ $(call cc-option,-march=core-avx2,$(call cc-option,-mtune=core-avx2))
2659 + cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom) \
2660 + $(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
2661 + cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
2662 +diff -uprN a/arch/x86/Makefile_32.cpu b/arch/x86/Makefile_32.cpu
2663 +--- a/arch/x86/Makefile_32.cpu 2013-11-03 18:41:51.000000000 -0500
2664 ++++ b/arch/x86/Makefile_32.cpu 2013-12-15 06:21:24.354455723 -0500
2665 +@@ -23,7 +23,14 @@ cflags-$(CONFIG_MK6) += -march=k6
2666 + # Please note, that patches that add -march=athlon-xp and friends are pointless.
2667 + # They make zero difference whatsosever to performance at this time.
2668 + cflags-$(CONFIG_MK7) += -march=athlon
2669 ++cflags-$(CONFIG_MNATIVE) += $(call cc-option,-march=native)
2670 + cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8,-march=athlon)
2671 ++cflags-$(CONFIG_MK10) += $(call cc-option,-march=amdfam10,-march=athlon)
2672 ++cflags-$(CONFIG_MBARCELONA) += $(call cc-option,-march=barcelona,-march=athlon)
2673 ++cflags-$(CONFIG_MBOBCAT) += $(call cc-option,-march=btver1,-march=athlon)
2674 ++cflags-$(CONFIG_MBULLDOZER) += $(call cc-option,-march=bdver1,-march=athlon)
2675 ++cflags-$(CONFIG_MPILEDRIVER) += $(call cc-option,-march=bdver2,-march=athlon)
2676 ++cflags-$(CONFIG_MJAGUAR) += $(call cc-option,-march=btver2,-march=athlon)
2677 + cflags-$(CONFIG_MCRUSOE) += -march=i686 $(align)-functions=0 $(align)-jumps=0 $(align)-loops=0
2678 + cflags-$(CONFIG_MEFFICEON) += -march=i686 $(call tune,pentium3) $(align)-functions=0 $(align)-jumps=0 $(align)-loops=0
2679 + cflags-$(CONFIG_MWINCHIPC6) += $(call cc-option,-march=winchip-c6,-march=i586)
2680 +@@ -32,6 +39,10 @@ cflags-$(CONFIG_MCYRIXIII) += $(call cc-
2681 + cflags-$(CONFIG_MVIAC3_2) += $(call cc-option,-march=c3-2,-march=i686)
2682 + cflags-$(CONFIG_MVIAC7) += -march=i686
2683 + cflags-$(CONFIG_MCORE2) += -march=i686 $(call tune,core2)
2684 ++cflags-$(CONFIG_MCOREI7) += -march=i686 $(call tune,corei7)
2685 ++cflags-$(CONFIG_MCOREI7AVX) += -march=i686 $(call tune,corei7-avx)
2686 ++cflags-$(CONFIG_MCOREAVXI) += -march=i686 $(call tune,core-avx-i)
2687 ++cflags-$(CONFIG_MCOREAVX2) += -march=i686 $(call tune,core-avx2)
2688 + cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom,$(call cc-option,-march=core2,-march=i686)) \
2689 + $(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
2690
2691 diff --git a/5010_enable-additional-cpu-optimizations-for-gcc-4.9.patch b/5010_enable-additional-cpu-optimizations-for-gcc-4.9.patch
2692 new file mode 100644
2693 index 0000000..f931f75
2694 --- /dev/null
2695 +++ b/5010_enable-additional-cpu-optimizations-for-gcc-4.9.patch
2696 @@ -0,0 +1,387 @@
2697 +WARNING - this version of the patch works with version 4.9+ of gcc and with
2698 +kernel version 3.15.x+ and should NOT be applied when compiling on older
2699 +versions due to name changes of the flags with the 4.9 release of gcc.
2700 +Use the older version of this patch hosted on the same github for older
2701 +versions of gcc. For example:
2702 +
2703 +corei7 --> nehalem
2704 +corei7-avx --> sandybridge
2705 +core-avx-i --> ivybridge
2706 +core-avx2 --> haswell
2707 +
2708 +For more, see: https://gcc.gnu.org/gcc-4.9/changes.html
2709 +
2710 +It also changes 'atom' to 'bonnell' in accordance with the gcc v4.9 changes.
2711 +Note that upstream is using the deprecated 'match=atom' flags when I believe it
2712 +should use the newer 'march=bonnell' flag for atom processors.
2713 +
2714 +I have made that change to this patch set as well. See the following kernel
2715 +bug report to see if I'm right: https://bugzilla.kernel.org/show_bug.cgi?id=77461
2716 +
2717 +This patch will expand the number of microarchitectures to include new
2718 +processors including: AMD K10-family, AMD Family 10h (Barcelona), AMD Family
2719 +14h (Bobcat), AMD Family 15h (Bulldozer), AMD Family 15h (Piledriver), AMD
2720 +Family 16h (Jaguar), Intel 1st Gen Core i3/i5/i7 (Nehalem), Intel 1.5 Gen Core
2721 +i3/i5/i7 (Westmere), Intel 2nd Gen Core i3/i5/i7 (Sandybridge), Intel 3rd Gen
2722 +Core i3/i5/i7 (Ivybridge), Intel 4th Gen Core i3/i5/i7 (Haswell), and Intel 5th
2723 +Gen Core i3/i5/i7 (Broadwell). It also offers the compiler the 'native' flag.
2724 +
2725 +Small but real speed increases are measurable using a make endpoint comparing
2726 +a generic kernel to one built with one of the respective microarchs.
2727 +
2728 +See the following experimental evidence supporting this statement:
2729 +https://github.com/graysky2/kernel_gcc_patch
2730 +
2731 +REQUIREMENTS
2732 +linux version >=3.15
2733 +gcc version >=4.9
2734 +
2735 +--- a/arch/x86/include/asm/module.h 2014-08-03 18:25:02.000000000 -0400
2736 ++++ b/arch/x86/include/asm/module.h 2014-09-13 09:37:16.721385247 -0400
2737 +@@ -15,6 +15,20 @@
2738 + #define MODULE_PROC_FAMILY "586MMX "
2739 + #elif defined CONFIG_MCORE2
2740 + #define MODULE_PROC_FAMILY "CORE2 "
2741 ++#elif defined CONFIG_MNATIVE
2742 ++#define MODULE_PROC_FAMILY "NATIVE "
2743 ++#elif defined CONFIG_MNEHALEM
2744 ++#define MODULE_PROC_FAMILY "NEHALEM "
2745 ++#elif defined CONFIG_MWESTMERE
2746 ++#define MODULE_PROC_FAMILY "WESTMERE "
2747 ++#elif defined CONFIG_MSANDYBRIDGE
2748 ++#define MODULE_PROC_FAMILY "SANDYBRIDGE "
2749 ++#elif defined CONFIG_MIVYBRIDGE
2750 ++#define MODULE_PROC_FAMILY "IVYBRIDGE "
2751 ++#elif defined CONFIG_MHASWELL
2752 ++#define MODULE_PROC_FAMILY "HASWELL "
2753 ++#elif defined CONFIG_MBROADWELL
2754 ++#define MODULE_PROC_FAMILY "BROADWELL "
2755 + #elif defined CONFIG_MATOM
2756 + #define MODULE_PROC_FAMILY "ATOM "
2757 + #elif defined CONFIG_M686
2758 +@@ -33,6 +47,20 @@
2759 + #define MODULE_PROC_FAMILY "K7 "
2760 + #elif defined CONFIG_MK8
2761 + #define MODULE_PROC_FAMILY "K8 "
2762 ++#elif defined CONFIG_MK8SSE3
2763 ++#define MODULE_PROC_FAMILY "K8SSE3 "
2764 ++#elif defined CONFIG_MK10
2765 ++#define MODULE_PROC_FAMILY "K10 "
2766 ++#elif defined CONFIG_MBARCELONA
2767 ++#define MODULE_PROC_FAMILY "BARCELONA "
2768 ++#elif defined CONFIG_MBOBCAT
2769 ++#define MODULE_PROC_FAMILY "BOBCAT "
2770 ++#elif defined CONFIG_MBULLDOZER
2771 ++#define MODULE_PROC_FAMILY "BULLDOZER "
2772 ++#elif defined CONFIG_MPILEDRIVER
2773 ++#define MODULE_PROC_FAMILY "PILEDRIVER "
2774 ++#elif defined CONFIG_MJAGUAR
2775 ++#define MODULE_PROC_FAMILY "JAGUAR "
2776 + #elif defined CONFIG_MELAN
2777 + #define MODULE_PROC_FAMILY "ELAN "
2778 + #elif defined CONFIG_MCRUSOE
2779 +--- a/arch/x86/Kconfig.cpu 2014-08-03 18:25:02.000000000 -0400
2780 ++++ b/arch/x86/Kconfig.cpu 2014-09-13 09:37:16.721385247 -0400
2781 +@@ -137,9 +137,8 @@ config MPENTIUM4
2782 + -Paxville
2783 + -Dempsey
2784 +
2785 +-
2786 + config MK6
2787 +- bool "K6/K6-II/K6-III"
2788 ++ bool "AMD K6/K6-II/K6-III"
2789 + depends on X86_32
2790 + ---help---
2791 + Select this for an AMD K6-family processor. Enables use of
2792 +@@ -147,7 +146,7 @@ config MK6
2793 + flags to GCC.
2794 +
2795 + config MK7
2796 +- bool "Athlon/Duron/K7"
2797 ++ bool "AMD Athlon/Duron/K7"
2798 + depends on X86_32
2799 + ---help---
2800 + Select this for an AMD Athlon K7-family processor. Enables use of
2801 +@@ -155,12 +154,62 @@ config MK7
2802 + flags to GCC.
2803 +
2804 + config MK8
2805 +- bool "Opteron/Athlon64/Hammer/K8"
2806 ++ bool "AMD Opteron/Athlon64/Hammer/K8"
2807 + ---help---
2808 + Select this for an AMD Opteron or Athlon64 Hammer-family processor.
2809 + Enables use of some extended instructions, and passes appropriate
2810 + optimization flags to GCC.
2811 +
2812 ++config MK8SSE3
2813 ++ bool "AMD Opteron/Athlon64/Hammer/K8 with SSE3"
2814 ++ ---help---
2815 ++ Select this for improved AMD Opteron or Athlon64 Hammer-family processors.
2816 ++ Enables use of some extended instructions, and passes appropriate
2817 ++ optimization flags to GCC.
2818 ++
2819 ++config MK10
2820 ++ bool "AMD 61xx/7x50/PhenomX3/X4/II/K10"
2821 ++ ---help---
2822 ++ Select this for an AMD 61xx Eight-Core Magny-Cours, Athlon X2 7x50,
2823 ++ Phenom X3/X4/II, Athlon II X2/X3/X4, or Turion II-family processor.
2824 ++ Enables use of some extended instructions, and passes appropriate
2825 ++ optimization flags to GCC.
2826 ++
2827 ++config MBARCELONA
2828 ++ bool "AMD Barcelona"
2829 ++ ---help---
2830 ++ Select this for AMD Barcelona and newer processors.
2831 ++
2832 ++ Enables -march=barcelona
2833 ++
2834 ++config MBOBCAT
2835 ++ bool "AMD Bobcat"
2836 ++ ---help---
2837 ++ Select this for AMD Bobcat processors.
2838 ++
2839 ++ Enables -march=btver1
2840 ++
2841 ++config MBULLDOZER
2842 ++ bool "AMD Bulldozer"
2843 ++ ---help---
2844 ++ Select this for AMD Bulldozer processors.
2845 ++
2846 ++ Enables -march=bdver1
2847 ++
2848 ++config MPILEDRIVER
2849 ++ bool "AMD Piledriver"
2850 ++ ---help---
2851 ++ Select this for AMD Piledriver processors.
2852 ++
2853 ++ Enables -march=bdver2
2854 ++
2855 ++config MJAGUAR
2856 ++ bool "AMD Jaguar"
2857 ++ ---help---
2858 ++ Select this for AMD Jaguar processors.
2859 ++
2860 ++ Enables -march=btver2
2861 ++
2862 + config MCRUSOE
2863 + bool "Crusoe"
2864 + depends on X86_32
2865 +@@ -251,8 +300,17 @@ config MPSC
2866 + using the cpu family field
2867 + in /proc/cpuinfo. Family 15 is an older Xeon, Family 6 a newer one.
2868 +
2869 ++config MATOM
2870 ++ bool "Intel Atom"
2871 ++ ---help---
2872 ++
2873 ++ Select this for the Intel Atom platform. Intel Atom CPUs have an
2874 ++ in-order pipelining architecture and thus can benefit from
2875 ++ accordingly optimized code. Use a recent GCC with specific Atom
2876 ++ support in order to fully benefit from selecting this option.
2877 ++
2878 + config MCORE2
2879 +- bool "Core 2/newer Xeon"
2880 ++ bool "Intel Core 2"
2881 + ---help---
2882 +
2883 + Select this for Intel Core 2 and newer Core 2 Xeons (Xeon 51xx and
2884 +@@ -260,14 +318,55 @@ config MCORE2
2885 + family in /proc/cpuinfo. Newer ones have 6 and older ones 15
2886 + (not a typo)
2887 +
2888 +-config MATOM
2889 +- bool "Intel Atom"
2890 ++ Enables -march=core2
2891 ++
2892 ++config MNEHALEM
2893 ++ bool "Intel Nehalem"
2894 + ---help---
2895 +
2896 +- Select this for the Intel Atom platform. Intel Atom CPUs have an
2897 +- in-order pipelining architecture and thus can benefit from
2898 +- accordingly optimized code. Use a recent GCC with specific Atom
2899 +- support in order to fully benefit from selecting this option.
2900 ++ Select this for 1st Gen Core processors in the Nehalem family.
2901 ++
2902 ++ Enables -march=nehalem
2903 ++
2904 ++config MWESTMERE
2905 ++ bool "Intel Westmere"
2906 ++ ---help---
2907 ++
2908 ++ Select this for the Intel Westmere formerly Nehalem-C family.
2909 ++
2910 ++ Enables -march=westmere
2911 ++
2912 ++config MSANDYBRIDGE
2913 ++ bool "Intel Sandy Bridge"
2914 ++ ---help---
2915 ++
2916 ++ Select this for 2nd Gen Core processors in the Sandy Bridge family.
2917 ++
2918 ++ Enables -march=sandybridge
2919 ++
2920 ++config MIVYBRIDGE
2921 ++ bool "Intel Ivy Bridge"
2922 ++ ---help---
2923 ++
2924 ++ Select this for 3rd Gen Core processors in the Ivy Bridge family.
2925 ++
2926 ++ Enables -march=ivybridge
2927 ++
2928 ++config MHASWELL
2929 ++ bool "Intel Haswell"
2930 ++ ---help---
2931 ++
2932 ++ Select this for 4th Gen Core processors in the Haswell family.
2933 ++
2934 ++ Enables -march=haswell
2935 ++
2936 ++config MBROADWELL
2937 ++ bool "Intel Broadwell"
2938 ++ ---help---
2939 ++
2940 ++ Select this for 5th Gen Core processors in the Broadwell family.
2941 ++
2942 ++ Enables -march=broadwell
2943 +
2944 + config GENERIC_CPU
2945 + bool "Generic-x86-64"
2946 +@@ -276,6 +375,19 @@ config GENERIC_CPU
2947 + Generic x86-64 CPU.
2948 + Run equally well on all x86-64 CPUs.
2949 +
2950 ++config MNATIVE
2951 ++ bool "Native optimizations autodetected by GCC"
2952 ++ ---help---
2953 ++
2954 ++ GCC 4.2 and above support -march=native, which automatically detects
2955 ++ the optimum settings to use based on your processor. -march=native
2956 ++ also detects and applies additional settings beyond -march specific
2957 ++ to your CPU, (eg. -msse4). Unless you have a specific reason not to
2958 ++ (e.g. distcc cross-compiling), you should probably be using
2959 ++ -march=native rather than anything listed below.
2960 ++
2961 ++ Enables -march=native
2962 ++
2963 + endchoice
2964 +
2965 + config X86_GENERIC
2966 +@@ -300,7 +412,7 @@ config X86_INTERNODE_CACHE_SHIFT
2967 + config X86_L1_CACHE_SHIFT
2968 + int
2969 + default "7" if MPENTIUM4 || MPSC
2970 +- default "6" if MK7 || MK8 || MPENTIUMM || MCORE2 || MATOM || MVIAC7 || X86_GENERIC || GENERIC_CPU
2971 ++ default "6" if MK7 || MK8 || MK8SSE3 || MK10 || MBARCELONA || MBOBCAT || MBULLDOZER || MPILEDRIVER || MJAGUAR || MPENTIUMM || MCORE2 || MNEHALEM || MWESTMERE || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || BROADWELL || MNATIVE || MATOM || MVIAC7 || X86_GENERIC || GENERIC_CPU
2972 + default "4" if MELAN || M486 || MGEODEGX1
2973 + default "5" if MWINCHIP3D || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE_LX
2974 +
2975 +@@ -331,11 +443,11 @@ config X86_ALIGNMENT_16
2976 +
2977 + config X86_INTEL_USERCOPY
2978 + def_bool y
2979 +- depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK7 || MEFFICEON || MCORE2
2980 ++ depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK8SSE3 || MK7 || MEFFICEON || MCORE2 || MK10 || MBARCELONA || MNEHALEM || MWESTMERE || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MNATIVE
2981 +
2982 + config X86_USE_PPRO_CHECKSUM
2983 + def_bool y
2984 +- depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 || MVIAC7 || MEFFICEON || MGEODE_LX || MCORE2 || MATOM
2985 ++ depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MK10 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MK8SSE3 || MVIAC3_2 || MVIAC7 || MEFFICEON || MGEODE_LX || MCORE2 || MNEHALEM || MWESTMERE || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MATOM || MNATIVE
2986 +
2987 + config X86_USE_3DNOW
2988 + def_bool y
2989 +@@ -359,17 +471,17 @@ config X86_P6_NOP
2990 +
2991 + config X86_TSC
2992 + def_bool y
2993 +- depends on (MWINCHIP3D || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MCORE2 || MATOM) || X86_64
2994 ++ depends on (MWINCHIP3D || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MK8SSE3 || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MCORE2 || MNEHALEM || MWESTMERE || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MNATIVE || MATOM) || X86_64
2995 +
2996 + config X86_CMPXCHG64
2997 + def_bool y
2998 +- depends on X86_PAE || X86_64 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MATOM
2999 ++ depends on X86_PAE || X86_64 || MCORE2 || MNEHALEM || MWESTMERE || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MATOM || MNATIVE
3000 +
3001 + # this should be set for all -march=.. options where the compiler
3002 + # generates cmov.
3003 + config X86_CMOV
3004 + def_bool y
3005 +- depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
3006 ++ depends on (MK8 || MK8SSE3 || MK10 || MBARCELONA || MBOBCAT || MBULLDOZER || MPILEDRIVER || MJAGUAR || MK7 || MCORE2 || MNEHALEM || MWESTMERE || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MNATIVE || MATOM || MGEODE_LX)
3007 +
3008 + config X86_MINIMUM_CPU_FAMILY
3009 + int
3010 +--- a/arch/x86/Makefile 2014-08-03 18:25:02.000000000 -0400
3011 ++++ b/arch/x86/Makefile 2014-09-13 09:37:16.721385247 -0400
3012 +@@ -92,13 +92,33 @@ else
3013 + KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=3)
3014 +
3015 + # FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu)
3016 ++ cflags-$(CONFIG_MNATIVE) += $(call cc-option,-march=native)
3017 + cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
3018 ++ cflags-$(CONFIG_MK8SSE3) += $(call cc-option,-march=k8-sse3,-mtune=k8)
3019 ++ cflags-$(CONFIG_MK10) += $(call cc-option,-march=amdfam10)
3020 ++ cflags-$(CONFIG_MBARCELONA) += $(call cc-option,-march=barcelona)
3021 ++ cflags-$(CONFIG_MBOBCAT) += $(call cc-option,-march=btver1)
3022 ++ cflags-$(CONFIG_MBULLDOZER) += $(call cc-option,-march=bdver1)
3023 ++ cflags-$(CONFIG_MPILEDRIVER) += $(call cc-option,-march=bdver2)
3024 ++ cflags-$(CONFIG_MJAGUAR) += $(call cc-option,-march=btver2)
3025 + cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
3026 +
3027 + cflags-$(CONFIG_MCORE2) += \
3028 +- $(call cc-option,-march=core2,$(call cc-option,-mtune=generic))
3029 +- cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom) \
3030 +- $(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
3031 ++ $(call cc-option,-march=core2,$(call cc-option,-mtune=core2))
3032 ++ cflags-$(CONFIG_MNEHALEM) += \
3033 ++ $(call cc-option,-march=nehalem,$(call cc-option,-mtune=nehalem))
3034 ++ cflags-$(CONFIG_MWESTMERE) += \
3035 ++ $(call cc-option,-march=westmere,$(call cc-option,-mtune=westmere))
3036 ++ cflags-$(CONFIG_MSANDYBRIDGE) += \
3037 ++ $(call cc-option,-march=sandybridge,$(call cc-option,-mtune=sandybridge))
3038 ++ cflags-$(CONFIG_MIVYBRIDGE) += \
3039 ++ $(call cc-option,-march=ivybridge,$(call cc-option,-mtune=ivybridge))
3040 ++ cflags-$(CONFIG_MHASWELL) += \
3041 ++ $(call cc-option,-march=haswell,$(call cc-option,-mtune=haswell))
3042 ++ cflags-$(CONFIG_MBROADWELL) += \
3043 ++ $(call cc-option,-march=broadwell,$(call cc-option,-mtune=broadwell))
3044 ++ cflags-$(CONFIG_MATOM) += $(call cc-option,-march=bonnell) \
3045 ++ $(call cc-option,-mtune=bonnell,$(call cc-option,-mtune=generic))
3046 + cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
3047 + KBUILD_CFLAGS += $(cflags-y)
3048 +
3049 +--- a/arch/x86/Makefile_32.cpu 2014-08-03 18:25:02.000000000 -0400
3050 ++++ b/arch/x86/Makefile_32.cpu 2014-09-13 09:37:16.721385247 -0400
3051 +@@ -23,7 +23,15 @@ cflags-$(CONFIG_MK6) += -march=k6
3052 + # Please note, that patches that add -march=athlon-xp and friends are pointless.
3053 + # They make zero difference whatsosever to performance at this time.
3054 + cflags-$(CONFIG_MK7) += -march=athlon
3055 ++cflags-$(CONFIG_MNATIVE) += $(call cc-option,-march=native)
3056 + cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8,-march=athlon)
3057 ++cflags-$(CONFIG_MK8SSE3) += $(call cc-option,-march=k8-sse3,-march=athlon)
3058 ++cflags-$(CONFIG_MK10) += $(call cc-option,-march=amdfam10,-march=athlon)
3059 ++cflags-$(CONFIG_MBARCELONA) += $(call cc-option,-march=barcelona,-march=athlon)
3060 ++cflags-$(CONFIG_MBOBCAT) += $(call cc-option,-march=btver1,-march=athlon)
3061 ++cflags-$(CONFIG_MBULLDOZER) += $(call cc-option,-march=bdver1,-march=athlon)
3062 ++cflags-$(CONFIG_MPILEDRIVER) += $(call cc-option,-march=bdver2,-march=athlon)
3063 ++cflags-$(CONFIG_MJAGUAR) += $(call cc-option,-march=btver2,-march=athlon)
3064 + cflags-$(CONFIG_MCRUSOE) += -march=i686 $(align)-functions=0 $(align)-jumps=0 $(align)-loops=0
3065 + cflags-$(CONFIG_MEFFICEON) += -march=i686 $(call tune,pentium3) $(align)-functions=0 $(align)-jumps=0 $(align)-loops=0
3066 + cflags-$(CONFIG_MWINCHIPC6) += $(call cc-option,-march=winchip-c6,-march=i586)
3067 +@@ -32,8 +40,14 @@ cflags-$(CONFIG_MCYRIXIII) += $(call cc-
3068 + cflags-$(CONFIG_MVIAC3_2) += $(call cc-option,-march=c3-2,-march=i686)
3069 + cflags-$(CONFIG_MVIAC7) += -march=i686
3070 + cflags-$(CONFIG_MCORE2) += -march=i686 $(call tune,core2)
3071 +-cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom,$(call cc-option,-march=core2,-march=i686)) \
3072 +- $(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
3073 ++cflags-$(CONFIG_MNEHALEM) += -march=i686 $(call tune,nehalem)
3074 ++cflags-$(CONFIG_MWESTMERE) += -march=i686 $(call tune,westmere)
3075 ++cflags-$(CONFIG_MSANDYBRIDGE) += -march=i686 $(call tune,sandybridge)
3076 ++cflags-$(CONFIG_MIVYBRIDGE) += -march=i686 $(call tune,ivybridge)
3077 ++cflags-$(CONFIG_MHASWELL) += -march=i686 $(call tune,haswell)
3078 ++cflags-$(CONFIG_MBROADWELL) += -march=i686 $(call tune,broadwell)
3079 ++cflags-$(CONFIG_MATOM) += $(call cc-option,-march=bonnell,$(call cc-option,-march=core2,-march=i686)) \
3080 ++ $(call cc-option,-mtune=bonnell,$(call cc-option,-mtune=generic))
3081 +
3082 + # AMD Elan support
3083 + cflags-$(CONFIG_MELAN) += -march=i486