[adm5120] add button devices to several boards
[openwrt.git] / target / linux / generic-2.6 / patches-2.6.22 / 014-x86_newsetup.patch
1 GIT 1783e2f0f21444020e3dee1be46b1e34af0ea3e7 git+ssh://master.kernel.org/pub/scm/linux/kernel/git/hpa/linux-2.6-newsetup.git
2
3 commit 1783e2f0f21444020e3dee1be46b1e34af0ea3e7
4 Author: Venki Pallipadi <venkatesh.pallipadi@intel.com>
5 Date: Wed Jun 20 14:12:39 2007 -0700
6
7 Use a new CPU feature word to cover all Intel features that are spread around
8
9 in different CPUID leafs like 0x5, 0x6 and 0xA. Make this
10 feature detection code common across i386 and x86_64.
11
12 Display Intel Dynamic Acceleration feature in /proc/cpuinfo. This feature
13 will be enabled automatically by current acpi-cpufreq driver.
14
15 Refer to Intel Software Developer's Manual for more details about the feature.
16
17 Thanks to hpa (H Peter Anvin) for the making the actual code detecting the
18 scattered features data-driven.
19
20 Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
21 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
22
23 commit cd19eb67cd6636a4e5c9df99631422c7c7286f59
24 Author: H. Peter Anvin <hpa@zytor.com>
25 Date: Wed Jun 20 14:33:17 2007 -0700
26
27 x86 setup: move __bss_start into the .bss segment
28
29 Move __bss_start into the .bss segment, and create __bss_end.
30
31 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
32
33 commit 100327ad6b609cd28970219be57d293847d1261d
34 Author: H. Peter Anvin <hpa@zytor.com>
35 Date: Wed Jun 6 22:07:01 2007 -0700
36
37 x86 setup: remove TSC as a required feature
38
39 Remove TSC as a required feature, in anticipation of CONFIG_X86_TSC
40 removal.
41
42 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
43
44 commit 7c91a172b8af7d4ba087f1f88ed5b155ed459ca3
45 Author: Antonino A. Daplas <adaplas@gmail.com>
46 Date: Tue Jun 5 19:21:05 2007 +0800
47
48 i386: Set 6-bit DAC channel properties in vesa video setup
49
50 If the video BIOS is not capable of switching or failed to switch the
51 hardware to 8-bit DAC, the channel properties are not set. This leads
52 to a blank (all black) display with vesafb at 8 bpp. Fix by defaulting
53 to a 6-bit DAC.
54
55 Signed-off-by: Antonino Daplas <adaplas@gmail.com>
56 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
57
58 commit 6eac2d442de8d87eac94a4ca8600bd87219fa06b
59 Author: H. Peter Anvin <hpa@zytor.com>
60 Date: Tue Jun 5 16:19:36 2007 -0700
61
62 x86 setup: arch/i386/boot/cpucheck.c whitespace cleanup
63
64 Remove stealth whitespace
65
66 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
67
68 commit f7d89f05a30433034a1b4651143afdbb2a8a9c92
69 Author: H. Peter Anvin <hpa@zytor.com>
70 Date: Thu May 24 16:56:44 2007 -0700
71
72 hd.c: remove BIOS/CMOS queries
73
74 An ST-506 disk these days is pretty much someone trying to pull ancient
75 data using an auxilliary controller. Pulling data from the BIOS or CMOS
76 is just plain wrong, since it's likely to be the primary OS disk... and
77 would be user-entered data anyway. Instead, require the user enters it
78 on the command line.
79
80 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
81
82 commit 14c2fdb3bbfd6a9a774980e446c2443150749891
83 Author: H. Peter Anvin <hpa@zytor.com>
84 Date: Thu May 24 15:25:10 2007 -0700
85
86 x86: add back pbe bit to visible CPUID flags
87
88 Add pbe back to the visible CPUID flags. We *do* correctly filter abuses
89 of this bit for 3DNow! in all the appropriate paths.
90
91 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
92
93 commit e071b068a3b9f318be314f0378e655e2eb50ac89
94 Author: H. Peter Anvin <hpa@zytor.com>
95 Date: Wed May 23 14:52:34 2007 -0700
96
97 x86 setup: VIA feature mask MSR doesn't just apply to model <= 9
98
99 The VIA feature mask MSR is known to be present on model 10, and it
100 seems likely it will continue to be supported. Since we only touch the
101 MSR if we're about to print an error message anyway, go ahead and be
102 aggressive.
103
104 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
105
106 commit abe0c5aa1827932cda9c754a3842ec22b278d704
107 Author: H. Peter Anvin <hpa@zytor.com>
108 Date: Tue May 22 17:17:41 2007 -0700
109
110 x86 setup: correct inline assembly constraints in edd.c
111
112 Fix the inline assembly constraints in edd.c. In particular, "driveno"
113 was getting clobbered on some (buggy?) BIOSes.
114
115 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
116
117 commit c2e5887ad275aab90673a3e33344f09946159cf7
118 Author: H. Peter Anvin <hpa@zytor.com>
119 Date: Fri May 18 10:02:55 2007 -0700
120
121 x86 setup: force the assembler to generate a 2-byte jump in header
122
123 The jump instruction in the header only has two bytes available, so
124 it *better* be a 2-byte jump! Unfortunately, the assembler will
125 always generate a 3/5-byte jump when the target is in a different
126 section. Deal with that by generating the jump instruction
127 explicitly from .byte's, just like we do elsewhere when we need a
128 specific binary representation of a certain instruction.
129
130 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
131
132 commit ce82e3b93eba48b6852822a03efa73c74e165d4f
133 Author: H. Peter Anvin <hpa@zytor.com>
134 Date: Thu May 17 15:44:48 2007 -0700
135
136 x86 setup: move the symbol start_of_setup into the proper section.
137
138 start_of_setup is the beginning of the executable code and should be
139 located in the appropriate section.
140
141 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
142
143 commit e5f3a529457a5bfaf8f8783fb86013221279a81c
144 Author: H. Peter Anvin <hpa@zytor.com>
145 Date: Thu May 17 15:43:19 2007 -0700
146
147 x86 setup: add an ASSERT that the header ends up in the right place
148
149 Just in case we have funnies involving the linker or people putting
150 inappropriate align statements, make the linker abort if the setup
151 header ends up in the wrong place.
152
153 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
154
155 commit d9dbde725687ab99d1f529f49f14d1e280cc5cac
156 Author: Alexander van Heukelum <heukelum@mailshack.com>
157 Date: Thu May 17 20:54:25 2007 +0200
158
159 x86 new setup: use appropriate sections for code and data
160
161 An intermediate elf file is generated for the 16-bit setup code.
162 The generated code can be viewed using objdump -m i8086 -d. As it
163 stands, it also tries to disassemble the bugger_off_msg, which
164 results in garbage. This introduces two new sections to separate
165 the code and the data part of the bootsector stub. It also moves
166 some code from the .header section (a data section) to .inittext.
167
168 Signed-off-by: Alexander van Heukelum <heukelum@mailshack.com>
169
170 commit 0d7558a81cf61e9fd2332a54897c5fd18df0d7f2
171 Author: H. Peter Anvin <hpa@zytor.com>
172 Date: Wed May 16 22:03:16 2007 -0700
173
174 x86 setup: use -include code16gcc.h instead of explicit #include
175
176 Use -include in the Makefile instead of #include to include code16gcc.h.
177 This really is more of a compiler switch than anything else, and is a lot
178 cleaner to do implicitly.
179
180 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
181
182 commit 017ce54e8a4a9628a76d6b510c7309a7e4e111a8
183 Author: H. Peter Anvin <hpa@zytor.com>
184 Date: Wed May 16 18:48:06 2007 -0700
185
186 x86 setup: enable features on Centaur (VIA) and Transmeta processors
187
188 AMD are not the only ones who sometimes mask features which the kernel
189 may very well depend on. VIA and Transmeta do, too. Add code to enable
190 these features during checking.
191
192 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
193
194 commit b794f5f9c5089709f3df38c6d91869fa38a9c1a4
195 Author: H. Peter Anvin <hpa@zytor.com>
196 Date: Wed May 16 16:37:47 2007 -0700
197
198 x86 setup: in older versions of ld, ASSERT() is an expression
199
200 Older versions of ld (pre-2.15 or so) need:
201
202 . = ASSERT(foo, "msg");
203
204 instead of:
205
206 ASSERT(foo, "msg")
207
208 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
209
210 commit 21c2b7c99c417d07015ee8e516a634ec3d98c4ee
211 Author: H. Peter Anvin <hpa@zytor.com>
212 Date: Wed May 16 10:52:41 2007 -0700
213
214 x86 setup: print a warning message if the bootloader gave us no heap.
215
216 If the bootloader is so old it doesn't set the CAN_USE_HEAP flag,
217 a lot of functionality will by necessity be disabled, so print a
218 warning message. This means either a 2.00 protocol bootloader or
219 a buggy bootloader; the Qemu bootloader falls in this category.
220
221 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
222
223 commit 52ca0431390d389a2a2246f02fe652ea84c1ddd8
224 Author: H. Peter Anvin <hpa@zytor.com>
225 Date: Wed May 16 10:51:03 2007 -0700
226
227 x86 setup: rely on a compiled-in default for load high/load low
228
229 When deciding if we should move the kernel from 0x10000 to 0x1000, as
230 is required for a zImage kernel, rely on a compiled-in default since
231 Qemu unconditionally zeroes the loadflags. This, of course, is a bug
232 in Qemu, but still...
233
234 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
235
236 commit 4db77a97793104a32e5fb83e62b943fa144b329d
237 Author: H. Peter Anvin <hpa@zytor.com>
238 Date: Wed May 16 08:45:37 2007 -0700
239
240 x86 setup: correct assembly constraints.
241
242 Double use of "d" in an asm() constraints; most gcc versions correctly
243 detect and avoid using it, but some version of gcc runs itself into
244 a brick wall instead. Fix the one "d" which should have been "a".
245
246 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
247
248 commit 4fbccbc1457d6710d3a9ce55ad70ec6cb0b75fc5
249 Author: H. Peter Anvin <hpa@zytor.com>
250 Date: Tue May 15 09:16:29 2007 -0700
251
252 x86 setup: include <asm/msr-index.h> not <asm/msr.h>
253
254 <asm/msr.h> brings in the accessor functions, which may potentially
255 bring in all other kinds of kernel headers which are inappropriate for
256 the setup code. For the setup code, include <asm/msr-index.h>
257 instead, which only includes the numeric constants.
258
259 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
260
261 commit 839cafa9c0020e7506722dd2a4fd82a71c2939cc
262 Author: H. Peter Anvin <hpa@zytor.com>
263 Date: Mon May 14 15:49:01 2007 -0700
264
265 x86 setup: protocol 2.0[01]: base for CL_OFFSET depends on setup_move_size
266
267 Handle the use of boot protocol 2.00 and 2.01: the base segment for
268 CL_OFFSET depends on the value of setup_move_size.
269
270 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
271
272 commit d60357ad68a694b03e9b952eadba5ac277c31df0
273 Author: H. Peter Anvin <hpa@zytor.com>
274 Date: Sat May 12 12:18:53 2007 -0700
275
276 x86 setup: remove unused variable
277
278 Remove unused variable
279
280 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
281
282 commit e21a2030b01081612259847321bcce13eae1e883
283 Author: Sam Ravnborg <sam@ravnborg.org>
284 Date: Sat May 12 12:17:30 2007 -0700
285
286 x86 setup: share i386 Makefile with x86_64
287
288 The boot Makefile for i386 and x86_64 are equal
289 except for the CFLAGS setting.
290 Teach x86_64 to use the Makefile from i386 and
291 make CFLAGS setting arch dependent in i386 Makefile.
292
293 Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
294 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
295
296 commit 8618d92339d0d106045f98f34833d863c3235cdb
297 Author: H. Peter Anvin <hpa@zytor.com>
298 Date: Sat May 12 00:32:12 2007 -0700
299
300 x86 setup: video-bios.c missed the pointer to the set_mode method!
301
302 We need the actual pointer to the set_mode method (oops!)
303
304 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
305
306 commit 85dfc374ea9aad33b9e0315f07a4b2722dc11e3e
307 Author: H. Peter Anvin <hpa@zytor.com>
308 Date: Sat May 12 00:14:43 2007 -0700
309
310 x86 setup: when setting unknown BIOS modes and failing, try to revert
311
312 If we set an unknown BIOS mode and fail, then explicitly try to revert
313 to the original mode.
314
315 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
316
317 commit f4f7949f126d2f152b09fa9367b1ec693f2ea818
318 Author: H. Peter Anvin <hpa@zytor.com>
319 Date: Fri May 11 11:20:59 2007 -0700
320
321 x86 setup: fix typo "video_bios" should be "video-bios"
322
323 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
324
325 commit 51ba7113ea5b07189b7f8a0534d400a072535197
326 Author: H. Peter Anvin <hpa@zytor.com>
327 Date: Fri May 11 11:09:55 2007 -0700
328
329 x86 setup: allow setting VESA modes "blind"
330
331 Apparently, people really do set VESA modes "blind". As a result, make
332 the framework for settting blind modes more general, to remove some
333 special cases.
334
335 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
336
337 commit 1b8f73d9b2bf7630a2914ddab606db16fddb509e
338 Author: H. Peter Anvin <hpa@zytor.com>
339 Date: Thu May 10 22:08:45 2007 -0700
340
341 x86_64: CONFIG_PHYSICAL_ALIGN should be 2 MB
342
343 It's not actually used yet, but set CONFIG_PHYSICAL_ALIGN to 2 MB
344 as it should be, to prevent conflicts with other works in progress.
345
346 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
347
348 commit b81f3c88923e4470cd0942d4596fafc0fb1cf4fd
349 Author: H. Peter Anvin <hpa@zytor.com>
350 Date: Thu May 10 19:11:32 2007 -0700
351
352 x86 setup: remove debugging statements
353
354 Remove debugging statements in video.c that were not meant for
355 production.
356
357 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
358
359 commit be58b6d7e9c14e482bce495e8343955999dea77f
360 Author: H. Peter Anvin <hpa@zytor.com>
361 Date: Thu May 10 18:49:40 2007 -0700
362
363 x86 setup: only restore the screen image when needed
364
365 Only restore the screen image when needed. This is how the original
366 code behaves, so it's presumably the desired behaviour.
367
368 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
369
370 commit 22f6bd8cc23b512af28e34ae7d40036982a0ac63
371 Author: H. Peter Anvin <hpa@zytor.com>
372 Date: Thu May 10 18:44:08 2007 -0700
373
374 x86 setup: correct the definition of the GDT limit
375
376 Like all other x86 segment limits, the GDT limit points to the last byte
377 that is *permitted* to access, so it needs to be sizeof(boot_gdt)-1.
378
379 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
380
381 commit 7f73f1f4aa4c97745bffe07a3ebcf226a4965b00
382 Author: H. Peter Anvin <hpa@zytor.com>
383 Date: Thu May 10 15:47:48 2007 -0700
384
385 x86 setup: Re-implement scanning for hidden video modes
386
387 Re-implement scanning for hidden video modes. Every now and then,
388 apparently, you can find them hidden like easter eggs.
389
390 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
391
392 commit 6770176714bc12ec92372311ac02c14f0d22776e
393 Author: H. Peter Anvin <hpa@zytor.com>
394 Date: Thu May 10 15:24:27 2007 -0700
395
396 x86 setup: whitespace cleanup
397
398 Clean up stealth whitespace.
399
400 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
401
402 commit ba0480a3537cf471b08bdb99dae6d0780cfb1972
403 Author: H. Peter Anvin <hpa@zytor.com>
404 Date: Wed May 9 16:54:42 2007 -0700
405
406 x86: sync the CPU feature string arrays
407
408 With <asm/cpufeature.h> unified, synchronize the CPU feature string
409 arrays. The whole kernel/cpu directory really needs to be unified.
410
411 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
412
413 commit ecb53b84efddbad3d9aa49e95598550831324348
414 Author: H. Peter Anvin <hpa@zytor.com>
415 Date: Tue May 8 22:06:04 2007 -0700
416
417 x86 setup: need to set orig_video_isVGA
418
419 After detecting a VGA console, we need to set
420 boot_params.screen_info.orig_video_isVGA.
421
422 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
423
424 commit dc97fc053faff17b984ec962686caea52bd27628
425 Author: H. Peter Anvin <hpa@zytor.com>
426 Date: Tue May 8 20:51:17 2007 -0700
427
428 x86 setup: boot sector should use ljmp, not jmpl
429
430 We have an "jmpl" instruction in the boot sector, which was meant
431 to be an "ljmp" instruction. It worked anyway because gas interpreted
432 a two-argument "jmpl" as an "ljmpl" instruction, however, use plain
433 "ljmp" (i.e. "ljmpw".)
434
435 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
436
437 commit 7907f05e9692557c53c9ac13647db5e5343c7c76
438 Author: H. Peter Anvin <hpa@zytor.com>
439 Date: Tue May 8 20:27:10 2007 -0700
440
441 x86 setup: only make VESA graphics modes selectable if CONFIG_FB
442
443 If we select a VESA graphics mode, we better have framebuffer support
444 or the user will have no console. Therefore, make these modes
445 non-selectable if CONFIG_FB is not set.
446
447 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
448
449 commit 8e509f9ebc44f45544d231454e84f10bf78d5772
450 Author: H. Peter Anvin <hpa@zytor.com>
451 Date: Tue May 8 20:24:11 2007 -0700
452
453 x86 setup: need to probe VESA EDID block 0 only
454
455 The VESA EDID BIOS call takes the EDID block number in %dx, and may
456 corrupt it by spec. Pass it in properly.
457
458 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
459
460 commit 9912b9aed7943773d1fadaa2e2e52f42af395048
461 Author: H. Peter Anvin <hpa@zytor.com>
462 Date: Mon May 7 18:22:04 2007 -0700
463
464 x86 setup: add missing file "bitops.h" missing from previous checkins
465
466 The file "bitops.h" was missing from previous checkins.
467
468 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
469
470 commit 732eb3fac2d772980e6555b8c69902c8107c72aa
471 Author: H. Peter Anvin <hpa@zytor.com>
472 Date: Mon May 7 14:59:43 2007 -0700
473
474 x86 setup: add -fno-stack-protector; other Makefile fixes
475
476 Add -fno-stack-protector for the gcc's that need that;
477 Use -ffreestanding consistently;
478 Use $(LINUXINCLUDE);
479 Handle linker scripts consistently with other Makefiles.
480
481 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
482
483 commit 2d5e47f21202e156fe97aba0a88d158d5c157a33
484 Author: H. Peter Anvin <hpa@zytor.com>
485 Date: Mon May 7 14:45:25 2007 -0700
486
487 x86 setup: swap cpu.c and cpucheck.c; rename functions
488
489 Make cpucheck.c the reusable component; the generically-named cpu.c
490 gets to be the wrapper. Accordingly, rename functions to make it
491 less confusing.
492
493 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
494
495 commit bf2a428a4e7c1ee3ab9acb23cfafb45e818887a1
496 Author: H. Peter Anvin <hpa@zytor.com>
497 Date: Mon May 7 14:09:38 2007 -0700
498
499 x86 setup: remove code moved from cpucheck.c -> cpu.c
500
501 Move all info about requirements into cpu.c.
502
503 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
504
505 commit 9ea8429fabe5df6aed6393ac3a00d0b64445ba6a
506 Author: H. Peter Anvin <hpa@zytor.com>
507 Date: Mon May 7 09:42:51 2007 -0700
508
509 x86 setup: remove double nesting of a20_test()
510
511 a20_test() was invoked as either a20_test() or a20_wait(), where the
512 latter was simply a loop around a loop. Make the count a parameter
513 instead; this is clearer and saves a couple of bytes.
514
515 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
516
517 commit 9edc55718f57195c664ee3175514d652f651cfd2
518 Author: H. Peter Anvin <hpa@zytor.com>
519 Date: Mon May 7 09:30:41 2007 -0700
520
521 x86 setup: compile with -fomit-frame-pointer
522
523 Compiling with -fomit-frame-pointer reduces the size by about 2%.
524
525 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
526
527 commit e1003433f2d491bf17c79437cd75268da220dab5
528 Author: H. Peter Anvin <hpa@zytor.com>
529 Date: Mon May 7 09:30:04 2007 -0700
530
531 x86 setup: be more paranoid about the stack setup in header.S
532
533 In particular, deal correctly with the stack pointer being zero on entry.
534 While we're at it, align the stack.
535
536 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
537
538 commit 853499c3dc3fcbeb192a613ac241d150ebc7c5a0
539 Author: H. Peter Anvin <hpa@zytor.com>
540 Date: Sun May 6 23:25:10 2007 -0700
541
542 x86 setup: Factor out the environment-independent part of the CPU check.
543
544 Factor out the environment-independent part of the CPU check so it can
545 be invoked from other parts of the kernel as well.
546
547 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
548
549 commit f235a61f6d6dff57883efad351d746540bcb8caf
550 Author: H. Peter Anvin <hpa@zytor.com>
551 Date: Sat May 5 22:16:54 2007 -0700
552
553 x86 setup: when watching the setup size, take the stack into account
554
555 When watching the setup size, we have to take the stack into account.
556 In particular, the stack is used not only by the setup code itself, but
557 by BIOS interrupt handlers and system calls. Reserve a minimum of
558 512 bytes.
559
560 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
561
562 commit 0d0e10091be48f7e4c8888e9d5c2836c704994f5
563 Author: H. Peter Anvin <hpa@zytor.com>
564 Date: Sat May 5 19:25:51 2007 -0700
565
566 x86 setup: actually check the end of the heap.
567
568 Keep track of where the heap ends and actually watch out for it.
569
570 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
571
572 commit 47aab0b8f4d012fad3c42b5b0754d3cb87961b37
573 Author: H. Peter Anvin <hpa@zytor.com>
574 Date: Sat May 5 15:47:58 2007 -0700
575
576 x86 setup: coppyright rPath, Inc.
577
578 This work was done on the dime of rPath, Inc.; they own the copyright.
579
580 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
581
582 commit d22571534d7eabf9408f29d9da423e1c6e04445f
583 Author: H. Peter Anvin <hpa@zytor.com>
584 Date: Sat May 5 15:21:11 2007 -0700
585
586 x86 setup: implement screen contents save/restore
587
588 The old setup code had screen contents save and restore, so implement
589 it for the new one as well.
590
591 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
592
593 commit e5145601a752bd998e783d159c187d3017d45d6d
594 Author: H. Peter Anvin <hpa@zytor.com>
595 Date: Sat May 5 15:20:19 2007 -0700
596
597 x86 setup: whitespace cleanup
598
599 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
600
601 commit 045ecb52f91a74eecad93ffc8791eefe59cf7fd1
602 Author: H. Peter Anvin <hpa@zytor.com>
603 Date: Sat May 5 14:22:39 2007 -0700
604
605 x86 setup: allow setting of VESA graphics modes; cleanups
606
607 - Allow setting of VESA graphics modes (used by vesafb)
608 - Clean up the macros related to the heap
609 - #if 0 copy functions that aren't actually currently being used
610
611 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
612
613 commit 58c04ed7e2d7d5979e1917a74b49bdc0f3dde211
614 Author: H. Peter Anvin <hpa@zytor.com>
615 Date: Sat May 5 12:06:14 2007 -0700
616
617 x86 setup: move all VESA-related code into video-vesa.c; add EDID
618
619 - Move all VESA-related code into video-vesa.c
620 - Add VESA EDID query support
621 - Remove some totally obsolete definitions from video.h
622
623 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
624
625 commit 07bc3931175fb98256140275c03194426d441b74
626 Author: H. Peter Anvin <hpa@zytor.com>
627 Date: Sat May 5 12:04:40 2007 -0700
628
629 x86-64: remove -traditional from AFLAGS
630
631 In arch/x86_64/boot/compressed, remove -traditional from AFLAGS.
632
633 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
634
635 commit a830f615eeef838d461cbf7bbbee8c1c84708ec8
636 Author: H. Peter Anvin <hpa@zytor.com>
637 Date: Fri May 4 18:44:38 2007 -0700
638
639 x86 setup: share code between i386 and x86-64
640
641 Share the boot (setup) code and tools between i386 and x86-64.
642 The compression code is now running in 64-bit mode in order to support
643 relocation, so do *not* share that code.
644
645 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
646
647 commit 3e159a323bdfa5d5a7be2c1f6be089ca22d598e0
648 Author: H. Peter Anvin <hpa@zytor.com>
649 Date: Fri May 4 18:43:35 2007 -0700
650
651 x86-64: use 0x1b4 as the scratch area in boot_params, not 0x3c
652
653 Use 0x1b4 as the scratch area in boot_params rather than 0x3c.
654
655 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
656
657 commit 4cf4424e7a0f29f251b781f9b5e3655b0645cb7f
658 Author: H. Peter Anvin <hpa@zytor.com>
659 Date: Fri May 4 18:26:18 2007 -0700
660
661 Revert "x86-64: Make arch/x86-64/boot a symlink to arch/i386/boot"
662
663 This reverts commit b2ad90f4969226fe8cf3edc5330711ed5fc20105.
664
665 Restore arch/x86_64/boot as a separate directory hierarchy.
666
667 Conflicts:
668
669 commit 8ed1ae1d2f94410811b7cca4b1a426e37652457f
670 Author: H. Peter Anvin <hpa@zytor.com>
671 Date: Fri May 4 17:00:33 2007 -0700
672
673 x86-64: It appears MTRR isn't a required feature after all.
674
675 MTRR was documented as a required feature, but appears to boot fine
676 without it (tested since Bochs doesn't have MTRR support.)
677
678 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
679
680 commit 7c616d098579fb790662cdc703f2a0f26ea1668c
681 Author: H. Peter Anvin <hpa@zytor.com>
682 Date: Fri May 4 16:22:57 2007 -0700
683
684 x86 setup: use 0x1e4 as scratch, instead of 0x3c
685
686 The compressed relocation needs a 4-byte scratch area to obtain
687 its own address.
688
689 0x3c is at the end of the video area, which is quite constrained -- it
690 only has 6 bytes left (12 if we recycle the obsolete fields which invade
691 this space.) Define 0x1e4 as a scratch field, and use it.
692
693 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
694
695 commit 5bc1019227e94576e4876d05ee920f59195bce90
696 Author: H. Peter Anvin <hpa@zytor.com>
697 Date: Fri May 4 16:09:15 2007 -0700
698
699 x86 setup: boot_params.e820_map is just the map, not the count; adjust
700
701 boot_params.e820_map is just a list of entries, whereas
702 "struct e820map" contains a count as well. Thus, don't use
703 "struct e820map" to describe struct boot_params.
704
705 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
706
707 commit 0f96b52497f444be2d52d1184ca90be49f713ea3
708 Author: H. Peter Anvin <hpa@zytor.com>
709 Date: Fri May 4 15:49:03 2007 -0700
710
711 x86 setup: E820MAX is a definitional constant; no need to use sizeof hacks
712
713 Now when we're using the standard headers for the setup code, we can use
714 E820MAX instead of playing sizeof games.
715
716 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
717
718 commit 3a23a428b20cbb31fd7ff5516a053b99afc447f7
719 Author: H. Peter Anvin <hpa@zytor.com>
720 Date: Fri May 4 12:08:46 2007 -0700
721
722 x86: move the bootparam structure definition into include/
723
724 Move the bootparam structure definition into include/, and make other
725 things use it. Haven't cleaned up all the macros yet, though.
726
727 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
728
729 commit e93ec58911995971aa059990f8a91a02b05f6c8f
730 Author: H. Peter Anvin <hpa@zytor.com>
731 Date: Fri May 4 12:07:50 2007 -0700
732
733 i386: change %lu to %u in arch/i386/kernel/e820.h
734
735 It's an u32, print it with %u
736
737 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
738
739 commit 2f47f004f614e2744867c0df274c55d8af2a42d5
740 Author: H. Peter Anvin <hpa@zytor.com>
741 Date: Fri May 4 12:06:04 2007 -0700
742
743 x86: fix differences between i386 and x86-64 <asm/e820.h>
744
745 Fix minor differences between i386 and x86-64 <asm/e820.h>
746
747 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
748
749 commit 56ec52f14e948f430af941052adee98019a617b7
750 Author: H. Peter Anvin <hpa@zytor.com>
751 Date: Fri May 4 11:45:17 2007 -0700
752
753 x86: fix the definition of struct screen_info
754
755 Name the fields that aren't really struct screen_info, and declare
756 the structure packed (the "capabilities" field is misaligned.)
757
758 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
759
760 commit 1d4429eaa564b0085d9ee3aa2de57e87a093a14e
761 Author: H. Peter Anvin <hpa@zytor.com>
762 Date: Fri May 4 11:43:10 2007 -0700
763
764 x86-64: Make arch/x86-64/boot a symlink to arch/i386/boot
765
766 Until such time that Kbuild allows for a cleaner solution, make
767 arch/x86-64/boot a symlink to arch/i386/boot.
768
769 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
770
771 commit 6a85f1b5fd041ea99d8604782559ce0502a60cc0
772 Author: H. Peter Anvin <hpa@zytor.com>
773 Date: Fri May 4 10:42:06 2007 -0700
774
775 x86-64: rearrange includes due to unifications and inclusion from setup
776
777 Unification caused a circular dependency between <asm/alternative.h>
778 and <asm/cpufeature.h>; resolve this.
779
780 Add #ifndef _SETUP in <asm/e820.h> so it can be included from the boot
781 code.
782
783 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
784
785 commit f6bbdc254bdbd5f7cf7a40c4cd6f9844af90824a
786 Author: H. Peter Anvin <hpa@zytor.com>
787 Date: Fri May 4 10:40:26 2007 -0700
788
789 x86: Complete <asm/cpufeature.h> with the union of i386 and x86-64
790
791 Add a feature to <asm/cpufeature.h> which was previously present
792 in x86-64 but missing in i386.
793
794 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
795
796 commit 1a0819281060489901732914f67869e0aa8f26fd
797 Author: H. Peter Anvin <hpa@zytor.com>
798 Date: Fri May 4 10:39:32 2007 -0700
799
800 x86: unify <asm/boot.h>
801
802 Unify <asm/boot.h> between i386 and x86-64
803
804 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
805
806 commit 8d9c54585f4623e0310f970fb5c6eda7ec1614df
807 Author: H. Peter Anvin <hpa@zytor.com>
808 Date: Fri May 4 10:38:35 2007 -0700
809
810 x86-64: verify_cpu.S: use new masks
811
812 Use the <asm/required-features.h> masks.
813
814 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
815
816 commit 6cf3308646bb7a3210f0f76bcb895b2dea76a93c
817 Author: H. Peter Anvin <hpa@zytor.com>
818 Date: Fri May 4 10:37:26 2007 -0700
819
820 x86-64: fix compilation errors due to required-features.h change
821
822 Fix compilation errors induced by required-features.h change.
823
824 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
825
826 commit 1324201a93ce380b46a3128826ecbd794e617e59
827 Author: H. Peter Anvin <hpa@zytor.com>
828 Date: Fri May 4 10:35:37 2007 -0700
829
830 x86-64: <asm/segment.h>: add boot segment descriptors
831
832 Add boot segment descriptors to <asm/segment.h> to match i386.
833
834 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
835
836 commit a0b15a9e79ed0310813709cd0690d6838917fe82
837 Author: H. Peter Anvin <hpa@zytor.com>
838 Date: Fri May 4 10:34:37 2007 -0700
839
840 x86-64: add CONFIG_PHYSICAL_ALIGN to match i386
841
842 Add CONFIG_PHYSICAL_ALIGN to match i386, even though we don't use it.
843
844 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
845
846 commit 8f5d14d11a7318e257351ae477392c7f7e314602
847 Author: H. Peter Anvin <hpa@zytor.com>
848 Date: Fri May 4 10:33:54 2007 -0700
849
850 x86 setup: cleanups for compatibility with x86-64
851
852 These changes are necessary to compile on x86-64.
853
854 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
855
856 commit a32f68b6d4023c1c6b1e62e8561189516c571ab9
857 Author: H. Peter Anvin <hpa@zytor.com>
858 Date: Fri May 4 08:40:07 2007 -0700
859
860 x86 setup: add missing linker script
861
862 Add linker script for the setup code, apparently missing from previous
863 checkins.
864
865 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
866
867 commit 4f34ca8e926b2d0bf3a7502b99f8dfced8cdba9d
868 Author: H. Peter Anvin <hpa@zytor.com>
869 Date: Thu May 3 17:42:29 2007 -0700
870
871 x86 setup: paranoia: clear the high half of %esp
872
873 We're invoked in 16-bit mode from an unknown bootloader. Make sure
874 we explicitly zero the upper half of %esp to avoid nasty surprises.
875
876 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
877
878 commit 19eb9b73cc1632a923003a002108b242af7a6080
879 Author: H. Peter Anvin <hpa@zytor.com>
880 Date: Thu May 3 17:35:41 2007 -0700
881
882 x86 setup: bootlin is *so* dead...
883
884 Bootlin was never able to load bzImage kernels, so who cares about it.
885
886 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
887
888 commit 3b9fb73c65151ee043bc74c333d9e3c9b1872125
889 Author: H. Peter Anvin <hpa@zytor.com>
890 Date: Thu May 3 10:56:40 2007 -0700
891
892 x86 setup: apparently $(src) is insufficient, needs $(srctree)/$(src)
893
894 For some unfanthomable reason the location of the source tree that
895 corresponds to the current directory has to be written as
896 $(srctree)/$(src) apparently. There might be a good reason for it,
897 but shorthand would be appreciated, and $(src) really should be the
898 short form.
899
900 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
901
902 commit a6d01d375a2269be1e3a6b31bcc4d426ad5a473d
903 Author: H. Peter Anvin <hpa@zytor.com>
904 Date: Thu May 3 10:51:45 2007 -0700
905
906 x86 setup: remove reference to obsolete cpureq.c
907
908 cpureq.c has been removed; remove it from the Makefile too.
909
910 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
911
912 commit cbe5b7585d800435080bcbf1b1fd242926982674
913 Author: H. Peter Anvin <hpa@zytor.com>
914 Date: Thu May 3 10:33:12 2007 -0700
915
916 x86 setup: use the required masks from <asm/required-features.h>
917
918 Use the now-uniform features from <asm/required-features.h>.
919
920 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
921
922 commit 99ed30180ecc1bb4e93f6edda5f6bad1adf3e630
923 Author: H. Peter Anvin <hpa@zytor.com>
924 Date: Thu May 3 10:31:12 2007 -0700
925
926 x86: make the handling of required features consistent
927
928 Make the handling of required features consistent between i386
929 and x86-64.
930
931 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
932
933 commit 1120d70a2be8f2deb6bda64047da288d8f86dad3
934 Author: H. Peter Anvin <hpa@zytor.com>
935 Date: Thu May 3 00:09:53 2007 -0700
936
937 x86: Kconfig.cpu: the minimum CPU model is always 3; WP_WORKS_OK = i486
938
939 The minimum CPU model number is always 3 (i386), and if we have
940 WP_WORKS_OK it means we need an i486.
941
942 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
943
944 commit ebc308c204149b86984ae2216f5b9b2e63932028
945 Author: H. Peter Anvin <hpa@zytor.com>
946 Date: Thu May 3 00:08:48 2007 -0700
947
948 x86 setup: use CONFIG_X86_MINIMUM_CPU_MODEL
949
950 Use CONFIG_X86_MINIMUM_CPU_MODEL as defined in Kconfig.cpu.
951
952 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
953
954 commit 8b50b640e015bf5d0f65502437da6fcab46c391b
955 Author: H. Peter Anvin <hpa@zytor.com>
956 Date: Wed May 2 23:45:42 2007 -0700
957
958 x86 setup: remove bogus "static"
959
960 Remove invalid "static" declarations in cpu.c
961
962 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
963
964 commit 35d23b60dfb110da81c24bcbfcda089cfc4fd264
965 Author: H. Peter Anvin <hpa@zytor.com>
966 Date: Wed May 2 23:37:50 2007 -0700
967
968 x86 setup: cpu detection cleanups
969
970 - Use <asm/processor-flags.h>
971 - Make sure %cr0 isn't in a dangerous configuration before probing the FPU
972
973 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
974
975 commit a1150a03247b355d11a4bb696b8aae1f46612992
976 Author: H. Peter Anvin <hpa@zytor.com>
977 Date: Wed May 2 23:36:55 2007 -0700
978
979 x86 setup: compile with -DSETUP
980
981 Define SETUP to make it easier to share code with the rest of the kernel.
982
983 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
984
985 commit 7eb52e8ad1bdf01886023d1a13b3313084cd7db6
986 Author: H. Peter Anvin <hpa@zytor.com>
987 Date: Wed May 2 23:34:57 2007 -0700
988
989 x86 setup: remove unused verify_cpu.S
990
991 verify_cpu.S is obsoleted by boot/cpu.c.
992
993 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
994
995 commit e90317a027c30176968220d18eb18bd6a9d9cc74
996 Author: H. Peter Anvin <hpa@zytor.com>
997 Date: Wed May 2 20:07:43 2007 -0700
998
999 x86 setup: files missing from previous checkin (cpu.c, cpureq.c)
1000
1001 These files were missing from a previous checkin; CPU feature-checking
1002 code and the list of CPU features to check for.
1003
1004 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1005
1006 commit 060f9b3db33c67b5344b2b4110bc823eb776e5cd
1007 Author: H. Peter Anvin <hpa@zytor.com>
1008 Date: Wed May 2 19:51:34 2007 -0700
1009
1010 x86 setup: whitespace cleanup
1011
1012 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1013
1014 commit 9f997a5569ec8fceaa15c2e9cf28e728e2ce118d
1015 Author: H. Peter Anvin <hpa@zytor.com>
1016 Date: Wed May 2 19:07:14 2007 -0700
1017
1018 x86 setup: add CPU feature detect/abort on insufficient featurage
1019
1020 The x86 setup is the right place to check features and abort if they
1021 are not present, since we can still get a message to the user via the
1022 firmware.
1023
1024 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1025
1026 commit de4e976376fddec340651ef40b16a45f6189619d
1027 Author: H. Peter Anvin <hpa@zytor.com>
1028 Date: Wed May 2 19:05:34 2007 -0700
1029
1030 x86 setup: whitespace cleanup
1031
1032 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1033
1034 commit bcd2d2f8de5d4568b6628aa133fce1ac40ece526
1035 Author: H. Peter Anvin <hpa@zytor.com>
1036 Date: Wed May 2 16:19:59 2007 -0700
1037
1038 x86 setup: tag functions noreturn; error message on A20 failure
1039
1040 Tag appropriate functions noreturn.
1041 If the A20 gate fails, output an error message and refuse to boot.
1042
1043 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1044
1045 commit 752aef90cbfc888084bf11fd83f8f72b6a668fc9
1046 Author: H. Peter Anvin <hpa@zytor.com>
1047 Date: Wed May 2 15:45:08 2007 -0700
1048
1049 x86 setup: clobber registers in keyboard BIOS call
1050
1051 Keyboard BIOS call to set repeat rate is known to clobber registers on
1052 "many" BIOSes.
1053
1054 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1055
1056 commit dde94003e4759aab275732cf9f1834440cd381d0
1057 Author: H. Peter Anvin <hpa@zytor.com>
1058 Date: Wed May 2 15:44:21 2007 -0700
1059
1060 x86 setup: implement APM BIOS probe
1061
1062 APM BIOS probe ported from assembly
1063
1064 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1065
1066 commit 9403917d79e3349184318704476fa080836bd52c
1067 Author: H. Peter Anvin <hpa@zytor.com>
1068 Date: Wed May 2 15:17:14 2007 -0700
1069
1070 x86 setup: remove references to obsolete probes
1071
1072 Remove "Hello, World!" as well as references to probes which are no
1073 longer used...
1074
1075 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1076
1077 commit 712f65ffbd1d4b55b4c55d68b4dcd32406c28fb8
1078 Author: H. Peter Anvin <hpa@zytor.com>
1079 Date: Wed May 2 12:17:15 2007 -0700
1080
1081 x86 setup: video.c: correct the handling of special mode numbers
1082
1083 Special mode numbers with the high bit set need to be handled *before*
1084 masking out the high bit.
1085
1086 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1087
1088 commit 9cf083204fe14cda3b09840eba8d131d2e48ccdf
1089 Author: H. Peter Anvin <hpa@zytor.com>
1090 Date: Wed May 2 11:44:16 2007 -0700
1091
1092 x86 setup: Modern ATI cards pass the probe but lacks the modes.
1093
1094 It appears modern ATI cards pass the probe for ATI-ness but lack the
1095 modes. Kill off the driver as being incorrect.
1096
1097 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1098
1099 commit 890cbe950589e30af17eac9da800efc76e35e01d
1100 Author: H. Peter Anvin <hpa@zytor.com>
1101 Date: Wed May 2 11:32:21 2007 -0700
1102
1103 x86 setup: a20.c: make empty_8042() return status
1104
1105 Make functions which could reasonably return status do so. It may
1106 be relevant in the future, and it's a lot better if the programmer
1107 doesn't have to figure out where everything should hook in.
1108
1109 Just on principle.
1110
1111 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1112
1113 commit 08a44dc655e0086d23fc3c70cb93eb51eaeec259
1114 Author: H. Peter Anvin <hpa@zytor.com>
1115 Date: Wed May 2 11:31:03 2007 -0700
1116
1117 x86 setup: video.c: clean up unused stuff
1118
1119 Clean up unused variables that we have no intent on using, as well
1120 as other cruft.
1121
1122 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1123
1124 commit 57e69acff1f577de430cae1523fd49a5d113e885
1125 Author: H. Peter Anvin <hpa@zytor.com>
1126 Date: Wed May 2 11:18:13 2007 -0700
1127
1128 x86 setup: drop video mode range checking
1129
1130 Drop video mode range checking. If someone really has, say, 12x40 mode
1131 visible through the BIOS then allow them to select it... odds are low
1132 that it will actually conflict with the very sparse allocation we have
1133 anyway.
1134
1135 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1136
1137 commit c0dda0b90f92d43872d55d295630a71cd357cfa6
1138 Author: H. Peter Anvin <hpa@zytor.com>
1139 Date: Wed May 2 11:15:53 2007 -0700
1140
1141 x86 setup: if no specific video mode ID is given, generate one
1142
1143 If we don't specify a certain video mode ID in the driver, then
1144 generate the 0xRRCC mode ID automatically.
1145
1146 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1147
1148 commit 0db5086e79810e7c5d560006b1c9a7501a02d80c
1149 Author: H. Peter Anvin <hpa@zytor.com>
1150 Date: Wed May 2 11:10:28 2007 -0700
1151
1152 x86 setup: Sadly, Cirrus removed extended text modes from their BIOS.
1153
1154 In the later era of the Cirrus 54xx series, Cirrus removed extended text
1155 modes from their BIOS. Neither Qemu nor Bochs implement them in the BIOS.
1156 If we can find a direct-register-poking method of setting them that
1157 works in Bochs/Qemu it might be worthwhile to resurrect this; the probing
1158 routine *does* work.
1159
1160 Of course, the Right Thing[TM] would be to submit such a routine to the
1161 Bochs/Qemu BIOS as a VESA text mode.
1162
1163 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1164
1165 commit 41f3fddeeb764687bf3fb0cf77fd858128571d58
1166 Author: H. Peter Anvin <hpa@zytor.com>
1167 Date: Wed May 2 10:18:07 2007 -0700
1168
1169 x86 setup: remove assembly implementation of putchar and puts
1170
1171 Already unused, remove assembly implementation of putchar and puts.
1172
1173 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1174
1175 commit dfa94cd86aca2c01d2f5e14b6e7c3e8258276195
1176 Author: H. Peter Anvin <hpa@zytor.com>
1177 Date: Tue May 1 21:41:28 2007 -0700
1178
1179 x86 setup: Call INT 15h AX=E820h properly
1180
1181 The calling convention for BIOS call 15:E820 was messed up.
1182
1183 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1184
1185 commit 2487575a36435c0a983febbb4f3751331bd2df7a
1186 Author: H. Peter Anvin <hpa@zytor.com>
1187 Date: Tue May 1 21:34:12 2007 -0700
1188
1189 x86 setup: advance one e820 descriptor at a time...
1190
1191 Adding sizeof(foo) to a foo * is not just useless, it's pretty damaging...
1192
1193 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1194
1195 commit 530d4f4f1732335ae8725c0b8c332a618e63ea1d
1196 Author: H. Peter Anvin <hpa@zytor.com>
1197 Date: Tue May 1 21:33:28 2007 -0700
1198
1199 x86 setup: fix memcmp_[fg]s()
1200
1201 Actually return a value from memcmp_[fg]s()...
1202
1203 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1204
1205 commit 8617cd56ff2e43303147da012b26c9dd46af726e
1206 Author: H. Peter Anvin <hpa@zytor.com>
1207 Date: Tue May 1 21:32:47 2007 -0700
1208
1209 x86 setup: fix missing semicolon in video-ati.c
1210
1211 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1212
1213 commit 7bbf7fa3e199b9cef4877c5a56128faff8636cc9
1214 Author: H. Peter Anvin <hpa@zytor.com>
1215 Date: Tue May 1 21:26:48 2007 -0700
1216
1217 x86 setup: make the video setup code actually do something...
1218
1219 Basic video setup now works (there is still work to be done, however.)
1220
1221 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1222
1223 commit 45bcd4406e4b812b32d317d9b3b8db2e5f135a3c
1224 Author: H. Peter Anvin <hpa@zytor.com>
1225 Date: Tue May 1 21:25:20 2007 -0700
1226
1227 x86 setup: segment descriptors need to be Present
1228
1229 The segment descriptors were missing the Present bit.
1230
1231 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1232
1233 commit a39479d4ccf4dceffb623ad2ec7e2d708c38c637
1234 Author: H. Peter Anvin <hpa@zytor.com>
1235 Date: Tue May 1 21:24:32 2007 -0700
1236
1237 build: setup sectors doesn't include the boot sector
1238
1239 The "setup sectors" field doesn't include the old boot sector,
1240 even though the two are now one module.
1241
1242 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1243
1244 commit d8f3d4928ead72e8febe2fcd740d0fee71a61f42
1245 Author: H. Peter Anvin <hpa@zytor.com>
1246 Date: Tue May 1 21:23:44 2007 -0700
1247
1248 x86 setup: in tty.c, actually tell it what character to print
1249
1250 putchar() was missing the actual passing of the character code to the
1251 BIOS call, with very silly-looking results.
1252
1253 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1254
1255 commit 4f1462ed0377e180484a223e622d62432baa64b7
1256 Author: H. Peter Anvin <hpa@zytor.com>
1257 Date: Tue May 1 21:22:46 2007 -0700
1258
1259 x86 setup: printf.c needs code16gcc.h
1260
1261 printf.c was missing code16gcc.h, with predictable consequences.
1262
1263 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1264
1265 commit a5ba7e6df198bd204b0f87fc6e3f68388b9d14c1
1266 Author: H. Peter Anvin <hpa@zytor.com>
1267 Date: Mon Apr 30 20:56:42 2007 -0700
1268
1269 MAINTAINERS: formally take responsibility for the i386 boot code
1270
1271 Change MAINTAINERS to formally take responsibility for the i386 boot code.
1272
1273 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1274
1275 commit 6c821fc005655a99eff6e86c2e4b13654de94dea
1276 Author: H. Peter Anvin <hpa@zytor.com>
1277 Date: Mon Apr 30 20:54:07 2007 -0700
1278
1279 x86 setup code rewrite: initial development snapshot
1280
1281 Clean up the setup code and rewrite it in C.
1282 This is an initial development snapshot, not a working tree.
1283
1284 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1285 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1286 ---
1287
1288 MAINTAINERS | 4
1289 arch/i386/Kconfig.cpu | 4
1290 arch/i386/boot/Makefile | 45
1291 arch/i386/boot/a20.c | 161 +
1292 arch/i386/boot/apm.c | 97
1293 arch/i386/boot/bitops.h | 45
1294 arch/i386/boot/boot.h | 290 ++
1295 arch/i386/boot/bootsect.S | 98
1296 arch/i386/boot/cmdline.c | 97
1297 arch/i386/boot/code16gcc.h | 9
1298 arch/i386/boot/compressed/Makefile | 7
1299 arch/i386/boot/compressed/head.S | 6
1300 arch/i386/boot/compressed/misc.c | 3
1301 arch/i386/boot/copy.S | 101
1302 arch/i386/boot/cpu.c | 69
1303 arch/i386/boot/cpucheck.c | 266 ++
1304 arch/i386/boot/edd.S | 231 --
1305 arch/i386/boot/edd.c | 196 +
1306 arch/i386/boot/header.S | 283 ++
1307 arch/i386/boot/main.c | 161 +
1308 arch/i386/boot/mca.c | 43
1309 arch/i386/boot/memory.c | 99
1310 arch/i386/boot/pm.c | 170 +
1311 arch/i386/boot/pmjump.S | 54
1312 arch/i386/boot/printf.c | 331 ++
1313 arch/i386/boot/setup.S | 1075 ---------
1314 arch/i386/boot/setup.ld | 54
1315 arch/i386/boot/string.c | 34
1316 arch/i386/boot/tools/build.c | 156 -
1317 arch/i386/boot/tty.c | 112
1318 arch/i386/boot/version.c | 23
1319 arch/i386/boot/vesa.h | 79
1320 arch/i386/boot/video-bios.c | 125 +
1321 arch/i386/boot/video-vesa.c | 283 ++
1322 arch/i386/boot/video-vga.c | 260 ++
1323 arch/i386/boot/video.S | 2043 ------------------
1324 arch/i386/boot/video.c | 456 ++++
1325 arch/i386/boot/video.h | 145 +
1326 arch/i386/boot/voyager.c | 46
1327 arch/i386/kernel/cpu/addon_cpuid_features.c | 50
1328 arch/i386/kernel/cpu/common.c | 2
1329 arch/i386/kernel/cpu/proc.c | 21
1330 arch/i386/kernel/e820.c | 2
1331 arch/i386/kernel/setup.c | 12
1332 arch/i386/kernel/verify_cpu.S | 94
1333 arch/x86_64/Kconfig | 4
1334 arch/x86_64/boot/Makefile | 136 -
1335 arch/x86_64/boot/bootsect.S | 98
1336 arch/x86_64/boot/compressed/Makefile | 9
1337 arch/x86_64/boot/compressed/head.S | 6
1338 arch/x86_64/boot/install.sh | 2
1339 arch/x86_64/boot/mtools.conf.in | 17
1340 arch/x86_64/boot/setup.S | 826 -------
1341 arch/x86_64/boot/tools/build.c | 185 -
1342 arch/x86_64/kernel/Makefile | 2
1343 arch/x86_64/kernel/setup.c | 21
1344 arch/x86_64/kernel/verify_cpu.S | 22
1345 drivers/ide/legacy/hd.c | 73
1346 include/asm-i386/boot.h | 6
1347 include/asm-i386/bootparam.h | 85
1348 include/asm-i386/cpufeature.h | 26
1349 include/asm-i386/e820.h | 14
1350 include/asm-i386/processor.h | 1
1351 include/asm-i386/required-features.h | 37
1352 include/asm-i386/setup.h | 10
1353 include/asm-x86_64/alternative.h | 68
1354 include/asm-x86_64/boot.h | 16
1355 include/asm-x86_64/bootparam.h | 1
1356 include/asm-x86_64/cpufeature.h | 115 -
1357 include/asm-x86_64/e820.h | 6
1358 include/asm-x86_64/processor.h | 3
1359 include/asm-x86_64/required-features.h | 46
1360 include/asm-x86_64/segment.h | 8
1361 include/linux/edd.h | 4
1362 include/linux/screen_info.h | 9
1363 75 files changed, 4594 insertions(+), 5204 deletions(-)
1364
1365 Index: linux-2.6.22.19/MAINTAINERS
1366 ===================================================================
1367 --- linux-2.6.22.19.orig/MAINTAINERS
1368 +++ linux-2.6.22.19/MAINTAINERS
1369 @@ -1750,8 +1750,8 @@ T: http://www.harbaum.org/till/i2c_tiny_
1370 S: Maintained
1371
1372 i386 BOOT CODE
1373 -P: Riley H. Williams
1374 -M: Riley@Williams.Name
1375 +P: H. Peter Anvin
1376 +M: hpa@zytor.com
1377 L: Linux-Kernel@vger.kernel.org
1378 S: Maintained
1379
1380 Index: linux-2.6.22.19/arch/i386/Kconfig.cpu
1381 ===================================================================
1382 --- linux-2.6.22.19.orig/arch/i386/Kconfig.cpu
1383 +++ linux-2.6.22.19/arch/i386/Kconfig.cpu
1384 @@ -346,6 +346,6 @@ config X86_CMOV
1385
1386 config X86_MINIMUM_CPU_MODEL
1387 int
1388 - default "4" if X86_XADD || X86_CMPXCHG || X86_BSWAP
1389 - default "0"
1390 + default "4" if X86_XADD || X86_CMPXCHG || X86_BSWAP || X86_WP_WORKS_OK
1391 + default "3"
1392
1393 Index: linux-2.6.22.19/arch/i386/boot/Makefile
1394 ===================================================================
1395 --- linux-2.6.22.19.orig/arch/i386/boot/Makefile
1396 +++ linux-2.6.22.19/arch/i386/boot/Makefile
1397 @@ -25,27 +25,53 @@ SVGA_MODE := -DSVGA_MODE=NORMAL_VGA
1398
1399 #RAMDISK := -DRAMDISK=512
1400
1401 -targets := vmlinux.bin bootsect bootsect.o \
1402 - setup setup.o zImage bzImage
1403 +targets := vmlinux.bin setup.bin setup.elf zImage bzImage
1404 subdir- := compressed
1405
1406 +setup-y += a20.o apm.o cmdline.o copy.o cpu.o cpucheck.o edd.o
1407 +setup-y += header.o main.o mca.o memory.o pm.o pmjump.o
1408 +setup-y += printf.o string.o tty.o video.o version.o voyager.o
1409 +
1410 +# The link order of the video-*.o modules can matter. In particular,
1411 +# video-vga.o *must* be listed first, followed by video-vesa.o.
1412 +# Hardware-specific drivers should follow in the order they should be
1413 +# probed, and video-bios.o should typically be last.
1414 +setup-y += video-vga.o
1415 +setup-y += video-vesa.o
1416 +setup-y += video-bios.o
1417 +
1418 hostprogs-y := tools/build
1419
1420 HOSTCFLAGS_build.o := $(LINUXINCLUDE)
1421
1422 # ---------------------------------------------------------------------------
1423
1424 +# How to compile the 16-bit code. Note we always compile for -march=i386,
1425 +# that way we can complain to the user if the CPU is insufficient.
1426 +cflags-i386 :=
1427 +cflags-x86_64 := -m32
1428 +CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
1429 + $(cflags-$(ARCH)) \
1430 + -Wall -Wstrict-prototypes \
1431 + -march=i386 -mregparm=3 \
1432 + -include $(srctree)/$(src)/code16gcc.h \
1433 + -fno-strict-aliasing -fomit-frame-pointer \
1434 + $(call cc-option, -ffreestanding) \
1435 + $(call cc-option, -fno-stack-protector)
1436 +AFLAGS := $(CFLAGS) -D__ASSEMBLY__
1437 +
1438 $(obj)/zImage: IMAGE_OFFSET := 0x1000
1439 $(obj)/zImage: EXTRA_AFLAGS := $(SVGA_MODE) $(RAMDISK)
1440 $(obj)/bzImage: IMAGE_OFFSET := 0x100000
1441 +$(obj)/bzImage: EXTRA_CFLAGS := -D__BIG_KERNEL__
1442 $(obj)/bzImage: EXTRA_AFLAGS := $(SVGA_MODE) $(RAMDISK) -D__BIG_KERNEL__
1443 $(obj)/bzImage: BUILDFLAGS := -b
1444
1445 quiet_cmd_image = BUILD $@
1446 -cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/bootsect $(obj)/setup \
1447 +cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/setup.bin \
1448 $(obj)/vmlinux.bin $(ROOT_DEV) > $@
1449
1450 -$(obj)/zImage $(obj)/bzImage: $(obj)/bootsect $(obj)/setup \
1451 +$(obj)/zImage $(obj)/bzImage: $(obj)/setup.bin \
1452 $(obj)/vmlinux.bin $(obj)/tools/build FORCE
1453 $(call if_changed,image)
1454 @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
1455 @@ -53,12 +79,17 @@ $(obj)/zImage $(obj)/bzImage: $(obj)/boo
1456 $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
1457 $(call if_changed,objcopy)
1458
1459 -LDFLAGS_bootsect := -Ttext 0x0 -s --oformat binary
1460 -LDFLAGS_setup := -Ttext 0x0 -s --oformat binary -e begtext
1461 +SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
1462
1463 -$(obj)/setup $(obj)/bootsect: %: %.o FORCE
1464 +LDFLAGS_setup.elf := -T
1465 +$(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
1466 $(call if_changed,ld)
1467
1468 +OBJCOPYFLAGS_setup.bin := -O binary
1469 +
1470 +$(obj)/setup.bin: $(obj)/setup.elf FORCE
1471 + $(call if_changed,objcopy)
1472 +
1473 $(obj)/compressed/vmlinux: FORCE
1474 $(Q)$(MAKE) $(build)=$(obj)/compressed IMAGE_OFFSET=$(IMAGE_OFFSET) $@
1475
1476 Index: linux-2.6.22.19/arch/i386/boot/a20.c
1477 ===================================================================
1478 --- /dev/null
1479 +++ linux-2.6.22.19/arch/i386/boot/a20.c
1480 @@ -0,0 +1,161 @@
1481 +/* -*- linux-c -*- ------------------------------------------------------- *
1482 + *
1483 + * Copyright (C) 1991, 1992 Linus Torvalds
1484 + * Copyright 2007 rPath, Inc. - All Rights Reserved
1485 + *
1486 + * This file is part of the Linux kernel, and is made available under
1487 + * the terms of the GNU General Public License version 2.
1488 + *
1489 + * ----------------------------------------------------------------------- */
1490 +
1491 +/*
1492 + * arch/i386/boot/a20.c
1493 + *
1494 + * Enable A20 gate (return -1 on failure)
1495 + */
1496 +
1497 +#include "boot.h"
1498 +
1499 +#define MAX_8042_LOOPS 100000
1500 +
1501 +static int empty_8042(void)
1502 +{
1503 + u8 status;
1504 + int loops = MAX_8042_LOOPS;
1505 +
1506 + while (loops--) {
1507 + io_delay();
1508 +
1509 + status = inb(0x64);
1510 + if (status & 1) {
1511 + /* Read and discard input data */
1512 + io_delay();
1513 + (void)inb(0x60);
1514 + } else if (!(status & 2)) {
1515 + /* Buffers empty, finished! */
1516 + return 0;
1517 + }
1518 + }
1519 +
1520 + return -1;
1521 +}
1522 +
1523 +/* Returns nonzero if the A20 line is enabled. The memory address
1524 + used as a test is the int $0x80 vector, which should be safe. */
1525 +
1526 +#define A20_TEST_ADDR (4*0x80)
1527 +#define A20_TEST_SHORT 32
1528 +#define A20_TEST_LONG 2097152 /* 2^21 */
1529 +
1530 +static int a20_test(int loops)
1531 +{
1532 + int ok = 0;
1533 + int saved, ctr;
1534 +
1535 + set_fs(0x0000);
1536 + set_gs(0xffff);
1537 +
1538 + saved = ctr = rdfs32(A20_TEST_ADDR);
1539 +
1540 + while (loops--) {
1541 + wrfs32(++ctr, A20_TEST_ADDR);
1542 + io_delay(); /* Serialize and make delay constant */
1543 + ok = rdgs32(A20_TEST_ADDR+0x10) ^ ctr;
1544 + if (ok)
1545 + break;
1546 + }
1547 +
1548 + wrfs32(saved, A20_TEST_ADDR);
1549 + return ok;
1550 +}
1551 +
1552 +/* Quick test to see if A20 is already enabled */
1553 +static int a20_test_short(void)
1554 +{
1555 + return a20_test(A20_TEST_SHORT);
1556 +}
1557 +
1558 +/* Longer test that actually waits for A20 to come on line; this
1559 + is useful when dealing with the KBC or other slow external circuitry. */
1560 +static int a20_test_long(void)
1561 +{
1562 + return a20_test(A20_TEST_LONG);
1563 +}
1564 +
1565 +static void enable_a20_bios(void)
1566 +{
1567 + asm volatile("pushfl; int $0x15; popfl"
1568 + : : "a" ((u16)0x2401));
1569 +}
1570 +
1571 +static void enable_a20_kbc(void)
1572 +{
1573 + empty_8042();
1574 +
1575 + outb(0xd1, 0x64); /* Command write */
1576 + empty_8042();
1577 +
1578 + outb(0xdf, 0x60); /* A20 on */
1579 + empty_8042();
1580 +}
1581 +
1582 +static void enable_a20_fast(void)
1583 +{
1584 + u8 port_a;
1585 +
1586 + port_a = inb(0x92); /* Configuration port A */
1587 + port_a |= 0x02; /* Enable A20 */
1588 + port_a &= ~0x01; /* Do not reset machine */
1589 + outb(port_a, 0x92);
1590 +}
1591 +
1592 +/*
1593 + * Actual routine to enable A20; return 0 on ok, -1 on failure
1594 + */
1595 +
1596 +#define A20_ENABLE_LOOPS 255 /* Number of times to try */
1597 +
1598 +int enable_a20(void)
1599 +{
1600 + int loops = A20_ENABLE_LOOPS;
1601 +
1602 +#if defined(CONFIG_X86_ELAN)
1603 + /* Elan croaks if we try to touch the KBC */
1604 + enable_a20_fast();
1605 + while (!a20_test_long())
1606 + ;
1607 + return 0;
1608 +#elif defined(CONFIG_X86_VOYAGER)
1609 + /* On Voyager, a20_test() is unsafe? */
1610 + enable_a20_kbc();
1611 + return 0;
1612 +#else
1613 + while (loops--) {
1614 + /* First, check to see if A20 is already enabled
1615 + (legacy free, etc.) */
1616 + if (a20_test_short())
1617 + return 0;
1618 +
1619 + /* Next, try the BIOS (INT 0x15, AX=0x2401) */
1620 + enable_a20_bios();
1621 + if (a20_test_short())
1622 + return 0;
1623 +
1624 + /* Try enabling A20 through the keyboard controller */
1625 + empty_8042();
1626 + if (a20_test_short())
1627 + return 0; /* BIOS worked, but with delayed reaction */
1628 +
1629 + enable_a20_kbc();
1630 + if (a20_test_long())
1631 + return 0;
1632 +
1633 + /* Finally, try enabling the "fast A20 gate" */
1634 + enable_a20_fast();
1635 + if (a20_test_long())
1636 + return 0;
1637 + }
1638 +
1639 + return -1;
1640 +#endif
1641 +}
1642 Index: linux-2.6.22.19/arch/i386/boot/apm.c
1643 ===================================================================
1644 --- /dev/null
1645 +++ linux-2.6.22.19/arch/i386/boot/apm.c
1646 @@ -0,0 +1,97 @@
1647 +/* -*- linux-c -*- ------------------------------------------------------- *
1648 + *
1649 + * Copyright (C) 1991, 1992 Linus Torvalds
1650 + * Copyright 2007 rPath, Inc. - All Rights Reserved
1651 + *
1652 + * Original APM BIOS checking by Stephen Rothwell, May 1994
1653 + * (sfr@canb.auug.org.au)
1654 + *
1655 + * This file is part of the Linux kernel, and is made available under
1656 + * the terms of the GNU General Public License version 2.
1657 + *
1658 + * ----------------------------------------------------------------------- */
1659 +
1660 +/*
1661 + * arch/i386/boot/apm.c
1662 + *
1663 + * Get APM BIOS information
1664 + */
1665 +
1666 +#include "boot.h"
1667 +
1668 +#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
1669 +
1670 +int query_apm_bios(void)
1671 +{
1672 + u16 ax, bx, cx, dx, di;
1673 + u32 ebx, esi;
1674 + u8 err;
1675 +
1676 + /* APM BIOS installation check */
1677 + ax = 0x5300;
1678 + bx = cx = 0;
1679 + asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp ; setc %0"
1680 + : "=d" (err), "+a" (ax), "+b" (bx), "+c" (cx)
1681 + : : "esi", "edi");
1682 +
1683 + if (err)
1684 + return -1; /* No APM BIOS */
1685 +
1686 + if (bx != 0x504d) /* "PM" signature */
1687 + return -1;
1688 +
1689 + if (cx & 0x02) /* 32 bits supported? */
1690 + return -1;
1691 +
1692 + /* Disconnect first, just in case */
1693 + ax = 0x5304;
1694 + asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp"
1695 + : "+a" (ax)
1696 + : : "ebx", "ecx", "edx", "esi", "edi");
1697 +
1698 + /* Paranoia */
1699 + ebx = esi = 0;
1700 + cx = dx = di = 0;
1701 +
1702 + /* 32-bit connect */
1703 + asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp ; setc %6"
1704 + : "=a" (ax), "+b" (ebx), "+c" (cx), "+d" (dx),
1705 + "+S" (esi), "+D" (di), "=m" (err)
1706 + : "a" (0x5303));
1707 +
1708 + boot_params.apm_bios_info.cseg = ax;
1709 + boot_params.apm_bios_info.offset = ebx;
1710 + boot_params.apm_bios_info.cseg_16 = cx;
1711 + boot_params.apm_bios_info.dseg = dx;
1712 + boot_params.apm_bios_info.cseg_len = (u16)esi;
1713 + boot_params.apm_bios_info.cseg_16_len = esi >> 16;
1714 + boot_params.apm_bios_info.dseg_len = di;
1715 +
1716 + if (err)
1717 + return -1;
1718 +
1719 + /* Redo the installation check as the 32-bit connect;
1720 + some BIOSes return different flags this way... */
1721 +
1722 + ax = 0x5300;
1723 + bx = cx = 0;
1724 + asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp ; setc %0"
1725 + : "=d" (err), "+a" (ax), "+b" (bx), "+c" (cx)
1726 + : : "esi", "edi");
1727 +
1728 + if (err || bx != 0x504d) {
1729 + /* Failure with 32-bit connect, try to disconect and ignore */
1730 + ax = 0x5304;
1731 + bx = 0;
1732 + asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp"
1733 + : "+a" (ax), "+b" (bx)
1734 + : : "ecx", "edx", "esi", "edi");
1735 + return -1;
1736 + }
1737 +
1738 + boot_params.apm_bios_info.version = ax;
1739 + boot_params.apm_bios_info.flags = cx;
1740 + return 0;
1741 +}
1742 +
1743 +#endif
1744 Index: linux-2.6.22.19/arch/i386/boot/bitops.h
1745 ===================================================================
1746 --- /dev/null
1747 +++ linux-2.6.22.19/arch/i386/boot/bitops.h
1748 @@ -0,0 +1,45 @@
1749 +/* -*- linux-c -*- ------------------------------------------------------- *
1750 + *
1751 + * Copyright (C) 1991, 1992 Linus Torvalds
1752 + * Copyright 2007 rPath, Inc. - All Rights Reserved
1753 + *
1754 + * This file is part of the Linux kernel, and is made available under
1755 + * the terms of the GNU General Public License version 2.
1756 + *
1757 + * ----------------------------------------------------------------------- */
1758 +
1759 +/*
1760 + * arch/i386/boot/bitops.h
1761 + *
1762 + * Very simple bitops for the boot code.
1763 + */
1764 +
1765 +#ifndef BOOT_BITOPS_H
1766 +#define BOOT_BITOPS_H
1767 +#define _LINUX_BITOPS_H /* Inhibit inclusion of <linux/bitops.h> */
1768 +
1769 +static inline int constant_test_bit(int nr, const void *addr)
1770 +{
1771 + const u32 *p = (const u32 *)addr;
1772 + return ((1UL << (nr & 31)) & (p[nr >> 5])) != 0;
1773 +}
1774 +static inline int variable_test_bit(int nr, const void *addr)
1775 +{
1776 + u8 v;
1777 + const u32 *p = (const u32 *)addr;
1778 +
1779 + asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
1780 + return v;
1781 +}
1782 +
1783 +#define test_bit(nr,addr) \
1784 +(__builtin_constant_p(nr) ? \
1785 + constant_test_bit((nr),(addr)) : \
1786 + variable_test_bit((nr),(addr)))
1787 +
1788 +static inline void set_bit(int nr, void *addr)
1789 +{
1790 + asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
1791 +}
1792 +
1793 +#endif /* BOOT_BITOPS_H */
1794 Index: linux-2.6.22.19/arch/i386/boot/boot.h
1795 ===================================================================
1796 --- /dev/null
1797 +++ linux-2.6.22.19/arch/i386/boot/boot.h
1798 @@ -0,0 +1,290 @@
1799 +/* -*- linux-c -*- ------------------------------------------------------- *
1800 + *
1801 + * Copyright (C) 1991, 1992 Linus Torvalds
1802 + * Copyright 2007 rPath, Inc. - All Rights Reserved
1803 + *
1804 + * This file is part of the Linux kernel, and is made available under
1805 + * the terms of the GNU General Public License version 2.
1806 + *
1807 + * ----------------------------------------------------------------------- */
1808 +
1809 +/*
1810 + * arch/i386/boot/boot.h
1811 + *
1812 + * Header file for the real-mode kernel code
1813 + */
1814 +
1815 +#ifndef BOOT_BOOT_H
1816 +#define BOOT_BOOT_H
1817 +
1818 +#ifndef __ASSEMBLY__
1819 +
1820 +#include <stdarg.h>
1821 +#include <linux/types.h>
1822 +#include <linux/edd.h>
1823 +#include <asm/boot.h>
1824 +#include <asm/bootparam.h>
1825 +
1826 +/* Useful macros */
1827 +#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
1828 +
1829 +extern struct setup_header hdr;
1830 +extern struct boot_params boot_params;
1831 +
1832 +/* Basic port I/O */
1833 +static inline void outb(u8 v, u16 port)
1834 +{
1835 + asm volatile("outb %0,%1" : : "a" (v), "dN" (port));
1836 +}
1837 +static inline u8 inb(u16 port)
1838 +{
1839 + u8 v;
1840 + asm volatile("inb %1,%0" : "=a" (v) : "dN" (port));
1841 + return v;
1842 +}
1843 +
1844 +static inline void outw(u16 v, u16 port)
1845 +{
1846 + asm volatile("outw %0,%1" : : "a" (v), "dN" (port));
1847 +}
1848 +static inline u16 inw(u16 port)
1849 +{
1850 + u16 v;
1851 + asm volatile("inw %1,%0" : "=a" (v) : "dN" (port));
1852 + return v;
1853 +}
1854 +
1855 +static inline void outl(u32 v, u16 port)
1856 +{
1857 + asm volatile("outl %0,%1" : : "a" (v), "dn" (port));
1858 +}
1859 +static inline u32 inl(u32 port)
1860 +{
1861 + u32 v;
1862 + asm volatile("inl %1,%0" : "=a" (v) : "dN" (port));
1863 + return v;
1864 +}
1865 +
1866 +static inline void io_delay(void)
1867 +{
1868 + const u16 DELAY_PORT = 0x80;
1869 + asm volatile("outb %%al,%0" : : "dN" (DELAY_PORT));
1870 +}
1871 +
1872 +/* These functions are used to reference data in other segments. */
1873 +
1874 +static inline u16 ds(void)
1875 +{
1876 + u16 seg;
1877 + asm("movw %%ds,%0" : "=rm" (seg));
1878 + return seg;
1879 +}
1880 +
1881 +static inline void set_fs(u16 seg)
1882 +{
1883 + asm volatile("movw %0,%%fs" : : "rm" (seg));
1884 +}
1885 +static inline u16 fs(void)
1886 +{
1887 + u16 seg;
1888 + asm("movw %%fs,%0" : "=rm" (seg));
1889 + return seg;
1890 +}
1891 +
1892 +static inline void set_gs(u16 seg)
1893 +{
1894 + asm volatile("movw %0,%%gs" : : "rm" (seg));
1895 +}
1896 +static inline u16 gs(void)
1897 +{
1898 + u16 seg;
1899 + asm("movw %%gs,%0" : "=rm" (seg));
1900 + return seg;
1901 +}
1902 +
1903 +typedef unsigned int addr_t;
1904 +
1905 +static inline u8 rdfs8(addr_t addr)
1906 +{
1907 + u8 v;
1908 + asm("movb %%fs:%1,%0" : "=r" (v) : "m" (*(u8 *)addr));
1909 + return v;
1910 +}
1911 +static inline u16 rdfs16(addr_t addr)
1912 +{
1913 + u16 v;
1914 + asm("movw %%fs:%1,%0" : "=r" (v) : "m" (*(u16 *)addr));
1915 + return v;
1916 +}
1917 +static inline u32 rdfs32(addr_t addr)
1918 +{
1919 + u32 v;
1920 + asm("movl %%fs:%1,%0" : "=r" (v) : "m" (*(u32 *)addr));
1921 + return v;
1922 +}
1923 +
1924 +static inline void wrfs8(u8 v, addr_t addr)
1925 +{
1926 + asm volatile("movb %1,%%fs:%0" : "+m" (*(u8 *)addr) : "r" (v));
1927 +}
1928 +static inline void wrfs16(u16 v, addr_t addr)
1929 +{
1930 + asm volatile("movw %1,%%fs:%0" : "+m" (*(u16 *)addr) : "r" (v));
1931 +}
1932 +static inline void wrfs32(u32 v, addr_t addr)
1933 +{
1934 + asm volatile("movl %1,%%fs:%0" : "+m" (*(u32 *)addr) : "r" (v));
1935 +}
1936 +
1937 +static inline u8 rdgs8(addr_t addr)
1938 +{
1939 + u8 v;
1940 + asm("movb %%gs:%1,%0" : "=r" (v) : "m" (*(u8 *)addr));
1941 + return v;
1942 +}
1943 +static inline u16 rdgs16(addr_t addr)
1944 +{
1945 + u16 v;
1946 + asm("movw %%gs:%1,%0" : "=r" (v) : "m" (*(u16 *)addr));
1947 + return v;
1948 +}
1949 +static inline u32 rdgs32(addr_t addr)
1950 +{
1951 + u32 v;
1952 + asm("movl %%gs:%1,%0" : "=r" (v) : "m" (*(u32 *)addr));
1953 + return v;
1954 +}
1955 +
1956 +static inline void wrgs8(u8 v, addr_t addr)
1957 +{
1958 + asm volatile("movb %1,%%gs:%0" : "+m" (*(u8 *)addr) : "r" (v));
1959 +}
1960 +static inline void wrgs16(u16 v, addr_t addr)
1961 +{
1962 + asm volatile("movw %1,%%gs:%0" : "+m" (*(u16 *)addr) : "r" (v));
1963 +}
1964 +static inline void wrgs32(u32 v, addr_t addr)
1965 +{
1966 + asm volatile("movl %1,%%gs:%0" : "+m" (*(u32 *)addr) : "r" (v));
1967 +}
1968 +
1969 +/* Note: these only return true/false, not a signed return value! */
1970 +static inline int memcmp(const void *s1, const void *s2, size_t len)
1971 +{
1972 + u8 diff;
1973 + asm("repe; cmpsb; setnz %0"
1974 + : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
1975 + return diff;
1976 +}
1977 +
1978 +static inline int memcmp_fs(const void *s1, addr_t s2, size_t len)
1979 +{
1980 + u8 diff;
1981 + asm("fs; repe; cmpsb; setnz %0"
1982 + : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
1983 + return diff;
1984 +}
1985 +static inline int memcmp_gs(const void *s1, addr_t s2, size_t len)
1986 +{
1987 + u8 diff;
1988 + asm("gs; repe; cmpsb; setnz %0"
1989 + : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
1990 + return diff;
1991 +}
1992 +
1993 +/* Heap -- available for dynamic lists. */
1994 +#define STACK_SIZE 512 /* Minimum number of bytes for stack */
1995 +
1996 +extern char _end[];
1997 +extern char *HEAP;
1998 +extern char *heap_end;
1999 +#define RESET_HEAP() ((void *)( HEAP = _end ))
2000 +static inline char *__get_heap(size_t s, size_t a, size_t n)
2001 +{
2002 + char *tmp;
2003 +
2004 + HEAP = (char *)(((size_t)HEAP+(a-1)) & ~(a-1));
2005 + tmp = HEAP;
2006 + HEAP += s*n;
2007 + return tmp;
2008 +}
2009 +#define GET_HEAP(type, n) \
2010 + ((type *)__get_heap(sizeof(type),__alignof__(type),(n)))
2011 +
2012 +static inline int heap_free(void)
2013 +{
2014 + return heap_end-HEAP;
2015 +}
2016 +
2017 +/* copy.S */
2018 +
2019 +void copy_to_fs(addr_t dst, void *src, size_t len);
2020 +void *copy_from_fs(void *dst, addr_t src, size_t len);
2021 +void copy_to_gs(addr_t dst, void *src, size_t len);
2022 +void *copy_from_gs(void *dst, addr_t src, size_t len);
2023 +void *memcpy(void *dst, void *src, size_t len);
2024 +void *memset(void *dst, int c, size_t len);
2025 +
2026 +#define memcpy(d,s,l) __builtin_memcpy(d,s,l)
2027 +#define memset(d,c,l) __builtin_memset(d,c,l)
2028 +
2029 +/* a20.c */
2030 +int enable_a20(void);
2031 +
2032 +/* apm.c */
2033 +int query_apm_bios(void);
2034 +
2035 +/* cmdline.c */
2036 +int cmdline_find_option(const char *option, char *buffer, int bufsize);
2037 +
2038 +/* cpu.c, cpucheck.c */
2039 +int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr);
2040 +int validate_cpu(void);
2041 +
2042 +/* edd.c */
2043 +void query_edd(void);
2044 +
2045 +/* header.S */
2046 +void __attribute__((noreturn)) die(void);
2047 +
2048 +/* mca.c */
2049 +int query_mca(void);
2050 +
2051 +/* memory.c */
2052 +int detect_memory(void);
2053 +
2054 +/* pm.c */
2055 +void __attribute__((noreturn)) go_to_protected_mode(void);
2056 +
2057 +/* pmjump.S */
2058 +void __attribute__((noreturn))
2059 + protected_mode_jump(u32 entrypoint, u32 bootparams);
2060 +
2061 +/* printf.c */
2062 +unsigned int atou(const char *s);
2063 +int sprintf(char *buf, const char *fmt, ...);
2064 +int vsprintf(char *buf, const char *fmt, va_list args);
2065 +int printf(const char *fmt, ...);
2066 +
2067 +/* string.c */
2068 +int strcmp(const char *str1, const char *str2);
2069 +
2070 +/* tty.c */
2071 +void puts(const char *);
2072 +void putchar(int);
2073 +int getchar(void);
2074 +void kbd_flush(void);
2075 +int getchar_timeout(void);
2076 +
2077 +/* video.c */
2078 +void set_video(void);
2079 +
2080 +/* video-vesa.c */
2081 +void vesa_store_edid(void);
2082 +
2083 +/* voyager.c */
2084 +int query_voyager(void);
2085 +
2086 +#endif /* __ASSEMBLY__ */
2087 +
2088 +#endif /* BOOT_BOOT_H */
2089 Index: linux-2.6.22.19/arch/i386/boot/bootsect.S
2090 ===================================================================
2091 --- linux-2.6.22.19.orig/arch/i386/boot/bootsect.S
2092 +++ /dev/null
2093 @@ -1,98 +0,0 @@
2094 -/*
2095 - * bootsect.S Copyright (C) 1991, 1992 Linus Torvalds
2096 - *
2097 - * modified by Drew Eckhardt
2098 - * modified by Bruce Evans (bde)
2099 - * modified by Chris Noe (May 1999) (as86 -> gas)
2100 - * gutted by H. Peter Anvin (Jan 2003)
2101 - *
2102 - * BIG FAT NOTE: We're in real mode using 64k segments. Therefore segment
2103 - * addresses must be multiplied by 16 to obtain their respective linear
2104 - * addresses. To avoid confusion, linear addresses are written using leading
2105 - * hex while segment addresses are written as segment:offset.
2106 - *
2107 - */
2108 -
2109 -#include <asm/boot.h>
2110 -
2111 -SETUPSECTS = 4 /* default nr of setup-sectors */
2112 -BOOTSEG = 0x07C0 /* original address of boot-sector */
2113 -INITSEG = DEF_INITSEG /* we move boot here - out of the way */
2114 -SETUPSEG = DEF_SETUPSEG /* setup starts here */
2115 -SYSSEG = DEF_SYSSEG /* system loaded at 0x10000 (65536) */
2116 -SYSSIZE = DEF_SYSSIZE /* system size: # of 16-byte clicks */
2117 - /* to be loaded */
2118 -ROOT_DEV = 0 /* ROOT_DEV is now written by "build" */
2119 -SWAP_DEV = 0 /* SWAP_DEV is now written by "build" */
2120 -
2121 -#ifndef SVGA_MODE
2122 -#define SVGA_MODE ASK_VGA
2123 -#endif
2124 -
2125 -#ifndef RAMDISK
2126 -#define RAMDISK 0
2127 -#endif
2128 -
2129 -#ifndef ROOT_RDONLY
2130 -#define ROOT_RDONLY 1
2131 -#endif
2132 -
2133 -.code16
2134 -.text
2135 -
2136 -.global _start
2137 -_start:
2138 -
2139 - # Normalize the start address
2140 - jmpl $BOOTSEG, $start2
2141 -
2142 -start2:
2143 - movw %cs, %ax
2144 - movw %ax, %ds
2145 - movw %ax, %es
2146 - movw %ax, %ss
2147 - movw $0x7c00, %sp
2148 - sti
2149 - cld
2150 -
2151 - movw $bugger_off_msg, %si
2152 -
2153 -msg_loop:
2154 - lodsb
2155 - andb %al, %al
2156 - jz die
2157 - movb $0xe, %ah
2158 - movw $7, %bx
2159 - int $0x10
2160 - jmp msg_loop
2161 -
2162 -die:
2163 - # Allow the user to press a key, then reboot
2164 - xorw %ax, %ax
2165 - int $0x16
2166 - int $0x19
2167 -
2168 - # int 0x19 should never return. In case it does anyway,
2169 - # invoke the BIOS reset code...
2170 - ljmp $0xf000,$0xfff0
2171 -
2172 -
2173 -bugger_off_msg:
2174 - .ascii "Direct booting from floppy is no longer supported.\r\n"
2175 - .ascii "Please use a boot loader program instead.\r\n"
2176 - .ascii "\n"
2177 - .ascii "Remove disk and press any key to reboot . . .\r\n"
2178 - .byte 0
2179 -
2180 -
2181 - # Kernel attributes; used by setup
2182 -
2183 - .org 497
2184 -setup_sects: .byte SETUPSECTS
2185 -root_flags: .word ROOT_RDONLY
2186 -syssize: .word SYSSIZE
2187 -swap_dev: .word SWAP_DEV
2188 -ram_size: .word RAMDISK
2189 -vid_mode: .word SVGA_MODE
2190 -root_dev: .word ROOT_DEV
2191 -boot_flag: .word 0xAA55
2192 Index: linux-2.6.22.19/arch/i386/boot/cmdline.c
2193 ===================================================================
2194 --- /dev/null
2195 +++ linux-2.6.22.19/arch/i386/boot/cmdline.c
2196 @@ -0,0 +1,97 @@
2197 +/* -*- linux-c -*- ------------------------------------------------------- *
2198 + *
2199 + * Copyright (C) 1991, 1992 Linus Torvalds
2200 + * Copyright 2007 rPath, Inc. - All Rights Reserved
2201 + *
2202 + * This file is part of the Linux kernel, and is made available under
2203 + * the terms of the GNU General Public License version 2.
2204 + *
2205 + * ----------------------------------------------------------------------- */
2206 +
2207 +/*
2208 + * arch/i386/boot/cmdline.c
2209 + *
2210 + * Simple command-line parser for early boot.
2211 + */
2212 +
2213 +#include "boot.h"
2214 +
2215 +static inline int myisspace(u8 c)
2216 +{
2217 + return c <= ' '; /* Close enough approximation */
2218 +}
2219 +
2220 +/*
2221 + * Find a non-boolean option, that is, "option=argument". In accordance
2222 + * with standard Linux practice, if this option is repeated, this returns
2223 + * the last instance on the command line.
2224 + *
2225 + * Returns the length of the argument (regardless of if it was
2226 + * truncated to fit in the buffer), or -1 on not found.
2227 + */
2228 +int cmdline_find_option(const char *option, char *buffer, int bufsize)
2229 +{
2230 + u32 cmdline_ptr = boot_params.hdr.cmd_line_ptr;
2231 + addr_t cptr;
2232 + char c;
2233 + int len = -1;
2234 + const char *opptr = NULL;
2235 + char *bufptr = buffer;
2236 + enum {
2237 + st_wordstart, /* Start of word/after whitespace */
2238 + st_wordcmp, /* Comparing this word */
2239 + st_wordskip, /* Miscompare, skip */
2240 + st_bufcpy /* Copying this to buffer */
2241 + } state = st_wordstart;
2242 +
2243 + if (!cmdline_ptr || cmdline_ptr >= 0x100000)
2244 + return -1; /* No command line, or inaccessible */
2245 +
2246 + cptr = cmdline_ptr & 0xf;
2247 + set_fs(cmdline_ptr >> 4);
2248 +
2249 + while (cptr < 0x10000 && (c = rdfs8(cptr++))) {
2250 + switch (state) {
2251 + case st_wordstart:
2252 + if (myisspace(c))
2253 + break;
2254 +
2255 + /* else */
2256 + state = st_wordcmp;
2257 + opptr = option;
2258 + /* fall through */
2259 +
2260 + case st_wordcmp:
2261 + if (c == '=' && !*opptr) {
2262 + len = 0;
2263 + bufptr = buffer;
2264 + state = st_bufcpy;
2265 + } else if (myisspace(c)) {
2266 + state = st_wordstart;
2267 + } else if (c != *opptr++) {
2268 + state = st_wordskip;
2269 + }
2270 + break;
2271 +
2272 + case st_wordskip:
2273 + if (myisspace(c))
2274 + state = st_wordstart;
2275 + break;
2276 +
2277 + case st_bufcpy:
2278 + if (myisspace(c)) {
2279 + state = st_wordstart;
2280 + } else {
2281 + if (len < bufsize-1)
2282 + *bufptr++ = c;
2283 + len++;
2284 + }
2285 + break;
2286 + }
2287 + }
2288 +
2289 + if (bufsize)
2290 + *bufptr = '\0';
2291 +
2292 + return len;
2293 +}
2294 Index: linux-2.6.22.19/arch/i386/boot/code16gcc.h
2295 ===================================================================
2296 --- /dev/null
2297 +++ linux-2.6.22.19/arch/i386/boot/code16gcc.h
2298 @@ -0,0 +1,9 @@
2299 +/*
2300 + * code16gcc.h
2301 + *
2302 + * This file is -include'd when compiling 16-bit C code.
2303 + */
2304 +
2305 +#ifndef __ASSEMBLY__
2306 +asm(".code16gcc");
2307 +#endif
2308 Index: linux-2.6.22.19/arch/i386/boot/compressed/Makefile
2309 ===================================================================
2310 --- linux-2.6.22.19.orig/arch/i386/boot/compressed/Makefile
2311 +++ linux-2.6.22.19/arch/i386/boot/compressed/Makefile
2312 @@ -9,9 +9,14 @@ targets := vmlinux vmlinux.bin vmlinux.
2313 EXTRA_AFLAGS := -traditional
2314
2315 LDFLAGS_vmlinux := -T
2316 -CFLAGS_misc.o += -fPIC
2317 hostprogs-y := relocs
2318
2319 +CFLAGS := -m32 -D__KERNEL__ $(LINUX_INCLUDE) -O2 \
2320 + -fno-strict-aliasing -fPIC \
2321 + $(call cc-option,-ffreestanding) \
2322 + $(call cc-option,-fno-stack-protector)
2323 +LDFLAGS := -m elf_i386
2324 +
2325 $(obj)/vmlinux: $(src)/vmlinux.lds $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE
2326 $(call if_changed,ld)
2327 @:
2328 Index: linux-2.6.22.19/arch/i386/boot/compressed/head.S
2329 ===================================================================
2330 --- linux-2.6.22.19.orig/arch/i386/boot/compressed/head.S
2331 +++ linux-2.6.22.19/arch/i386/boot/compressed/head.S
2332 @@ -45,10 +45,10 @@ startup_32:
2333 * at and where we were actually loaded at. This can only be done
2334 * with a short local call on x86. Nothing else will tell us what
2335 * address we are running at. The reserved chunk of the real-mode
2336 - * data at 0x34-0x3f are used as the stack for this calculation.
2337 - * Only 4 bytes are needed.
2338 + * data at 0x1e4 (defined as a scratch field) are used as the stack
2339 + * for this calculation. Only 4 bytes are needed.
2340 */
2341 - leal 0x40(%esi), %esp
2342 + leal (0x1e4+4)(%esi), %esp
2343 call 1f
2344 1: popl %ebp
2345 subl $1b, %ebp
2346 Index: linux-2.6.22.19/arch/i386/boot/compressed/misc.c
2347 ===================================================================
2348 --- linux-2.6.22.19.orig/arch/i386/boot/compressed/misc.c
2349 +++ linux-2.6.22.19/arch/i386/boot/compressed/misc.c
2350 @@ -11,7 +11,6 @@
2351
2352 #undef CONFIG_PARAVIRT
2353 #include <linux/linkage.h>
2354 -#include <linux/vmalloc.h>
2355 #include <linux/screen_info.h>
2356 #include <asm/io.h>
2357 #include <asm/page.h>
2358 @@ -364,8 +363,10 @@ asmlinkage void decompress_kernel(void *
2359
2360 if ((u32)output & (CONFIG_PHYSICAL_ALIGN -1))
2361 error("Destination address not CONFIG_PHYSICAL_ALIGN aligned");
2362 +#ifndef CONFIG_X86_64
2363 if (end > ((-__PAGE_OFFSET-(512 <<20)-1) & 0x7fffffff))
2364 error("Destination address too large");
2365 +#endif
2366 #ifndef CONFIG_RELOCATABLE
2367 if ((u32)output != LOAD_PHYSICAL_ADDR)
2368 error("Wrong destination address");
2369 Index: linux-2.6.22.19/arch/i386/boot/copy.S
2370 ===================================================================
2371 --- /dev/null
2372 +++ linux-2.6.22.19/arch/i386/boot/copy.S
2373 @@ -0,0 +1,101 @@
2374 +/* ----------------------------------------------------------------------- *
2375 + *
2376 + * Copyright (C) 1991, 1992 Linus Torvalds
2377 + * Copyright 2007 rPath, Inc. - All Rights Reserved
2378 + *
2379 + * This file is part of the Linux kernel, and is made available under
2380 + * the terms of the GNU General Public License version 2.
2381 + *
2382 + * ----------------------------------------------------------------------- */
2383 +
2384 +/*
2385 + * arch/i386/boot/copy.S
2386 + *
2387 + * Memory copy routines
2388 + */
2389 +
2390 + .code16gcc
2391 + .text
2392 +
2393 + .globl memcpy
2394 + .type memcpy, @function
2395 +memcpy:
2396 + pushw %si
2397 + pushw %di
2398 + movw %ax, %di
2399 + movw %dx, %si
2400 + pushw %cx
2401 + shrw $2, %cx
2402 + rep; movsl
2403 + popw %cx
2404 + andw $3, %cx
2405 + rep; movsb
2406 + popw %di
2407 + popw %si
2408 + ret
2409 + .size memcpy, .-memcpy
2410 +
2411 + .globl memset
2412 + .type memset, @function
2413 +memset:
2414 + pushw %di
2415 + movw %ax, %di
2416 + movzbl %dl, %eax
2417 + imull $0x01010101,%eax
2418 + pushw %cx
2419 + shrw $2, %cx
2420 + rep; stosl
2421 + popw %cx
2422 + andw $3, %cx
2423 + rep; stosb
2424 + popw %di
2425 + ret
2426 + .size memset, .-memset
2427 +
2428 + .globl copy_from_fs
2429 + .type copy_from_fs, @function
2430 +copy_from_fs:
2431 + pushw %ds
2432 + pushw %fs
2433 + popw %ds
2434 + call memcpy
2435 + popw %ds
2436 + ret
2437 + .size copy_from_fs, .-copy_from_fs
2438 +
2439 + .globl copy_to_fs
2440 + .type copy_to_fs, @function
2441 +copy_to_fs:
2442 + pushw %es
2443 + pushw %fs
2444 + popw %es
2445 + call memcpy
2446 + popw %es
2447 + ret
2448 + .size copy_to_fs, .-copy_to_fs
2449 +
2450 +#if 0 /* Not currently used, but can be enabled as needed */
2451 +
2452 + .globl copy_from_gs
2453 + .type copy_from_gs, @function
2454 +copy_from_gs:
2455 + pushw %ds
2456 + pushw %gs
2457 + popw %ds
2458 + call memcpy
2459 + popw %ds
2460 + ret
2461 + .size copy_from_gs, .-copy_from_gs
2462 + .globl copy_to_gs
2463 +
2464 + .type copy_to_gs, @function
2465 +copy_to_gs:
2466 + pushw %es
2467 + pushw %gs
2468 + popw %es
2469 + call memcpy
2470 + popw %es
2471 + ret
2472 + .size copy_to_gs, .-copy_to_gs
2473 +
2474 +#endif
2475 Index: linux-2.6.22.19/arch/i386/boot/cpu.c
2476 ===================================================================
2477 --- /dev/null
2478 +++ linux-2.6.22.19/arch/i386/boot/cpu.c
2479 @@ -0,0 +1,69 @@
2480 +/* -*- linux-c -*- ------------------------------------------------------- *
2481 + *
2482 + * Copyright (C) 1991, 1992 Linus Torvalds
2483 + * Copyright 2007 rPath, Inc. - All Rights Reserved
2484 + *
2485 + * This file is part of the Linux kernel, and is made available under
2486 + * the terms of the GNU General Public License version 2.
2487 + *
2488 + * ----------------------------------------------------------------------- */
2489 +
2490 +/*
2491 + * arch/i386/boot/cpucheck.c
2492 + *
2493 + * Check for obligatory CPU features and abort if the features are not
2494 + * present.
2495 + */
2496 +
2497 +#include "boot.h"
2498 +#include "bitops.h"
2499 +#include <asm/cpufeature.h>
2500 +
2501 +static char *cpu_name(int level)
2502 +{
2503 + static char buf[6];
2504 +
2505 + if (level == 64) {
2506 + return "x86-64";
2507 + } else {
2508 + sprintf(buf, "i%d86", level);
2509 + return buf;
2510 + }
2511 +}
2512 +
2513 +int validate_cpu(void)
2514 +{
2515 + u32 *err_flags;
2516 + int cpu_level, req_level;
2517 +
2518 + check_cpu(&cpu_level, &req_level, &err_flags);
2519 +
2520 + if (cpu_level < req_level) {
2521 + printf("This kernel requires an %s CPU, ",
2522 + cpu_name(req_level));
2523 + printf("but only detected an %s CPU.\n",
2524 + cpu_name(cpu_level));
2525 + return -1;
2526 + }
2527 +
2528 + if (err_flags) {
2529 + int i, j;
2530 + puts("This kernel requires the following features "
2531 + "not present on the CPU:\n");
2532 +
2533 + for (i = 0; i < NCAPINTS; i++) {
2534 + u32 e = err_flags[i];
2535 +
2536 + for (j = 0; j < 32; j++) {
2537 + if (e & 1)
2538 + printf("%d:%d ", i, j);
2539 +
2540 + e >>= 1;
2541 + }
2542 + }
2543 + putchar('\n');
2544 + return -1;
2545 + } else {
2546 + return 0;
2547 + }
2548 +}
2549 Index: linux-2.6.22.19/arch/i386/boot/cpucheck.c
2550 ===================================================================
2551 --- /dev/null
2552 +++ linux-2.6.22.19/arch/i386/boot/cpucheck.c
2553 @@ -0,0 +1,266 @@
2554 +/* -*- linux-c -*- ------------------------------------------------------- *
2555 + *
2556 + * Copyright (C) 1991, 1992 Linus Torvalds
2557 + * Copyright 2007 rPath, Inc. - All Rights Reserved
2558 + *
2559 + * This file is part of the Linux kernel, and is made available under
2560 + * the terms of the GNU General Public License version 2.
2561 + *
2562 + * ----------------------------------------------------------------------- */
2563 +
2564 +/*
2565 + * arch/i386/boot/cpu.c
2566 + *
2567 + * Check for obligatory CPU features and abort if the features are not
2568 + * present. This code should be compilable as 16-, 32- or 64-bit
2569 + * code, so be very careful with types and inline assembly.
2570 + *
2571 + * This code should not contain any messages; that requires an
2572 + * additional wrapper.
2573 + *
2574 + * As written, this code is not safe for inclusion into the kernel
2575 + * proper (after FPU initialization, in particular).
2576 + */
2577 +
2578 +#ifdef _SETUP
2579 +# include "boot.h"
2580 +# include "bitops.h"
2581 +#endif
2582 +#include <linux/types.h>
2583 +#include <asm/cpufeature.h>
2584 +#include <asm/processor-flags.h>
2585 +#include <asm/required-features.h>
2586 +#include <asm/msr-index.h>
2587 +
2588 +struct cpu_features {
2589 + int level;
2590 + int model;
2591 + u32 flags[NCAPINTS];
2592 +};
2593 +
2594 +static struct cpu_features cpu;
2595 +static u32 cpu_vendor[3];
2596 +static u32 err_flags[NCAPINTS];
2597 +
2598 +#ifdef CONFIG_X86_64
2599 +static const int req_level = 64;
2600 +#elif defined(CONFIG_X86_MINIMUM_CPU_MODEL)
2601 +static const int req_level = CONFIG_X86_MINIMUM_CPU_MODEL;
2602 +#else
2603 +static const int req_level = 3;
2604 +#endif
2605 +
2606 +static const u32 req_flags[NCAPINTS] =
2607 +{
2608 + REQUIRED_MASK0,
2609 + REQUIRED_MASK1,
2610 + REQUIRED_MASK2,
2611 + REQUIRED_MASK3,
2612 + REQUIRED_MASK4,
2613 + REQUIRED_MASK5,
2614 + REQUIRED_MASK6,
2615 +};
2616 +
2617 +#define A32(a,b,c,d) (((d) << 24)+((c) << 16)+((b) << 8)+(a))
2618 +
2619 +static int is_amd(void)
2620 +{
2621 + return cpu_vendor[0] == A32('A','u','t','h') &&
2622 + cpu_vendor[1] == A32('e','n','t','i') &&
2623 + cpu_vendor[2] == A32('c','A','M','D');
2624 +}
2625 +
2626 +static int is_centaur(void)
2627 +{
2628 + return cpu_vendor[0] == A32('C','e','n','t') &&
2629 + cpu_vendor[1] == A32('a','u','r','H') &&
2630 + cpu_vendor[2] == A32('a','u','l','s');
2631 +}
2632 +
2633 +static int is_transmeta(void)
2634 +{
2635 + return cpu_vendor[0] == A32('G','e','n','u') &&
2636 + cpu_vendor[1] == A32('i','n','e','T') &&
2637 + cpu_vendor[2] == A32('M','x','8','6');
2638 +}
2639 +
2640 +static int has_fpu(void)
2641 +{
2642 + u16 fcw = -1, fsw = -1;
2643 + u32 cr0;
2644 +
2645 + asm("movl %%cr0,%0" : "=r" (cr0));
2646 + if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
2647 + cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
2648 + asm volatile("movl %0,%%cr0" : : "r" (cr0));
2649 + }
2650 +
2651 + asm("fninit ; fnstsw %0 ; fnstcw %1" : "+m" (fsw), "+m" (fcw));
2652 +
2653 + return fsw == 0 && (fcw & 0x103f) == 0x003f;
2654 +}
2655 +
2656 +static int has_eflag(u32 mask)
2657 +{
2658 + u32 f0, f1;
2659 +
2660 + asm("pushfl ; "
2661 + "pushfl ; "
2662 + "popl %0 ; "
2663 + "movl %0,%1 ; "
2664 + "xorl %2,%1 ; "
2665 + "pushl %1 ; "
2666 + "popfl ; "
2667 + "pushfl ; "
2668 + "popl %1 ; "
2669 + "popfl"
2670 + : "=r" (f0), "=r" (f1)
2671 + : "g" (mask));
2672 +
2673 + return !!((f0^f1) & mask);
2674 +}
2675 +
2676 +static void get_flags(void)
2677 +{
2678 + u32 max_intel_level, max_amd_level;
2679 + u32 tfms;
2680 +
2681 + if (has_fpu())
2682 + set_bit(X86_FEATURE_FPU, cpu.flags);
2683 +
2684 + if (has_eflag(X86_EFLAGS_ID)) {
2685 + asm("cpuid"
2686 + : "=a" (max_intel_level),
2687 + "=b" (cpu_vendor[0]),
2688 + "=d" (cpu_vendor[1]),
2689 + "=c" (cpu_vendor[2])
2690 + : "a" (0));
2691 +
2692 + if (max_intel_level >= 0x00000001 &&
2693 + max_intel_level <= 0x0000ffff) {
2694 + asm("cpuid"
2695 + : "=a" (tfms),
2696 + "=c" (cpu.flags[4]),
2697 + "=d" (cpu.flags[0])
2698 + : "a" (0x00000001)
2699 + : "ebx");
2700 + cpu.level = (tfms >> 8) & 15;
2701 + cpu.model = (tfms >> 4) & 15;
2702 + if (cpu.level >= 6)
2703 + cpu.model += ((tfms >> 16) & 0xf) << 4;
2704 + }
2705 +
2706 + asm("cpuid"
2707 + : "=a" (max_amd_level)
2708 + : "a" (0x80000000)
2709 + : "ebx", "ecx", "edx");
2710 +
2711 + if (max_amd_level >= 0x80000001 &&
2712 + max_amd_level <= 0x8000ffff) {
2713 + u32 eax = 0x80000001;
2714 + asm("cpuid"
2715 + : "+a" (eax),
2716 + "=c" (cpu.flags[6]),
2717 + "=d" (cpu.flags[1])
2718 + : : "ebx");
2719 + }
2720 + }
2721 +}
2722 +
2723 +/* Returns a bitmask of which words we have error bits in */
2724 +static int check_flags(void)
2725 +{
2726 + u32 err;
2727 + int i;
2728 +
2729 + err = 0;
2730 + for (i = 0; i < NCAPINTS; i++) {
2731 + err_flags[i] = req_flags[i] & ~cpu.flags[i];
2732 + if (err_flags[i])
2733 + err |= 1 << i;
2734 + }
2735 +
2736 + return err;
2737 +}
2738 +
2739 +/*
2740 + * Returns -1 on error.
2741 + *
2742 + * *cpu_level is set to the current CPU level; *req_level to the required
2743 + * level. x86-64 is considered level 64 for this purpose.
2744 + *
2745 + * *err_flags_ptr is set to the flags error array if there are flags missing.
2746 + */
2747 +int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
2748 +{
2749 + int err;
2750 +
2751 + memset(&cpu.flags, 0, sizeof cpu.flags);
2752 + cpu.level = 3;
2753 +
2754 + if (has_eflag(X86_EFLAGS_AC))
2755 + cpu.level = 4;
2756 +
2757 + get_flags();
2758 + err = check_flags();
2759 +
2760 + if (test_bit(X86_FEATURE_LM, cpu.flags))
2761 + cpu.level = 64;
2762 +
2763 + if (err == 0x01 &&
2764 + !(err_flags[0] &
2765 + ~((1 << X86_FEATURE_XMM)|(1 << X86_FEATURE_XMM2))) &&
2766 + is_amd()) {
2767 + /* If this is an AMD and we're only missing SSE+SSE2, try to
2768 + turn them on */
2769 +
2770 + u32 ecx = MSR_K7_HWCR;
2771 + u32 eax, edx;
2772 +
2773 + asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
2774 + eax &= ~(1 << 15);
2775 + asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
2776 +
2777 + get_flags(); /* Make sure it really did something */
2778 + err = check_flags();
2779 + } else if (err == 0x01 &&
2780 + !(err_flags[0] & ~(1 << X86_FEATURE_CX8)) &&
2781 + is_centaur() && cpu.model >= 6) {
2782 + /* If this is a VIA C3, we might have to enable CX8
2783 + explicitly */
2784 +
2785 + u32 ecx = MSR_VIA_FCR;
2786 + u32 eax, edx;
2787 +
2788 + asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
2789 + eax |= (1<<1)|(1<<7);
2790 + asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
2791 +
2792 + set_bit(X86_FEATURE_CX8, cpu.flags);
2793 + err = check_flags();
2794 + } else if (err == 0x01 && is_transmeta()) {
2795 + /* Transmeta might have masked feature bits in word 0 */
2796 +
2797 + u32 ecx = 0x80860004;
2798 + u32 eax, edx;
2799 + u32 level = 1;
2800 +
2801 + asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
2802 + asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
2803 + asm("cpuid"
2804 + : "+a" (level), "=d" (cpu.flags[0])
2805 + : : "ecx", "ebx");
2806 + asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
2807 +
2808 + err = check_flags();
2809 + }
2810 +
2811 + if (err_flags_ptr)
2812 + *err_flags_ptr = err ? err_flags : NULL;
2813 + if (cpu_level_ptr)
2814 + *cpu_level_ptr = cpu.level;
2815 + if (req_level_ptr)
2816 + *req_level_ptr = req_level;
2817 +
2818 + return (cpu.level < req_level || err) ? -1 : 0;
2819 +}
2820 Index: linux-2.6.22.19/arch/i386/boot/edd.S
2821 ===================================================================
2822 --- linux-2.6.22.19.orig/arch/i386/boot/edd.S
2823 +++ /dev/null
2824 @@ -1,231 +0,0 @@
2825 -/*
2826 - * BIOS Enhanced Disk Drive support
2827 - * Copyright (C) 2002, 2003, 2004 Dell, Inc.
2828 - * by Matt Domsch <Matt_Domsch@dell.com> October 2002
2829 - * conformant to T13 Committee www.t13.org
2830 - * projects 1572D, 1484D, 1386D, 1226DT
2831 - * disk signature read by Matt Domsch <Matt_Domsch@dell.com>
2832 - * and Andrew Wilks <Andrew_Wilks@dell.com> September 2003, June 2004
2833 - * legacy CHS retrieval by Patrick J. LoPresti <patl@users.sourceforge.net>
2834 - * March 2004
2835 - * Command line option parsing, Matt Domsch, November 2004
2836 - */
2837 -
2838 -#include <linux/edd.h>
2839 -#include <asm/setup.h>
2840 -
2841 -#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
2842 -
2843 -# It is assumed that %ds == INITSEG here
2844 -
2845 - movb $0, (EDD_MBR_SIG_NR_BUF)
2846 - movb $0, (EDDNR)
2847 -
2848 -# Check the command line for options:
2849 -# edd=of disables EDD completely (edd=off)
2850 -# edd=sk skips the MBR test (edd=skipmbr)
2851 -# edd=on re-enables EDD (edd=on)
2852 -
2853 - pushl %esi
2854 - movw $edd_mbr_sig_start, %di # Default to edd=on
2855 -
2856 - movl %cs:(cmd_line_ptr), %esi
2857 - andl %esi, %esi
2858 - jz old_cl # Old boot protocol?
2859 -
2860 -# Convert to a real-mode pointer in fs:si
2861 - movl %esi, %eax
2862 - shrl $4, %eax
2863 - movw %ax, %fs
2864 - andw $0xf, %si
2865 - jmp have_cl_pointer
2866 -
2867 -# Old-style boot protocol?
2868 -old_cl:
2869 - push %ds # aka INITSEG
2870 - pop %fs
2871 -
2872 - cmpw $0xa33f, (0x20)
2873 - jne done_cl # No command line at all?
2874 - movw (0x22), %si # Pointer relative to INITSEG
2875 -
2876 -# fs:si has the pointer to the command line now
2877 -have_cl_pointer:
2878 -
2879 -# Loop through kernel command line one byte at a time. Just in
2880 -# case the loader is buggy and failed to null-terminate the command line
2881 -# terminate if we get close enough to the end of the segment that we
2882 -# cannot fit "edd=XX"...
2883 -cl_atspace:
2884 - cmpw $-5, %si # Watch for segment wraparound
2885 - jae done_cl
2886 - movl %fs:(%si), %eax
2887 - andb %al, %al # End of line?
2888 - jz done_cl
2889 - cmpl $EDD_CL_EQUALS, %eax
2890 - jz found_edd_equals
2891 - cmpb $0x20, %al # <= space consider whitespace
2892 - ja cl_skipword
2893 - incw %si
2894 - jmp cl_atspace
2895 -
2896 -cl_skipword:
2897 - cmpw $-5, %si # Watch for segment wraparound
2898 - jae done_cl
2899 - movb %fs:(%si), %al # End of string?
2900 - andb %al, %al
2901 - jz done_cl
2902 - cmpb $0x20, %al
2903 - jbe cl_atspace
2904 - incw %si
2905 - jmp cl_skipword
2906 -
2907 -found_edd_equals:
2908 -# only looking at first two characters after equals
2909 -# late overrides early on the command line, so keep going after finding something
2910 - movw %fs:4(%si), %ax
2911 - cmpw $EDD_CL_OFF, %ax # edd=of
2912 - je do_edd_off
2913 - cmpw $EDD_CL_SKIP, %ax # edd=sk
2914 - je do_edd_skipmbr
2915 - cmpw $EDD_CL_ON, %ax # edd=on
2916 - je do_edd_on
2917 - jmp cl_skipword
2918 -do_edd_skipmbr:
2919 - movw $edd_start, %di
2920 - jmp cl_skipword
2921 -do_edd_off:
2922 - movw $edd_done, %di
2923 - jmp cl_skipword
2924 -do_edd_on:
2925 - movw $edd_mbr_sig_start, %di
2926 - jmp cl_skipword
2927 -
2928 -done_cl:
2929 - popl %esi
2930 - jmpw *%di
2931 -
2932 -# Read the first sector of each BIOS disk device and store the 4-byte signature
2933 -edd_mbr_sig_start:
2934 - movb $0x80, %dl # from device 80
2935 - movw $EDD_MBR_SIG_BUF, %bx # store buffer ptr in bx
2936 -edd_mbr_sig_read:
2937 - movl $0xFFFFFFFF, %eax
2938 - movl %eax, (%bx) # assume failure
2939 - pushw %bx
2940 - movb $READ_SECTORS, %ah
2941 - movb $1, %al # read 1 sector
2942 - movb $0, %dh # at head 0
2943 - movw $1, %cx # cylinder 0, sector 0
2944 - pushw %es
2945 - pushw %ds
2946 - popw %es
2947 - movw $EDDBUF, %bx # disk's data goes into EDDBUF
2948 - pushw %dx # work around buggy BIOSes
2949 - stc # work around buggy BIOSes
2950 - int $0x13
2951 - sti # work around buggy BIOSes
2952 - popw %dx
2953 - popw %es
2954 - popw %bx
2955 - jc edd_mbr_sig_done # on failure, we're done.
2956 - cmpb $0, %ah # some BIOSes do not set CF
2957 - jne edd_mbr_sig_done # on failure, we're done.
2958 - movl (EDDBUF+EDD_MBR_SIG_OFFSET), %eax # read sig out of the MBR
2959 - movl %eax, (%bx) # store success
2960 - incb (EDD_MBR_SIG_NR_BUF) # note that we stored something
2961 - incb %dl # increment to next device
2962 - addw $4, %bx # increment sig buffer ptr
2963 - cmpb $EDD_MBR_SIG_MAX, (EDD_MBR_SIG_NR_BUF) # Out of space?
2964 - jb edd_mbr_sig_read # keep looping
2965 -edd_mbr_sig_done:
2966 -
2967 -# Do the BIOS Enhanced Disk Drive calls
2968 -# This consists of two calls:
2969 -# int 13h ah=41h "Check Extensions Present"
2970 -# int 13h ah=48h "Get Device Parameters"
2971 -# int 13h ah=08h "Legacy Get Device Parameters"
2972 -#
2973 -# A buffer of size EDDMAXNR*(EDDEXTSIZE+EDDPARMSIZE) is reserved for our use
2974 -# in the boot_params at EDDBUF. The first four bytes of which are
2975 -# used to store the device number, interface support map and version
2976 -# results from fn41. The next four bytes are used to store the legacy
2977 -# cylinders, heads, and sectors from fn08. The following 74 bytes are used to
2978 -# store the results from fn48. Starting from device 80h, fn41, then fn48
2979 -# are called and their results stored in EDDBUF+n*(EDDEXTSIZE+EDDPARMIZE).
2980 -# Then the pointer is incremented to store the data for the next call.
2981 -# This repeats until either a device doesn't exist, or until EDDMAXNR
2982 -# devices have been stored.
2983 -# The one tricky part is that ds:si always points EDDEXTSIZE bytes into
2984 -# the structure, and the fn41 and fn08 results are stored at offsets
2985 -# from there. This removes the need to increment the pointer for
2986 -# every store, and leaves it ready for the fn48 call.
2987 -# A second one-byte buffer, EDDNR, in the boot_params stores
2988 -# the number of BIOS devices which exist, up to EDDMAXNR.
2989 -# In setup.c, copy_edd() stores both boot_params buffers away
2990 -# for later use, as they would get overwritten otherwise.
2991 -# This code is sensitive to the size of the structs in edd.h
2992 -edd_start:
2993 - # %ds points to the bootsector
2994 - # result buffer for fn48
2995 - movw $EDDBUF+EDDEXTSIZE, %si # in ds:si, fn41 results
2996 - # kept just before that
2997 - movb $0x80, %dl # BIOS device 0x80
2998 -
2999 -edd_check_ext:
3000 - movb $CHECKEXTENSIONSPRESENT, %ah # Function 41
3001 - movw $EDDMAGIC1, %bx # magic
3002 - int $0x13 # make the call
3003 - jc edd_done # no more BIOS devices
3004 -
3005 - cmpw $EDDMAGIC2, %bx # is magic right?
3006 - jne edd_next # nope, next...
3007 -
3008 - movb %dl, %ds:-8(%si) # store device number
3009 - movb %ah, %ds:-7(%si) # store version
3010 - movw %cx, %ds:-6(%si) # store extensions
3011 - incb (EDDNR) # note that we stored something
3012 -
3013 -edd_get_device_params:
3014 - movw $EDDPARMSIZE, %ds:(%si) # put size
3015 - movw $0x0, %ds:2(%si) # work around buggy BIOSes
3016 - movb $GETDEVICEPARAMETERS, %ah # Function 48
3017 - int $0x13 # make the call
3018 - # Don't check for fail return
3019 - # it doesn't matter.
3020 -edd_get_legacy_chs:
3021 - xorw %ax, %ax
3022 - movw %ax, %ds:-4(%si)
3023 - movw %ax, %ds:-2(%si)
3024 - # Ralf Brown's Interrupt List says to set ES:DI to
3025 - # 0000h:0000h "to guard against BIOS bugs"
3026 - pushw %es
3027 - movw %ax, %es
3028 - movw %ax, %di
3029 - pushw %dx # legacy call clobbers %dl
3030 - movb $LEGACYGETDEVICEPARAMETERS, %ah # Function 08
3031 - int $0x13 # make the call
3032 - jc edd_legacy_done # failed
3033 - movb %cl, %al # Low 6 bits are max
3034 - andb $0x3F, %al # sector number
3035 - movb %al, %ds:-1(%si) # Record max sect
3036 - movb %dh, %ds:-2(%si) # Record max head number
3037 - movb %ch, %al # Low 8 bits of max cyl
3038 - shr $6, %cl
3039 - movb %cl, %ah # High 2 bits of max cyl
3040 - movw %ax, %ds:-4(%si)
3041 -
3042 -edd_legacy_done:
3043 - popw %dx
3044 - popw %es
3045 - movw %si, %ax # increment si
3046 - addw $EDDPARMSIZE+EDDEXTSIZE, %ax
3047 - movw %ax, %si
3048 -
3049 -edd_next:
3050 - incb %dl # increment to next device
3051 - cmpb $EDDMAXNR, (EDDNR) # Out of space?
3052 - jb edd_check_ext # keep looping
3053 -
3054 -edd_done:
3055 -#endif
3056 Index: linux-2.6.22.19/arch/i386/boot/edd.c
3057 ===================================================================
3058 --- /dev/null
3059 +++ linux-2.6.22.19/arch/i386/boot/edd.c
3060 @@ -0,0 +1,196 @@
3061 +/* -*- linux-c -*- ------------------------------------------------------- *
3062 + *
3063 + * Copyright (C) 1991, 1992 Linus Torvalds
3064 + * Copyright 2007 rPath, Inc. - All Rights Reserved
3065 + *
3066 + * This file is part of the Linux kernel, and is made available under
3067 + * the terms of the GNU General Public License version 2.
3068 + *
3069 + * ----------------------------------------------------------------------- */
3070 +
3071 +/*
3072 + * arch/i386/boot/edd.c
3073 + *
3074 + * Get EDD BIOS disk information
3075 + */
3076 +
3077 +#include "boot.h"
3078 +#include <linux/edd.h>
3079 +
3080 +#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
3081 +
3082 +struct edd_dapa {
3083 + u8 pkt_size;
3084 + u8 rsvd;
3085 + u16 sector_cnt;
3086 + u16 buf_off, buf_seg;
3087 + u64 lba;
3088 + u64 buf_lin_addr;
3089 +};
3090 +
3091 +/*
3092 + * Note: this uses the heap to hold the loaded sector.
3093 + */
3094 +static int read_sector(u8 devno, u64 lba, void *buf)
3095 +{
3096 + struct edd_dapa dapa;
3097 + u16 ax, bx, cx, dx, si;
3098 +
3099 + memset(&dapa, 0, sizeof dapa);
3100 + dapa.pkt_size = sizeof(dapa);
3101 + dapa.sector_cnt = 1;
3102 + dapa.buf_off = (size_t)buf;
3103 + dapa.buf_seg = ds();
3104 + dapa.lba = lba;
3105 +
3106 + ax = 0x4200; /* Extended Read */
3107 + si = (size_t)&dapa;
3108 + dx = devno;
3109 + asm("pushfl; stc; int $0x13; setc %%al; popfl"
3110 + : "+a" (ax), "+S" (si), "+d" (dx)
3111 + : "m" (dapa)
3112 + : "ebx", "ecx", "edi", "memory");
3113 +
3114 + if (!(u8)ax)
3115 + return 0; /* OK */
3116 +
3117 + ax = 0x0201; /* Legacy Read, one sector */
3118 + cx = 0x0001; /* Sector 0-0-1 */
3119 + dx = devno;
3120 + bx = (size_t)buf;
3121 + asm("pushfl; stc; int $0x13; setc %%al; popfl"
3122 + : "+a" (ax), "+c" (cx), "+d" (dx), "+b" (bx)
3123 + : : "esi", "edi", "memory");
3124 +
3125 + return -(u8)ax; /* 0 or -1 */
3126 +}
3127 +
3128 +static u32 read_mbr_sig(u8 devno, struct edd_info *ei)
3129 +{
3130 + int sector_size;
3131 + char *mbrbuf_ptr, *mbrbuf_end;
3132 + u32 mbrsig;
3133 + u32 buf_base, mbr_base;
3134 + extern char _end[];
3135 + static char mbr_buf[1024];
3136 +
3137 + sector_size = ei->params.bytes_per_sector;
3138 + if (!sector_size)
3139 + sector_size = 512; /* Best available guess */
3140 +
3141 + buf_base = (ds() << 4) + (u32)&_end;
3142 + mbr_base = (buf_base+sector_size-1) & ~(sector_size-1);
3143 + mbrbuf_ptr = mbr_buf + (mbr_base-buf_base);
3144 + mbrbuf_end = mbrbuf_ptr + sector_size;
3145 +
3146 + if (!(boot_params.hdr.loadflags & CAN_USE_HEAP))
3147 + return 0;
3148 + if (mbrbuf_end > (char *)(size_t)boot_params.hdr.heap_end_ptr)
3149 + return 0;
3150 +
3151 + if (read_sector(devno, 0, mbrbuf_ptr))
3152 + return 0;
3153 +
3154 + mbrsig = *(u32 *)&mbrbuf_ptr[EDD_MBR_SIG_OFFSET];
3155 + return mbrsig;
3156 +}
3157 +
3158 +static int get_edd_info(u8 devno, struct edd_info *ei)
3159 +{
3160 + u16 ax, bx, cx, dx, di;
3161 +
3162 + memset(ei, 0, sizeof *ei);
3163 +
3164 + /* Check Extensions Present */
3165 +
3166 + ax = 0x4100;
3167 + bx = EDDMAGIC1;
3168 + dx = devno;
3169 + asm("pushfl; stc; int $0x13; setc %%al; popfl"
3170 + : "+a" (ax), "+b" (bx), "=c" (cx), "+d" (dx)
3171 + : : "esi", "edi");
3172 +
3173 + if ((u8)ax)
3174 + return -1; /* No extended information */
3175 +
3176 + if (bx != EDDMAGIC2)
3177 + return -1;
3178 +
3179 + ei->device = devno;
3180 + ei->version = ax >> 8; /* EDD version number */
3181 + ei->interface_support = cx; /* EDD functionality subsets */
3182 +
3183 + /* Extended Get Device Parameters */
3184 +
3185 + ei->params.length = sizeof(ei->params);
3186 + ax = 0x4800;
3187 + dx = devno;
3188 + asm("pushfl; int $0x13; popfl"
3189 + : "+a" (ax), "+d" (dx)
3190 + : "S" (&ei->params)
3191 + : "ebx", "ecx", "edi");
3192 +
3193 + /* Get legacy CHS parameters */
3194 +
3195 + /* Ralf Brown recommends setting ES:DI to 0:0 */
3196 + ax = 0x0800;
3197 + dx = devno;
3198 + di = 0;
3199 + asm("pushw %%es; "
3200 + "movw %%di,%%es; "
3201 + "pushfl; stc; int $0x13; setc %%al; popfl; "
3202 + "popw %%es"
3203 + : "+a" (ax), "=b" (bx), "=c" (cx), "+d" (dx), "+D" (di)
3204 + : : "esi");
3205 +
3206 + if ((u8)ax == 0) {
3207 + ei->legacy_max_cylinder = (cx >> 8) + ((cx & 0xc0) << 2);
3208 + ei->legacy_max_head = dx >> 8;
3209 + ei->legacy_sectors_per_track = cx & 0x3f;
3210 + }
3211 +
3212 + return 0;
3213 +}
3214 +
3215 +void query_edd(void)
3216 +{
3217 + char eddarg[8];
3218 + int do_mbr = 1;
3219 + int do_edd = 1;
3220 + int devno;
3221 + struct edd_info ei, *edp;
3222 +
3223 + if (cmdline_find_option("edd", eddarg, sizeof eddarg) > 0) {
3224 + if (!strcmp(eddarg, "skipmbr") || !strcmp(eddarg, "skip"))
3225 + do_mbr = 0;
3226 + else if (!strcmp(eddarg, "off"))
3227 + do_edd = 0;
3228 + }
3229 +
3230 + edp = (struct edd_info *)boot_params.eddbuf;
3231 +
3232 + if (!do_edd)
3233 + return;
3234 +
3235 + for (devno = 0x80; devno < 0x80+EDD_MBR_SIG_MAX; devno++) {
3236 + /*
3237 + * Scan the BIOS-supported hard disks and query EDD
3238 + * information...
3239 + */
3240 + get_edd_info(devno, &ei);
3241 +
3242 + if (boot_params.eddbuf_entries < EDDMAXNR) {
3243 + memcpy(edp, &ei, sizeof ei);
3244 + edp++;
3245 + boot_params.eddbuf_entries++;
3246 + }
3247 +
3248 + if (do_mbr) {
3249 + u32 mbr_sig;
3250 + mbr_sig = read_mbr_sig(devno, &ei);
3251 + boot_params.edd_mbr_sig_buffer[devno-0x80] = mbr_sig;
3252 + }
3253 + }
3254 +}
3255 +
3256 +#endif
3257 Index: linux-2.6.22.19/arch/i386/boot/header.S
3258 ===================================================================
3259 --- /dev/null
3260 +++ linux-2.6.22.19/arch/i386/boot/header.S
3261 @@ -0,0 +1,283 @@
3262 +/*
3263 + * header.S
3264 + *
3265 + * Copyright (C) 1991, 1992 Linus Torvalds
3266 + *
3267 + * Based on bootsect.S and setup.S
3268 + * modified by more people than can be counted
3269 + *
3270 + * Rewritten as a common file by H. Peter Anvin (Apr 2007)
3271 + *
3272 + * BIG FAT NOTE: We're in real mode using 64k segments. Therefore segment
3273 + * addresses must be multiplied by 16 to obtain their respective linear
3274 + * addresses. To avoid confusion, linear addresses are written using leading
3275 + * hex while segment addresses are written as segment:offset.
3276 + *
3277 + */
3278 +
3279 +#include <asm/segment.h>
3280 +#include <linux/utsrelease.h>
3281 +#include <asm/boot.h>
3282 +#include <asm/e820.h>
3283 +#include <asm/page.h>
3284 +#include <asm/setup.h>
3285 +#include "boot.h"
3286 +
3287 +SETUPSECTS = 4 /* default nr of setup-sectors */
3288 +BOOTSEG = 0x07C0 /* original address of boot-sector */
3289 +SYSSEG = DEF_SYSSEG /* system loaded at 0x10000 (65536) */
3290 +SYSSIZE = DEF_SYSSIZE /* system size: # of 16-byte clicks */
3291 + /* to be loaded */
3292 +ROOT_DEV = 0 /* ROOT_DEV is now written by "build" */
3293 +SWAP_DEV = 0 /* SWAP_DEV is now written by "build" */
3294 +
3295 +#ifndef SVGA_MODE
3296 +#define SVGA_MODE ASK_VGA
3297 +#endif
3298 +
3299 +#ifndef RAMDISK
3300 +#define RAMDISK 0
3301 +#endif
3302 +
3303 +#ifndef ROOT_RDONLY
3304 +#define ROOT_RDONLY 1
3305 +#endif
3306 +
3307 + .code16
3308 + .section ".bstext", "ax"
3309 +
3310 + .global bootsect_start
3311 +bootsect_start:
3312 +
3313 + # Normalize the start address
3314 + ljmp $BOOTSEG, $start2
3315 +
3316 +start2:
3317 + movw %cs, %ax
3318 + movw %ax, %ds
3319 + movw %ax, %es
3320 + movw %ax, %ss
3321 + xorw %sp, %sp
3322 + sti
3323 + cld
3324 +
3325 + movw $bugger_off_msg, %si
3326 +
3327 +msg_loop:
3328 + lodsb
3329 + andb %al, %al
3330 + jz bs_die
3331 + movb $0xe, %ah
3332 + movw $7, %bx
3333 + int $0x10
3334 + jmp msg_loop
3335 +
3336 +bs_die:
3337 + # Allow the user to press a key, then reboot
3338 + xorw %ax, %ax
3339 + int $0x16
3340 + int $0x19
3341 +
3342 + # int 0x19 should never return. In case it does anyway,
3343 + # invoke the BIOS reset code...
3344 + ljmp $0xf000,$0xfff0
3345 +
3346 + .section ".bsdata", "a"
3347 +bugger_off_msg:
3348 + .ascii "Direct booting from floppy is no longer supported.\r\n"
3349 + .ascii "Please use a boot loader program instead.\r\n"
3350 + .ascii "\n"
3351 + .ascii "Remove disk and press any key to reboot . . .\r\n"
3352 + .byte 0
3353 +
3354 +
3355 + # Kernel attributes; used by setup. This is part 1 of the
3356 + # header, from the old boot sector.
3357 +
3358 + .section ".header", "a"
3359 + .globl hdr
3360 +hdr:
3361 +setup_sects: .byte SETUPSECTS
3362 +root_flags: .word ROOT_RDONLY
3363 +syssize: .long SYSSIZE
3364 +ram_size: .word RAMDISK
3365 +vid_mode: .word SVGA_MODE
3366 +root_dev: .word ROOT_DEV
3367 +boot_flag: .word 0xAA55
3368 +
3369 + # offset 512, entry point
3370 +
3371 + .globl _start
3372 +_start:
3373 + # Explicitly enter this as bytes, or the assembler
3374 + # tries to generate a 3-byte jump here, which causes
3375 + # everything else to push off to the wrong offset.
3376 + .byte 0xeb # short (2-byte) jump
3377 + .byte start_of_setup-1f
3378 +1:
3379 +
3380 + # Part 2 of the header, from the old setup.S
3381 +
3382 + .ascii "HdrS" # header signature
3383 + .word 0x0206 # header version number (>= 0x0105)
3384 + # or else old loadlin-1.5 will fail)
3385 + .globl realmode_swtch
3386 +realmode_swtch: .word 0, 0 # default_switch, SETUPSEG
3387 +start_sys_seg: .word SYSSEG
3388 + .word kernel_version-512 # pointing to kernel version string
3389 + # above section of header is compatible
3390 + # with loadlin-1.5 (header v1.5). Don't
3391 + # change it.
3392 +
3393 +type_of_loader: .byte 0 # = 0, old one (LILO, Loadlin,
3394 + # Bootlin, SYSLX, bootsect...)
3395 + # See Documentation/i386/boot.txt for
3396 + # assigned ids
3397 +
3398 +# flags, unused bits must be zero (RFU) bit within loadflags
3399 +loadflags:
3400 +LOADED_HIGH = 1 # If set, the kernel is loaded high
3401 +CAN_USE_HEAP = 0x80 # If set, the loader also has set
3402 + # heap_end_ptr to tell how much
3403 + # space behind setup.S can be used for
3404 + # heap purposes.
3405 + # Only the loader knows what is free
3406 +#ifndef __BIG_KERNEL__
3407 + .byte 0
3408 +#else
3409 + .byte LOADED_HIGH
3410 +#endif
3411 +
3412 +setup_move_size: .word 0x8000 # size to move, when setup is not
3413 + # loaded at 0x90000. We will move setup
3414 + # to 0x90000 then just before jumping
3415 + # into the kernel. However, only the
3416 + # loader knows how much data behind
3417 + # us also needs to be loaded.
3418 +
3419 +code32_start: # here loaders can put a different
3420 + # start address for 32-bit code.
3421 +#ifndef __BIG_KERNEL__
3422 + .long 0x1000 # 0x1000 = default for zImage
3423 +#else
3424 + .long 0x100000 # 0x100000 = default for big kernel
3425 +#endif
3426 +
3427 +ramdisk_image: .long 0 # address of loaded ramdisk image
3428 + # Here the loader puts the 32-bit
3429 + # address where it loaded the image.
3430 + # This only will be read by the kernel.
3431 +
3432 +ramdisk_size: .long 0 # its size in bytes
3433 +
3434 +bootsect_kludge:
3435 + .long 0 # obsolete
3436 +
3437 +heap_end_ptr: .word _end+1024 # (Header version 0x0201 or later)
3438 + # space from here (exclusive) down to
3439 + # end of setup code can be used by setup
3440 + # for local heap purposes.
3441 +
3442 +pad1: .word 0
3443 +cmd_line_ptr: .long 0 # (Header version 0x0202 or later)
3444 + # If nonzero, a 32-bit pointer
3445 + # to the kernel command line.
3446 + # The command line should be
3447 + # located between the start of
3448 + # setup and the end of low
3449 + # memory (0xa0000), or it may
3450 + # get overwritten before it
3451 + # gets read. If this field is
3452 + # used, there is no longer
3453 + # anything magical about the
3454 + # 0x90000 segment; the setup
3455 + # can be located anywhere in
3456 + # low memory 0x10000 or higher.
3457 +
3458 +ramdisk_max: .long (-__PAGE_OFFSET-(512 << 20)-1) & 0x7fffffff
3459 + # (Header version 0x0203 or later)
3460 + # The highest safe address for
3461 + # the contents of an initrd
3462 +
3463 +kernel_alignment: .long CONFIG_PHYSICAL_ALIGN #physical addr alignment
3464 + #required for protected mode
3465 + #kernel
3466 +#ifdef CONFIG_RELOCATABLE
3467 +relocatable_kernel: .byte 1
3468 +#else
3469 +relocatable_kernel: .byte 0
3470 +#endif
3471 +pad2: .byte 0
3472 +pad3: .word 0
3473 +
3474 +cmdline_size: .long COMMAND_LINE_SIZE-1 #length of the command line,
3475 + #added with boot protocol
3476 + #version 2.06
3477 +
3478 +# End of setup header #####################################################
3479 +
3480 + .section ".inittext", "ax"
3481 +start_of_setup:
3482 +#ifdef SAFE_RESET_DISK_CONTROLLER
3483 +# Reset the disk controller.
3484 + movw $0x0000, %ax # Reset disk controller
3485 + movb $0x80, %dl # All disks
3486 + int $0x13
3487 +#endif
3488 +
3489 +# We will have entired with %cs = %ds+0x20, normalize %cs so
3490 +# it is on par with the other segments.
3491 + pushw %ds
3492 + pushw $setup2
3493 + lretw
3494 +
3495 +setup2:
3496 +# Force %es = %ds
3497 + movw %ds, %ax
3498 + movw %ax, %es
3499 + cld
3500 +
3501 +# Stack paranoia: align the stack and make sure it is good
3502 +# for both 16- and 32-bit references. In particular, if we
3503 +# were meant to have been using the full 16-bit segment, the
3504 +# caller might have set %sp to zero, which breaks %esp-based
3505 +# references.
3506 + andw $~3, %sp # dword align (might as well...)
3507 + jnz 1f
3508 + movw $0xfffc, %sp # Make sure we're not zero
3509 +1: movzwl %sp, %esp # Clear upper half of %esp
3510 + sti
3511 +
3512 +# Check signature at end of setup
3513 + cmpl $0x5a5aaa55, setup_sig
3514 + jne setup_bad
3515 +
3516 +# Zero the bss
3517 + movw $__bss_start, %di
3518 + movw $_end+3, %cx
3519 + xorl %eax, %eax
3520 + subw %di, %cx
3521 + shrw $2, %cx
3522 + rep; stosl
3523 +
3524 +# Jump to C code (should not return)
3525 + calll main
3526 +
3527 +# Setup corrupt somehow...
3528 +setup_bad:
3529 + movl $setup_corrupt, %eax
3530 + calll puts
3531 + # Fall through...
3532 +
3533 + .globl die
3534 + .type die, @function
3535 +die:
3536 + hlt
3537 + jmp die
3538 +
3539 + .size die, .-due
3540 +
3541 + .section ".initdata", "a"
3542 +setup_corrupt:
3543 + .byte 7
3544 + .string "No setup signature found..."
3545 Index: linux-2.6.22.19/arch/i386/boot/main.c
3546 ===================================================================
3547 --- /dev/null
3548 +++ linux-2.6.22.19/arch/i386/boot/main.c
3549 @@ -0,0 +1,161 @@
3550 +/* -*- linux-c -*- ------------------------------------------------------- *
3551 + *
3552 + * Copyright (C) 1991, 1992 Linus Torvalds
3553 + * Copyright 2007 rPath, Inc. - All Rights Reserved
3554 + *
3555 + * This file is part of the Linux kernel, and is made available under
3556 + * the terms of the GNU General Public License version 2.
3557 + *
3558 + * ----------------------------------------------------------------------- */
3559 +
3560 +/*
3561 + * arch/i386/boot/main.c
3562 + *
3563 + * Main module for the real-mode kernel code
3564 + */
3565 +
3566 +#include "boot.h"
3567 +
3568 +struct boot_params boot_params __attribute__((aligned(16)));
3569 +
3570 +char *HEAP = _end;
3571 +char *heap_end = _end; /* Default end of heap = no heap */
3572 +
3573 +/*
3574 + * Copy the header into the boot parameter block. Since this
3575 + * screws up the old-style command line protocol, adjust by
3576 + * filling in the new-style command line pointer instead.
3577 + */
3578 +#define OLD_CL_MAGIC 0xA33F
3579 +#define OLD_CL_ADDRESS 0x20
3580 +
3581 +static void copy_boot_params(void)
3582 +{
3583 + struct old_cmdline {
3584 + u16 cl_magic;
3585 + u16 cl_offset;
3586 + };
3587 + const struct old_cmdline * const oldcmd =
3588 + (const struct old_cmdline *)OLD_CL_ADDRESS;
3589 +
3590 + BUILD_BUG_ON(sizeof boot_params != 4096);
3591 + memcpy(&boot_params.hdr, &hdr, sizeof hdr);
3592 +
3593 + if (!boot_params.hdr.cmd_line_ptr &&
3594 + oldcmd->cl_magic == OLD_CL_MAGIC) {
3595 + /* Old-style command line protocol. */
3596 + u16 cmdline_seg;
3597 +
3598 + /* Figure out if the command line falls in the region
3599 + of memory that an old kernel would have copied up
3600 + to 0x90000... */
3601 + if (oldcmd->cl_offset < boot_params.hdr.setup_move_size)
3602 + cmdline_seg = ds();
3603 + else
3604 + cmdline_seg = 0x9000;
3605 +
3606 + boot_params.hdr.cmd_line_ptr =
3607 + (cmdline_seg << 4) + oldcmd->cl_offset;
3608 + }
3609 +}
3610 +
3611 +/*
3612 + * Set the keyboard repeat rate to maximum. Unclear why this
3613 + * is done here; this might be possible to kill off as stale code.
3614 + */
3615 +static void keyboard_set_repeat(void)
3616 +{
3617 + u16 ax = 0x0305;
3618 + u16 bx = 0;
3619 + asm volatile("int $0x16"
3620 + : "+a" (ax), "+b" (bx)
3621 + : : "ecx", "edx", "esi", "edi");
3622 +}
3623 +
3624 +/*
3625 + * Get Intel SpeedStep IST information.
3626 + */
3627 +static void query_speedstep_ist(void)
3628 +{
3629 + asm("int $0x15"
3630 + : "=a" (boot_params.speedstep_info[0]),
3631 + "=b" (boot_params.speedstep_info[1]),
3632 + "=c" (boot_params.speedstep_info[2]),
3633 + "=d" (boot_params.speedstep_info[3])
3634 + : "a" (0x0000e980), /* IST Support */
3635 + "d" (0x47534943)); /* Request value */
3636 +}
3637 +
3638 +/*
3639 + * Tell the BIOS what CPU mode we intend to run in.
3640 + */
3641 +static void set_bios_mode(void)
3642 +{
3643 +#ifdef CONFIG_X86_64
3644 + u32 eax, ebx;
3645 +
3646 + eax = 0xec00;
3647 + ebx = 2;
3648 + asm volatile("int $0x15"
3649 + : "+a" (eax), "+b" (ebx)
3650 + : : "ecx", "edx", "esi", "edi");
3651 +#endif
3652 +}
3653 +
3654 +void main(void)
3655 +{
3656 + /* First, copy the boot header into the "zeropage" */
3657 + copy_boot_params();
3658 +
3659 + /* End of heap check */
3660 + if (boot_params.hdr.loadflags & CAN_USE_HEAP) {
3661 + heap_end = (char *)(boot_params.hdr.heap_end_ptr
3662 + +0x200-STACK_SIZE);
3663 + } else {
3664 + /* Boot protocol 2.00 only, no heap available */
3665 + puts("WARNING: Ancient bootloader, some functionality "
3666 + "may be limited!\n");
3667 + }
3668 +
3669 + /* Make sure we have all the proper CPU support */
3670 + if (validate_cpu()) {
3671 + puts("Unable to boot - please use a kernel appropriate "
3672 + "for your CPU.\n");
3673 + die();
3674 + }
3675 +
3676 + /* Tell the BIOS what CPU mode we intend to run in. */
3677 + set_bios_mode();
3678 +
3679 + /* Detect memory layout */
3680 + detect_memory();
3681 +
3682 + /* Set keyboard repeat rate (why?) */
3683 + keyboard_set_repeat();
3684 +
3685 + /* Set the video mode */
3686 + set_video();
3687 +
3688 + /* Query MCA information */
3689 + query_mca();
3690 +
3691 + /* Voyager */
3692 +#ifdef CONFIG_X86_VOYAGER
3693 + query_voyager();
3694 +#endif
3695 +
3696 + /* Query SpeedStep IST information */
3697 + query_speedstep_ist();
3698 +
3699 + /* Query APM information */
3700 +#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
3701 + query_apm_bios();
3702 +#endif
3703 +
3704 + /* Query EDD information */
3705 +#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
3706 + query_edd();
3707 +#endif
3708 + /* Do the last things and invoke protected mode */
3709 + go_to_protected_mode();
3710 +}
3711 Index: linux-2.6.22.19/arch/i386/boot/mca.c
3712 ===================================================================
3713 --- /dev/null
3714 +++ linux-2.6.22.19/arch/i386/boot/mca.c
3715 @@ -0,0 +1,43 @@
3716 +/* -*- linux-c -*- ------------------------------------------------------- *
3717 + *
3718 + * Copyright (C) 1991, 1992 Linus Torvalds
3719 + * Copyright 2007 rPath, Inc. - All Rights Reserved
3720 + *
3721 + * This file is part of the Linux kernel, and is made available under
3722 + * the terms of the GNU General Public License version 2.
3723 + *
3724 + * ----------------------------------------------------------------------- */
3725 +
3726 +/*
3727 + * arch/i386/boot/mca.c
3728 + *
3729 + * Get the MCA system description table
3730 + */
3731 +
3732 +#include "boot.h"
3733 +
3734 +int query_mca(void)
3735 +{
3736 + u8 err;
3737 + u16 es, bx, len;
3738 +
3739 + asm("pushw %%es ; "
3740 + "int $0x15 ; "
3741 + "setc %0 ; "
3742 + "movw %%es, %1 ; "
3743 + "popw %%es"
3744 + : "=acdSDm" (err), "=acdSDm" (es), "=b" (bx)
3745 + : "a" (0xc000));
3746 +
3747 + if (err)
3748 + return -1; /* No MCA present */
3749 +
3750 + set_fs(es);
3751 + len = rdfs16(bx);
3752 +
3753 + if (len > sizeof(boot_params.sys_desc_table))
3754 + len = sizeof(boot_params.sys_desc_table);
3755 +
3756 + copy_from_fs(&boot_params.sys_desc_table, bx, len);
3757 + return 0;
3758 +}
3759 Index: linux-2.6.22.19/arch/i386/boot/memory.c
3760 ===================================================================
3761 --- /dev/null
3762 +++ linux-2.6.22.19/arch/i386/boot/memory.c
3763 @@ -0,0 +1,99 @@
3764 +/* -*- linux-c -*- ------------------------------------------------------- *
3765 + *
3766 + * Copyright (C) 1991, 1992 Linus Torvalds
3767 + * Copyright 2007 rPath, Inc. - All Rights Reserved
3768 + *
3769 + * This file is part of the Linux kernel, and is made available under
3770 + * the terms of the GNU General Public License version 2.
3771 + *
3772 + * ----------------------------------------------------------------------- */
3773 +
3774 +/*
3775 + * arch/i386/boot/memory.c
3776 + *
3777 + * Memory detection code
3778 + */
3779 +
3780 +#include "boot.h"
3781 +
3782 +#define SMAP 0x534d4150 /* ASCII "SMAP" */
3783 +
3784 +static int detect_memory_e820(void)
3785 +{
3786 + u32 next = 0;
3787 + u32 size, id;
3788 + u8 err;
3789 + struct e820entry *desc = boot_params.e820_map;
3790 +
3791 + do {
3792 + size = sizeof(struct e820entry);
3793 + id = SMAP;
3794 + asm("int $0x15; setc %0"
3795 + : "=am" (err), "+b" (next), "+d" (id), "+c" (size),
3796 + "=m" (*desc)
3797 + : "D" (desc), "a" (0xe820));
3798 +
3799 + if (err || id != SMAP)
3800 + break;
3801 +
3802 + boot_params.e820_entries++;
3803 + desc++;
3804 + } while (next && boot_params.e820_entries < E820MAX);
3805 +
3806 + return boot_params.e820_entries;
3807 +}
3808 +
3809 +static int detect_memory_e801(void)
3810 +{
3811 + u16 ax, bx, cx, dx;
3812 + u8 err;
3813 +
3814 + bx = cx = dx = 0;
3815 + ax = 0xe801;
3816 + asm("stc; int $0x15; setc %0"
3817 + : "=m" (err), "+a" (ax), "+b" (bx), "+c" (cx), "+d" (dx));
3818 +
3819 + if (err)
3820 + return -1;
3821 +
3822 + /* Do we really need to do this? */
3823 + if (cx || dx) {
3824 + ax = cx;
3825 + bx = dx;
3826 + }
3827 +
3828 + if (ax > 15*1024)
3829 + return -1; /* Bogus! */
3830 +
3831 + /* This ignores memory above 16MB if we have a memory hole
3832 + there. If someone actually finds a machine with a memory
3833 + hole at 16MB and no support for 0E820h they should probably
3834 + generate a fake e820 map. */
3835 + boot_params.alt_mem_k = (ax == 15*1024) ? (dx << 6)+ax : ax;
3836 +
3837 + return 0;
3838 +}
3839 +
3840 +static int detect_memory_88(void)
3841 +{
3842 + u16 ax;
3843 + u8 err;
3844 +
3845 + ax = 0x8800;
3846 + asm("stc; int $0x15; setc %0" : "=bcdm" (err), "+a" (ax));
3847 +
3848 + boot_params.screen_info.ext_mem_k = ax;
3849 +
3850 + return -err;
3851 +}
3852 +
3853 +int detect_memory(void)
3854 +{
3855 + if (detect_memory_e820() > 0)
3856 + return 0;
3857 +
3858 + if (!detect_memory_e801())
3859 + return 0;
3860 +
3861 + return detect_memory_88();
3862 +}
3863 Index: linux-2.6.22.19/arch/i386/boot/pm.c
3864 ===================================================================
3865 --- /dev/null
3866 +++ linux-2.6.22.19/arch/i386/boot/pm.c
3867 @@ -0,0 +1,170 @@
3868 +/* -*- linux-c -*- ------------------------------------------------------- *
3869 + *
3870 + * Copyright (C) 1991, 1992 Linus Torvalds
3871 + * Copyright 2007 rPath, Inc. - All Rights Reserved
3872 + *
3873 + * This file is part of the Linux kernel, and is made available under
3874 + * the terms of the GNU General Public License version 2.
3875 + *
3876 + * ----------------------------------------------------------------------- */
3877 +
3878 +/*
3879 + * arch/i386/boot/pm.c
3880 + *
3881 + * Prepare the machine for transition to protected mode.
3882 + */
3883 +
3884 +#include "boot.h"
3885 +#include <asm/segment.h>
3886 +
3887 +/*
3888 + * Invoke the realmode switch hook if present; otherwise
3889 + * disable all interrupts.
3890 + */
3891 +static void realmode_switch_hook(void)
3892 +{
3893 + if (boot_params.hdr.realmode_swtch) {
3894 + asm volatile("lcallw *%0"
3895 + : : "m" (boot_params.hdr.realmode_swtch)
3896 + : "eax", "ebx", "ecx", "edx");
3897 + } else {
3898 + asm volatile("cli");
3899 + outb(0x80, 0x70); /* Disable NMI */
3900 + io_delay();
3901 + }
3902 +}
3903 +
3904 +/*
3905 + * A zImage kernel is loaded at 0x10000 but wants to run at 0x1000.
3906 + * A bzImage kernel is loaded and runs at 0x100000.
3907 + */
3908 +static void move_kernel_around(void)
3909 +{
3910 + /* Note: rely on the compile-time option here rather than
3911 + the LOADED_HIGH flag. The Qemu kernel loader unconditionally
3912 + sets the loadflags to zero. */
3913 +#ifndef __BIG_KERNEL__
3914 + u16 dst_seg, src_seg;
3915 + u32 syssize;
3916 +
3917 + dst_seg = 0x1000 >> 4;
3918 + src_seg = 0x10000 >> 4;
3919 + syssize = boot_params.hdr.syssize; /* Size in 16-byte paragraps */
3920 +
3921 + while (syssize) {
3922 + int paras = (syssize >= 0x1000) ? 0x1000 : syssize;
3923 + int dwords = paras << 2;
3924 +
3925 + asm volatile("pushw %%es ; "
3926 + "pushw %%ds ; "
3927 + "movw %1,%%es ; "
3928 + "movw %2,%%ds ; "
3929 + "xorw %%di,%%di ; "
3930 + "xorw %%si,%%si ; "
3931 + "rep;movsl ; "
3932 + "popw %%ds ; "
3933 + "popw %%es"
3934 + : "+c" (dwords)
3935 + : "rm" (dst_seg), "rm" (src_seg)
3936 + : "esi", "edi");
3937 +
3938 + syssize -= paras;
3939 + dst_seg += paras;
3940 + src_seg += paras;
3941 + }
3942 +#endif
3943 +}
3944 +
3945 +/*
3946 + * Disable all interrupts at the legacy PIC.
3947 + */
3948 +static void mask_all_interrupts(void)
3949 +{
3950 + outb(0xff, 0xa1); /* Mask all interrupts on the seconday PIC */
3951 + io_delay();
3952 + outb(0xfb, 0x21); /* Mask all but cascade on the primary PIC */
3953 + io_delay();
3954 +}
3955 +
3956 +/*
3957 + * Reset IGNNE# if asserted in the FPU.
3958 + */
3959 +static void reset_coprocessor(void)
3960 +{
3961 + outb(0, 0xf0);
3962 + io_delay();
3963 + outb(0, 0xf1);
3964 + io_delay();
3965 +}
3966 +
3967 +/*
3968 + * Set up the GDT
3969 + */
3970 +#define GDT_ENTRY(flags,base,limit) \
3971 + (((u64)(base & 0xff000000) << 32) | \
3972 + ((u64)flags << 40) | \
3973 + ((u64)(limit & 0x00ff0000) << 32) | \
3974 + ((u64)(base & 0x00ffff00) << 16) | \
3975 + ((u64)(limit & 0x0000ffff)))
3976 +
3977 +struct gdt_ptr {
3978 + u16 len;
3979 + u32 ptr;
3980 +} __attribute__((packed));
3981 +
3982 +static void setup_gdt(void)
3983 +{
3984 + /* There are machines which are known to not boot with the GDT
3985 + being 8-byte unaligned. Intel recommends 16 byte alignment. */
3986 + static const u64 boot_gdt[] __attribute__((aligned(16))) = {
3987 + /* CS: code, read/execute, 4 GB, base 0 */
3988 + [GDT_ENTRY_BOOT_CS] = GDT_ENTRY(0xc09b, 0, 0xfffff),
3989 + /* DS: data, read/write, 4 GB, base 0 */
3990 + [GDT_ENTRY_BOOT_DS] = GDT_ENTRY(0xc093, 0, 0xfffff),
3991 + };
3992 + struct gdt_ptr gdt;
3993 +
3994 + gdt.len = sizeof(boot_gdt)-1;
3995 + gdt.ptr = (u32)&boot_gdt + (ds() << 4);
3996 +
3997 + asm volatile("lgdtl %0" : : "m" (gdt));
3998 +}
3999 +
4000 +/*
4001 + * Set up the IDT
4002 + */
4003 +static void setup_idt(void)
4004 +{
4005 + static const struct gdt_ptr null_idt = {0, 0};
4006 + asm volatile("lidtl %0" : : "m" (null_idt));
4007 +}
4008 +
4009 +/*
4010 + * Actual invocation sequence
4011 + */
4012 +void go_to_protected_mode(void)
4013 +{
4014 + /* Hook before leaving real mode, also disables interrupts */
4015 + realmode_switch_hook();
4016 +
4017 + /* Move the kernel/setup to their final resting places */
4018 + move_kernel_around();
4019 +
4020 + /* Enable the A20 gate */
4021 + if (enable_a20()) {
4022 + puts("A20 gate not responding, unable to boot...\n");
4023 + die();
4024 + }
4025 +
4026 + /* Reset coprocessor (IGNNE#) */
4027 + reset_coprocessor();
4028 +
4029 + /* Mask all interrupts in the PIC */
4030 + mask_all_interrupts();
4031 +
4032 + /* Actual transition to protected mode... */
4033 + setup_idt();
4034 + setup_gdt();
4035 + protected_mode_jump(boot_params.hdr.code32_start,
4036 + (u32)&boot_params + (ds() << 4));
4037 +}
4038 Index: linux-2.6.22.19/arch/i386/boot/pmjump.S
4039 ===================================================================
4040 --- /dev/null
4041 +++ linux-2.6.22.19/arch/i386/boot/pmjump.S
4042 @@ -0,0 +1,54 @@
4043 +/* ----------------------------------------------------------------------- *
4044 + *
4045 + * Copyright (C) 1991, 1992 Linus Torvalds
4046 + * Copyright 2007 rPath, Inc. - All Rights Reserved
4047 + *
4048 + * This file is part of the Linux kernel, and is made available under
4049 + * the terms of the GNU General Public License version 2.
4050 + *
4051 + * ----------------------------------------------------------------------- */
4052 +
4053 +/*
4054 + * arch/i386/boot/pmjump.S
4055 + *
4056 + * The actual transition into protected mode
4057 + */
4058 +
4059 +#include <asm/boot.h>
4060 +#include <asm/segment.h>
4061 +
4062 + .text
4063 +
4064 + .globl protected_mode_jump
4065 + .type protected_mode_jump, @function
4066 +
4067 + .code16
4068 +
4069 +/*
4070 + * void protected_mode_jump(u32 entrypoint, u32 bootparams);
4071 + */
4072 +protected_mode_jump:
4073 + xorl %ebx, %ebx # Flag to indicate this is a boot
4074 + movl %edx, %esi # Pointer to boot_params table
4075 + movl %eax, 2f # Patch ljmpl instruction
4076 + jmp 1f # Short jump to flush instruction q.
4077 +
4078 +1:
4079 + movw $__BOOT_DS, %cx
4080 +
4081 + movl %cr0, %edx
4082 + orb $1, %dl # Protected mode (PE) bit
4083 + movl %edx, %cr0
4084 +
4085 + movw %cx, %ds
4086 + movw %cx, %es
4087 + movw %cx, %fs
4088 + movw %cx, %gs
4089 + movw %cx, %ss
4090 +
4091 + # Jump to the 32-bit entrypoint
4092 + .byte 0x66, 0xea # ljmpl opcode
4093 +2: .long 0 # offset
4094 + .word __BOOT_CS # segment
4095 +
4096 + .size protected_mode_jump, .-protected_mode_jump
4097 Index: linux-2.6.22.19/arch/i386/boot/printf.c
4098 ===================================================================
4099 --- /dev/null
4100 +++ linux-2.6.22.19/arch/i386/boot/printf.c
4101 @@ -0,0 +1,331 @@
4102 +/* -*- linux-c -*- ------------------------------------------------------- *
4103 + *
4104 + * Copyright (C) 1991, 1992 Linus Torvalds
4105 + * Copyright 2007 rPath, Inc. - All Rights Reserved
4106 + *
4107 + * This file is part of the Linux kernel, and is made available under
4108 + * the terms of the GNU General Public License version 2.
4109 + *
4110 + * ----------------------------------------------------------------------- */
4111 +
4112 +/*
4113 + * arch/i386/boot/printf.c
4114 + *
4115 + * Oh, it's a waste of space, but oh-so-yummy for debugging. This
4116 + * version of printf() does not include 64-bit support. "Live with
4117 + * it."
4118 + *
4119 + */
4120 +
4121 +#include "boot.h"
4122 +
4123 +static inline int isdigit(int ch)
4124 +{
4125 + return (ch >= '0') && (ch <= '9');
4126 +}
4127 +
4128 +static int skip_atoi(const char **s)
4129 +{
4130 + int i = 0;
4131 +
4132 + while (isdigit(**s))
4133 + i = i * 10 + *((*s)++) - '0';
4134 + return i;
4135 +}
4136 +
4137 +unsigned int atou(const char *s)
4138 +{
4139 + unsigned int i = 0;
4140 + while (isdigit(*s))
4141 + i = i * 10 + (*s++ - '0');
4142 + return i;
4143 +}
4144 +
4145 +static int strnlen(const char *s, int maxlen)
4146 +{
4147 + const char *es = s;
4148 + while (*es && maxlen) {
4149 + es++;
4150 + maxlen--;
4151 + }
4152 +
4153 + return (es - s);
4154 +}
4155 +
4156 +#define ZEROPAD 1 /* pad with zero */
4157 +#define SIGN 2 /* unsigned/signed long */
4158 +#define PLUS 4 /* show plus */
4159 +#define SPACE 8 /* space if plus */
4160 +#define LEFT 16 /* left justified */
4161 +#define SPECIAL 32 /* 0x */
4162 +#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
4163 +
4164 +#define do_div(n,base) ({ \
4165 +int __res; \
4166 +__res = ((unsigned long) n) % (unsigned) base; \
4167 +n = ((unsigned long) n) / (unsigned) base; \
4168 +__res; })
4169 +
4170 +static char *number(char *str, long num, int base, int size, int precision,
4171 + int type)
4172 +{
4173 + char c, sign, tmp[66];
4174 + const char *digits = "0123456789abcdefghijklmnopqrstuvwxyz";
4175 + int i;
4176 +
4177 + if (type & LARGE)
4178 + digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
4179 + if (type & LEFT)
4180 + type &= ~ZEROPAD;
4181 + if (base < 2 || base > 36)
4182 + return 0;
4183 + c = (type & ZEROPAD) ? '0' : ' ';
4184 + sign = 0;
4185 + if (type & SIGN) {
4186 + if (num < 0) {
4187 + sign = '-';
4188 + num = -num;
4189 + size--;
4190 + } else if (type & PLUS) {
4191 + sign = '+';
4192 + size--;
4193 + } else if (type & SPACE) {
4194 + sign = ' ';
4195 + size--;
4196 + }
4197 + }
4198 + if (type & SPECIAL) {
4199 + if (base == 16)
4200 + size -= 2;
4201 + else if (base == 8)
4202 + size--;
4203 + }
4204 + i = 0;
4205 + if (num == 0)
4206 + tmp[i++] = '0';
4207 + else
4208 + while (num != 0)
4209 + tmp[i++] = digits[do_div(num, base)];
4210 + if (i > precision)
4211 + precision = i;
4212 + size -= precision;
4213 + if (!(type & (ZEROPAD + LEFT)))
4214 + while (size-- > 0)
4215 + *str++ = ' ';
4216 + if (sign)
4217 + *str++ = sign;
4218 + if (type & SPECIAL) {
4219 + if (base == 8)
4220 + *str++ = '0';
4221 + else if (base == 16) {
4222 + *str++ = '0';
4223 + *str++ = digits[33];
4224 + }
4225 + }
4226 + if (!(type & LEFT))
4227 + while (size-- > 0)
4228 + *str++ = c;
4229 + while (i < precision--)
4230 + *str++ = '0';
4231 + while (i-- > 0)
4232 + *str++ = tmp[i];
4233 + while (size-- > 0)
4234 + *str++ = ' ';
4235 + return str;
4236 +}
4237 +
4238 +int vsprintf(char *buf, const char *fmt, va_list args)
4239 +{
4240 + int len;
4241 + unsigned long num;
4242 + int i, base;
4243 + char *str;
4244 + const char *s;
4245 +
4246 + int flags; /* flags to number() */
4247 +
4248 + int field_width; /* width of output field */
4249 + int precision; /* min. # of digits for integers; max
4250 + number of chars for from string */
4251 + int qualifier; /* 'h', 'l', or 'L' for integer fields */
4252 +
4253 + for (str = buf; *fmt; ++fmt) {
4254 + if (*fmt != '%') {
4255 + *str++ = *fmt;
4256 + continue;
4257 + }
4258 +
4259 + /* process flags */
4260 + flags = 0;
4261 + repeat:
4262 + ++fmt; /* this also skips first '%' */
4263 + switch (*fmt) {
4264 + case '-':
4265 + flags |= LEFT;
4266 + goto repeat;
4267 + case '+':
4268 + flags |= PLUS;
4269 + goto repeat;
4270 + case ' ':
4271 + flags |= SPACE;
4272 + goto repeat;
4273 + case '#':
4274 + flags |= SPECIAL;
4275 + goto repeat;
4276 + case '0':
4277 + flags |= ZEROPAD;
4278 + goto repeat;
4279 + }
4280 +
4281 + /* get field width */
4282 + field_width = -1;
4283 + if (isdigit(*fmt))
4284 + field_width = skip_atoi(&fmt);
4285 + else if (*fmt == '*') {
4286 + ++fmt;
4287 + /* it's the next argument */
4288 + field_width = va_arg(args, int);
4289 + if (field_width < 0) {
4290 + field_width = -field_width;
4291 + flags |= LEFT;
4292 + }
4293 + }
4294 +
4295 + /* get the precision */
4296 + precision = -1;
4297 + if (*fmt == '.') {
4298 + ++fmt;
4299 + if (isdigit(*fmt))
4300 + precision = skip_atoi(&fmt);
4301 + else if (*fmt == '*') {
4302 + ++fmt;
4303 + /* it's the next argument */
4304 + precision = va_arg(args, int);
4305 + }
4306 + if (precision < 0)
4307 + precision = 0;
4308 + }
4309 +
4310 + /* get the conversion qualifier */
4311 + qualifier = -1;
4312 + if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
4313 + qualifier = *fmt;
4314 + ++fmt;
4315 + }
4316 +
4317 + /* default base */
4318 + base = 10;
4319 +
4320 + switch (*fmt) {
4321 + case 'c':
4322 + if (!(flags & LEFT))
4323 + while (--field_width > 0)
4324 + *str++ = ' ';
4325 + *str++ = (unsigned char)va_arg(args, int);
4326 + while (--field_width > 0)
4327 + *str++ = ' ';
4328 + continue;
4329 +
4330 + case 's':
4331 + s = va_arg(args, char *);
4332 + len = strnlen(s, precision);
4333 +
4334 + if (!(flags & LEFT))
4335 + while (len < field_width--)
4336 + *str++ = ' ';
4337 + for (i = 0; i < len; ++i)
4338 + *str++ = *s++;
4339 + while (len < field_width--)
4340 + *str++ = ' ';
4341 + continue;
4342 +
4343 + case 'p':
4344 + if (field_width == -1) {
4345 + field_width = 2 * sizeof(void *);
4346 + flags |= ZEROPAD;
4347 + }
4348 + str = number(str,
4349 + (unsigned long)va_arg(args, void *), 16,
4350 + field_width, precision, flags);
4351 + continue;
4352 +
4353 + case 'n':
4354 + if (qualifier == 'l') {
4355 + long *ip = va_arg(args, long *);
4356 + *ip = (str - buf);
4357 + } else {
4358 + int *ip = va_arg(args, int *);
4359 + *ip = (str - buf);
4360 + }
4361 + continue;
4362 +
4363 + case '%':
4364 + *str++ = '%';
4365 + continue;
4366 +
4367 + /* integer number formats - set up the flags and "break" */
4368 + case 'o':
4369 + base = 8;
4370 + break;
4371 +
4372 + case 'X':
4373 + flags |= LARGE;
4374 + case 'x':
4375 + base = 16;
4376 + break;
4377 +
4378 + case 'd':
4379 + case 'i':
4380 + flags |= SIGN;
4381 + case 'u':
4382 + break;
4383 +
4384 + default:
4385 + *str++ = '%';
4386 + if (*fmt)
4387 + *str++ = *fmt;
4388 + else
4389 + --fmt;
4390 + continue;
4391 + }
4392 + if (qualifier == 'l')
4393 + num = va_arg(args, unsigned long);
4394 + else if (qualifier == 'h') {
4395 + num = (unsigned short)va_arg(args, int);
4396 + if (flags & SIGN)
4397 + num = (short)num;
4398 + } else if (flags & SIGN)
4399 + num = va_arg(args, int);
4400 + else
4401 + num = va_arg(args, unsigned int);
4402 + str = number(str, num, base, field_width, precision, flags);
4403 + }
4404 + *str = '\0';
4405 + return str - buf;
4406 +}
4407 +
4408 +int sprintf(char *buf, const char *fmt, ...)
4409 +{
4410 + va_list args;
4411 + int i;
4412 +
4413 + va_start(args, fmt);
4414 + i = vsprintf(buf, fmt, args);
4415 + va_end(args);
4416 + return i;
4417 +}
4418 +
4419 +int printf(const char *fmt, ...)
4420 +{
4421 + char printf_buf[1024];
4422 + va_list args;
4423 + int printed;
4424 +
4425 + va_start(args, fmt);
4426 + printed = vsprintf(printf_buf, fmt, args);
4427 + va_end(args);
4428 +
4429 + puts(printf_buf);
4430 +
4431 + return printed;
4432 +}
4433 Index: linux-2.6.22.19/arch/i386/boot/setup.S
4434 ===================================================================
4435 --- linux-2.6.22.19.orig/arch/i386/boot/setup.S
4436 +++ /dev/null
4437 @@ -1,1075 +0,0 @@
4438 -/*
4439 - * setup.S Copyright (C) 1991, 1992 Linus Torvalds
4440 - *
4441 - * setup.s is responsible for getting the system data from the BIOS,
4442 - * and putting them into the appropriate places in system memory.
4443 - * both setup.s and system has been loaded by the bootblock.
4444 - *
4445 - * This code asks the bios for memory/disk/other parameters, and
4446 - * puts them in a "safe" place: 0x90000-0x901FF, ie where the
4447 - * boot-block used to be. It is then up to the protected mode
4448 - * system to read them from there before the area is overwritten
4449 - * for buffer-blocks.
4450 - *
4451 - * Move PS/2 aux init code to psaux.c
4452 - * (troyer@saifr00.cfsat.Honeywell.COM) 03Oct92
4453 - *
4454 - * some changes and additional features by Christoph Niemann,
4455 - * March 1993/June 1994 (Christoph.Niemann@linux.org)
4456 - *
4457 - * add APM BIOS checking by Stephen Rothwell, May 1994
4458 - * (sfr@canb.auug.org.au)
4459 - *
4460 - * High load stuff, initrd support and position independency
4461 - * by Hans Lermen & Werner Almesberger, February 1996
4462 - * <lermen@elserv.ffm.fgan.de>, <almesber@lrc.epfl.ch>
4463 - *
4464 - * Video handling moved to video.S by Martin Mares, March 1996
4465 - * <mj@k332.feld.cvut.cz>
4466 - *
4467 - * Extended memory detection scheme retwiddled by orc@pell.chi.il.us (david
4468 - * parsons) to avoid loadlin confusion, July 1997
4469 - *
4470 - * Transcribed from Intel (as86) -> AT&T (gas) by Chris Noe, May 1999.
4471 - * <stiker@northlink.com>
4472 - *
4473 - * Fix to work around buggy BIOSes which don't use carry bit correctly
4474 - * and/or report extended memory in CX/DX for e801h memory size detection
4475 - * call. As a result the kernel got wrong figures. The int15/e801h docs
4476 - * from Ralf Brown interrupt list seem to indicate AX/BX should be used
4477 - * anyway. So to avoid breaking many machines (presumably there was a reason
4478 - * to orginally use CX/DX instead of AX/BX), we do a kludge to see
4479 - * if CX/DX have been changed in the e801 call and if so use AX/BX .
4480 - * Michael Miller, April 2001 <michaelm@mjmm.org>
4481 - *
4482 - * New A20 code ported from SYSLINUX by H. Peter Anvin. AMD Elan bugfixes
4483 - * by Robert Schwebel, December 2001 <robert@schwebel.de>
4484 - */
4485 -
4486 -#include <asm/segment.h>
4487 -#include <linux/utsrelease.h>
4488 -#include <linux/compile.h>
4489 -#include <asm/boot.h>
4490 -#include <asm/e820.h>
4491 -#include <asm/page.h>
4492 -#include <asm/setup.h>
4493 -
4494 -/* Signature words to ensure LILO loaded us right */
4495 -#define SIG1 0xAA55
4496 -#define SIG2 0x5A5A
4497 -
4498 -INITSEG = DEF_INITSEG # 0x9000, we move boot here, out of the way
4499 -SYSSEG = DEF_SYSSEG # 0x1000, system loaded at 0x10000 (65536).
4500 -SETUPSEG = DEF_SETUPSEG # 0x9020, this is the current segment
4501 - # ... and the former contents of CS
4502 -
4503 -DELTA_INITSEG = SETUPSEG - INITSEG # 0x0020
4504 -
4505 -.code16
4506 -.globl begtext, begdata, begbss, endtext, enddata, endbss
4507 -
4508 -.text
4509 -begtext:
4510 -.data
4511 -begdata:
4512 -.bss
4513 -begbss:
4514 -.text
4515 -
4516 -start:
4517 - jmp trampoline
4518 -
4519 -# This is the setup header, and it must start at %cs:2 (old 0x9020:2)
4520 -
4521 - .ascii "HdrS" # header signature
4522 - .word 0x0206 # header version number (>= 0x0105)
4523 - # or else old loadlin-1.5 will fail)
4524 -realmode_swtch: .word 0, 0 # default_switch, SETUPSEG
4525 -start_sys_seg: .word SYSSEG
4526 - .word kernel_version # pointing to kernel version string
4527 - # above section of header is compatible
4528 - # with loadlin-1.5 (header v1.5). Don't
4529 - # change it.
4530 -
4531 -type_of_loader: .byte 0 # = 0, old one (LILO, Loadlin,
4532 - # Bootlin, SYSLX, bootsect...)
4533 - # See Documentation/i386/boot.txt for
4534 - # assigned ids
4535 -
4536 -# flags, unused bits must be zero (RFU) bit within loadflags
4537 -loadflags:
4538 -LOADED_HIGH = 1 # If set, the kernel is loaded high
4539 -CAN_USE_HEAP = 0x80 # If set, the loader also has set
4540 - # heap_end_ptr to tell how much
4541 - # space behind setup.S can be used for
4542 - # heap purposes.
4543 - # Only the loader knows what is free
4544 -#ifndef __BIG_KERNEL__
4545 - .byte 0
4546 -#else
4547 - .byte LOADED_HIGH
4548 -#endif
4549 -
4550 -setup_move_size: .word 0x8000 # size to move, when setup is not
4551 - # loaded at 0x90000. We will move setup
4552 - # to 0x90000 then just before jumping
4553 - # into the kernel. However, only the
4554 - # loader knows how much data behind
4555 - # us also needs to be loaded.
4556 -
4557 -code32_start: # here loaders can put a different
4558 - # start address for 32-bit code.
4559 -#ifndef __BIG_KERNEL__
4560 - .long 0x1000 # 0x1000 = default for zImage
4561 -#else
4562 - .long 0x100000 # 0x100000 = default for big kernel
4563 -#endif
4564 -
4565 -ramdisk_image: .long 0 # address of loaded ramdisk image
4566 - # Here the loader puts the 32-bit
4567 - # address where it loaded the image.
4568 - # This only will be read by the kernel.
4569 -
4570 -ramdisk_size: .long 0 # its size in bytes
4571 -
4572 -bootsect_kludge:
4573 - .long 0 # obsolete
4574 -
4575 -heap_end_ptr: .word modelist+1024 # (Header version 0x0201 or later)
4576 - # space from here (exclusive) down to
4577 - # end of setup code can be used by setup
4578 - # for local heap purposes.
4579 -
4580 -pad1: .word 0
4581 -cmd_line_ptr: .long 0 # (Header version 0x0202 or later)
4582 - # If nonzero, a 32-bit pointer
4583 - # to the kernel command line.
4584 - # The command line should be
4585 - # located between the start of
4586 - # setup and the end of low
4587 - # memory (0xa0000), or it may
4588 - # get overwritten before it
4589 - # gets read. If this field is
4590 - # used, there is no longer
4591 - # anything magical about the
4592 - # 0x90000 segment; the setup
4593 - # can be located anywhere in
4594 - # low memory 0x10000 or higher.
4595 -
4596 -ramdisk_max: .long (-__PAGE_OFFSET-(512 << 20)-1) & 0x7fffffff
4597 - # (Header version 0x0203 or later)
4598 - # The highest safe address for
4599 - # the contents of an initrd
4600 -
4601 -kernel_alignment: .long CONFIG_PHYSICAL_ALIGN #physical addr alignment
4602 - #required for protected mode
4603 - #kernel
4604 -#ifdef CONFIG_RELOCATABLE
4605 -relocatable_kernel: .byte 1
4606 -#else
4607 -relocatable_kernel: .byte 0
4608 -#endif
4609 -pad2: .byte 0
4610 -pad3: .word 0
4611 -
4612 -cmdline_size: .long COMMAND_LINE_SIZE-1 #length of the command line,
4613 - #added with boot protocol
4614 - #version 2.06
4615 -
4616 -trampoline: call start_of_setup
4617 - .align 16
4618 - # The offset at this point is 0x240
4619 - .space (0xeff-0x240+1) # E820 & EDD space (ending at 0xeff)
4620 -# End of setup header #####################################################
4621 -
4622 -start_of_setup:
4623 -# Bootlin depends on this being done early
4624 - movw $0x01500, %ax
4625 - movb $0x81, %dl
4626 - int $0x13
4627 -
4628 -#ifdef SAFE_RESET_DISK_CONTROLLER
4629 -# Reset the disk controller.
4630 - movw $0x0000, %ax
4631 - movb $0x80, %dl
4632 - int $0x13
4633 -#endif
4634 -
4635 -# Set %ds = %cs, we know that SETUPSEG = %cs at this point
4636 - movw %cs, %ax # aka SETUPSEG
4637 - movw %ax, %ds
4638 -# Check signature at end of setup
4639 - cmpw $SIG1, setup_sig1
4640 - jne bad_sig
4641 -
4642 - cmpw $SIG2, setup_sig2
4643 - jne bad_sig
4644 -
4645 - jmp good_sig1
4646 -
4647 -# Routine to print asciiz string at ds:si
4648 -prtstr:
4649 - lodsb
4650 - andb %al, %al
4651 - jz fin
4652 -
4653 - call prtchr
4654 - jmp prtstr
4655 -
4656 -fin: ret
4657 -
4658 -# Space printing
4659 -prtsp2: call prtspc # Print double space
4660 -prtspc: movb $0x20, %al # Print single space (note: fall-thru)
4661 -
4662 -# Part of above routine, this one just prints ascii al
4663 -prtchr: pushw %ax
4664 - pushw %cx
4665 - movw $7,%bx
4666 - movw $0x01, %cx
4667 - movb $0x0e, %ah
4668 - int $0x10
4669 - popw %cx
4670 - popw %ax
4671 - ret
4672 -
4673 -beep: movb $0x07, %al
4674 - jmp prtchr
4675 -
4676 -no_sig_mess: .string "No setup signature found ..."
4677 -
4678 -good_sig1:
4679 - jmp good_sig
4680 -
4681 -# We now have to find the rest of the setup code/data
4682 -bad_sig:
4683 - movw %cs, %ax # SETUPSEG
4684 - subw $DELTA_INITSEG, %ax # INITSEG
4685 - movw %ax, %ds
4686 - xorb %bh, %bh
4687 - movb (497), %bl # get setup sect from bootsect
4688 - subw $4, %bx # LILO loads 4 sectors of setup
4689 - shlw $8, %bx # convert to words (1sect=2^8 words)
4690 - movw %bx, %cx
4691 - shrw $3, %bx # convert to segment
4692 - addw $SYSSEG, %bx
4693 - movw %bx, %cs:start_sys_seg
4694 -# Move rest of setup code/data to here
4695 - movw $2048, %di # four sectors loaded by LILO
4696 - subw %si, %si
4697 - pushw %cs
4698 - popw %es
4699 - movw $SYSSEG, %ax
4700 - movw %ax, %ds
4701 - rep
4702 - movsw
4703 - movw %cs, %ax # aka SETUPSEG
4704 - movw %ax, %ds
4705 - cmpw $SIG1, setup_sig1
4706 - jne no_sig
4707 -
4708 - cmpw $SIG2, setup_sig2
4709 - jne no_sig
4710 -
4711 - jmp good_sig
4712 -
4713 -no_sig:
4714 - lea no_sig_mess, %si
4715 - call prtstr
4716 -
4717 -no_sig_loop:
4718 - hlt
4719 - jmp no_sig_loop
4720 -
4721 -good_sig:
4722 - movw %cs, %ax # aka SETUPSEG
4723 - subw $DELTA_INITSEG, %ax # aka INITSEG
4724 - movw %ax, %ds
4725 -# Check if an old loader tries to load a big-kernel
4726 - testb $LOADED_HIGH, %cs:loadflags # Do we have a big kernel?
4727 - jz loader_ok # No, no danger for old loaders.
4728 -
4729 - cmpb $0, %cs:type_of_loader # Do we have a loader that
4730 - # can deal with us?
4731 - jnz loader_ok # Yes, continue.
4732 -
4733 - pushw %cs # No, we have an old loader,
4734 - popw %ds # die.
4735 - lea loader_panic_mess, %si
4736 - call prtstr
4737 -
4738 - jmp no_sig_loop
4739 -
4740 -loader_panic_mess: .string "Wrong loader, giving up..."
4741 -
4742 -# check minimum cpuid
4743 -# we do this here because it is the last place we can actually
4744 -# show a user visible error message. Later the video modus
4745 -# might be already messed up.
4746 -loader_ok:
4747 - call verify_cpu
4748 - testl %eax,%eax
4749 - jz cpu_ok
4750 - movw %cs,%ax # aka SETUPSEG
4751 - movw %ax,%ds
4752 - lea cpu_panic_mess,%si
4753 - call prtstr
4754 -1: jmp 1b
4755 -
4756 -cpu_panic_mess:
4757 - .asciz "PANIC: CPU too old for this kernel."
4758 -
4759 -#include "../kernel/verify_cpu.S"
4760 -
4761 -cpu_ok:
4762 -# Get memory size (extended mem, kB)
4763 -
4764 - xorl %eax, %eax
4765 - movl %eax, (0x1e0)
4766 -#ifndef STANDARD_MEMORY_BIOS_CALL
4767 - movb %al, (E820NR)
4768 -# Try three different memory detection schemes. First, try
4769 -# e820h, which lets us assemble a memory map, then try e801h,
4770 -# which returns a 32-bit memory size, and finally 88h, which
4771 -# returns 0-64m
4772 -
4773 -# method E820H:
4774 -# the memory map from hell. e820h returns memory classified into
4775 -# a whole bunch of different types, and allows memory holes and
4776 -# everything. We scan through this memory map and build a list
4777 -# of the first 32 memory areas, which we return at [E820MAP].
4778 -# This is documented at http://www.acpi.info/, in the ACPI 2.0 specification.
4779 -
4780 -#define SMAP 0x534d4150
4781 -
4782 -meme820:
4783 - xorl %ebx, %ebx # continuation counter
4784 - movw $E820MAP, %di # point into the whitelist
4785 - # so we can have the bios
4786 - # directly write into it.
4787 -
4788 -jmpe820:
4789 - movl $0x0000e820, %eax # e820, upper word zeroed
4790 - movl $SMAP, %edx # ascii 'SMAP'
4791 - movl $20, %ecx # size of the e820rec
4792 - pushw %ds # data record.
4793 - popw %es
4794 - int $0x15 # make the call
4795 - jc bail820 # fall to e801 if it fails
4796 -
4797 - cmpl $SMAP, %eax # check the return is `SMAP'
4798 - jne bail820 # fall to e801 if it fails
4799 -
4800 -# cmpl $1, 16(%di) # is this usable memory?
4801 -# jne again820
4802 -
4803 - # If this is usable memory, we save it by simply advancing %di by
4804 - # sizeof(e820rec).
4805 - #
4806 -good820:
4807 - movb (E820NR), %al # up to 128 entries
4808 - cmpb $E820MAX, %al
4809 - jae bail820
4810 -
4811 - incb (E820NR)
4812 - movw %di, %ax
4813 - addw $20, %ax
4814 - movw %ax, %di
4815 -again820:
4816 - cmpl $0, %ebx # check to see if
4817 - jne jmpe820 # %ebx is set to EOF
4818 -bail820:
4819 -
4820 -
4821 -# method E801H:
4822 -# memory size is in 1k chunksizes, to avoid confusing loadlin.
4823 -# we store the 0xe801 memory size in a completely different place,
4824 -# because it will most likely be longer than 16 bits.
4825 -# (use 1e0 because that's what Larry Augustine uses in his
4826 -# alternative new memory detection scheme, and it's sensible
4827 -# to write everything into the same place.)
4828 -
4829 -meme801:
4830 - stc # fix to work around buggy
4831 - xorw %cx,%cx # BIOSes which don't clear/set
4832 - xorw %dx,%dx # carry on pass/error of
4833 - # e801h memory size call
4834 - # or merely pass cx,dx though
4835 - # without changing them.
4836 - movw $0xe801, %ax
4837 - int $0x15
4838 - jc mem88
4839 -
4840 - cmpw $0x0, %cx # Kludge to handle BIOSes
4841 - jne e801usecxdx # which report their extended
4842 - cmpw $0x0, %dx # memory in AX/BX rather than
4843 - jne e801usecxdx # CX/DX. The spec I have read
4844 - movw %ax, %cx # seems to indicate AX/BX
4845 - movw %bx, %dx # are more reasonable anyway...
4846 -
4847 -e801usecxdx:
4848 - andl $0xffff, %edx # clear sign extend
4849 - shll $6, %edx # and go from 64k to 1k chunks
4850 - movl %edx, (0x1e0) # store extended memory size
4851 - andl $0xffff, %ecx # clear sign extend
4852 - addl %ecx, (0x1e0) # and add lower memory into
4853 - # total size.
4854 -
4855 -# Ye Olde Traditional Methode. Returns the memory size (up to 16mb or
4856 -# 64mb, depending on the bios) in ax.
4857 -mem88:
4858 -
4859 -#endif
4860 - movb $0x88, %ah
4861 - int $0x15
4862 - movw %ax, (2)
4863 -
4864 -# Set the keyboard repeat rate to the max
4865 - movw $0x0305, %ax
4866 - xorw %bx, %bx
4867 - int $0x16
4868 -
4869 -# Check for video adapter and its parameters and allow the
4870 -# user to browse video modes.
4871 - call video # NOTE: we need %ds pointing
4872 - # to bootsector
4873 -
4874 -# Get hd0 data...
4875 - xorw %ax, %ax
4876 - movw %ax, %ds
4877 - ldsw (4 * 0x41), %si
4878 - movw %cs, %ax # aka SETUPSEG
4879 - subw $DELTA_INITSEG, %ax # aka INITSEG
4880 - pushw %ax
4881 - movw %ax, %es
4882 - movw $0x0080, %di
4883 - movw $0x10, %cx
4884 - pushw %cx
4885 - cld
4886 - rep
4887 - movsb
4888 -# Get hd1 data...
4889 - xorw %ax, %ax
4890 - movw %ax, %ds
4891 - ldsw (4 * 0x46), %si
4892 - popw %cx
4893 - popw %es
4894 - movw $0x0090, %di
4895 - rep
4896 - movsb
4897 -# Check that there IS a hd1 :-)
4898 - movw $0x01500, %ax
4899 - movb $0x81, %dl
4900 - int $0x13
4901 - jc no_disk1
4902 -
4903 - cmpb $3, %ah
4904 - je is_disk1
4905 -
4906 -no_disk1:
4907 - movw %cs, %ax # aka SETUPSEG
4908 - subw $DELTA_INITSEG, %ax # aka INITSEG
4909 - movw %ax, %es
4910 - movw $0x0090, %di
4911 - movw $0x10, %cx
4912 - xorw %ax, %ax
4913 - cld
4914 - rep
4915 - stosb
4916 -is_disk1:
4917 -# check for Micro Channel (MCA) bus
4918 - movw %cs, %ax # aka SETUPSEG
4919 - subw $DELTA_INITSEG, %ax # aka INITSEG
4920 - movw %ax, %ds
4921 - xorw %ax, %ax
4922 - movw %ax, (0xa0) # set table length to 0
4923 - movb $0xc0, %ah
4924 - stc
4925 - int $0x15 # moves feature table to es:bx
4926 - jc no_mca
4927 -
4928 - pushw %ds
4929 - movw %es, %ax
4930 - movw %ax, %ds
4931 - movw %cs, %ax # aka SETUPSEG
4932 - subw $DELTA_INITSEG, %ax # aka INITSEG
4933 - movw %ax, %es
4934 - movw %bx, %si
4935 - movw $0xa0, %di
4936 - movw (%si), %cx
4937 - addw $2, %cx # table length is a short
4938 - cmpw $0x10, %cx
4939 - jc sysdesc_ok
4940 -
4941 - movw $0x10, %cx # we keep only first 16 bytes
4942 -sysdesc_ok:
4943 - rep
4944 - movsb
4945 - popw %ds
4946 -no_mca:
4947 -#ifdef CONFIG_X86_VOYAGER
4948 - movb $0xff, 0x40 # flag on config found
4949 - movb $0xc0, %al
4950 - mov $0xff, %ah
4951 - int $0x15 # put voyager config info at es:di
4952 - jc no_voyager
4953 - movw $0x40, %si # place voyager info in apm table
4954 - cld
4955 - movw $7, %cx
4956 -voyager_rep:
4957 - movb %es:(%di), %al
4958 - movb %al,(%si)
4959 - incw %di
4960 - incw %si
4961 - decw %cx
4962 - jnz voyager_rep
4963 -no_voyager:
4964 -#endif
4965 -# Check for PS/2 pointing device
4966 - movw %cs, %ax # aka SETUPSEG
4967 - subw $DELTA_INITSEG, %ax # aka INITSEG
4968 - movw %ax, %ds
4969 - movb $0, (0x1ff) # default is no pointing device
4970 - int $0x11 # int 0x11: equipment list
4971 - testb $0x04, %al # check if mouse installed
4972 - jz no_psmouse
4973 -
4974 - movb $0xAA, (0x1ff) # device present
4975 -no_psmouse:
4976 -
4977 -#if defined(CONFIG_X86_SPEEDSTEP_SMI) || defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE)
4978 - movl $0x0000E980, %eax # IST Support
4979 - movl $0x47534943, %edx # Request value
4980 - int $0x15
4981 -
4982 - movl %eax, (96)
4983 - movl %ebx, (100)
4984 - movl %ecx, (104)
4985 - movl %edx, (108)
4986 -#endif
4987 -
4988 -#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
4989 -# Then check for an APM BIOS...
4990 - # %ds points to the bootsector
4991 - movw $0, 0x40 # version = 0 means no APM BIOS
4992 - movw $0x05300, %ax # APM BIOS installation check
4993 - xorw %bx, %bx
4994 - int $0x15
4995 - jc done_apm_bios # Nope, no APM BIOS
4996 -
4997 - cmpw $0x0504d, %bx # Check for "PM" signature
4998 - jne done_apm_bios # No signature, no APM BIOS
4999 -
5000 - andw $0x02, %cx # Is 32 bit supported?
5001 - je done_apm_bios # No 32-bit, no (good) APM BIOS
5002 -
5003 - movw $0x05304, %ax # Disconnect first just in case
5004 - xorw %bx, %bx
5005 - int $0x15 # ignore return code
5006 - movw $0x05303, %ax # 32 bit connect
5007 - xorl %ebx, %ebx
5008 - xorw %cx, %cx # paranoia :-)
5009 - xorw %dx, %dx # ...
5010 - xorl %esi, %esi # ...
5011 - xorw %di, %di # ...
5012 - int $0x15
5013 - jc no_32_apm_bios # Ack, error.
5014 -
5015 - movw %ax, (66) # BIOS code segment
5016 - movl %ebx, (68) # BIOS entry point offset
5017 - movw %cx, (72) # BIOS 16 bit code segment
5018 - movw %dx, (74) # BIOS data segment
5019 - movl %esi, (78) # BIOS code segment lengths
5020 - movw %di, (82) # BIOS data segment length
5021 -# Redo the installation check as the 32 bit connect
5022 -# modifies the flags returned on some BIOSs
5023 - movw $0x05300, %ax # APM BIOS installation check
5024 - xorw %bx, %bx
5025 - xorw %cx, %cx # paranoia
5026 - int $0x15
5027 - jc apm_disconnect # error -> shouldn't happen
5028 -
5029 - cmpw $0x0504d, %bx # check for "PM" signature
5030 - jne apm_disconnect # no sig -> shouldn't happen
5031 -
5032 - movw %ax, (64) # record the APM BIOS version
5033 - movw %cx, (76) # and flags
5034 - jmp done_apm_bios
5035 -
5036 -apm_disconnect: # Tidy up
5037 - movw $0x05304, %ax # Disconnect
5038 - xorw %bx, %bx
5039 - int $0x15 # ignore return code
5040 -
5041 - jmp done_apm_bios
5042 -
5043 -no_32_apm_bios:
5044 - andw $0xfffd, (76) # remove 32 bit support bit
5045 -done_apm_bios:
5046 -#endif
5047 -
5048 -#include "edd.S"
5049 -
5050 -# Now we want to move to protected mode ...
5051 - cmpw $0, %cs:realmode_swtch
5052 - jz rmodeswtch_normal
5053 -
5054 - lcall *%cs:realmode_swtch
5055 -
5056 - jmp rmodeswtch_end
5057 -
5058 -rmodeswtch_normal:
5059 - pushw %cs
5060 - call default_switch
5061 -
5062 -rmodeswtch_end:
5063 -# Now we move the system to its rightful place ... but we check if we have a
5064 -# big-kernel. In that case we *must* not move it ...
5065 - testb $LOADED_HIGH, %cs:loadflags
5066 - jz do_move0 # .. then we have a normal low
5067 - # loaded zImage
5068 - # .. or else we have a high
5069 - # loaded bzImage
5070 - jmp end_move # ... and we skip moving
5071 -
5072 -do_move0:
5073 - movw $0x100, %ax # start of destination segment
5074 - movw %cs, %bp # aka SETUPSEG
5075 - subw $DELTA_INITSEG, %bp # aka INITSEG
5076 - movw %cs:start_sys_seg, %bx # start of source segment
5077 - cld
5078 -do_move:
5079 - movw %ax, %es # destination segment
5080 - incb %ah # instead of add ax,#0x100
5081 - movw %bx, %ds # source segment
5082 - addw $0x100, %bx
5083 - subw %di, %di
5084 - subw %si, %si
5085 - movw $0x800, %cx
5086 - rep
5087 - movsw
5088 - cmpw %bp, %bx # assume start_sys_seg > 0x200,
5089 - # so we will perhaps read one
5090 - # page more than needed, but
5091 - # never overwrite INITSEG
5092 - # because destination is a
5093 - # minimum one page below source
5094 - jb do_move
5095 -
5096 -end_move:
5097 -# then we load the segment descriptors
5098 - movw %cs, %ax # aka SETUPSEG
5099 - movw %ax, %ds
5100 -
5101 -# Check whether we need to be downward compatible with version <=201
5102 - cmpl $0, cmd_line_ptr
5103 - jne end_move_self # loader uses version >=202 features
5104 - cmpb $0x20, type_of_loader
5105 - je end_move_self # bootsect loader, we know of it
5106 -
5107 -# Boot loader doesnt support boot protocol version 2.02.
5108 -# If we have our code not at 0x90000, we need to move it there now.
5109 -# We also then need to move the params behind it (commandline)
5110 -# Because we would overwrite the code on the current IP, we move
5111 -# it in two steps, jumping high after the first one.
5112 - movw %cs, %ax
5113 - cmpw $SETUPSEG, %ax
5114 - je end_move_self
5115 -
5116 - cli # make sure we really have
5117 - # interrupts disabled !
5118 - # because after this the stack
5119 - # should not be used
5120 - subw $DELTA_INITSEG, %ax # aka INITSEG
5121 - movw %ss, %dx
5122 - cmpw %ax, %dx
5123 - jb move_self_1
5124 -
5125 - addw $INITSEG, %dx
5126 - subw %ax, %dx # this will go into %ss after
5127 - # the move
5128 -move_self_1:
5129 - movw %ax, %ds
5130 - movw $INITSEG, %ax # real INITSEG
5131 - movw %ax, %es
5132 - movw %cs:setup_move_size, %cx
5133 - std # we have to move up, so we use
5134 - # direction down because the
5135 - # areas may overlap
5136 - movw %cx, %di
5137 - decw %di
5138 - movw %di, %si
5139 - subw $move_self_here+0x200, %cx
5140 - rep
5141 - movsb
5142 - ljmp $SETUPSEG, $move_self_here
5143 -
5144 -move_self_here:
5145 - movw $move_self_here+0x200, %cx
5146 - rep
5147 - movsb
5148 - movw $SETUPSEG, %ax
5149 - movw %ax, %ds
5150 - movw %dx, %ss
5151 -end_move_self: # now we are at the right place
5152 -
5153 -#
5154 -# Enable A20. This is at the very best an annoying procedure.
5155 -# A20 code ported from SYSLINUX 1.52-1.63 by H. Peter Anvin.
5156 -# AMD Elan bug fix by Robert Schwebel.
5157 -#
5158 -
5159 -#if defined(CONFIG_X86_ELAN)
5160 - movb $0x02, %al # alternate A20 gate
5161 - outb %al, $0x92 # this works on SC410/SC520
5162 -a20_elan_wait:
5163 - call a20_test
5164 - jz a20_elan_wait
5165 - jmp a20_done
5166 -#endif
5167 -
5168 -
5169 -A20_TEST_LOOPS = 32 # Iterations per wait
5170 -A20_ENABLE_LOOPS = 255 # Total loops to try
5171 -
5172 -
5173 -#ifndef CONFIG_X86_VOYAGER
5174 -a20_try_loop:
5175 -
5176 - # First, see if we are on a system with no A20 gate.
5177 -a20_none:
5178 - call a20_test
5179 - jnz a20_done
5180 -
5181 - # Next, try the BIOS (INT 0x15, AX=0x2401)
5182 -a20_bios:
5183 - movw $0x2401, %ax
5184 - pushfl # Be paranoid about flags
5185 - int $0x15
5186 - popfl
5187 -
5188 - call a20_test
5189 - jnz a20_done
5190 -
5191 - # Try enabling A20 through the keyboard controller
5192 -#endif /* CONFIG_X86_VOYAGER */
5193 -a20_kbc:
5194 - call empty_8042
5195 -
5196 -#ifndef CONFIG_X86_VOYAGER
5197 - call a20_test # Just in case the BIOS worked
5198 - jnz a20_done # but had a delayed reaction.
5199 -#endif
5200 -
5201 - movb $0xD1, %al # command write
5202 - outb %al, $0x64
5203 - call empty_8042
5204 -
5205 - movb $0xDF, %al # A20 on
5206 - outb %al, $0x60
5207 - call empty_8042
5208 -
5209 -#ifndef CONFIG_X86_VOYAGER
5210 - # Wait until a20 really *is* enabled; it can take a fair amount of
5211 - # time on certain systems; Toshiba Tecras are known to have this
5212 - # problem.
5213 -a20_kbc_wait:
5214 - xorw %cx, %cx
5215 -a20_kbc_wait_loop:
5216 - call a20_test
5217 - jnz a20_done
5218 - loop a20_kbc_wait_loop
5219 -
5220 - # Final attempt: use "configuration port A"
5221 -a20_fast:
5222 - inb $0x92, %al # Configuration Port A
5223 - orb $0x02, %al # "fast A20" version
5224 - andb $0xFE, %al # don't accidentally reset
5225 - outb %al, $0x92
5226 -
5227 - # Wait for configuration port A to take effect
5228 -a20_fast_wait:
5229 - xorw %cx, %cx
5230 -a20_fast_wait_loop:
5231 - call a20_test
5232 - jnz a20_done
5233 - loop a20_fast_wait_loop
5234 -
5235 - # A20 is still not responding. Try frobbing it again.
5236 - #
5237 - decb (a20_tries)
5238 - jnz a20_try_loop
5239 -
5240 - movw $a20_err_msg, %si
5241 - call prtstr
5242 -
5243 -a20_die:
5244 - hlt
5245 - jmp a20_die
5246 -
5247 -a20_tries:
5248 - .byte A20_ENABLE_LOOPS
5249 -
5250 -a20_err_msg:
5251 - .ascii "linux: fatal error: A20 gate not responding!"
5252 - .byte 13, 10, 0
5253 -
5254 - # If we get here, all is good
5255 -a20_done:
5256 -
5257 -#endif /* CONFIG_X86_VOYAGER */
5258 -# set up gdt and idt and 32bit start address
5259 - lidt idt_48 # load idt with 0,0
5260 - xorl %eax, %eax # Compute gdt_base
5261 - movw %ds, %ax # (Convert %ds:gdt to a linear ptr)
5262 - shll $4, %eax
5263 - addl %eax, code32
5264 - addl $gdt, %eax
5265 - movl %eax, (gdt_48+2)
5266 - lgdt gdt_48 # load gdt with whatever is
5267 - # appropriate
5268 -
5269 -# make sure any possible coprocessor is properly reset..
5270 - xorw %ax, %ax
5271 - outb %al, $0xf0
5272 - call delay
5273 -
5274 - outb %al, $0xf1
5275 - call delay
5276 -
5277 -# well, that went ok, I hope. Now we mask all interrupts - the rest
5278 -# is done in init_IRQ().
5279 - movb $0xFF, %al # mask all interrupts for now
5280 - outb %al, $0xA1
5281 - call delay
5282 -
5283 - movb $0xFB, %al # mask all irq's but irq2 which
5284 - outb %al, $0x21 # is cascaded
5285 -
5286 -# Well, that certainly wasn't fun :-(. Hopefully it works, and we don't
5287 -# need no steenking BIOS anyway (except for the initial loading :-).
5288 -# The BIOS-routine wants lots of unnecessary data, and it's less
5289 -# "interesting" anyway. This is how REAL programmers do it.
5290 -#
5291 -# Well, now's the time to actually move into protected mode. To make
5292 -# things as simple as possible, we do no register set-up or anything,
5293 -# we let the gnu-compiled 32-bit programs do that. We just jump to
5294 -# absolute address 0x1000 (or the loader supplied one),
5295 -# in 32-bit protected mode.
5296 -#
5297 -# Note that the short jump isn't strictly needed, although there are
5298 -# reasons why it might be a good idea. It won't hurt in any case.
5299 - movw $1, %ax # protected mode (PE) bit
5300 - lmsw %ax # This is it!
5301 - jmp flush_instr
5302 -
5303 -flush_instr:
5304 - xorw %bx, %bx # Flag to indicate a boot
5305 - xorl %esi, %esi # Pointer to real-mode code
5306 - movw %cs, %si
5307 - subw $DELTA_INITSEG, %si
5308 - shll $4, %esi # Convert to 32-bit pointer
5309 -
5310 -# jump to startup_32 in arch/i386/boot/compressed/head.S
5311 -#
5312 -# NOTE: For high loaded big kernels we need a
5313 -# jmpi 0x100000,__BOOT_CS
5314 -#
5315 -# but we yet haven't reloaded the CS register, so the default size
5316 -# of the target offset still is 16 bit.
5317 -# However, using an operand prefix (0x66), the CPU will properly
5318 -# take our 48 bit far pointer. (INTeL 80386 Programmer's Reference
5319 -# Manual, Mixing 16-bit and 32-bit code, page 16-6)
5320 -
5321 - .byte 0x66, 0xea # prefix + jmpi-opcode
5322 -code32: .long startup_32 # will be set to %cs+startup_32
5323 - .word __BOOT_CS
5324 -.code32
5325 -startup_32:
5326 - movl $(__BOOT_DS), %eax
5327 - movl %eax, %ds
5328 - movl %eax, %es
5329 - movl %eax, %fs
5330 - movl %eax, %gs
5331 - movl %eax, %ss
5332 -
5333 - xorl %eax, %eax
5334 -1: incl %eax # check that A20 really IS enabled
5335 - movl %eax, 0x00000000 # loop forever if it isn't
5336 - cmpl %eax, 0x00100000
5337 - je 1b
5338 -
5339 - # Jump to the 32bit entry point
5340 - jmpl *(code32_start - start + (DELTA_INITSEG << 4))(%esi)
5341 -.code16
5342 -
5343 -# Here's a bunch of information about your current kernel..
5344 -kernel_version: .ascii UTS_RELEASE
5345 - .ascii " ("
5346 - .ascii LINUX_COMPILE_BY
5347 - .ascii "@"
5348 - .ascii LINUX_COMPILE_HOST
5349 - .ascii ") "
5350 - .ascii UTS_VERSION
5351 - .byte 0
5352 -
5353 -# This is the default real mode switch routine.
5354 -# to be called just before protected mode transition
5355 -default_switch:
5356 - cli # no interrupts allowed !
5357 - movb $0x80, %al # disable NMI for bootup
5358 - # sequence
5359 - outb %al, $0x70
5360 - lret
5361 -
5362 -
5363 -#ifndef CONFIG_X86_VOYAGER
5364 -# This routine tests whether or not A20 is enabled. If so, it
5365 -# exits with zf = 0.
5366 -#
5367 -# The memory address used, 0x200, is the int $0x80 vector, which
5368 -# should be safe.
5369 -
5370 -A20_TEST_ADDR = 4*0x80
5371 -
5372 -a20_test:
5373 - pushw %cx
5374 - pushw %ax
5375 - xorw %cx, %cx
5376 - movw %cx, %fs # Low memory
5377 - decw %cx
5378 - movw %cx, %gs # High memory area
5379 - movw $A20_TEST_LOOPS, %cx
5380 - movw %fs:(A20_TEST_ADDR), %ax
5381 - pushw %ax
5382 -a20_test_wait:
5383 - incw %ax
5384 - movw %ax, %fs:(A20_TEST_ADDR)
5385 - call delay # Serialize and make delay constant
5386 - cmpw %gs:(A20_TEST_ADDR+0x10), %ax
5387 - loope a20_test_wait
5388 -
5389 - popw %fs:(A20_TEST_ADDR)
5390 - popw %ax
5391 - popw %cx
5392 - ret
5393 -
5394 -#endif /* CONFIG_X86_VOYAGER */
5395 -
5396 -# This routine checks that the keyboard command queue is empty
5397 -# (after emptying the output buffers)
5398 -#
5399 -# Some machines have delusions that the keyboard buffer is always full
5400 -# with no keyboard attached...
5401 -#
5402 -# If there is no keyboard controller, we will usually get 0xff
5403 -# to all the reads. With each IO taking a microsecond and
5404 -# a timeout of 100,000 iterations, this can take about half a
5405 -# second ("delay" == outb to port 0x80). That should be ok,
5406 -# and should also be plenty of time for a real keyboard controller
5407 -# to empty.
5408 -#
5409 -
5410 -empty_8042:
5411 - pushl %ecx
5412 - movl $100000, %ecx
5413 -
5414 -empty_8042_loop:
5415 - decl %ecx
5416 - jz empty_8042_end_loop
5417 -
5418 - call delay
5419 -
5420 - inb $0x64, %al # 8042 status port
5421 - testb $1, %al # output buffer?
5422 - jz no_output
5423 -
5424 - call delay
5425 - inb $0x60, %al # read it
5426 - jmp empty_8042_loop
5427 -
5428 -no_output:
5429 - testb $2, %al # is input buffer full?
5430 - jnz empty_8042_loop # yes - loop
5431 -empty_8042_end_loop:
5432 - popl %ecx
5433 - ret
5434 -
5435 -# Read the cmos clock. Return the seconds in al
5436 -gettime:
5437 - pushw %cx
5438 - movb $0x02, %ah
5439 - int $0x1a
5440 - movb %dh, %al # %dh contains the seconds
5441 - andb $0x0f, %al
5442 - movb %dh, %ah
5443 - movb $0x04, %cl
5444 - shrb %cl, %ah
5445 - aad
5446 - popw %cx
5447 - ret
5448 -
5449 -# Delay is needed after doing I/O
5450 -delay:
5451 - outb %al,$0x80
5452 - ret
5453 -
5454 -# Descriptor tables
5455 -#
5456 -# NOTE: The intel manual says gdt should be sixteen bytes aligned for
5457 -# efficiency reasons. However, there are machines which are known not
5458 -# to boot with misaligned GDTs, so alter this at your peril! If you alter
5459 -# GDT_ENTRY_BOOT_CS (in asm/segment.h) remember to leave at least two
5460 -# empty GDT entries (one for NULL and one reserved).
5461 -#
5462 -# NOTE: On some CPUs, the GDT must be 8 byte aligned. This is
5463 -# true for the Voyager Quad CPU card which will not boot without
5464 -# This directive. 16 byte aligment is recommended by intel.
5465 -#
5466 - .align 16
5467 -gdt:
5468 - .fill GDT_ENTRY_BOOT_CS,8,0
5469 -
5470 - .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb)
5471 - .word 0 # base address = 0
5472 - .word 0x9A00 # code read/exec
5473 - .word 0x00CF # granularity = 4096, 386
5474 - # (+5th nibble of limit)
5475 -
5476 - .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb)
5477 - .word 0 # base address = 0
5478 - .word 0x9200 # data read/write
5479 - .word 0x00CF # granularity = 4096, 386
5480 - # (+5th nibble of limit)
5481 -gdt_end:
5482 - .align 4
5483 -
5484 - .word 0 # alignment byte
5485 -idt_48:
5486 - .word 0 # idt limit = 0
5487 - .word 0, 0 # idt base = 0L
5488 -
5489 - .word 0 # alignment byte
5490 -gdt_48:
5491 - .word gdt_end - gdt - 1 # gdt limit
5492 - .word 0, 0 # gdt base (filled in later)
5493 -
5494 -# Include video setup & detection code
5495 -
5496 -#include "video.S"
5497 -
5498 -# Setup signature -- must be last
5499 -setup_sig1: .word SIG1
5500 -setup_sig2: .word SIG2
5501 -
5502 -# After this point, there is some free space which is used by the video mode
5503 -# handling code to store the temporary mode table (not used by the kernel).
5504 -
5505 -modelist:
5506 -
5507 -.text
5508 -endtext:
5509 -.data
5510 -enddata:
5511 -.bss
5512 -endbss:
5513 Index: linux-2.6.22.19/arch/i386/boot/setup.ld
5514 ===================================================================
5515 --- /dev/null
5516 +++ linux-2.6.22.19/arch/i386/boot/setup.ld
5517 @@ -0,0 +1,54 @@
5518 +/*
5519 + * setup.ld
5520 + *
5521 + * Linker script for the i386 setup code
5522 + */
5523 +OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
5524 +OUTPUT_ARCH(i386)
5525 +ENTRY(_start)
5526 +
5527 +SECTIONS
5528 +{
5529 + . = 0;
5530 + .bstext : { *(.bstext) }
5531 + .bsdata : { *(.bsdata) }
5532 +
5533 + . = 497;
5534 + .header : { *(.header) }
5535 + .inittext : { *(.inittext) }
5536 + .initdata : { *(.initdata) }
5537 + .text : { *(.text*) }
5538 +
5539 + . = ALIGN(16);
5540 + .rodata : { *(.rodata*) }
5541 +
5542 + .videocards : {
5543 + video_cards = .;
5544 + *(.videocards)
5545 + video_cards_end = .;
5546 + }
5547 +
5548 + . = ALIGN(16);
5549 + .data : { *(.data*) }
5550 +
5551 + .signature : {
5552 + setup_sig = .;
5553 + LONG(0x5a5aaa55)
5554 + }
5555 +
5556 +
5557 + . = ALIGN(16);
5558 + .bss :
5559 + {
5560 + __bss_start = .;
5561 + *(.bss)
5562 + __bss_end = .;
5563 + }
5564 + . = ALIGN(16);
5565 + _end = .;
5566 +
5567 + /DISCARD/ : { *(.note*) }
5568 +
5569 + . = ASSERT(_end <= 0x8000, "Setup too big!");
5570 + . = ASSERT(hdr == 0x1f1, "The setup header has the wrong offset!");
5571 +}
5572 Index: linux-2.6.22.19/arch/i386/boot/string.c
5573 ===================================================================
5574 --- /dev/null
5575 +++ linux-2.6.22.19/arch/i386/boot/string.c
5576 @@ -0,0 +1,34 @@
5577 +/* -*- linux-c -*- ------------------------------------------------------- *
5578 + *
5579 + * Copyright (C) 1991, 1992 Linus Torvalds
5580 + * Copyright 2007 rPath, Inc. - All Rights Reserved
5581 + *
5582 + * This file is part of the Linux kernel, and is made available under
5583 + * the terms of the GNU General Public License version 2.
5584 + *
5585 + * ----------------------------------------------------------------------- */
5586 +
5587 +/*
5588 + * arch/i386/boot/string.c
5589 + *
5590 + * Very basic string functions
5591 + */
5592 +
5593 +#include "boot.h"
5594 +#include <linux/edd.h>
5595 +
5596 +int strcmp(const char *str1, const char *str2)
5597 +{
5598 + const unsigned char *s1 = (const unsigned char *)str1;
5599 + const unsigned char *s2 = (const unsigned char *)str2;
5600 + int delta = 0;
5601 +
5602 + while (*s1 || *s2) {
5603 + delta = *s2 - *s1;
5604 + if (delta)
5605 + return delta;
5606 + s1++;
5607 + s2++;
5608 + }
5609 + return 0;
5610 +}
5611 Index: linux-2.6.22.19/arch/i386/boot/tools/build.c
5612 ===================================================================
5613 --- linux-2.6.22.19.orig/arch/i386/boot/tools/build.c
5614 +++ linux-2.6.22.19/arch/i386/boot/tools/build.c
5615 @@ -1,13 +1,12 @@
5616 /*
5617 * Copyright (C) 1991, 1992 Linus Torvalds
5618 * Copyright (C) 1997 Martin Mares
5619 + * Copyright (C) 2007 H. Peter Anvin
5620 */
5621
5622 /*
5623 * This file builds a disk-image from three different files:
5624 *
5625 - * - bootsect: compatibility mbr which prints an error message if
5626 - * someone tries to boot the kernel directly.
5627 * - setup: 8086 machine code, sets up system parm
5628 * - system: 80386 code for actual system
5629 *
5630 @@ -21,6 +20,7 @@
5631 * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
5632 * Cross compiling fixes by Gertjan van Wingerde, July 1996
5633 * Rewritten by Martin Mares, April 1997
5634 + * Substantially overhauled by H. Peter Anvin, April 2007
5635 */
5636
5637 #include <stdio.h>
5638 @@ -32,23 +32,25 @@
5639 #include <sys/sysmacros.h>
5640 #include <unistd.h>
5641 #include <fcntl.h>
5642 +#include <sys/mman.h>
5643 #include <asm/boot.h>
5644
5645 -typedef unsigned char byte;
5646 -typedef unsigned short word;
5647 -typedef unsigned long u32;
5648 +typedef unsigned char u8;
5649 +typedef unsigned short u16;
5650 +typedef unsigned long u32;
5651
5652 #define DEFAULT_MAJOR_ROOT 0
5653 #define DEFAULT_MINOR_ROOT 0
5654
5655 -/* Minimal number of setup sectors (see also bootsect.S) */
5656 -#define SETUP_SECTS 4
5657 +/* Minimal number of setup sectors */
5658 +#define SETUP_SECT_MIN 5
5659 +#define SETUP_SECT_MAX 64
5660
5661 -byte buf[1024];
5662 -int fd;
5663 +/* This must be large enough to hold the entire setup */
5664 +u8 buf[SETUP_SECT_MAX*512];
5665 int is_big_kernel;
5666
5667 -void die(const char * str, ...)
5668 +static void die(const char * str, ...)
5669 {
5670 va_list args;
5671 va_start(args, str);
5672 @@ -57,15 +59,9 @@ void die(const char * str, ...)
5673 exit(1);
5674 }
5675
5676 -void file_open(const char *name)
5677 +static void usage(void)
5678 {
5679 - if ((fd = open(name, O_RDONLY, 0)) < 0)
5680 - die("Unable to open `%s': %m", name);
5681 -}
5682 -
5683 -void usage(void)
5684 -{
5685 - die("Usage: build [-b] bootsect setup system [rootdev] [> image]");
5686 + die("Usage: build [-b] setup system [rootdev] [> image]");
5687 }
5688
5689 int main(int argc, char ** argv)
5690 @@ -73,27 +69,30 @@ int main(int argc, char ** argv)
5691 unsigned int i, sz, setup_sectors;
5692 int c;
5693 u32 sys_size;
5694 - byte major_root, minor_root;
5695 + u8 major_root, minor_root;
5696 struct stat sb;
5697 + FILE *file;
5698 + int fd;
5699 + void *kernel;
5700
5701 if (argc > 2 && !strcmp(argv[1], "-b"))
5702 {
5703 is_big_kernel = 1;
5704 argc--, argv++;
5705 }
5706 - if ((argc < 4) || (argc > 5))
5707 + if ((argc < 3) || (argc > 4))
5708 usage();
5709 - if (argc > 4) {
5710 - if (!strcmp(argv[4], "CURRENT")) {
5711 + if (argc > 3) {
5712 + if (!strcmp(argv[3], "CURRENT")) {
5713 if (stat("/", &sb)) {
5714 perror("/");
5715 die("Couldn't stat /");
5716 }
5717 major_root = major(sb.st_dev);
5718 minor_root = minor(sb.st_dev);
5719 - } else if (strcmp(argv[4], "FLOPPY")) {
5720 - if (stat(argv[4], &sb)) {
5721 - perror(argv[4]);
5722 + } else if (strcmp(argv[3], "FLOPPY")) {
5723 + if (stat(argv[3], &sb)) {
5724 + perror(argv[3]);
5725 die("Couldn't stat root device.");
5726 }
5727 major_root = major(sb.st_rdev);
5728 @@ -108,79 +107,62 @@ int main(int argc, char ** argv)
5729 }
5730 fprintf(stderr, "Root device is (%d, %d)\n", major_root, minor_root);
5731
5732 - file_open(argv[1]);
5733 - i = read(fd, buf, sizeof(buf));
5734 - fprintf(stderr,"Boot sector %d bytes.\n",i);
5735 - if (i != 512)
5736 - die("Boot block must be exactly 512 bytes");
5737 + /* Copy the setup code */
5738 + file = fopen(argv[1], "r");
5739 + if (!file)
5740 + die("Unable to open `%s': %m", argv[1]);
5741 + c = fread(buf, 1, sizeof(buf), file);
5742 + if (ferror(file))
5743 + die("read-error on `setup'");
5744 + if (c < 1024)
5745 + die("The setup must be at least 1024 bytes");
5746 if (buf[510] != 0x55 || buf[511] != 0xaa)
5747 die("Boot block hasn't got boot flag (0xAA55)");
5748 + fclose(file);
5749 +
5750 + /* Pad unused space with zeros */
5751 + setup_sectors = (c + 511) / 512;
5752 + if (setup_sectors < SETUP_SECT_MIN)
5753 + setup_sectors = SETUP_SECT_MIN;
5754 + i = setup_sectors*512;
5755 + memset(buf+c, 0, i-c);
5756 +
5757 + /* Set the default root device */
5758 buf[508] = minor_root;
5759 buf[509] = major_root;
5760 - if (write(1, buf, 512) != 512)
5761 - die("Write call failed");
5762 - close (fd);
5763 -
5764 - file_open(argv[2]); /* Copy the setup code */
5765 - for (i=0 ; (c=read(fd, buf, sizeof(buf)))>0 ; i+=c )
5766 - if (write(1, buf, c) != c)
5767 - die("Write call failed");
5768 - if (c != 0)
5769 - die("read-error on `setup'");
5770 - close (fd);
5771
5772 - setup_sectors = (i + 511) / 512; /* Pad unused space with zeros */
5773 - /* for compatibility with ancient versions of LILO. */
5774 - if (setup_sectors < SETUP_SECTS)
5775 - setup_sectors = SETUP_SECTS;
5776 - fprintf(stderr, "Setup is %d bytes.\n", i);
5777 - memset(buf, 0, sizeof(buf));
5778 - while (i < setup_sectors * 512) {
5779 - c = setup_sectors * 512 - i;
5780 - if (c > sizeof(buf))
5781 - c = sizeof(buf);
5782 - if (write(1, buf, c) != c)
5783 - die("Write call failed");
5784 - i += c;
5785 - }
5786 + fprintf(stderr, "Setup is %d bytes (padded to %d bytes).\n", c, i);
5787
5788 - file_open(argv[3]);
5789 - if (fstat (fd, &sb))
5790 - die("Unable to stat `%s': %m", argv[3]);
5791 + /* Open and stat the kernel file */
5792 + fd = open(argv[2], O_RDONLY);
5793 + if (fd < 0)
5794 + die("Unable to open `%s': %m", argv[2]);
5795 + if (fstat(fd, &sb))
5796 + die("Unable to stat `%s': %m", argv[2]);
5797 sz = sb.st_size;
5798 - fprintf (stderr, "System is %d kB\n", sz/1024);
5799 + fprintf (stderr, "System is %d kB\n", (sz+1023)/1024);
5800 + kernel = mmap(NULL, sz, PROT_READ, MAP_SHARED, fd, 0);
5801 + if (kernel == MAP_FAILED)
5802 + die("Unable to mmap '%s': %m", argv[2]);
5803 sys_size = (sz + 15) / 16;
5804 if (!is_big_kernel && sys_size > DEF_SYSSIZE)
5805 die("System is too big. Try using bzImage or modules.");
5806 - while (sz > 0) {
5807 - int l, n;
5808
5809 - l = (sz > sizeof(buf)) ? sizeof(buf) : sz;
5810 - if ((n=read(fd, buf, l)) != l) {
5811 - if (n < 0)
5812 - die("Error reading %s: %m", argv[3]);
5813 - else
5814 - die("%s: Unexpected EOF", argv[3]);
5815 - }
5816 - if (write(1, buf, l) != l)
5817 - die("Write failed");
5818 - sz -= l;
5819 - }
5820 + /* Patch the setup code with the appropriate size parameters */
5821 + buf[0x1f1] = setup_sectors-1;
5822 + buf[0x1f4] = sys_size;
5823 + buf[0x1f5] = sys_size >> 8;
5824 + buf[0x1f6] = sys_size >> 16;
5825 + buf[0x1f7] = sys_size >> 24;
5826 +
5827 + if (fwrite(buf, 1, i, stdout) != i)
5828 + die("Writing setup failed");
5829 +
5830 + /* Copy the kernel code */
5831 + if (fwrite(kernel, 1, sz, stdout) != sz)
5832 + die("Writing kernel failed");
5833 close(fd);
5834
5835 - if (lseek(1, 497, SEEK_SET) != 497) /* Write sizes to the bootsector */
5836 - die("Output: seek failed");
5837 - buf[0] = setup_sectors;
5838 - if (write(1, buf, 1) != 1)
5839 - die("Write of setup sector count failed");
5840 - if (lseek(1, 500, SEEK_SET) != 500)
5841 - die("Output: seek failed");
5842 - buf[0] = (sys_size & 0xff);
5843 - buf[1] = ((sys_size >> 8) & 0xff);
5844 - buf[2] = ((sys_size >> 16) & 0xff);
5845 - buf[3] = ((sys_size >> 24) & 0xff);
5846 - if (write(1, buf, 4) != 4)
5847 - die("Write of image length failed");
5848 -
5849 - return 0; /* Everything is OK */
5850 + /* Everything is OK */
5851 + return 0;
5852 }
5853 Index: linux-2.6.22.19/arch/i386/boot/tty.c
5854 ===================================================================
5855 --- /dev/null
5856 +++ linux-2.6.22.19/arch/i386/boot/tty.c
5857 @@ -0,0 +1,112 @@
5858 +/* -*- linux-c -*- ------------------------------------------------------- *
5859 + *
5860 + * Copyright (C) 1991, 1992 Linus Torvalds
5861 + * Copyright 2007 rPath, Inc. - All Rights Reserved
5862 + *
5863 + * This file is part of the Linux kernel, and is made available under
5864 + * the terms of the GNU General Public License version 2.
5865 + *
5866 + * ----------------------------------------------------------------------- */
5867 +
5868 +/*
5869 + * arch/i386/boot/tty.c
5870 + *
5871 + * Very simple screen I/O
5872 + * XXX: Probably should add very simple serial I/O?
5873 + */
5874 +
5875 +#include "boot.h"
5876 +
5877 +/*
5878 + * These functions are in .inittext so they can be used to signal
5879 + * error during initialization.
5880 + */
5881 +
5882 +void __attribute__((section(".inittext"))) putchar(int ch)
5883 +{
5884 + unsigned char c = ch;
5885 +
5886 + if (c == '\n')
5887 + putchar('\r'); /* \n -> \r\n */
5888 +
5889 + /* int $0x10 is known to have bugs involving touching registers
5890 + it shouldn't. Be extra conservative... */
5891 + asm volatile("pushal; int $0x10; popal"
5892 + : : "b" (0x0007), "c" (0x0001), "a" (0x0e00|ch));
5893 +}
5894 +
5895 +void __attribute__((section(".inittext"))) puts(const char *str)
5896 +{
5897 + int n = 0;
5898 + while (*str) {
5899 + putchar(*str++);
5900 + n++;
5901 + }
5902 +}
5903 +
5904 +/*
5905 + * Read the CMOS clock through the BIOS, and return the
5906 + * seconds in BCD.
5907 + */
5908 +
5909 +static u8 gettime(void)
5910 +{
5911 + u16 ax = 0x0200;
5912 + u16 cx, dx;
5913 +
5914 + asm("int $0x1a"
5915 + : "+a" (ax), "=c" (cx), "=d" (dx)
5916 + : : "ebx", "esi", "edi");
5917 +
5918 + return dx >> 8;
5919 +}
5920 +
5921 +/*
5922 + * Read from the keyboard
5923 + */
5924 +int getchar(void)
5925 +{
5926 + u16 ax = 0;
5927 + asm("int $0x16" : "+a" (ax));
5928 +
5929 + return ax & 0xff;
5930 +}
5931 +
5932 +static int kbd_pending(void)
5933 +{
5934 + u8 pending;
5935 + asm("int $0x16; setnz %0"
5936 + : "=rm" (pending)
5937 + : "a" (0x0100));
5938 + return pending;
5939 +}
5940 +
5941 +void kbd_flush(void)
5942 +{
5943 + for (;;) {
5944 + if (!kbd_pending())
5945 + break;
5946 + getchar();
5947 + }
5948 +}
5949 +
5950 +int getchar_timeout(void)
5951 +{
5952 + int cnt = 30;
5953 + int t0, t1;
5954 +
5955 + t0 = gettime();
5956 +
5957 + while (cnt) {
5958 + if (kbd_pending())
5959 + return getchar();
5960 +
5961 + t1 = gettime();
5962 + if (t0 != t1) {
5963 + cnt--;
5964 + t0 = t1;
5965 + }
5966 + }
5967 +
5968 + return 0; /* Timeout! */
5969 +}
5970 Index: linux-2.6.22.19/arch/i386/boot/version.c
5971 ===================================================================
5972 --- /dev/null
5973 +++ linux-2.6.22.19/arch/i386/boot/version.c
5974 @@ -0,0 +1,23 @@
5975 +/* -*- linux-c -*- ------------------------------------------------------- *
5976 + *
5977 + * Copyright (C) 1991, 1992 Linus Torvalds
5978 + * Copyright 2007 rPath, Inc. - All Rights Reserved
5979 + *
5980 + * This file is part of the Linux kernel, and is made available under
5981 + * the terms of the GNU General Public License version 2.
5982 + *
5983 + * ----------------------------------------------------------------------- */
5984 +
5985 +/*
5986 + * arch/i386/boot/version.c
5987 + *
5988 + * Kernel version string
5989 + */
5990 +
5991 +#include "boot.h"
5992 +#include <linux/utsrelease.h>
5993 +#include <linux/compile.h>
5994 +
5995 +const char kernel_version[] =
5996 + UTS_RELEASE " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ") "
5997 + UTS_VERSION;
5998 Index: linux-2.6.22.19/arch/i386/boot/vesa.h
5999 ===================================================================
6000 --- /dev/null
6001 +++ linux-2.6.22.19/arch/i386/boot/vesa.h
6002 @@ -0,0 +1,79 @@
6003 +/* ----------------------------------------------------------------------- *
6004 + *
6005 + * Copyright 1999-2007 H. Peter Anvin - All Rights Reserved
6006 + *
6007 + * This program is free software; you can redistribute it and/or modify
6008 + * it under the terms of the GNU General Public License as published by
6009 + * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
6010 + * Boston MA 02111-1307, USA; either version 2 of the License, or
6011 + * (at your option) any later version; incorporated herein by reference.
6012 + *
6013 + * ----------------------------------------------------------------------- */
6014 +
6015 +#ifndef BOOT_VESA_H
6016 +#define BOOT_VESA_H
6017 +
6018 +typedef struct {
6019 + u16 off, seg;
6020 +} far_ptr;
6021 +
6022 +/* VESA General Information table */
6023 +struct vesa_general_info {
6024 + u32 signature; /* 0 Magic number = "VESA" */
6025 + u16 version; /* 4 */
6026 + far_ptr vendor_string; /* 6 */
6027 + u32 capabilities; /* 10 */
6028 + far_ptr video_mode_ptr; /* 14 */
6029 + u16 total_memory; /* 18 */
6030 +
6031 + u16 oem_software_rev; /* 20 */
6032 + far_ptr oem_vendor_name_ptr; /* 22 */
6033 + far_ptr oem_product_name_ptr; /* 26 */
6034 + far_ptr oem_product_rev_ptr; /* 30 */
6035 +
6036 + u8 reserved[222]; /* 34 */
6037 + u8 oem_data[256]; /* 256 */
6038 +} __attribute__((packed));
6039 +
6040 +#define VESA_MAGIC ('V' + ('E' << 8) + ('S' << 16) + ('A' << 24))
6041 +#define VBE2_MAGIC ('V' + ('B' << 8) + ('E' << 16) + ('2' << 24))
6042 +
6043 +struct vesa_mode_info {
6044 + u16 mode_attr; /* 0 */
6045 + u8 win_attr[2]; /* 2 */
6046 + u16 win_grain; /* 4 */
6047 + u16 win_size; /* 6 */
6048 + u16 win_seg[2]; /* 8 */
6049 + far_ptr win_scheme; /* 12 */
6050 + u16 logical_scan; /* 16 */
6051 +
6052 + u16 h_res; /* 18 */
6053 + u16 v_res; /* 20 */
6054 + u8 char_width; /* 22 */
6055 + u8 char_height; /* 23 */
6056 + u8 memory_planes; /* 24 */
6057 + u8 bpp; /* 25 */
6058 + u8 banks; /* 26 */
6059 + u8 memory_layout; /* 27 */
6060 + u8 bank_size; /* 28 */
6061 + u8 image_planes; /* 29 */
6062 + u8 page_function; /* 30 */
6063 +
6064 + u8 rmask; /* 31 */
6065 + u8 rpos; /* 32 */
6066 + u8 gmask; /* 33 */
6067 + u8 gpos; /* 34 */
6068 + u8 bmask; /* 35 */
6069 + u8 bpos; /* 36 */
6070 + u8 resv_mask; /* 37 */
6071 + u8 resv_pos; /* 38 */
6072 + u8 dcm_info; /* 39 */
6073 +
6074 + u32 lfb_ptr; /* 40 Linear frame buffer address */
6075 + u32 offscreen_ptr; /* 44 Offscreen memory address */
6076 + u16 offscreen_size; /* 48 */
6077 +
6078 + u8 reserved[206]; /* 50 */
6079 +} __attribute__((packed));
6080 +
6081 +#endif /* LIB_SYS_VESA_H */
6082 Index: linux-2.6.22.19/arch/i386/boot/video-bios.c
6083 ===================================================================
6084 --- /dev/null
6085 +++ linux-2.6.22.19/arch/i386/boot/video-bios.c
6086 @@ -0,0 +1,125 @@
6087 +/* -*- linux-c -*- ------------------------------------------------------- *
6088 + *
6089 + * Copyright (C) 1991, 1992 Linus Torvalds
6090 + * Copyright 2007 rPath, Inc. - All Rights Reserved
6091 + *
6092 + * This file is part of the Linux kernel, and is made available under
6093 + * the terms of the GNU General Public License version 2.
6094 + *
6095 + * ----------------------------------------------------------------------- */
6096 +
6097 +/*
6098 + * arch/i386/boot/video-bios.c
6099 + *
6100 + * Standard video BIOS modes
6101 + *
6102 + * We have two options for this; silent and scanned.
6103 + */
6104 +
6105 +#include "boot.h"
6106 +#include "video.h"
6107 +
6108 +__videocard video_bios;
6109 +
6110 +/* Set a conventional BIOS mode */
6111 +static int set_bios_mode(u8 mode);
6112 +
6113 +static int bios_set_mode(struct mode_info *mi)
6114 +{
6115 + return set_bios_mode(mi->mode - VIDEO_FIRST_BIOS);
6116 +}
6117 +
6118 +static int set_bios_mode(u8 mode)
6119 +{
6120 + u16 ax;
6121 + u8 new_mode;
6122 +
6123 + ax = mode; /* AH=0x00 Set Video Mode */
6124 + asm volatile(INT10
6125 + : "+a" (ax)
6126 + : : "ebx", "ecx", "edx", "esi", "edi");
6127 +
6128 + ax = 0x0f00; /* Get Current Video Mode */
6129 + asm volatile(INT10
6130 + : "+a" (ax)
6131 + : : "ebx", "ecx", "edx", "esi", "edi");
6132 +
6133 + do_restore = 1; /* Assume video contents was lost */
6134 + new_mode = ax & 0x7f; /* Not all BIOSes are clean with the top bit */
6135 +
6136 + if (new_mode == mode)
6137 + return 0; /* Mode change OK */
6138 +
6139 + if (new_mode != boot_params.screen_info.orig_video_mode) {
6140 + /* Mode setting failed, but we didn't end up where we
6141 + started. That's bad. Try to revert to the original
6142 + video mode. */
6143 + ax = boot_params.screen_info.orig_video_mode;
6144 + asm volatile(INT10
6145 + : "+a" (ax)
6146 + : : "ebx", "ecx", "edx", "esi", "edi");
6147 + }
6148 + return -1;
6149 +}
6150 +
6151 +static int bios_probe(void)
6152 +{
6153 + u8 mode;
6154 + u8 saved_mode = boot_params.screen_info.orig_video_mode;
6155 + u16 crtc;
6156 + struct mode_info *mi;
6157 + int nmodes = 0;
6158 +
6159 + if (adapter != ADAPTER_EGA && adapter != ADAPTER_VGA)
6160 + return 0;
6161 +
6162 + set_fs(0);
6163 + crtc = vga_crtc();
6164 +
6165 + video_bios.modes = GET_HEAP(struct mode_info, 0);
6166 +
6167 + for (mode = 0x14; mode <= 0x7f; mode++) {
6168 + if (heap_free() < sizeof(struct mode_info))
6169 + break;
6170 +
6171 + if (mode_defined(VIDEO_FIRST_BIOS+mode))
6172 + continue;
6173 +
6174 + if (set_bios_mode(mode))
6175 + continue;
6176 +
6177 + /* Try to verify that it's a text mode. */
6178 +
6179 + /* Attribute Controller: make graphics controller disabled */
6180 + if (in_idx(0x3c0, 0x10) & 0x01)
6181 + continue;
6182 +
6183 + /* Graphics Controller: verify Alpha addressing enabled */
6184 + if (in_idx(0x3ce, 0x06) & 0x01)
6185 + continue;
6186 +
6187 + /* CRTC cursor location low should be zero(?) */
6188 + if (in_idx(crtc, 0x0f))
6189 + continue;
6190 +
6191 + mi = GET_HEAP(struct mode_info, 1);
6192 + mi->mode = VIDEO_FIRST_BIOS+mode;
6193 + mi->x = rdfs16(0x44a);
6194 + mi->y = rdfs8(0x484)+1;
6195 + nmodes++;
6196 + }
6197 +
6198 + set_bios_mode(saved_mode);
6199 +
6200 + return nmodes;
6201 +}
6202 +
6203 +__videocard video_bios =
6204 +{
6205 + .card_name = "BIOS (scanned)",
6206 + .probe = bios_probe,
6207 + .set_mode = bios_set_mode,
6208 + .unsafe = 1,
6209 + .xmode_first = VIDEO_FIRST_BIOS,
6210 + .xmode_n = 0x80,
6211 +};
6212 Index: linux-2.6.22.19/arch/i386/boot/video-vesa.c
6213 ===================================================================
6214 --- /dev/null
6215 +++ linux-2.6.22.19/arch/i386/boot/video-vesa.c
6216 @@ -0,0 +1,283 @@
6217 +/* -*- linux-c -*- ------------------------------------------------------- *
6218 + *
6219 + * Copyright (C) 1991, 1992 Linus Torvalds
6220 + * Copyright 2007 rPath, Inc. - All Rights Reserved
6221 + *
6222 + * This file is part of the Linux kernel, and is made available under
6223 + * the terms of the GNU General Public License version 2.
6224 + *
6225 + * ----------------------------------------------------------------------- */
6226 +
6227 +/*
6228 + * arch/i386/boot/video-vesa.c
6229 + *
6230 + * VESA text modes
6231 + */
6232 +
6233 +#include "boot.h"
6234 +#include "video.h"
6235 +#include "vesa.h"
6236 +
6237 +/* VESA information */
6238 +static struct vesa_general_info vginfo;
6239 +static struct vesa_mode_info vminfo;
6240 +
6241 +__videocard video_vesa;
6242 +
6243 +static void vesa_store_mode_params_graphics(void);
6244 +
6245 +static int vesa_probe(void)
6246 +{
6247 +#ifdef CONFIG_VIDEO_VESA
6248 + u16 ax;
6249 + u16 mode;
6250 + addr_t mode_ptr;
6251 + struct mode_info *mi;
6252 + int nmodes = 0;
6253 +
6254 + video_vesa.modes = GET_HEAP(struct mode_info, 0);
6255 +
6256 + vginfo.signature = VBE2_MAGIC;
6257 +
6258 + /* Optimistically assume a VESA BIOS is register-clean... */
6259 + ax = 0x4f00;
6260 + asm("int $0x10" : "+a" (ax), "=m" (vginfo) : "D" (&vginfo));
6261 +
6262 + if (ax != 0x004f ||
6263 + vginfo.signature != VESA_MAGIC ||
6264 + vginfo.version < 0x0102)
6265 + return 0; /* Not present */
6266 +
6267 + set_fs(vginfo.video_mode_ptr.seg);
6268 + mode_ptr = vginfo.video_mode_ptr.off;
6269 +
6270 + while ((mode = rdfs16(mode_ptr)) != 0xffff) {
6271 + mode_ptr += 2;
6272 +
6273 + if (heap_free() < sizeof(struct mode_info))
6274 + break; /* Heap full, can't save mode info */
6275 +
6276 + if (mode & ~0x1ff)
6277 + continue;
6278 +
6279 + memset(&vminfo, 0, sizeof vminfo); /* Just in case... */
6280 +
6281 + ax = 0x4f01;
6282 + asm("int $0x10"
6283 + : "+a" (ax), "=m" (vminfo)
6284 + : "c" (mode), "D" (&vminfo));
6285 +
6286 + if (ax != 0x004f)
6287 + continue;
6288 +
6289 + if ((vminfo.mode_attr & 0x15) == 0x05) {
6290 + /* Text Mode, TTY BIOS supported,
6291 + supported by hardware */
6292 + mi = GET_HEAP(struct mode_info, 1);
6293 + mi->mode = mode + VIDEO_FIRST_VESA;
6294 + mi->x = vminfo.h_res;
6295 + mi->y = vminfo.v_res;
6296 + nmodes++;
6297 + } else if ((vminfo.mode_attr & 0x99) == 0x99) {
6298 +#ifdef CONFIG_FB
6299 + /* Graphics mode, color, linear frame buffer
6300 + supported -- register the mode but hide from
6301 + the menu. Only do this if framebuffer is
6302 + configured, however, otherwise the user will
6303 + be left without a screen. */
6304 + mi = GET_HEAP(struct mode_info, 1);
6305 + mi->mode = mode + VIDEO_FIRST_VESA;
6306 + mi->x = mi->y = 0;
6307 + nmodes++;
6308 +#endif
6309 + }
6310 + }
6311 +
6312 + return nmodes;
6313 +#else
6314 + return 0;
6315 +#endif
6316 +}
6317 +
6318 +static int vesa_set_mode(struct mode_info *mode)
6319 +{
6320 + u16 ax;
6321 + int is_graphic;
6322 + u16 vesa_mode = mode->mode - VIDEO_FIRST_VESA;
6323 +
6324 + memset(&vminfo, 0, sizeof vminfo); /* Just in case... */
6325 +
6326 + ax = 0x4f01;
6327 + asm("int $0x10"
6328 + : "+a" (ax), "=m" (vminfo)
6329 + : "c" (vesa_mode), "D" (&vminfo));
6330 +
6331 + if (ax != 0x004f)
6332 + return -1;
6333 +
6334 + if ((vminfo.mode_attr & 0x15) == 0x05) {
6335 + /* It's a supported text mode */
6336 + is_graphic = 0;
6337 + } else if ((vminfo.mode_attr & 0x99) == 0x99) {
6338 + /* It's a graphics mode with linear frame buffer */
6339 + is_graphic = 1;
6340 + vesa_mode |= 0x4000; /* Request linear frame buffer */
6341 + } else {
6342 + return -1; /* Invalid mode */
6343 + }
6344 +
6345 +
6346 + ax = 0x4f02;
6347 + asm volatile("int $0x10"
6348 + : "+a" (ax)
6349 + : "b" (vesa_mode), "D" (0));
6350 +
6351 + if (ax != 0x004f)
6352 + return -1;
6353 +
6354 + graphic_mode = is_graphic;
6355 + if (!is_graphic) {
6356 + /* Text mode */
6357 + force_x = mode->x;
6358 + force_y = mode->y;
6359 + do_restore = 1;
6360 + } else {
6361 + /* Graphics mode */
6362 + vesa_store_mode_params_graphics();
6363 + }
6364 +
6365 + return 0;
6366 +}
6367 +
6368 +
6369 +/* Switch DAC to 8-bit mode */
6370 +static void vesa_dac_set_8bits(void)
6371 +{
6372 + u8 dac_size = 6;
6373 +
6374 + /* If possible, switch the DAC to 8-bit mode */
6375 + if (vginfo.capabilities & 1) {
6376 + u16 ax, bx;
6377 +
6378 + ax = 0x4f08;
6379 + bx = 0x0800;
6380 + asm volatile(INT10
6381 + : "+a" (ax), "+b" (bx)
6382 + : : "ecx", "edx", "esi", "edi");
6383 +
6384 + if (ax == 0x004f)
6385 + dac_size = bx >> 8;
6386 + }
6387 +
6388 + /* Set the color sizes to the DAC size, and offsets to 0 */
6389 + boot_params.screen_info.red_size = dac_size;
6390 + boot_params.screen_info.green_size = dac_size;
6391 + boot_params.screen_info.blue_size = dac_size;
6392 + boot_params.screen_info.rsvd_size = dac_size;
6393 +
6394 + boot_params.screen_info.red_pos = 0;
6395 + boot_params.screen_info.green_pos = 0;
6396 + boot_params.screen_info.blue_pos = 0;
6397 + boot_params.screen_info.rsvd_pos = 0;
6398 +}
6399 +
6400 +/* Save the VESA protected mode info */
6401 +static void vesa_store_pm_info(void)
6402 +{
6403 + u16 ax, bx, di, es;
6404 +
6405 + ax = 0x4f0a;
6406 + bx = di = 0;
6407 + asm("pushw %%es; "INT10"; movw %%es,%0; popw %%es"
6408 + : "=d" (es), "+a" (ax), "+b" (bx), "+D" (di)
6409 + : : "ecx", "esi");
6410 +
6411 + if (ax != 0x004f)
6412 + return;
6413 +
6414 + boot_params.screen_info.vesapm_seg = es;
6415 + boot_params.screen_info.vesapm_off = di;
6416 +}
6417 +
6418 +/*
6419 + * Save video mode parameters for graphics mode
6420 + */
6421 +static void vesa_store_mode_params_graphics(void)
6422 +{
6423 + /* Tell the kernel we're in VESA graphics mode */
6424 + boot_params.screen_info.orig_video_isVGA = 0x23;
6425 +
6426 + /* Mode parameters */
6427 + boot_params.screen_info.vesa_attributes = vminfo.mode_attr;
6428 + boot_params.screen_info.lfb_linelength = vminfo.logical_scan;
6429 + boot_params.screen_info.lfb_width = vminfo.h_res;
6430 + boot_params.screen_info.lfb_height = vminfo.v_res;
6431 + boot_params.screen_info.lfb_depth = vminfo.bpp;
6432 + boot_params.screen_info.pages = vminfo.image_planes;
6433 + boot_params.screen_info.lfb_base = vminfo.lfb_ptr;
6434 + memcpy(&boot_params.screen_info.red_size,
6435 + &vminfo.rmask, 8);
6436 +
6437 + /* General parameters */
6438 + boot_params.screen_info.lfb_size = vginfo.total_memory;
6439 +
6440 + if (vminfo.bpp <= 8)
6441 + vesa_dac_set_8bits();
6442 +
6443 + vesa_store_pm_info();
6444 +}
6445 +
6446 +/*
6447 + * Save EDID information for the kernel; this is invoked, separately,
6448 + * after mode-setting.
6449 + */
6450 +void vesa_store_edid(void)
6451 +{
6452 +#ifdef CONFIG_FIRMWARE_EDID
6453 + u16 ax, bx, cx, dx, di;
6454 +
6455 + /* Apparently used as a nonsense token... */
6456 + memset(&boot_params.edid_info, 0x13, sizeof boot_params.edid_info);
6457 +
6458 + if (vginfo.version < 0x0200)
6459 + return; /* EDID requires VBE 2.0+ */
6460 +
6461 + ax = 0x4f15; /* VBE DDC */
6462 + bx = 0x0000; /* Report DDC capabilities */
6463 + cx = 0; /* Controller 0 */
6464 + di = 0; /* ES:DI must be 0 by spec */
6465 +
6466 + /* Note: The VBE DDC spec is different from the main VESA spec;
6467 + we genuinely have to assume all registers are destroyed here. */
6468 +
6469 + asm("pushw %%es; movw %2,%%es; "INT10"; popw %%es"
6470 + : "+a" (ax), "+b" (bx)
6471 + : "c" (cx), "D" (di)
6472 + : "esi");
6473 +
6474 + if (ax != 0x004f)
6475 + return; /* No EDID */
6476 +
6477 + /* BH = time in seconds to transfer EDD information */
6478 + /* BL = DDC level supported */
6479 +
6480 + ax = 0x4f15; /* VBE DDC */
6481 + bx = 0x0001; /* Read EDID */
6482 + cx = 0; /* Controller 0 */
6483 + dx = 0; /* EDID block number */
6484 + di =(size_t) &boot_params.edid_info; /* (ES:)Pointer to block */
6485 + asm(INT10
6486 + : "+a" (ax), "+b" (bx), "+d" (dx)
6487 + : "c" (cx), "D" (di)
6488 + : "esi");
6489 +#endif /* CONFIG_FIRMWARE_EDID */
6490 +}
6491 +
6492 +__videocard video_vesa =
6493 +{
6494 + .card_name = "VESA",
6495 + .probe = vesa_probe,
6496 + .set_mode = vesa_set_mode,
6497 + .xmode_first = VIDEO_FIRST_VESA,
6498 + .xmode_n = 0x200,
6499 +};
6500 Index: linux-2.6.22.19/arch/i386/boot/video-vga.c
6501 ===================================================================
6502 --- /dev/null
6503 +++ linux-2.6.22.19/arch/i386/boot/video-vga.c
6504 @@ -0,0 +1,260 @@
6505 +/* -*- linux-c -*- ------------------------------------------------------- *
6506 + *
6507 + * Copyright (C) 1991, 1992 Linus Torvalds
6508 + * Copyright 2007 rPath, Inc. - All Rights Reserved
6509 + *
6510 + * This file is part of the Linux kernel, and is made available under
6511 + * the terms of the GNU General Public License version 2.
6512 + *
6513 + * ----------------------------------------------------------------------- */
6514 +
6515 +/*
6516 + * arch/i386/boot/video-vga.c
6517 + *
6518 + * Common all-VGA modes
6519 + */
6520 +
6521 +#include "boot.h"
6522 +#include "video.h"
6523 +
6524 +static struct mode_info vga_modes[] = {
6525 + { VIDEO_80x25, 80, 25 },
6526 + { VIDEO_8POINT, 80, 50 },
6527 + { VIDEO_80x43, 80, 43 },
6528 + { VIDEO_80x28, 80, 28 },
6529 + { VIDEO_80x30, 80, 30 },
6530 + { VIDEO_80x34, 80, 34 },
6531 + { VIDEO_80x60, 80, 60 },
6532 +};
6533 +
6534 +static struct mode_info ega_modes[] = {
6535 + { VIDEO_80x25, 80, 25 },
6536 + { VIDEO_8POINT, 80, 43 },
6537 +};
6538 +
6539 +static struct mode_info cga_modes[] = {
6540 + { VIDEO_80x25, 80, 25 },
6541 +};
6542 +
6543 +__videocard video_vga;
6544 +
6545 +/* Set basic 80x25 mode */
6546 +static u8 vga_set_basic_mode(void)
6547 +{
6548 + u16 ax;
6549 + u8 rows;
6550 + u8 mode;
6551 +
6552 +#ifdef CONFIG_VIDEO_400_HACK
6553 + if (adapter >= ADAPTER_VGA) {
6554 + asm(INT10
6555 + : : "a" (0x1202), "b" (0x0030)
6556 + : "ecx", "edx", "esi", "edi");
6557 + }
6558 +#endif
6559 +
6560 + ax = 0x0f00;
6561 + asm(INT10
6562 + : "+a" (ax)
6563 + : : "ebx", "ecx", "edx", "esi", "edi");
6564 +
6565 + mode = (u8)ax;
6566 +
6567 + set_fs(0);
6568 + rows = rdfs8(0x484); /* rows minus one */
6569 +
6570 +#ifndef CONFIG_VIDEO_400_HACK
6571 + if ((ax == 0x5003 || ax == 0x5007) &&
6572 + (rows == 0 || rows == 24))
6573 + return mode;
6574 +#endif
6575 +
6576 + if (mode != 3 && mode != 7)
6577 + mode = 3;
6578 +
6579 + /* Set the mode */
6580 + asm volatile(INT10
6581 + : : "a" (mode)
6582 + : "ebx", "ecx", "edx", "esi", "edi");
6583 + do_restore = 1;
6584 + return mode;
6585 +}
6586 +
6587 +static void vga_set_8font(void)
6588 +{
6589 + /* Set 8x8 font - 80x43 on EGA, 80x50 on VGA */
6590 +
6591 + /* Set 8x8 font */
6592 + asm volatile(INT10 : : "a" (0x1112), "b" (0));
6593 +
6594 + /* Use alternate print screen */
6595 + asm volatile(INT10 : : "a" (0x1200), "b" (0x20));
6596 +
6597 + /* Turn off cursor emulation */
6598 + asm volatile(INT10 : : "a" (0x1201), "b" (0x34));
6599 +
6600 + /* Cursor is scan lines 6-7 */
6601 + asm volatile(INT10 : : "a" (0x0100), "c" (0x0607));
6602 +}
6603 +
6604 +static void vga_set_14font(void)
6605 +{
6606 + /* Set 9x14 font - 80x28 on VGA */
6607 +
6608 + /* Set 9x14 font */
6609 + asm volatile(INT10 : : "a" (0x1111), "b" (0));
6610 +
6611 + /* Turn off cursor emulation */
6612 + asm volatile(INT10 : : "a" (0x1201), "b" (0x34));
6613 +
6614 + /* Cursor is scan lines 11-12 */
6615 + asm volatile(INT10 : : "a" (0x0100), "c" (0x0b0c));
6616 +}
6617 +
6618 +static void vga_set_80x43(void)
6619 +{
6620 + /* Set 80x43 mode on VGA (not EGA) */
6621 +
6622 + /* Set 350 scans */
6623 + asm volatile(INT10 : : "a" (0x1201), "b" (0x30));
6624 +
6625 + /* Reset video mode */
6626 + asm volatile(INT10 : : "a" (0x0003));
6627 +
6628 + vga_set_8font();
6629 +}
6630 +
6631 +/* I/O address of the VGA CRTC */
6632 +u16 vga_crtc(void)
6633 +{
6634 + return (inb(0x3cc) & 1) ? 0x3d4 : 0x3b4;
6635 +}
6636 +
6637 +static void vga_set_480_scanlines(int end)
6638 +{
6639 + u16 crtc;
6640 + u8 csel;
6641 +
6642 + crtc = vga_crtc();
6643 +
6644 + out_idx(0x0c, crtc, 0x11); /* Vertical sync end, unlock CR0-7 */
6645 + out_idx(0x0b, crtc, 0x06); /* Vertical total */
6646 + out_idx(0x3e, crtc, 0x07); /* Vertical overflow */
6647 + out_idx(0xea, crtc, 0x10); /* Vertical sync start */
6648 + out_idx(end, crtc, 0x12); /* Vertical display end */
6649 + out_idx(0xe7, crtc, 0x15); /* Vertical blank start */
6650 + out_idx(0x04, crtc, 0x16); /* Vertical blank end */
6651 + csel = inb(0x3cc);
6652 + csel &= 0x0d;
6653 + csel |= 0xe2;
6654 + outb(csel, 0x3cc);
6655 +}
6656 +
6657 +static void vga_set_80x30(void)
6658 +{
6659 + vga_set_480_scanlines(0xdf);
6660 +}
6661 +
6662 +static void vga_set_80x34(void)
6663 +{
6664 + vga_set_14font();
6665 + vga_set_480_scanlines(0xdb);
6666 +}
6667 +
6668 +static void vga_set_80x60(void)
6669 +{
6670 + vga_set_8font();
6671 + vga_set_480_scanlines(0xdf);
6672 +}
6673 +
6674 +static int vga_set_mode(struct mode_info *mode)
6675 +{
6676 + /* Set the basic mode */
6677 + vga_set_basic_mode();
6678 +
6679 + /* Override a possibly broken BIOS */
6680 + force_x = mode->x;
6681 + force_y = mode->y;
6682 +
6683 + switch (mode->mode) {
6684 + case VIDEO_80x25:
6685 + break;
6686 + case VIDEO_8POINT:
6687 + vga_set_8font();
6688 + break;
6689 + case VIDEO_80x43:
6690 + vga_set_80x43();
6691 + break;
6692 + case VIDEO_80x28:
6693 + vga_set_14font();
6694 + break;
6695 + case VIDEO_80x30:
6696 + vga_set_80x30();
6697 + break;
6698 + case VIDEO_80x34:
6699 + vga_set_80x34();
6700 + break;
6701 + case VIDEO_80x60:
6702 + vga_set_80x60();
6703 + break;
6704 + }
6705 +
6706 + return 0;
6707 +}
6708 +
6709 +/*
6710 + * Note: this probe includes basic information required by all
6711 + * systems. It should be executed first, by making sure
6712 + * video-vga.c is listed first in the Makefile.
6713 + */
6714 +static int vga_probe(void)
6715 +{
6716 + static const char *card_name[] = {
6717 + "CGA/MDA/HGC", "EGA", "VGA"
6718 + };
6719 + static struct mode_info *mode_lists[] = {
6720 + cga_modes,
6721 + ega_modes,
6722 + vga_modes,
6723 + };
6724 + static int mode_count[] = {
6725 + sizeof(cga_modes)/sizeof(struct mode_info),
6726 + sizeof(ega_modes)/sizeof(struct mode_info),
6727 + sizeof(vga_modes)/sizeof(struct mode_info),
6728 + };
6729 + u8 vga_flag;
6730 +
6731 + asm(INT10
6732 + : "=b" (boot_params.screen_info.orig_video_ega_bx)
6733 + : "a" (0x1200), "b" (0x10) /* Check EGA/VGA */
6734 + : "ecx", "edx", "esi", "edi");
6735 +
6736 + /* If we have MDA/CGA/HGC then BL will be unchanged at 0x10 */
6737 + if ((u8)boot_params.screen_info.orig_video_ega_bx != 0x10) {
6738 + /* EGA/VGA */
6739 + asm(INT10
6740 + : "=a" (vga_flag)
6741 + : "a" (0x1a00)
6742 + : "ebx", "ecx", "edx", "esi", "edi");
6743 +
6744 + if (vga_flag == 0x1a) {
6745 + adapter = ADAPTER_VGA;
6746 + boot_params.screen_info.orig_video_isVGA = 1;
6747 + } else {
6748 + adapter = ADAPTER_EGA;
6749 + }
6750 + } else {
6751 + adapter = ADAPTER_CGA;
6752 + }
6753 +
6754 + video_vga.modes = mode_lists[adapter];
6755 + video_vga.card_name = card_name[adapter];
6756 + return mode_count[adapter];
6757 +}
6758 +
6759 +__videocard video_vga =
6760 +{
6761 + .card_name = "VGA",
6762 + .probe = vga_probe,
6763 + .set_mode = vga_set_mode,
6764 +};
6765 Index: linux-2.6.22.19/arch/i386/boot/video.S
6766 ===================================================================
6767 --- linux-2.6.22.19.orig/arch/i386/boot/video.S
6768 +++ /dev/null
6769 @@ -1,2043 +0,0 @@
6770 -/* video.S
6771 - *
6772 - * Display adapter & video mode setup, version 2.13 (14-May-99)
6773 - *
6774 - * Copyright (C) 1995 -- 1998 Martin Mares <mj@ucw.cz>
6775 - * Based on the original setup.S code (C) Linus Torvalds and Mats Anderson
6776 - *
6777 - * Rewritten to use GNU 'as' by Chris Noe <stiker@northlink.com> May 1999
6778 - *
6779 - * For further information, look at Documentation/svga.txt.
6780 - *
6781 - */
6782 -
6783 -/* Enable autodetection of SVGA adapters and modes. */
6784 -#undef CONFIG_VIDEO_SVGA
6785 -
6786 -/* Enable autodetection of VESA modes */
6787 -#define CONFIG_VIDEO_VESA
6788 -
6789 -/* Enable compacting of mode table */
6790 -#define CONFIG_VIDEO_COMPACT
6791 -
6792 -/* Retain screen contents when switching modes */
6793 -#define CONFIG_VIDEO_RETAIN
6794 -
6795 -/* Enable local mode list */
6796 -#undef CONFIG_VIDEO_LOCAL
6797 -
6798 -/* Force 400 scan lines for standard modes (hack to fix bad BIOS behaviour */
6799 -#undef CONFIG_VIDEO_400_HACK
6800 -
6801 -/* Hack that lets you force specific BIOS mode ID and specific dimensions */
6802 -#undef CONFIG_VIDEO_GFX_HACK
6803 -#define VIDEO_GFX_BIOS_AX 0x4f02 /* 800x600 on ThinkPad */
6804 -#define VIDEO_GFX_BIOS_BX 0x0102
6805 -#define VIDEO_GFX_DUMMY_RESOLUTION 0x6425 /* 100x37 */
6806 -
6807 -/* This code uses an extended set of video mode numbers. These include:
6808 - * Aliases for standard modes
6809 - * NORMAL_VGA (-1)
6810 - * EXTENDED_VGA (-2)
6811 - * ASK_VGA (-3)
6812 - * Video modes numbered by menu position -- NOT RECOMMENDED because of lack
6813 - * of compatibility when extending the table. These are between 0x00 and 0xff.
6814 - */
6815 -#define VIDEO_FIRST_MENU 0x0000
6816 -
6817 -/* Standard BIOS video modes (BIOS number + 0x0100) */
6818 -#define VIDEO_FIRST_BIOS 0x0100
6819 -
6820 -/* VESA BIOS video modes (VESA number + 0x0200) */
6821 -#define VIDEO_FIRST_VESA 0x0200
6822 -
6823 -/* Video7 special modes (BIOS number + 0x0900) */
6824 -#define VIDEO_FIRST_V7 0x0900
6825 -
6826 -/* Special video modes */
6827 -#define VIDEO_FIRST_SPECIAL 0x0f00
6828 -#define VIDEO_80x25 0x0f00
6829 -#define VIDEO_8POINT 0x0f01
6830 -#define VIDEO_80x43 0x0f02
6831 -#define VIDEO_80x28 0x0f03
6832 -#define VIDEO_CURRENT_MODE 0x0f04
6833 -#define VIDEO_80x30 0x0f05
6834 -#define VIDEO_80x34 0x0f06
6835 -#define VIDEO_80x60 0x0f07
6836 -#define VIDEO_GFX_HACK 0x0f08
6837 -#define VIDEO_LAST_SPECIAL 0x0f09
6838 -
6839 -/* Video modes given by resolution */
6840 -#define VIDEO_FIRST_RESOLUTION 0x1000
6841 -
6842 -/* The "recalculate timings" flag */
6843 -#define VIDEO_RECALC 0x8000
6844 -
6845 -/* Positions of various video parameters passed to the kernel */
6846 -/* (see also include/linux/tty.h) */
6847 -#define PARAM_CURSOR_POS 0x00
6848 -#define PARAM_VIDEO_PAGE 0x04
6849 -#define PARAM_VIDEO_MODE 0x06
6850 -#define PARAM_VIDEO_COLS 0x07
6851 -#define PARAM_VIDEO_EGA_BX 0x0a
6852 -#define PARAM_VIDEO_LINES 0x0e
6853 -#define PARAM_HAVE_VGA 0x0f
6854 -#define PARAM_FONT_POINTS 0x10
6855 -
6856 -#define PARAM_LFB_WIDTH 0x12
6857 -#define PARAM_LFB_HEIGHT 0x14
6858 -#define PARAM_LFB_DEPTH 0x16
6859 -#define PARAM_LFB_BASE 0x18
6860 -#define PARAM_LFB_SIZE 0x1c
6861 -#define PARAM_LFB_LINELENGTH 0x24
6862 -#define PARAM_LFB_COLORS 0x26
6863 -#define PARAM_VESAPM_SEG 0x2e
6864 -#define PARAM_VESAPM_OFF 0x30
6865 -#define PARAM_LFB_PAGES 0x32
6866 -#define PARAM_VESA_ATTRIB 0x34
6867 -#define PARAM_CAPABILITIES 0x36
6868 -
6869 -/* Define DO_STORE according to CONFIG_VIDEO_RETAIN */
6870 -#ifdef CONFIG_VIDEO_RETAIN
6871 -#define DO_STORE call store_screen
6872 -#else
6873 -#define DO_STORE
6874 -#endif /* CONFIG_VIDEO_RETAIN */
6875 -
6876 -# This is the main entry point called by setup.S
6877 -# %ds *must* be pointing to the bootsector
6878 -video: pushw %ds # We use different segments
6879 - pushw %ds # FS contains original DS
6880 - popw %fs
6881 - pushw %cs # DS is equal to CS
6882 - popw %ds
6883 - pushw %cs # ES is equal to CS
6884 - popw %es
6885 - xorw %ax, %ax
6886 - movw %ax, %gs # GS is zero
6887 - cld
6888 - call basic_detect # Basic adapter type testing (EGA/VGA/MDA/CGA)
6889 -#ifdef CONFIG_VIDEO_SELECT
6890 - movw %fs:(0x01fa), %ax # User selected video mode
6891 - cmpw $ASK_VGA, %ax # Bring up the menu
6892 - jz vid2
6893 -
6894 - call mode_set # Set the mode
6895 - jc vid1
6896 -
6897 - leaw badmdt, %si # Invalid mode ID
6898 - call prtstr
6899 -vid2: call mode_menu
6900 -vid1:
6901 -#ifdef CONFIG_VIDEO_RETAIN
6902 - call restore_screen # Restore screen contents
6903 -#endif /* CONFIG_VIDEO_RETAIN */
6904 - call store_edid
6905 -#endif /* CONFIG_VIDEO_SELECT */
6906 - call mode_params # Store mode parameters
6907 - popw %ds # Restore original DS
6908 - ret
6909 -
6910 -# Detect if we have CGA, MDA, EGA or VGA and pass it to the kernel.
6911 -basic_detect:
6912 - movb $0, %fs:(PARAM_HAVE_VGA)
6913 - movb $0x12, %ah # Check EGA/VGA
6914 - movb $0x10, %bl
6915 - int $0x10
6916 - movw %bx, %fs:(PARAM_VIDEO_EGA_BX) # Identifies EGA to the kernel
6917 - cmpb $0x10, %bl # No, it's a CGA/MDA/HGA card.
6918 - je basret
6919 -
6920 - incb adapter
6921 - movw $0x1a00, %ax # Check EGA or VGA?
6922 - int $0x10
6923 - cmpb $0x1a, %al # 1a means VGA...
6924 - jne basret # anything else is EGA.
6925 -
6926 - incb %fs:(PARAM_HAVE_VGA) # We've detected a VGA
6927 - incb adapter
6928 -basret: ret
6929 -
6930 -# Store the video mode parameters for later usage by the kernel.
6931 -# This is done by asking the BIOS except for the rows/columns
6932 -# parameters in the default 80x25 mode -- these are set directly,
6933 -# because some very obscure BIOSes supply insane values.
6934 -mode_params:
6935 -#ifdef CONFIG_VIDEO_SELECT
6936 - cmpb $0, graphic_mode
6937 - jnz mopar_gr
6938 -#endif
6939 - movb $0x03, %ah # Read cursor position
6940 - xorb %bh, %bh
6941 - int $0x10
6942 - movw %dx, %fs:(PARAM_CURSOR_POS)
6943 - movb $0x0f, %ah # Read page/mode/width
6944 - int $0x10
6945 - movw %bx, %fs:(PARAM_VIDEO_PAGE)
6946 - movw %ax, %fs:(PARAM_VIDEO_MODE) # Video mode and screen width
6947 - cmpb $0x7, %al # MDA/HGA => segment differs
6948 - jnz mopar0
6949 -
6950 - movw $0xb000, video_segment
6951 -mopar0: movw %gs:(0x485), %ax # Font size
6952 - movw %ax, %fs:(PARAM_FONT_POINTS) # (valid only on EGA/VGA)
6953 - movw force_size, %ax # Forced size?
6954 - orw %ax, %ax
6955 - jz mopar1
6956 -
6957 - movb %ah, %fs:(PARAM_VIDEO_COLS)
6958 - movb %al, %fs:(PARAM_VIDEO_LINES)
6959 - ret
6960 -
6961 -mopar1: movb $25, %al
6962 - cmpb $0, adapter # If we are on CGA/MDA/HGA, the
6963 - jz mopar2 # screen must have 25 lines.
6964 -
6965 - movb %gs:(0x484), %al # On EGA/VGA, use the EGA+ BIOS
6966 - incb %al # location of max lines.
6967 -mopar2: movb %al, %fs:(PARAM_VIDEO_LINES)
6968 - ret
6969 -
6970 -#ifdef CONFIG_VIDEO_SELECT
6971 -# Fetching of VESA frame buffer parameters
6972 -mopar_gr:
6973 - leaw modelist+1024, %di
6974 - movb $0x23, %fs:(PARAM_HAVE_VGA)
6975 - movw 16(%di), %ax
6976 - movw %ax, %fs:(PARAM_LFB_LINELENGTH)
6977 - movw 18(%di), %ax
6978 - movw %ax, %fs:(PARAM_LFB_WIDTH)
6979 - movw 20(%di), %ax
6980 - movw %ax, %fs:(PARAM_LFB_HEIGHT)
6981 - movb 25(%di), %al
6982 - movb $0, %ah
6983 - movw %ax, %fs:(PARAM_LFB_DEPTH)
6984 - movb 29(%di), %al
6985 - movb $0, %ah
6986 - movw %ax, %fs:(PARAM_LFB_PAGES)
6987 - movl 40(%di), %eax
6988 - movl %eax, %fs:(PARAM_LFB_BASE)
6989 - movl 31(%di), %eax
6990 - movl %eax, %fs:(PARAM_LFB_COLORS)
6991 - movl 35(%di), %eax
6992 - movl %eax, %fs:(PARAM_LFB_COLORS+4)
6993 - movw 0(%di), %ax
6994 - movw %ax, %fs:(PARAM_VESA_ATTRIB)
6995 -
6996 -# get video mem size
6997 - leaw modelist+1024, %di
6998 - movw $0x4f00, %ax
6999 - int $0x10
7000 - xorl %eax, %eax
7001 - movw 18(%di), %ax
7002 - movl %eax, %fs:(PARAM_LFB_SIZE)
7003 -
7004 -# store mode capabilities
7005 - movl 10(%di), %eax
7006 - movl %eax, %fs:(PARAM_CAPABILITIES)
7007 -
7008 -# switching the DAC to 8-bit is for <= 8 bpp only
7009 - movw %fs:(PARAM_LFB_DEPTH), %ax
7010 - cmpw $8, %ax
7011 - jg dac_done
7012 -
7013 -# get DAC switching capability
7014 - xorl %eax, %eax
7015 - movb 10(%di), %al
7016 - testb $1, %al
7017 - jz dac_set
7018 -
7019 -# attempt to switch DAC to 8-bit
7020 - movw $0x4f08, %ax
7021 - movw $0x0800, %bx
7022 - int $0x10
7023 - cmpw $0x004f, %ax
7024 - jne dac_set
7025 - movb %bh, dac_size # store actual DAC size
7026 -
7027 -dac_set:
7028 -# set color size to DAC size
7029 - movb dac_size, %al
7030 - movb %al, %fs:(PARAM_LFB_COLORS+0)
7031 - movb %al, %fs:(PARAM_LFB_COLORS+2)
7032 - movb %al, %fs:(PARAM_LFB_COLORS+4)
7033 - movb %al, %fs:(PARAM_LFB_COLORS+6)
7034 -
7035 -# set color offsets to 0
7036 - movb $0, %fs:(PARAM_LFB_COLORS+1)
7037 - movb $0, %fs:(PARAM_LFB_COLORS+3)
7038 - movb $0, %fs:(PARAM_LFB_COLORS+5)
7039 - movb $0, %fs:(PARAM_LFB_COLORS+7)
7040 -
7041 -dac_done:
7042 -# get protected mode interface informations
7043 - movw $0x4f0a, %ax
7044 - xorw %bx, %bx
7045 - xorw %di, %di
7046 - int $0x10
7047 - cmp $0x004f, %ax
7048 - jnz no_pm
7049 -
7050 - movw %es, %fs:(PARAM_VESAPM_SEG)
7051 - movw %di, %fs:(PARAM_VESAPM_OFF)
7052 -no_pm: ret
7053 -
7054 -# The video mode menu
7055 -mode_menu:
7056 - leaw keymsg, %si # "Return/Space/Timeout" message
7057 - call prtstr
7058 - call flush
7059 -nokey: call getkt
7060 -
7061 - cmpb $0x0d, %al # ENTER ?
7062 - je listm # yes - manual mode selection
7063 -
7064 - cmpb $0x20, %al # SPACE ?
7065 - je defmd1 # no - repeat
7066 -
7067 - call beep
7068 - jmp nokey
7069 -
7070 -defmd1: ret # No mode chosen? Default 80x25
7071 -
7072 -listm: call mode_table # List mode table
7073 -listm0: leaw name_bann, %si # Print adapter name
7074 - call prtstr
7075 - movw card_name, %si
7076 - orw %si, %si
7077 - jnz an2
7078 -
7079 - movb adapter, %al
7080 - leaw old_name, %si
7081 - orb %al, %al
7082 - jz an1
7083 -
7084 - leaw ega_name, %si
7085 - decb %al
7086 - jz an1
7087 -
7088 - leaw vga_name, %si
7089 - jmp an1
7090 -
7091 -an2: call prtstr
7092 - leaw svga_name, %si
7093 -an1: call prtstr
7094 - leaw listhdr, %si # Table header
7095 - call prtstr
7096 - movb $0x30, %dl # DL holds mode number
7097 - leaw modelist, %si
7098 -lm1: cmpw $ASK_VGA, (%si) # End?
7099 - jz lm2
7100 -
7101 - movb %dl, %al # Menu selection number
7102 - call prtchr
7103 - call prtsp2
7104 - lodsw
7105 - call prthw # Mode ID
7106 - call prtsp2
7107 - movb 0x1(%si), %al
7108 - call prtdec # Rows
7109 - movb $0x78, %al # the letter 'x'
7110 - call prtchr
7111 - lodsw
7112 - call prtdec # Columns
7113 - movb $0x0d, %al # New line
7114 - call prtchr
7115 - movb $0x0a, %al
7116 - call prtchr
7117 - incb %dl # Next character
7118 - cmpb $0x3a, %dl
7119 - jnz lm1
7120 -
7121 - movb $0x61, %dl
7122 - jmp lm1
7123 -
7124 -lm2: leaw prompt, %si # Mode prompt
7125 - call prtstr
7126 - leaw edit_buf, %di # Editor buffer
7127 -lm3: call getkey
7128 - cmpb $0x0d, %al # Enter?
7129 - jz lment
7130 -
7131 - cmpb $0x08, %al # Backspace?
7132 - jz lmbs
7133 -
7134 - cmpb $0x20, %al # Printable?
7135 - jc lm3
7136 -
7137 - cmpw $edit_buf+4, %di # Enough space?
7138 - jz lm3
7139 -
7140 - stosb
7141 - call prtchr
7142 - jmp lm3
7143 -
7144 -lmbs: cmpw $edit_buf, %di # Backspace
7145 - jz lm3
7146 -
7147 - decw %di
7148 - movb $0x08, %al
7149 - call prtchr
7150 - call prtspc
7151 - movb $0x08, %al
7152 - call prtchr
7153 - jmp lm3
7154 -
7155 -lment: movb $0, (%di)
7156 - leaw crlft, %si
7157 - call prtstr
7158 - leaw edit_buf, %si
7159 - cmpb $0, (%si) # Empty string = default mode
7160 - jz lmdef
7161 -
7162 - cmpb $0, 1(%si) # One character = menu selection
7163 - jz mnusel
7164 -
7165 - cmpw $0x6373, (%si) # "scan" => mode scanning
7166 - jnz lmhx
7167 -
7168 - cmpw $0x6e61, 2(%si)
7169 - jz lmscan
7170 -
7171 -lmhx: xorw %bx, %bx # Else => mode ID in hex
7172 -lmhex: lodsb
7173 - orb %al, %al
7174 - jz lmuse1
7175 -
7176 - subb $0x30, %al
7177 - jc lmbad
7178 -
7179 - cmpb $10, %al
7180 - jc lmhx1
7181 -
7182 - subb $7, %al
7183 - andb $0xdf, %al
7184 - cmpb $10, %al
7185 - jc lmbad
7186 -
7187 - cmpb $16, %al
7188 - jnc lmbad
7189 -
7190 -lmhx1: shlw $4, %bx
7191 - orb %al, %bl
7192 - jmp lmhex
7193 -
7194 -lmuse1: movw %bx, %ax
7195 - jmp lmuse
7196 -
7197 -mnusel: lodsb # Menu selection
7198 - xorb %ah, %ah
7199 - subb $0x30, %al
7200 - jc lmbad
7201 -
7202 - cmpb $10, %al
7203 - jc lmuse
7204 -
7205 - cmpb $0x61-0x30, %al
7206 - jc lmbad
7207 -
7208 - subb $0x61-0x30-10, %al
7209 - cmpb $36, %al
7210 - jnc lmbad
7211 -
7212 -lmuse: call mode_set
7213 - jc lmdef
7214 -
7215 -lmbad: leaw unknt, %si
7216 - call prtstr
7217 - jmp lm2
7218 -lmscan: cmpb $0, adapter # Scanning only on EGA/VGA
7219 - jz lmbad
7220 -
7221 - movw $0, mt_end # Scanning of modes is
7222 - movb $1, scanning # done as new autodetection.
7223 - call mode_table
7224 - jmp listm0
7225 -lmdef: ret
7226 -
7227 -# Additional parts of mode_set... (relative jumps, you know)
7228 -setv7: # Video7 extended modes
7229 - DO_STORE
7230 - subb $VIDEO_FIRST_V7>>8, %bh
7231 - movw $0x6f05, %ax
7232 - int $0x10
7233 - stc
7234 - ret
7235 -
7236 -_setrec: jmp setrec # Ugly...
7237 -_set_80x25: jmp set_80x25
7238 -
7239 -# Aliases for backward compatibility.
7240 -setalias:
7241 - movw $VIDEO_80x25, %ax
7242 - incw %bx
7243 - jz mode_set
7244 -
7245 - movb $VIDEO_8POINT-VIDEO_FIRST_SPECIAL, %al
7246 - incw %bx
7247 - jnz setbad # Fall-through!
7248 -
7249 -# Setting of user mode (AX=mode ID) => CF=success
7250 -mode_set:
7251 - movw %ax, %fs:(0x01fa) # Store mode for use in acpi_wakeup.S
7252 - movw %ax, %bx
7253 - cmpb $0xff, %ah
7254 - jz setalias
7255 -
7256 - testb $VIDEO_RECALC>>8, %ah
7257 - jnz _setrec
7258 -
7259 - cmpb $VIDEO_FIRST_RESOLUTION>>8, %ah
7260 - jnc setres
7261 -
7262 - cmpb $VIDEO_FIRST_SPECIAL>>8, %ah
7263 - jz setspc
7264 -
7265 - cmpb $VIDEO_FIRST_V7>>8, %ah
7266 - jz setv7
7267 -
7268 - cmpb $VIDEO_FIRST_VESA>>8, %ah
7269 - jnc check_vesa
7270 -
7271 - orb %ah, %ah
7272 - jz setmenu
7273 -
7274 - decb %ah
7275 - jz setbios
7276 -
7277 -setbad: clc
7278 - movb $0, do_restore # The screen needn't be restored
7279 - ret
7280 -
7281 -setvesa:
7282 - DO_STORE
7283 - subb $VIDEO_FIRST_VESA>>8, %bh
7284 - movw $0x4f02, %ax # VESA BIOS mode set call
7285 - int $0x10
7286 - cmpw $0x004f, %ax # AL=4f if implemented
7287 - jnz setbad # AH=0 if OK
7288 -
7289 - stc
7290 - ret
7291 -
7292 -setbios:
7293 - DO_STORE
7294 - int $0x10 # Standard BIOS mode set call
7295 - pushw %bx
7296 - movb $0x0f, %ah # Check if really set
7297 - int $0x10
7298 - popw %bx
7299 - cmpb %bl, %al
7300 - jnz setbad
7301 -
7302 - stc
7303 - ret
7304 -
7305 -setspc: xorb %bh, %bh # Set special mode
7306 - cmpb $VIDEO_LAST_SPECIAL-VIDEO_FIRST_SPECIAL, %bl
7307 - jnc setbad
7308 -
7309 - addw %bx, %bx
7310 - jmp *spec_inits(%bx)
7311 -
7312 -setmenu:
7313 - orb %al, %al # 80x25 is an exception
7314 - jz _set_80x25
7315 -
7316 - pushw %bx # Set mode chosen from menu
7317 - call mode_table # Build the mode table
7318 - popw %ax
7319 - shlw $2, %ax
7320 - addw %ax, %si
7321 - cmpw %di, %si
7322 - jnc setbad
7323 -
7324 - movw (%si), %ax # Fetch mode ID
7325 -_m_s: jmp mode_set
7326 -
7327 -setres: pushw %bx # Set mode chosen by resolution
7328 - call mode_table
7329 - popw %bx
7330 - xchgb %bl, %bh
7331 -setr1: lodsw
7332 - cmpw $ASK_VGA, %ax # End of the list?
7333 - jz setbad
7334 -
7335 - lodsw
7336 - cmpw %bx, %ax
7337 - jnz setr1
7338 -
7339 - movw -4(%si), %ax # Fetch mode ID
7340 - jmp _m_s
7341 -
7342 -check_vesa:
7343 -#ifdef CONFIG_FIRMWARE_EDID
7344 - leaw modelist+1024, %di
7345 - movw $0x4f00, %ax
7346 - int $0x10
7347 - cmpw $0x004f, %ax
7348 - jnz setbad
7349 -
7350 - movw 4(%di), %ax
7351 - movw %ax, vbe_version
7352 -#endif
7353 - leaw modelist+1024, %di
7354 - subb $VIDEO_FIRST_VESA>>8, %bh
7355 - movw %bx, %cx # Get mode information structure
7356 - movw $0x4f01, %ax
7357 - int $0x10
7358 - addb $VIDEO_FIRST_VESA>>8, %bh
7359 - cmpw $0x004f, %ax
7360 - jnz setbad
7361 -
7362 - movb (%di), %al # Check capabilities.
7363 - andb $0x19, %al
7364 - cmpb $0x09, %al
7365 - jz setvesa # This is a text mode
7366 -
7367 - movb (%di), %al # Check capabilities.
7368 - andb $0x99, %al
7369 - cmpb $0x99, %al
7370 - jnz _setbad # Doh! No linear frame buffer.
7371 -
7372 - subb $VIDEO_FIRST_VESA>>8, %bh
7373 - orw $0x4000, %bx # Use linear frame buffer
7374 - movw $0x4f02, %ax # VESA BIOS mode set call
7375 - int $0x10
7376 - cmpw $0x004f, %ax # AL=4f if implemented
7377 - jnz _setbad # AH=0 if OK
7378 -
7379 - movb $1, graphic_mode # flag graphic mode
7380 - movb $0, do_restore # no screen restore
7381 - stc
7382 - ret
7383 -
7384 -_setbad: jmp setbad # Ugly...
7385 -
7386 -# Recalculate vertical display end registers -- this fixes various
7387 -# inconsistencies of extended modes on many adapters. Called when
7388 -# the VIDEO_RECALC flag is set in the mode ID.
7389 -
7390 -setrec: subb $VIDEO_RECALC>>8, %ah # Set the base mode
7391 - call mode_set
7392 - jnc rct3
7393 -
7394 - movw %gs:(0x485), %ax # Font size in pixels
7395 - movb %gs:(0x484), %bl # Number of rows
7396 - incb %bl
7397 - mulb %bl # Number of visible
7398 - decw %ax # scan lines - 1
7399 - movw $0x3d4, %dx
7400 - movw %ax, %bx
7401 - movb $0x12, %al # Lower 8 bits
7402 - movb %bl, %ah
7403 - outw %ax, %dx
7404 - movb $0x07, %al # Bits 8 and 9 in the overflow register
7405 - call inidx
7406 - xchgb %al, %ah
7407 - andb $0xbd, %ah
7408 - shrb %bh
7409 - jnc rct1
7410 - orb $0x02, %ah
7411 -rct1: shrb %bh
7412 - jnc rct2
7413 - orb $0x40, %ah
7414 -rct2: movb $0x07, %al
7415 - outw %ax, %dx
7416 - stc
7417 -rct3: ret
7418 -
7419 -# Table of routines for setting of the special modes.
7420 -spec_inits:
7421 - .word set_80x25
7422 - .word set_8pixel
7423 - .word set_80x43
7424 - .word set_80x28
7425 - .word set_current
7426 - .word set_80x30
7427 - .word set_80x34
7428 - .word set_80x60
7429 - .word set_gfx
7430 -
7431 -# Set the 80x25 mode. If already set, do nothing.
7432 -set_80x25:
7433 - movw $0x5019, force_size # Override possibly broken BIOS
7434 -use_80x25:
7435 -#ifdef CONFIG_VIDEO_400_HACK
7436 - movw $0x1202, %ax # Force 400 scan lines
7437 - movb $0x30, %bl
7438 - int $0x10
7439 -#else
7440 - movb $0x0f, %ah # Get current mode ID
7441 - int $0x10
7442 - cmpw $0x5007, %ax # Mode 7 (80x25 mono) is the only one available
7443 - jz st80 # on CGA/MDA/HGA and is also available on EGAM
7444 -
7445 - cmpw $0x5003, %ax # Unknown mode, force 80x25 color
7446 - jnz force3
7447 -
7448 -st80: cmpb $0, adapter # CGA/MDA/HGA => mode 3/7 is always 80x25
7449 - jz set80
7450 -
7451 - movb %gs:(0x0484), %al # This is EGA+ -- beware of 80x50 etc.
7452 - orb %al, %al # Some buggy BIOS'es set 0 rows
7453 - jz set80
7454 -
7455 - cmpb $24, %al # It's hopefully correct
7456 - jz set80
7457 -#endif /* CONFIG_VIDEO_400_HACK */
7458 -force3: DO_STORE
7459 - movw $0x0003, %ax # Forced set
7460 - int $0x10
7461 -set80: stc
7462 - ret
7463 -
7464 -# Set the 80x50/80x43 8-pixel mode. Simple BIOS calls.
7465 -set_8pixel:
7466 - DO_STORE
7467 - call use_80x25 # The base is 80x25
7468 -set_8pt:
7469 - movw $0x1112, %ax # Use 8x8 font
7470 - xorb %bl, %bl
7471 - int $0x10
7472 - movw $0x1200, %ax # Use alternate print screen
7473 - movb $0x20, %bl
7474 - int $0x10
7475 - movw $0x1201, %ax # Turn off cursor emulation
7476 - movb $0x34, %bl
7477 - int $0x10
7478 - movb $0x01, %ah # Define cursor scan lines 6-7
7479 - movw $0x0607, %cx
7480 - int $0x10
7481 -set_current:
7482 - stc
7483 - ret
7484 -
7485 -# Set the 80x28 mode. This mode works on all VGA's, because it's a standard
7486 -# 80x25 mode with 14-point fonts instead of 16-point.
7487 -set_80x28:
7488 - DO_STORE
7489 - call use_80x25 # The base is 80x25
7490 -set14: movw $0x1111, %ax # Use 9x14 font
7491 - xorb %bl, %bl
7492 - int $0x10
7493 - movb $0x01, %ah # Define cursor scan lines 11-12
7494 - movw $0x0b0c, %cx
7495 - int $0x10
7496 - stc
7497 - ret
7498 -
7499 -# Set the 80x43 mode. This mode is works on all VGA's.
7500 -# It's a 350-scanline mode with 8-pixel font.
7501 -set_80x43:
7502 - DO_STORE
7503 - movw $0x1201, %ax # Set 350 scans
7504 - movb $0x30, %bl
7505 - int $0x10
7506 - movw $0x0003, %ax # Reset video mode
7507 - int $0x10
7508 - jmp set_8pt # Use 8-pixel font
7509 -
7510 -# Set the 80x30 mode (all VGA's). 480 scanlines, 16-pixel font.
7511 -set_80x30:
7512 - call use_80x25 # Start with real 80x25
7513 - DO_STORE
7514 - movw $0x3cc, %dx # Get CRTC port
7515 - inb %dx, %al
7516 - movb $0xd4, %dl
7517 - rorb %al # Mono or color?
7518 - jc set48a
7519 -
7520 - movb $0xb4, %dl
7521 -set48a: movw $0x0c11, %ax # Vertical sync end (also unlocks CR0-7)
7522 - call outidx
7523 - movw $0x0b06, %ax # Vertical total
7524 - call outidx
7525 - movw $0x3e07, %ax # (Vertical) overflow
7526 - call outidx
7527 - movw $0xea10, %ax # Vertical sync start
7528 - call outidx
7529 - movw $0xdf12, %ax # Vertical display end
7530 - call outidx
7531 - movw $0xe715, %ax # Vertical blank start
7532 - call outidx
7533 - movw $0x0416, %ax # Vertical blank end
7534 - call outidx
7535 - pushw %dx
7536 - movb $0xcc, %dl # Misc output register (read)
7537 - inb %dx, %al
7538 - movb $0xc2, %dl # (write)
7539 - andb $0x0d, %al # Preserve clock select bits and color bit
7540 - orb $0xe2, %al # Set correct sync polarity
7541 - outb %al, %dx
7542 - popw %dx
7543 - movw $0x501e, force_size
7544 - stc # That's all.
7545 - ret
7546 -
7547 -# Set the 80x34 mode (all VGA's). 480 scans, 14-pixel font.
7548 -set_80x34:
7549 - call set_80x30 # Set 480 scans
7550 - call set14 # And 14-pt font
7551 - movw $0xdb12, %ax # VGA vertical display end
7552 - movw $0x5022, force_size
7553 -setvde: call outidx
7554 - stc
7555 - ret
7556 -
7557 -# Set the 80x60 mode (all VGA's). 480 scans, 8-pixel font.
7558 -set_80x60:
7559 - call set_80x30 # Set 480 scans
7560 - call set_8pt # And 8-pt font
7561 - movw $0xdf12, %ax # VGA vertical display end
7562 - movw $0x503c, force_size
7563 - jmp setvde
7564 -
7565 -# Special hack for ThinkPad graphics
7566 -set_gfx:
7567 -#ifdef CONFIG_VIDEO_GFX_HACK
7568 - movw $VIDEO_GFX_BIOS_AX, %ax
7569 - movw $VIDEO_GFX_BIOS_BX, %bx
7570 - int $0x10
7571 - movw $VIDEO_GFX_DUMMY_RESOLUTION, force_size
7572 - stc
7573 -#endif
7574 - ret
7575 -
7576 -#ifdef CONFIG_VIDEO_RETAIN
7577 -
7578 -# Store screen contents to temporary buffer.
7579 -store_screen:
7580 - cmpb $0, do_restore # Already stored?
7581 - jnz stsr
7582 -
7583 - testb $CAN_USE_HEAP, loadflags # Have we space for storing?
7584 - jz stsr
7585 -
7586 - pushw %ax
7587 - pushw %bx
7588 - pushw force_size # Don't force specific size
7589 - movw $0, force_size
7590 - call mode_params # Obtain params of current mode
7591 - popw force_size
7592 - movb %fs:(PARAM_VIDEO_LINES), %ah
7593 - movb %fs:(PARAM_VIDEO_COLS), %al
7594 - movw %ax, %bx # BX=dimensions
7595 - mulb %ah
7596 - movw %ax, %cx # CX=number of characters
7597 - addw %ax, %ax # Calculate image size
7598 - addw $modelist+1024+4, %ax
7599 - cmpw heap_end_ptr, %ax
7600 - jnc sts1 # Unfortunately, out of memory
7601 -
7602 - movw %fs:(PARAM_CURSOR_POS), %ax # Store mode params
7603 - leaw modelist+1024, %di
7604 - stosw
7605 - movw %bx, %ax
7606 - stosw
7607 - pushw %ds # Store the screen
7608 - movw video_segment, %ds
7609 - xorw %si, %si
7610 - rep
7611 - movsw
7612 - popw %ds
7613 - incb do_restore # Screen will be restored later
7614 -sts1: popw %bx
7615 - popw %ax
7616 -stsr: ret
7617 -
7618 -# Restore screen contents from temporary buffer.
7619 -restore_screen:
7620 - cmpb $0, do_restore # Has the screen been stored?
7621 - jz res1
7622 -
7623 - call mode_params # Get parameters of current mode
7624 - movb %fs:(PARAM_VIDEO_LINES), %cl
7625 - movb %fs:(PARAM_VIDEO_COLS), %ch
7626 - leaw modelist+1024, %si # Screen buffer
7627 - lodsw # Set cursor position
7628 - movw %ax, %dx
7629 - cmpb %cl, %dh
7630 - jc res2
7631 -
7632 - movb %cl, %dh
7633 - decb %dh
7634 -res2: cmpb %ch, %dl
7635 - jc res3
7636 -
7637 - movb %ch, %dl
7638 - decb %dl
7639 -res3: movb $0x02, %ah
7640 - movb $0x00, %bh
7641 - int $0x10
7642 - lodsw # Display size
7643 - movb %ah, %dl # DL=number of lines
7644 - movb $0, %ah # BX=phys. length of orig. line
7645 - movw %ax, %bx
7646 - cmpb %cl, %dl # Too many?
7647 - jc res4
7648 -
7649 - pushw %ax
7650 - movb %dl, %al
7651 - subb %cl, %al
7652 - mulb %bl
7653 - addw %ax, %si
7654 - addw %ax, %si
7655 - popw %ax
7656 - movb %cl, %dl
7657 -res4: cmpb %ch, %al # Too wide?
7658 - jc res5
7659 -
7660 - movb %ch, %al # AX=width of src. line
7661 -res5: movb $0, %cl
7662 - xchgb %ch, %cl
7663 - movw %cx, %bp # BP=width of dest. line
7664 - pushw %es
7665 - movw video_segment, %es
7666 - xorw %di, %di # Move the data
7667 - addw %bx, %bx # Convert BX and BP to _bytes_
7668 - addw %bp, %bp
7669 -res6: pushw %si
7670 - pushw %di
7671 - movw %ax, %cx
7672 - rep
7673 - movsw
7674 - popw %di
7675 - popw %si
7676 - addw %bp, %di
7677 - addw %bx, %si
7678 - decb %dl
7679 - jnz res6
7680 -
7681 - popw %es # Done
7682 -res1: ret
7683 -#endif /* CONFIG_VIDEO_RETAIN */
7684 -
7685 -# Write to indexed VGA register (AL=index, AH=data, DX=index reg. port)
7686 -outidx: outb %al, %dx
7687 - pushw %ax
7688 - movb %ah, %al
7689 - incw %dx
7690 - outb %al, %dx
7691 - decw %dx
7692 - popw %ax
7693 - ret
7694 -
7695 -# Build the table of video modes (stored after the setup.S code at the
7696 -# `modelist' label. Each video mode record looks like:
7697 -# .word MODE-ID (our special mode ID (see above))
7698 -# .byte rows (number of rows)
7699 -# .byte columns (number of columns)
7700 -# Returns address of the end of the table in DI, the end is marked
7701 -# with a ASK_VGA ID.
7702 -mode_table:
7703 - movw mt_end, %di # Already filled?
7704 - orw %di, %di
7705 - jnz mtab1x
7706 -
7707 - leaw modelist, %di # Store standard modes:
7708 - movl $VIDEO_80x25 + 0x50190000, %eax # The 80x25 mode (ALL)
7709 - stosl
7710 - movb adapter, %al # CGA/MDA/HGA -- no more modes
7711 - orb %al, %al
7712 - jz mtabe
7713 -
7714 - decb %al
7715 - jnz mtabv
7716 -
7717 - movl $VIDEO_8POINT + 0x502b0000, %eax # The 80x43 EGA mode
7718 - stosl
7719 - jmp mtabe
7720 -
7721 -mtab1x: jmp mtab1
7722 -
7723 -mtabv: leaw vga_modes, %si # All modes for std VGA
7724 - movw $vga_modes_end-vga_modes, %cx
7725 - rep # I'm unable to use movsw as I don't know how to store a half
7726 - movsb # of the expression above to cx without using explicit shr.
7727 -
7728 - cmpb $0, scanning # Mode scan requested?
7729 - jz mscan1
7730 -
7731 - call mode_scan
7732 -mscan1:
7733 -
7734 -#ifdef CONFIG_VIDEO_LOCAL
7735 - call local_modes
7736 -#endif /* CONFIG_VIDEO_LOCAL */
7737 -
7738 -#ifdef CONFIG_VIDEO_VESA
7739 - call vesa_modes # Detect VESA VGA modes
7740 -#endif /* CONFIG_VIDEO_VESA */
7741 -
7742 -#ifdef CONFIG_VIDEO_SVGA
7743 - cmpb $0, scanning # Bypass when scanning
7744 - jnz mscan2
7745 -
7746 - call svga_modes # Detect SVGA cards & modes
7747 -mscan2:
7748 -#endif /* CONFIG_VIDEO_SVGA */
7749 -
7750 -mtabe:
7751 -
7752 -#ifdef CONFIG_VIDEO_COMPACT
7753 - leaw modelist, %si
7754 - movw %di, %dx
7755 - movw %si, %di
7756 -cmt1: cmpw %dx, %si # Scan all modes
7757 - jz cmt2
7758 -
7759 - leaw modelist, %bx # Find in previous entries
7760 - movw 2(%si), %cx
7761 -cmt3: cmpw %bx, %si
7762 - jz cmt4
7763 -
7764 - cmpw 2(%bx), %cx # Found => don't copy this entry
7765 - jz cmt5
7766 -
7767 - addw $4, %bx
7768 - jmp cmt3
7769 -
7770 -cmt4: movsl # Copy entry
7771 - jmp cmt1
7772 -
7773 -cmt5: addw $4, %si # Skip entry
7774 - jmp cmt1
7775 -
7776 -cmt2:
7777 -#endif /* CONFIG_VIDEO_COMPACT */
7778 -
7779 - movw $ASK_VGA, (%di) # End marker
7780 - movw %di, mt_end
7781 -mtab1: leaw modelist, %si # SI=mode list, DI=list end
7782 -ret0: ret
7783 -
7784 -# Modes usable on all standard VGAs
7785 -vga_modes:
7786 - .word VIDEO_8POINT
7787 - .word 0x5032 # 80x50
7788 - .word VIDEO_80x43
7789 - .word 0x502b # 80x43
7790 - .word VIDEO_80x28
7791 - .word 0x501c # 80x28
7792 - .word VIDEO_80x30
7793 - .word 0x501e # 80x30
7794 - .word VIDEO_80x34
7795 - .word 0x5022 # 80x34
7796 - .word VIDEO_80x60
7797 - .word 0x503c # 80x60
7798 -#ifdef CONFIG_VIDEO_GFX_HACK
7799 - .word VIDEO_GFX_HACK
7800 - .word VIDEO_GFX_DUMMY_RESOLUTION
7801 -#endif
7802 -
7803 -vga_modes_end:
7804 -# Detect VESA modes.
7805 -
7806 -#ifdef CONFIG_VIDEO_VESA
7807 -vesa_modes:
7808 - cmpb $2, adapter # VGA only
7809 - jnz ret0
7810 -
7811 - movw %di, %bp # BP=original mode table end
7812 - addw $0x200, %di # Buffer space
7813 - movw $0x4f00, %ax # VESA Get card info call
7814 - int $0x10
7815 - movw %bp, %di
7816 - cmpw $0x004f, %ax # Successful?
7817 - jnz ret0
7818 -
7819 - cmpw $0x4556, 0x200(%di)
7820 - jnz ret0
7821 -
7822 - cmpw $0x4153, 0x202(%di)
7823 - jnz ret0
7824 -
7825 - movw $vesa_name, card_name # Set name to "VESA VGA"
7826 - pushw %gs
7827 - lgsw 0x20e(%di), %si # GS:SI=mode list
7828 - movw $128, %cx # Iteration limit
7829 -vesa1:
7830 -# gas version 2.9.1, using BFD version 2.9.1.0.23 buggers the next inst.
7831 -# XXX: lodsw %gs:(%si), %ax # Get next mode in the list
7832 - gs; lodsw
7833 - cmpw $0xffff, %ax # End of the table?
7834 - jz vesar
7835 -
7836 - cmpw $0x0080, %ax # Check validity of mode ID
7837 - jc vesa2
7838 -
7839 - orb %ah, %ah # Valid IDs: 0x0000-0x007f/0x0100-0x07ff
7840 - jz vesan # Certain BIOSes report 0x80-0xff!
7841 -
7842 - cmpw $0x0800, %ax
7843 - jnc vesae
7844 -
7845 -vesa2: pushw %cx
7846 - movw %ax, %cx # Get mode information structure
7847 - movw $0x4f01, %ax
7848 - int $0x10
7849 - movw %cx, %bx # BX=mode number
7850 - addb $VIDEO_FIRST_VESA>>8, %bh
7851 - popw %cx
7852 - cmpw $0x004f, %ax
7853 - jnz vesan # Don't report errors (buggy BIOSES)
7854 -
7855 - movb (%di), %al # Check capabilities. We require
7856 - andb $0x19, %al # a color text mode.
7857 - cmpb $0x09, %al
7858 - jnz vesan
7859 -
7860 - cmpw $0xb800, 8(%di) # Standard video memory address required
7861 - jnz vesan
7862 -
7863 - testb $2, (%di) # Mode characteristics supplied?
7864 - movw %bx, (%di) # Store mode number
7865 - jz vesa3
7866 -
7867 - xorw %dx, %dx
7868 - movw 0x12(%di), %bx # Width
7869 - orb %bh, %bh
7870 - jnz vesan
7871 -
7872 - movb %bl, 0x3(%di)
7873 - movw 0x14(%di), %ax # Height
7874 - orb %ah, %ah
7875 - jnz vesan
7876 -
7877 - movb %al, 2(%di)
7878 - mulb %bl
7879 - cmpw $8193, %ax # Small enough for Linux console driver?
7880 - jnc vesan
7881 -
7882 - jmp vesaok
7883 -
7884 -vesa3: subw $0x8108, %bx # This mode has no detailed info specified,
7885 - jc vesan # so it must be a standard VESA mode.
7886 -
7887 - cmpw $5, %bx
7888 - jnc vesan
7889 -
7890 - movw vesa_text_mode_table(%bx), %ax
7891 - movw %ax, 2(%di)
7892 -vesaok: addw $4, %di # The mode is valid. Store it.
7893 -vesan: loop vesa1 # Next mode. Limit exceeded => error
7894 -vesae: leaw vesaer, %si
7895 - call prtstr
7896 - movw %bp, %di # Discard already found modes.
7897 -vesar: popw %gs
7898 - ret
7899 -
7900 -# Dimensions of standard VESA text modes
7901 -vesa_text_mode_table:
7902 - .byte 60, 80 # 0108
7903 - .byte 25, 132 # 0109
7904 - .byte 43, 132 # 010A
7905 - .byte 50, 132 # 010B
7906 - .byte 60, 132 # 010C
7907 -#endif /* CONFIG_VIDEO_VESA */
7908 -
7909 -# Scan for video modes. A bit dirty, but should work.
7910 -mode_scan:
7911 - movw $0x0100, %cx # Start with mode 0
7912 -scm1: movb $0, %ah # Test the mode
7913 - movb %cl, %al
7914 - int $0x10
7915 - movb $0x0f, %ah
7916 - int $0x10
7917 - cmpb %cl, %al
7918 - jnz scm2 # Mode not set
7919 -
7920 - movw $0x3c0, %dx # Test if it's a text mode
7921 - movb $0x10, %al # Mode bits
7922 - call inidx
7923 - andb $0x03, %al
7924 - jnz scm2
7925 -
7926 - movb $0xce, %dl # Another set of mode bits
7927 - movb $0x06, %al
7928 - call inidx
7929 - shrb %al
7930 - jc scm2
7931 -
7932 - movb $0xd4, %dl # Cursor location
7933 - movb $0x0f, %al
7934 - call inidx
7935 - orb %al, %al
7936 - jnz scm2
7937 -
7938 - movw %cx, %ax # Ok, store the mode
7939 - stosw
7940 - movb %gs:(0x484), %al # Number of rows
7941 - incb %al
7942 - stosb
7943 - movw %gs:(0x44a), %ax # Number of columns
7944 - stosb
7945 -scm2: incb %cl
7946 - jns scm1
7947 -
7948 - movw $0x0003, %ax # Return back to mode 3
7949 - int $0x10
7950 - ret
7951 -
7952 -tstidx: outw %ax, %dx # OUT DX,AX and inidx
7953 -inidx: outb %al, %dx # Read from indexed VGA register
7954 - incw %dx # AL=index, DX=index reg port -> AL=data
7955 - inb %dx, %al
7956 - decw %dx
7957 - ret
7958 -
7959 -# Try to detect type of SVGA card and supply (usually approximate) video
7960 -# mode table for it.
7961 -
7962 -#ifdef CONFIG_VIDEO_SVGA
7963 -svga_modes:
7964 - leaw svga_table, %si # Test all known SVGA adapters
7965 -dosvga: lodsw
7966 - movw %ax, %bp # Default mode table
7967 - orw %ax, %ax
7968 - jz didsv1
7969 -
7970 - lodsw # Pointer to test routine
7971 - pushw %si
7972 - pushw %di
7973 - pushw %es
7974 - movw $0xc000, %bx
7975 - movw %bx, %es
7976 - call *%ax # Call test routine
7977 - popw %es
7978 - popw %di
7979 - popw %si
7980 - orw %bp, %bp
7981 - jz dosvga
7982 -
7983 - movw %bp, %si # Found, copy the modes
7984 - movb svga_prefix, %ah
7985 -cpsvga: lodsb
7986 - orb %al, %al
7987 - jz didsv
7988 -
7989 - stosw
7990 - movsw
7991 - jmp cpsvga
7992 -
7993 -didsv: movw %si, card_name # Store pointer to card name
7994 -didsv1: ret
7995 -
7996 -# Table of all known SVGA cards. For each card, we store a pointer to
7997 -# a table of video modes supported by the card and a pointer to a routine
7998 -# used for testing of presence of the card. The video mode table is always
7999 -# followed by the name of the card or the chipset.
8000 -svga_table:
8001 - .word ati_md, ati_test
8002 - .word oak_md, oak_test
8003 - .word paradise_md, paradise_test
8004 - .word realtek_md, realtek_test
8005 - .word s3_md, s3_test
8006 - .word chips_md, chips_test
8007 - .word video7_md, video7_test
8008 - .word cirrus5_md, cirrus5_test
8009 - .word cirrus6_md, cirrus6_test
8010 - .word cirrus1_md, cirrus1_test
8011 - .word ahead_md, ahead_test
8012 - .word everex_md, everex_test
8013 - .word genoa_md, genoa_test
8014 - .word trident_md, trident_test
8015 - .word tseng_md, tseng_test
8016 - .word 0
8017 -
8018 -# Test routines and mode tables:
8019 -
8020 -# S3 - The test algorithm was taken from the SuperProbe package
8021 -# for XFree86 1.2.1. Report bugs to Christoph.Niemann@linux.org
8022 -s3_test:
8023 - movw $0x0f35, %cx # we store some constants in cl/ch
8024 - movw $0x03d4, %dx
8025 - movb $0x38, %al
8026 - call inidx
8027 - movb %al, %bh # store current CRT-register 0x38
8028 - movw $0x0038, %ax
8029 - call outidx # disable writing to special regs
8030 - movb %cl, %al # check whether we can write special reg 0x35
8031 - call inidx
8032 - movb %al, %bl # save the current value of CRT reg 0x35
8033 - andb $0xf0, %al # clear bits 0-3
8034 - movb %al, %ah
8035 - movb %cl, %al # and write it to CRT reg 0x35
8036 - call outidx
8037 - call inidx # now read it back
8038 - andb %ch, %al # clear the upper 4 bits
8039 - jz s3_2 # the first test failed. But we have a
8040 -
8041 - movb %bl, %ah # second chance
8042 - movb %cl, %al
8043 - call outidx
8044 - jmp s3_1 # do the other tests
8045 -
8046 -s3_2: movw %cx, %ax # load ah with 0xf and al with 0x35
8047 - orb %bl, %ah # set the upper 4 bits of ah with the orig value
8048 - call outidx # write ...
8049 - call inidx # ... and reread
8050 - andb %cl, %al # turn off the upper 4 bits
8051 - pushw %ax
8052 - movb %bl, %ah # restore old value in register 0x35
8053 - movb %cl, %al
8054 - call outidx
8055 - popw %ax
8056 - cmpb %ch, %al # setting lower 4 bits was successful => bad
8057 - je no_s3 # writing is allowed => this is not an S3
8058 -
8059 -s3_1: movw $0x4838, %ax # allow writing to special regs by putting
8060 - call outidx # magic number into CRT-register 0x38
8061 - movb %cl, %al # check whether we can write special reg 0x35
8062 - call inidx
8063 - movb %al, %bl
8064 - andb $0xf0, %al
8065 - movb %al, %ah
8066 - movb %cl, %al
8067 - call outidx
8068 - call inidx
8069 - andb %ch, %al
8070 - jnz no_s3 # no, we can't write => no S3
8071 -
8072 - movw %cx, %ax
8073 - orb %bl, %ah
8074 - call outidx
8075 - call inidx
8076 - andb %ch, %al
8077 - pushw %ax
8078 - movb %bl, %ah # restore old value in register 0x35
8079 - movb %cl, %al
8080 - call outidx
8081 - popw %ax
8082 - cmpb %ch, %al
8083 - jne no_s31 # writing not possible => no S3
8084 - movb $0x30, %al
8085 - call inidx # now get the S3 id ...
8086 - leaw idS3, %di
8087 - movw $0x10, %cx
8088 - repne
8089 - scasb
8090 - je no_s31
8091 -
8092 - movb %bh, %ah
8093 - movb $0x38, %al
8094 - jmp s3rest
8095 -
8096 -no_s3: movb $0x35, %al # restore CRT register 0x35
8097 - movb %bl, %ah
8098 - call outidx
8099 -no_s31: xorw %bp, %bp # Detection failed
8100 -s3rest: movb %bh, %ah
8101 - movb $0x38, %al # restore old value of CRT register 0x38
8102 - jmp outidx
8103 -
8104 -idS3: .byte 0x81, 0x82, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95
8105 - .byte 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa8, 0xb0
8106 -
8107 -s3_md: .byte 0x54, 0x2b, 0x84
8108 - .byte 0x55, 0x19, 0x84
8109 - .byte 0
8110 - .ascii "S3"
8111 - .byte 0
8112 -
8113 -# ATI cards.
8114 -ati_test:
8115 - leaw idati, %si
8116 - movw $0x31, %di
8117 - movw $0x09, %cx
8118 - repe
8119 - cmpsb
8120 - je atiok
8121 -
8122 - xorw %bp, %bp
8123 -atiok: ret
8124 -
8125 -idati: .ascii "761295520"
8126 -
8127 -ati_md: .byte 0x23, 0x19, 0x84
8128 - .byte 0x33, 0x2c, 0x84
8129 - .byte 0x22, 0x1e, 0x64
8130 - .byte 0x21, 0x19, 0x64
8131 - .byte 0x58, 0x21, 0x50
8132 - .byte 0x5b, 0x1e, 0x50
8133 - .byte 0
8134 - .ascii "ATI"
8135 - .byte 0
8136 -
8137 -# AHEAD
8138 -ahead_test:
8139 - movw $0x200f, %ax
8140 - movw $0x3ce, %dx
8141 - outw %ax, %dx
8142 - incw %dx
8143 - inb %dx, %al
8144 - cmpb $0x20, %al
8145 - je isahed
8146 -
8147 - cmpb $0x21, %al
8148 - je isahed
8149 -
8150 - xorw %bp, %bp
8151 -isahed: ret
8152 -
8153 -ahead_md:
8154 - .byte 0x22, 0x2c, 0x84
8155 - .byte 0x23, 0x19, 0x84
8156 - .byte 0x24, 0x1c, 0x84
8157 - .byte 0x2f, 0x32, 0xa0
8158 - .byte 0x32, 0x22, 0x50
8159 - .byte 0x34, 0x42, 0x50
8160 - .byte 0
8161 - .ascii "Ahead"
8162 - .byte 0
8163 -
8164 -# Chips & Tech.
8165 -chips_test:
8166 - movw $0x3c3, %dx
8167 - inb %dx, %al
8168 - orb $0x10, %al
8169 - outb %al, %dx
8170 - movw $0x104, %dx
8171 - inb %dx, %al
8172 - movb %al, %bl
8173 - movw $0x3c3, %dx
8174 - inb %dx, %al
8175 - andb $0xef, %al
8176 - outb %al, %dx
8177 - cmpb $0xa5, %bl
8178 - je cantok
8179 -
8180 - xorw %bp, %bp
8181 -cantok: ret
8182 -
8183 -chips_md:
8184 - .byte 0x60, 0x19, 0x84
8185 - .byte 0x61, 0x32, 0x84
8186 - .byte 0
8187 - .ascii "Chips & Technologies"
8188 - .byte 0
8189 -
8190 -# Cirrus Logic 5X0
8191 -cirrus1_test:
8192 - movw $0x3d4, %dx
8193 - movb $0x0c, %al
8194 - outb %al, %dx
8195 - incw %dx
8196 - inb %dx, %al
8197 - movb %al, %bl
8198 - xorb %al, %al
8199 - outb %al, %dx
8200 - decw %dx
8201 - movb $0x1f, %al
8202 - outb %al, %dx
8203 - incw %dx
8204 - inb %dx, %al
8205 - movb %al, %bh
8206 - xorb %ah, %ah
8207 - shlb $4, %al
8208 - movw %ax, %cx
8209 - movb %bh, %al
8210 - shrb $4, %al
8211 - addw %ax, %cx
8212 - shlw $8, %cx
8213 - addw $6, %cx
8214 - movw %cx, %ax
8215 - movw $0x3c4, %dx
8216 - outw %ax, %dx
8217 - incw %dx
8218 - inb %dx, %al
8219 - andb %al, %al
8220 - jnz nocirr
8221 -
8222 - movb %bh, %al
8223 - outb %al, %dx
8224 - inb %dx, %al
8225 - cmpb $0x01, %al
8226 - je iscirr
8227 -
8228 -nocirr: xorw %bp, %bp
8229 -iscirr: movw $0x3d4, %dx
8230 - movb %bl, %al
8231 - xorb %ah, %ah
8232 - shlw $8, %ax
8233 - addw $0x0c, %ax
8234 - outw %ax, %dx
8235 - ret
8236 -
8237 -cirrus1_md:
8238 - .byte 0x1f, 0x19, 0x84
8239 - .byte 0x20, 0x2c, 0x84
8240 - .byte 0x22, 0x1e, 0x84
8241 - .byte 0x31, 0x25, 0x64
8242 - .byte 0
8243 - .ascii "Cirrus Logic 5X0"
8244 - .byte 0
8245 -
8246 -# Cirrus Logic 54XX
8247 -cirrus5_test:
8248 - movw $0x3c4, %dx
8249 - movb $6, %al
8250 - call inidx
8251 - movb %al, %bl # BL=backup
8252 - movw $6, %ax
8253 - call tstidx
8254 - cmpb $0x0f, %al
8255 - jne c5fail
8256 -
8257 - movw $0x1206, %ax
8258 - call tstidx
8259 - cmpb $0x12, %al
8260 - jne c5fail
8261 -
8262 - movb $0x1e, %al
8263 - call inidx
8264 - movb %al, %bh
8265 - movb %bh, %ah
8266 - andb $0xc0, %ah
8267 - movb $0x1e, %al
8268 - call tstidx
8269 - andb $0x3f, %al
8270 - jne c5xx
8271 -
8272 - movb $0x1e, %al
8273 - movb %bh, %ah
8274 - orb $0x3f, %ah
8275 - call tstidx
8276 - xorb $0x3f, %al
8277 - andb $0x3f, %al
8278 -c5xx: pushf
8279 - movb $0x1e, %al
8280 - movb %bh, %ah
8281 - outw %ax, %dx
8282 - popf
8283 - je c5done
8284 -
8285 -c5fail: xorw %bp, %bp
8286 -c5done: movb $6, %al
8287 - movb %bl, %ah
8288 - outw %ax, %dx
8289 - ret
8290 -
8291 -cirrus5_md:
8292 - .byte 0x14, 0x19, 0x84
8293 - .byte 0x54, 0x2b, 0x84
8294 - .byte 0
8295 - .ascii "Cirrus Logic 54XX"
8296 - .byte 0
8297 -
8298 -# Cirrus Logic 64XX -- no known extra modes, but must be identified, because
8299 -# it's misidentified by the Ahead test.
8300 -cirrus6_test:
8301 - movw $0x3ce, %dx
8302 - movb $0x0a, %al
8303 - call inidx
8304 - movb %al, %bl # BL=backup
8305 - movw $0xce0a, %ax
8306 - call tstidx
8307 - orb %al, %al
8308 - jne c2fail
8309 -
8310 - movw $0xec0a, %ax
8311 - call tstidx
8312 - cmpb $0x01, %al
8313 - jne c2fail
8314 -
8315 - movb $0xaa, %al
8316 - call inidx # 4X, 5X, 7X and 8X are valid 64XX chip ID's.
8317 - shrb $4, %al
8318 - subb $4, %al
8319 - jz c6done
8320 -
8321 - decb %al
8322 - jz c6done
8323 -
8324 - subb $2, %al
8325 - jz c6done
8326 -
8327 - decb %al
8328 - jz c6done
8329 -
8330 -c2fail: xorw %bp, %bp
8331 -c6done: movb $0x0a, %al
8332 - movb %bl, %ah
8333 - outw %ax, %dx
8334 - ret
8335 -
8336 -cirrus6_md:
8337 - .byte 0
8338 - .ascii "Cirrus Logic 64XX"
8339 - .byte 0
8340 -
8341 -# Everex / Trident
8342 -everex_test:
8343 - movw $0x7000, %ax
8344 - xorw %bx, %bx
8345 - int $0x10
8346 - cmpb $0x70, %al
8347 - jne noevrx
8348 -
8349 - shrw $4, %dx
8350 - cmpw $0x678, %dx
8351 - je evtrid
8352 -
8353 - cmpw $0x236, %dx
8354 - jne evrxok
8355 -
8356 -evtrid: leaw trident_md, %bp
8357 -evrxok: ret
8358 -
8359 -noevrx: xorw %bp, %bp
8360 - ret
8361 -
8362 -everex_md:
8363 - .byte 0x03, 0x22, 0x50
8364 - .byte 0x04, 0x3c, 0x50
8365 - .byte 0x07, 0x2b, 0x64
8366 - .byte 0x08, 0x4b, 0x64
8367 - .byte 0x0a, 0x19, 0x84
8368 - .byte 0x0b, 0x2c, 0x84
8369 - .byte 0x16, 0x1e, 0x50
8370 - .byte 0x18, 0x1b, 0x64
8371 - .byte 0x21, 0x40, 0xa0
8372 - .byte 0x40, 0x1e, 0x84
8373 - .byte 0
8374 - .ascii "Everex/Trident"
8375 - .byte 0
8376 -
8377 -# Genoa.
8378 -genoa_test:
8379 - leaw idgenoa, %si # Check Genoa 'clues'
8380 - xorw %ax, %ax
8381 - movb %es:(0x37), %al
8382 - movw %ax, %di
8383 - movw $0x04, %cx
8384 - decw %si
8385 - decw %di
8386 -l1: incw %si
8387 - incw %di
8388 - movb (%si), %al
8389 - testb %al, %al
8390 - jz l2
8391 -
8392 - cmpb %es:(%di), %al
8393 -l2: loope l1
8394 - orw %cx, %cx
8395 - je isgen
8396 -
8397 - xorw %bp, %bp
8398 -isgen: ret
8399 -
8400 -idgenoa: .byte 0x77, 0x00, 0x99, 0x66
8401 -
8402 -genoa_md:
8403 - .byte 0x58, 0x20, 0x50
8404 - .byte 0x5a, 0x2a, 0x64
8405 - .byte 0x60, 0x19, 0x84
8406 - .byte 0x61, 0x1d, 0x84
8407 - .byte 0x62, 0x20, 0x84
8408 - .byte 0x63, 0x2c, 0x84
8409 - .byte 0x64, 0x3c, 0x84
8410 - .byte 0x6b, 0x4f, 0x64
8411 - .byte 0x72, 0x3c, 0x50
8412 - .byte 0x74, 0x42, 0x50
8413 - .byte 0x78, 0x4b, 0x64
8414 - .byte 0
8415 - .ascii "Genoa"
8416 - .byte 0
8417 -
8418 -# OAK
8419 -oak_test:
8420 - leaw idoakvga, %si
8421 - movw $0x08, %di
8422 - movw $0x08, %cx
8423 - repe
8424 - cmpsb
8425 - je isoak
8426 -
8427 - xorw %bp, %bp
8428 -isoak: ret
8429 -
8430 -idoakvga: .ascii "OAK VGA "
8431 -
8432 -oak_md: .byte 0x4e, 0x3c, 0x50
8433 - .byte 0x4f, 0x3c, 0x84
8434 - .byte 0x50, 0x19, 0x84
8435 - .byte 0x51, 0x2b, 0x84
8436 - .byte 0
8437 - .ascii "OAK"
8438 - .byte 0
8439 -
8440 -# WD Paradise.
8441 -paradise_test:
8442 - leaw idparadise, %si
8443 - movw $0x7d, %di
8444 - movw $0x04, %cx
8445 - repe
8446 - cmpsb
8447 - je ispara
8448 -
8449 - xorw %bp, %bp
8450 -ispara: ret
8451 -
8452 -idparadise: .ascii "VGA="
8453 -
8454 -paradise_md:
8455 - .byte 0x41, 0x22, 0x50
8456 - .byte 0x47, 0x1c, 0x84
8457 - .byte 0x55, 0x19, 0x84
8458 - .byte 0x54, 0x2c, 0x84
8459 - .byte 0
8460 - .ascii "Paradise"
8461 - .byte 0
8462 -
8463 -# Trident.
8464 -trident_test:
8465 - movw $0x3c4, %dx
8466 - movb $0x0e, %al
8467 - outb %al, %dx
8468 - incw %dx
8469 - inb %dx, %al
8470 - xchgb %al, %ah
8471 - xorb %al, %al
8472 - outb %al, %dx
8473 - inb %dx, %al
8474 - xchgb %ah, %al
8475 - movb %al, %bl # Strange thing ... in the book this wasn't
8476 - andb $0x02, %bl # necessary but it worked on my card which
8477 - jz setb2 # is a trident. Without it the screen goes
8478 - # blurred ...
8479 - andb $0xfd, %al
8480 - jmp clrb2
8481 -
8482 -setb2: orb $0x02, %al
8483 -clrb2: outb %al, %dx
8484 - andb $0x0f, %ah
8485 - cmpb $0x02, %ah
8486 - je istrid
8487 -
8488 - xorw %bp, %bp
8489 -istrid: ret
8490 -
8491 -trident_md:
8492 - .byte 0x50, 0x1e, 0x50
8493 - .byte 0x51, 0x2b, 0x50
8494 - .byte 0x52, 0x3c, 0x50
8495 - .byte 0x57, 0x19, 0x84
8496 - .byte 0x58, 0x1e, 0x84
8497 - .byte 0x59, 0x2b, 0x84
8498 - .byte 0x5a, 0x3c, 0x84
8499 - .byte 0
8500 - .ascii "Trident"
8501 - .byte 0
8502 -
8503 -# Tseng.
8504 -tseng_test:
8505 - movw $0x3cd, %dx
8506 - inb %dx, %al # Could things be this simple ! :-)
8507 - movb %al, %bl
8508 - movb $0x55, %al
8509 - outb %al, %dx
8510 - inb %dx, %al
8511 - movb %al, %ah
8512 - movb %bl, %al
8513 - outb %al, %dx
8514 - cmpb $0x55, %ah
8515 - je istsen
8516 -
8517 -isnot: xorw %bp, %bp
8518 -istsen: ret
8519 -
8520 -tseng_md:
8521 - .byte 0x26, 0x3c, 0x50
8522 - .byte 0x2a, 0x28, 0x64
8523 - .byte 0x23, 0x19, 0x84
8524 - .byte 0x24, 0x1c, 0x84
8525 - .byte 0x22, 0x2c, 0x84
8526 - .byte 0x21, 0x3c, 0x84
8527 - .byte 0
8528 - .ascii "Tseng"
8529 - .byte 0
8530 -
8531 -# Video7.
8532 -video7_test:
8533 - movw $0x3cc, %dx
8534 - inb %dx, %al
8535 - movw $0x3b4, %dx
8536 - andb $0x01, %al
8537 - jz even7
8538 -
8539 - movw $0x3d4, %dx
8540 -even7: movb $0x0c, %al
8541 - outb %al, %dx
8542 - incw %dx
8543 - inb %dx, %al
8544 - movb %al, %bl
8545 - movb $0x55, %al
8546 - outb %al, %dx
8547 - inb %dx, %al
8548 - decw %dx
8549 - movb $0x1f, %al
8550 - outb %al, %dx
8551 - incw %dx
8552 - inb %dx, %al
8553 - movb %al, %bh
8554 - decw %dx
8555 - movb $0x0c, %al
8556 - outb %al, %dx
8557 - incw %dx
8558 - movb %bl, %al
8559 - outb %al, %dx
8560 - movb $0x55, %al
8561 - xorb $0xea, %al
8562 - cmpb %bh, %al
8563 - jne isnot
8564 -
8565 - movb $VIDEO_FIRST_V7>>8, svga_prefix # Use special mode switching
8566 - ret
8567 -
8568 -video7_md:
8569 - .byte 0x40, 0x2b, 0x50
8570 - .byte 0x43, 0x3c, 0x50
8571 - .byte 0x44, 0x3c, 0x64
8572 - .byte 0x41, 0x19, 0x84
8573 - .byte 0x42, 0x2c, 0x84
8574 - .byte 0x45, 0x1c, 0x84
8575 - .byte 0
8576 - .ascii "Video 7"
8577 - .byte 0
8578 -
8579 -# Realtek VGA
8580 -realtek_test:
8581 - leaw idrtvga, %si
8582 - movw $0x45, %di
8583 - movw $0x0b, %cx
8584 - repe
8585 - cmpsb
8586 - je isrt
8587 -
8588 - xorw %bp, %bp
8589 -isrt: ret
8590 -
8591 -idrtvga: .ascii "REALTEK VGA"
8592 -
8593 -realtek_md:
8594 - .byte 0x1a, 0x3c, 0x50
8595 - .byte 0x1b, 0x19, 0x84
8596 - .byte 0x1c, 0x1e, 0x84
8597 - .byte 0x1d, 0x2b, 0x84
8598 - .byte 0x1e, 0x3c, 0x84
8599 - .byte 0
8600 - .ascii "REALTEK"
8601 - .byte 0
8602 -
8603 -#endif /* CONFIG_VIDEO_SVGA */
8604 -
8605 -# User-defined local mode table (VGA only)
8606 -#ifdef CONFIG_VIDEO_LOCAL
8607 -local_modes:
8608 - leaw local_mode_table, %si
8609 -locm1: lodsw
8610 - orw %ax, %ax
8611 - jz locm2
8612 -
8613 - stosw
8614 - movsw
8615 - jmp locm1
8616 -
8617 -locm2: ret
8618 -
8619 -# This is the table of local video modes which can be supplied manually
8620 -# by the user. Each entry consists of mode ID (word) and dimensions
8621 -# (byte for column count and another byte for row count). These modes
8622 -# are placed before all SVGA and VESA modes and override them if table
8623 -# compacting is enabled. The table must end with a zero word followed
8624 -# by NUL-terminated video adapter name.
8625 -local_mode_table:
8626 - .word 0x0100 # Example: 40x25
8627 - .byte 25,40
8628 - .word 0
8629 - .ascii "Local"
8630 - .byte 0
8631 -#endif /* CONFIG_VIDEO_LOCAL */
8632 -
8633 -# Read a key and return the ASCII code in al, scan code in ah
8634 -getkey: xorb %ah, %ah
8635 - int $0x16
8636 - ret
8637 -
8638 -# Read a key with a timeout of 30 seconds.
8639 -# The hardware clock is used to get the time.
8640 -getkt: call gettime
8641 - addb $30, %al # Wait 30 seconds
8642 - cmpb $60, %al
8643 - jl lminute
8644 -
8645 - subb $60, %al
8646 -lminute:
8647 - movb %al, %cl
8648 -again: movb $0x01, %ah
8649 - int $0x16
8650 - jnz getkey # key pressed, so get it
8651 -
8652 - call gettime
8653 - cmpb %cl, %al
8654 - jne again
8655 -
8656 - movb $0x20, %al # timeout, return `space'
8657 - ret
8658 -
8659 -# Flush the keyboard buffer
8660 -flush: movb $0x01, %ah
8661 - int $0x16
8662 - jz empty
8663 -
8664 - xorb %ah, %ah
8665 - int $0x16
8666 - jmp flush
8667 -
8668 -empty: ret
8669 -
8670 -# Print hexadecimal number.
8671 -prthw: pushw %ax
8672 - movb %ah, %al
8673 - call prthb
8674 - popw %ax
8675 -prthb: pushw %ax
8676 - shrb $4, %al
8677 - call prthn
8678 - popw %ax
8679 - andb $0x0f, %al
8680 -prthn: cmpb $0x0a, %al
8681 - jc prth1
8682 -
8683 - addb $0x07, %al
8684 -prth1: addb $0x30, %al
8685 - jmp prtchr
8686 -
8687 -# Print decimal number in al
8688 -prtdec: pushw %ax
8689 - pushw %cx
8690 - xorb %ah, %ah
8691 - movb $0x0a, %cl
8692 - idivb %cl
8693 - cmpb $0x09, %al
8694 - jbe lt100
8695 -
8696 - call prtdec
8697 - jmp skip10
8698 -
8699 -lt100: addb $0x30, %al
8700 - call prtchr
8701 -skip10: movb %ah, %al
8702 - addb $0x30, %al
8703 - call prtchr
8704 - popw %cx
8705 - popw %ax
8706 - ret
8707 -
8708 -store_edid:
8709 -#ifdef CONFIG_FIRMWARE_EDID
8710 - pushw %es # just save all registers
8711 - pushw %ax
8712 - pushw %bx
8713 - pushw %cx
8714 - pushw %dx
8715 - pushw %di
8716 -
8717 - pushw %fs
8718 - popw %es
8719 -
8720 - movl $0x13131313, %eax # memset block with 0x13
8721 - movw $32, %cx
8722 - movw $0x140, %di
8723 - cld
8724 - rep
8725 - stosl
8726 -
8727 - cmpw $0x0200, vbe_version # only do EDID on >= VBE2.0
8728 - jl no_edid
8729 -
8730 - pushw %es # save ES
8731 - xorw %di, %di # Report Capability
8732 - pushw %di
8733 - popw %es # ES:DI must be 0:0
8734 - movw $0x4f15, %ax
8735 - xorw %bx, %bx
8736 - xorw %cx, %cx
8737 - int $0x10
8738 - popw %es # restore ES
8739 -
8740 - cmpb $0x00, %ah # call successful
8741 - jne no_edid
8742 -
8743 - cmpb $0x4f, %al # function supported
8744 - jne no_edid
8745 -
8746 - movw $0x4f15, %ax # do VBE/DDC
8747 - movw $0x01, %bx
8748 - movw $0x00, %cx
8749 - movw $0x00, %dx
8750 - movw $0x140, %di
8751 - int $0x10
8752 -
8753 -no_edid:
8754 - popw %di # restore all registers
8755 - popw %dx
8756 - popw %cx
8757 - popw %bx
8758 - popw %ax
8759 - popw %es
8760 -#endif
8761 - ret
8762 -
8763 -# VIDEO_SELECT-only variables
8764 -mt_end: .word 0 # End of video mode table if built
8765 -edit_buf: .space 6 # Line editor buffer
8766 -card_name: .word 0 # Pointer to adapter name
8767 -scanning: .byte 0 # Performing mode scan
8768 -do_restore: .byte 0 # Screen contents altered during mode change
8769 -svga_prefix: .byte VIDEO_FIRST_BIOS>>8 # Default prefix for BIOS modes
8770 -graphic_mode: .byte 0 # Graphic mode with a linear frame buffer
8771 -dac_size: .byte 6 # DAC bit depth
8772 -vbe_version: .word 0 # VBE bios version
8773 -
8774 -# Status messages
8775 -keymsg: .ascii "Press <RETURN> to see video modes available, "
8776 - .ascii "<SPACE> to continue or wait 30 secs"
8777 - .byte 0x0d, 0x0a, 0
8778 -
8779 -listhdr: .byte 0x0d, 0x0a
8780 - .ascii "Mode: COLSxROWS:"
8781 -
8782 -crlft: .byte 0x0d, 0x0a, 0
8783 -
8784 -prompt: .byte 0x0d, 0x0a
8785 - .asciz "Enter mode number or `scan': "
8786 -
8787 -unknt: .asciz "Unknown mode ID. Try again."
8788 -
8789 -badmdt: .ascii "You passed an undefined mode number."
8790 - .byte 0x0d, 0x0a, 0
8791 -
8792 -vesaer: .ascii "Error: Scanning of VESA modes failed. Please "
8793 - .ascii "report to <mj@ucw.cz>."
8794 - .byte 0x0d, 0x0a, 0
8795 -
8796 -old_name: .asciz "CGA/MDA/HGA"
8797 -
8798 -ega_name: .asciz "EGA"
8799 -
8800 -svga_name: .ascii " "
8801 -
8802 -vga_name: .asciz "VGA"
8803 -
8804 -vesa_name: .asciz "VESA"
8805 -
8806 -name_bann: .asciz "Video adapter: "
8807 -#endif /* CONFIG_VIDEO_SELECT */
8808 -
8809 -# Other variables:
8810 -adapter: .byte 0 # Video adapter: 0=CGA/MDA/HGA,1=EGA,2=VGA
8811 -video_segment: .word 0xb800 # Video memory segment
8812 -force_size: .word 0 # Use this size instead of the one in BIOS vars
8813 Index: linux-2.6.22.19/arch/i386/boot/video.c
8814 ===================================================================
8815 --- /dev/null
8816 +++ linux-2.6.22.19/arch/i386/boot/video.c
8817 @@ -0,0 +1,456 @@
8818 +/* -*- linux-c -*- ------------------------------------------------------- *
8819 + *
8820 + * Copyright (C) 1991, 1992 Linus Torvalds
8821 + * Copyright 2007 rPath, Inc. - All Rights Reserved
8822 + *
8823 + * This file is part of the Linux kernel, and is made available under
8824 + * the terms of the GNU General Public License version 2.
8825 + *
8826 + * ----------------------------------------------------------------------- */
8827 +
8828 +/*
8829 + * arch/i386/boot/video.c
8830 + *
8831 + * Select video mode
8832 + */
8833 +
8834 +#include "boot.h"
8835 +#include "video.h"
8836 +#include "vesa.h"
8837 +
8838 +/*
8839 + * Mode list variables
8840 + */
8841 +static struct card_info cards[]; /* List of cards to probe for */
8842 +
8843 +/*
8844 + * Common variables
8845 + */
8846 +int adapter; /* 0=CGA/MDA/HGC, 1=EGA, 2=VGA+ */
8847 +u16 video_segment;
8848 +int force_x, force_y; /* Don't query the BIOS for cols/rows */
8849 +
8850 +int do_restore = 0; /* Screen contents changed during mode flip */
8851 +int graphic_mode; /* Graphic mode with linear frame buffer */
8852 +
8853 +static void store_cursor_position(void)
8854 +{
8855 + u16 curpos;
8856 + u16 ax, bx;
8857 +
8858 + ax = 0x0300;
8859 + bx = 0;
8860 + asm(INT10
8861 + : "=d" (curpos), "+a" (ax), "+b" (bx)
8862 + : : "ecx", "esi", "edi");
8863 +
8864 + boot_params.screen_info.orig_x = curpos;
8865 + boot_params.screen_info.orig_y = curpos >> 8;
8866 +}
8867 +
8868 +static void store_video_mode(void)
8869 +{
8870 + u16 ax, page;
8871 +
8872 + /* N.B.: the saving of the video page here is a bit silly,
8873 + since we pretty much assume page 0 everywhere. */
8874 + ax = 0x0f00;
8875 + asm(INT10
8876 + : "+a" (ax), "=b" (page)
8877 + : : "ecx", "edx", "esi", "edi");
8878 +
8879 + /* Not all BIOSes are clean with respect to the top bit */
8880 + boot_params.screen_info.orig_video_mode = ax & 0x7f;
8881 + boot_params.screen_info.orig_video_page = page;
8882 +}
8883 +
8884 +/*
8885 + * Store the video mode parameters for later usage by the kernel.
8886 + * This is done by asking the BIOS except for the rows/columns
8887 + * parameters in the default 80x25 mode -- these are set directly,
8888 + * because some very obscure BIOSes supply insane values.
8889 + */
8890 +static void store_mode_params(void)
8891 +{
8892 + u16 font_size;
8893 + int x, y;
8894 +
8895 + /* For graphics mode, it is up to the mode-setting driver
8896 + (currently only video-vesa.c) to store the parameters */
8897 + if (graphic_mode)
8898 + return;
8899 +
8900 + store_cursor_position();
8901 + store_video_mode();
8902 +
8903 + if (boot_params.screen_info.orig_video_mode == 0x07) {
8904 + /* MDA, HGC, or VGA in monochrome mode */
8905 + video_segment = 0xb000;
8906 + } else {
8907 + /* CGA, EGA, VGA and so forth */
8908 + video_segment = 0xb800;
8909 + }
8910 +
8911 + set_fs(0);
8912 + font_size = rdfs16(0x485); /* Font size, BIOS area */
8913 + boot_params.screen_info.orig_video_points = font_size;
8914 +
8915 + x = rdfs16(0x44a);
8916 + y = (adapter == ADAPTER_CGA) ? 25 : rdfs8(0x484)+1;
8917 +
8918 + if (force_x)
8919 + x = force_x;
8920 + if (force_y)
8921 + y = force_y;
8922 +
8923 + boot_params.screen_info.orig_video_cols = x;
8924 + boot_params.screen_info.orig_video_lines = y;
8925 +}
8926 +
8927 +/* Probe the video drivers and have them generate their mode lists. */
8928 +static void probe_cards(int unsafe)
8929 +{
8930 + struct card_info *card;
8931 + static u8 probed[2];
8932 +
8933 + if (probed[unsafe])
8934 + return;
8935 +
8936 + probed[unsafe] = 1;
8937 +
8938 + for (card = video_cards; card < video_cards_end; card++) {
8939 + if (card->unsafe == unsafe) {
8940 + if (card->probe)
8941 + card->nmodes = card->probe();
8942 + else
8943 + card->nmodes = 0;
8944 + }
8945 + }
8946 +}
8947 +
8948 +/* Test if a mode is defined */
8949 +int mode_defined(u16 mode)
8950 +{
8951 + struct card_info *card;
8952 + struct mode_info *mi;
8953 + int i;
8954 +
8955 + for (card = video_cards; card < video_cards_end; card++) {
8956 + mi = card->modes;
8957 + for (i = 0; i < card->nmodes; i++, mi++) {
8958 + if (mi->mode == mode)
8959 + return 1;
8960 + }
8961 + }
8962 +
8963 + return 0;
8964 +}
8965 +
8966 +/* Set mode (without recalc) */
8967 +static int raw_set_mode(u16 mode)
8968 +{
8969 + int nmode, i;
8970 + struct card_info *card;
8971 + struct mode_info *mi;
8972 +
8973 + /* Drop the recalc bit if set */
8974 + mode &= ~VIDEO_RECALC;
8975 +
8976 + /* Scan for mode based on fixed ID, position, or resolution */
8977 + nmode = 0;
8978 + for (card = video_cards; card < video_cards_end; card++) {
8979 + mi = card->modes;
8980 + for (i = 0; i < card->nmodes; i++, mi++) {
8981 + int visible = mi->x || mi->y;
8982 +
8983 + if ((mode == nmode && visible) ||
8984 + mode == mi->mode ||
8985 + mode == (mi->y << 8)+mi->x)
8986 + return card->set_mode(mi);
8987 +
8988 + if (visible)
8989 + nmode++;
8990 + }
8991 + }
8992 +
8993 + /* Nothing found? Is it an "exceptional" (unprobed) mode? */
8994 + for (card = video_cards; card < video_cards_end; card++) {
8995 + if (mode >= card->xmode_first &&
8996 + mode < card->xmode_first+card->xmode_n) {
8997 + struct mode_info mix;
8998 + mix.mode = mode;
8999 + mix.x = mix.y = 0;
9000 + return card->set_mode(&mix);
9001 + }
9002 + }
9003 +
9004 + /* Otherwise, failure... */
9005 + return -1;
9006 +}
9007 +
9008 +/*
9009 + * Recalculate the vertical video cutoff (hack!)
9010 + */
9011 +static void vga_recalc_vertical(void)
9012 +{
9013 + unsigned int font_size, rows;
9014 + u16 crtc;
9015 + u8 ov;
9016 +
9017 + set_fs(0);
9018 + font_size = rdfs8(0x485); /* BIOS: font size (pixels) */
9019 + rows = force_y ? force_y : rdfs8(0x484)+1; /* Text rows */
9020 +
9021 + rows *= font_size; /* Visible scan lines */
9022 + rows--; /* ... minus one */
9023 +
9024 + crtc = vga_crtc();
9025 +
9026 + out_idx((u8)rows, crtc, 0x12); /* Lower height register */
9027 + ov = in_idx(crtc, 0x07); /* Overflow register */
9028 + ov &= 0xbd;
9029 + ov |= (rows >> (8-1)) & 0x02;
9030 + ov |= (rows >> (9-6)) & 0x40;
9031 + out_idx(ov, crtc, 0x07);
9032 +}
9033 +
9034 +/* Set mode (with recalc if specified) */
9035 +static int set_mode(u16 mode)
9036 +{
9037 + int rv;
9038 +
9039 + /* Very special mode numbers... */
9040 + if (mode == VIDEO_CURRENT_MODE)
9041 + return 0; /* Nothing to do... */
9042 + else if (mode == NORMAL_VGA)
9043 + mode = VIDEO_80x25;
9044 + else if (mode == EXTENDED_VGA)
9045 + mode = VIDEO_8POINT;
9046 +
9047 + rv = raw_set_mode(mode);
9048 + if (rv)
9049 + return rv;
9050 +
9051 + if (mode & VIDEO_RECALC)
9052 + vga_recalc_vertical();
9053 +
9054 + return 0;
9055 +}
9056 +
9057 +static unsigned int get_entry(void)
9058 +{
9059 + char entry_buf[4];
9060 + int i, len = 0;
9061 + int key;
9062 + unsigned int v;
9063 +
9064 + do {
9065 + key = getchar();
9066 +
9067 + if (key == '\b') {
9068 + if (len > 0) {
9069 + puts("\b \b");
9070 + len--;
9071 + }
9072 + } else if ((key >= '0' && key <= '9') ||
9073 + (key >= 'A' && key <= 'Z') ||
9074 + (key >= 'a' && key <= 'z')) {
9075 + if (len < sizeof entry_buf) {
9076 + entry_buf[len++] = key;
9077 + putchar(key);
9078 + }
9079 + }
9080 + } while (key != '\r');
9081 + putchar('\n');
9082 +
9083 + if (len == 0)
9084 + return VIDEO_CURRENT_MODE; /* Default */
9085 +
9086 + v = 0;
9087 + for (i = 0; i < len; i++) {
9088 + v <<= 4;
9089 + key = entry_buf[i] | 0x20;
9090 + v += (key > '9') ? key-'a'+10 : key-'0';
9091 + }
9092 +
9093 + return v;
9094 +}
9095 +
9096 +static void display_menu(void)
9097 +{
9098 + struct card_info *card;
9099 + struct mode_info *mi;
9100 + char ch;
9101 + int i;
9102 +
9103 + puts("Mode: COLSxROWS:\n");
9104 +
9105 + ch = '0';
9106 + for (card = video_cards; card < video_cards_end; card++) {
9107 + mi = card->modes;
9108 + for (i = 0; i < card->nmodes; i++, mi++) {
9109 + int visible = mi->x && mi->y;
9110 + u16 mode_id = mi->mode ? mi->mode :
9111 + (mi->y << 8)+mi->x;
9112 +
9113 + if (!visible)
9114 + continue; /* Hidden mode */
9115 +
9116 + printf("%c %04X %3dx%-3d %s\n",
9117 + ch, mode_id, mi->x, mi->y, card->card_name);
9118 +
9119 + if (ch == '9')
9120 + ch = 'a';
9121 + else if (ch == 'z' || ch == ' ')
9122 + ch = ' '; /* Out of keys... */
9123 + else
9124 + ch++;
9125 + }
9126 + }
9127 +}
9128 +
9129 +#define H(x) ((x)-'a'+10)
9130 +#define SCAN ((H('s')<<12)+(H('c')<<8)+(H('a')<<4)+H('n'))
9131 +
9132 +static unsigned int mode_menu(void)
9133 +{
9134 + int key;
9135 + unsigned int sel;
9136 +
9137 + puts("Press <ENTER> to see video modes available, "
9138 + "<SPACE> to continue, or wait 30 sec\n");
9139 +
9140 + kbd_flush();
9141 + while (1) {
9142 + key = getchar_timeout();
9143 + if (key == ' ' || key == 0)
9144 + return VIDEO_CURRENT_MODE; /* Default */
9145 + if (key == '\r')
9146 + break;
9147 + putchar('\a'); /* Beep! */
9148 + }
9149 +
9150 +
9151 + for (;;) {
9152 + display_menu();
9153 +
9154 + puts("Enter a video mode or \"scan\" to scan for "
9155 + "additional modes: ");
9156 + sel = get_entry();
9157 + if (sel != SCAN)
9158 + return sel;
9159 +
9160 + probe_cards(1);
9161 + }
9162 +}
9163 +
9164 +#ifdef CONFIG_VIDEO_RETAIN
9165 +/* Save screen content to the heap */
9166 +struct saved_screen {
9167 + int x, y;
9168 + int curx, cury;
9169 + u16 *data;
9170 +} saved;
9171 +
9172 +static void save_screen(void)
9173 +{
9174 + /* Should be called after store_mode_params() */
9175 + saved.x = boot_params.screen_info.orig_video_cols;
9176 + saved.y = boot_params.screen_info.orig_video_lines;
9177 + saved.curx = boot_params.screen_info.orig_x;
9178 + saved.cury = boot_params.screen_info.orig_y;
9179 +
9180 + if (heap_free() < saved.x*saved.y*sizeof(u16)+512)
9181 + return; /* Not enough heap to save the screen */
9182 +
9183 + saved.data = GET_HEAP(u16, saved.x*saved.y);
9184 +
9185 + set_fs(video_segment);
9186 + copy_from_fs(saved.data, 0, saved.x*saved.y*sizeof(u16));
9187 +}
9188 +
9189 +static void restore_screen(void)
9190 +{
9191 + /* Should be called after store_mode_params() */
9192 + int xs = boot_params.screen_info.orig_video_cols;
9193 + int ys = boot_params.screen_info.orig_video_lines;
9194 + int y;
9195 + addr_t dst = 0;
9196 + u16 *src = saved.data;
9197 + u16 ax, bx, dx;
9198 +
9199 + if (graphic_mode)
9200 + return; /* Can't restore onto a graphic mode */
9201 +
9202 + if (!src)
9203 + return; /* No saved screen contents */
9204 +
9205 + /* Restore screen contents */
9206 +
9207 + set_fs(video_segment);
9208 + for (y = 0; y < ys; y++) {
9209 + int npad;
9210 +
9211 + if (y < saved.y) {
9212 + int copy = (xs < saved.x) ? xs : saved.x;
9213 + copy_to_fs(dst, src, copy*sizeof(u16));
9214 + dst += copy*sizeof(u16);
9215 + src += saved.x;
9216 + npad = (xs < saved.x) ? 0 : xs-saved.x;
9217 + } else {
9218 + npad = xs;
9219 + }
9220 +
9221 + /* Writes "npad" blank characters to
9222 + video_segment:dst and advances dst */
9223 + asm volatile("pushw %%es ; "
9224 + "movw %2,%%es ; "
9225 + "shrw %%cx ; "
9226 + "jnc 1f ; "
9227 + "stosw \n\t"
9228 + "1: rep;stosl ; "
9229 + "popw %%es"
9230 + : "+D" (dst), "+c" (npad)
9231 + : "bdSm" (video_segment),
9232 + "a" (0x07200720));
9233 + }
9234 +
9235 + /* Restore cursor position */
9236 + ax = 0x0200; /* Set cursor position */
9237 + bx = 0; /* Page number (<< 8) */
9238 + dx = (saved.cury << 8)+saved.curx;
9239 + asm volatile(INT10
9240 + : "+a" (ax), "+b" (bx), "+d" (dx)
9241 + : : "ecx", "esi", "edi");
9242 +}
9243 +#else
9244 +#define save_screen() ((void)0)
9245 +#define restore_screen() ((void)0)
9246 +#endif
9247 +
9248 +void set_video(void)
9249 +{
9250 + u16 mode = boot_params.hdr.vid_mode;
9251 +
9252 + RESET_HEAP();
9253 +
9254 + store_mode_params();
9255 + save_screen();
9256 + probe_cards(0);
9257 +
9258 + for (;;) {
9259 + if (mode == ASK_VGA)
9260 + mode = mode_menu();
9261 +
9262 + if (!set_mode(mode))
9263 + break;
9264 +
9265 + printf("Undefined video mode number: %x\n", mode);
9266 + mode = ASK_VGA;
9267 + }
9268 + vesa_store_edid();
9269 + store_mode_params();
9270 +
9271 + if (do_restore)
9272 + restore_screen();
9273 +}
9274 Index: linux-2.6.22.19/arch/i386/boot/video.h
9275 ===================================================================
9276 --- /dev/null
9277 +++ linux-2.6.22.19/arch/i386/boot/video.h
9278 @@ -0,0 +1,145 @@
9279 +/* -*- linux-c -*- ------------------------------------------------------- *
9280 + *
9281 + * Copyright (C) 1991, 1992 Linus Torvalds
9282 + * Copyright 2007 rPath, Inc. - All Rights Reserved
9283 + *
9284 + * This file is part of the Linux kernel, and is made available under
9285 + * the terms of the GNU General Public License version 2.
9286 + *
9287 + * ----------------------------------------------------------------------- */
9288 +
9289 +/*
9290 + * arch/i386/boot/video.h
9291 + *
9292 + * Header file for the real-mode video probing code
9293 + */
9294 +
9295 +#ifndef BOOT_VIDEO_H
9296 +#define BOOT_VIDEO_H
9297 +
9298 +#include <linux/types.h>
9299 +
9300 +/* Enable autodetection of SVGA adapters and modes. */
9301 +#undef CONFIG_VIDEO_SVGA
9302 +
9303 +/* Enable autodetection of VESA modes */
9304 +#define CONFIG_VIDEO_VESA
9305 +
9306 +/* Retain screen contents when switching modes */
9307 +#define CONFIG_VIDEO_RETAIN
9308 +
9309 +/* Force 400 scan lines for standard modes (hack to fix bad BIOS behaviour */
9310 +#undef CONFIG_VIDEO_400_HACK
9311 +
9312 +/* This code uses an extended set of video mode numbers. These include:
9313 + * Aliases for standard modes
9314 + * NORMAL_VGA (-1)
9315 + * EXTENDED_VGA (-2)
9316 + * ASK_VGA (-3)
9317 + * Video modes numbered by menu position -- NOT RECOMMENDED because of lack
9318 + * of compatibility when extending the table. These are between 0x00 and 0xff.
9319 + */
9320 +#define VIDEO_FIRST_MENU 0x0000
9321 +
9322 +/* Standard BIOS video modes (BIOS number + 0x0100) */
9323 +#define VIDEO_FIRST_BIOS 0x0100
9324 +
9325 +/* VESA BIOS video modes (VESA number + 0x0200) */
9326 +#define VIDEO_FIRST_VESA 0x0200
9327 +
9328 +/* Video7 special modes (BIOS number + 0x0900) */
9329 +#define VIDEO_FIRST_V7 0x0900
9330 +
9331 +/* Special video modes */
9332 +#define VIDEO_FIRST_SPECIAL 0x0f00
9333 +#define VIDEO_80x25 0x0f00
9334 +#define VIDEO_8POINT 0x0f01
9335 +#define VIDEO_80x43 0x0f02
9336 +#define VIDEO_80x28 0x0f03
9337 +#define VIDEO_CURRENT_MODE 0x0f04
9338 +#define VIDEO_80x30 0x0f05
9339 +#define VIDEO_80x34 0x0f06
9340 +#define VIDEO_80x60 0x0f07
9341 +#define VIDEO_GFX_HACK 0x0f08
9342 +#define VIDEO_LAST_SPECIAL 0x0f09
9343 +
9344 +/* Video modes given by resolution */
9345 +#define VIDEO_FIRST_RESOLUTION 0x1000
9346 +
9347 +/* The "recalculate timings" flag */
9348 +#define VIDEO_RECALC 0x8000
9349 +
9350 +/* Define DO_STORE according to CONFIG_VIDEO_RETAIN */
9351 +#ifdef CONFIG_VIDEO_RETAIN
9352 +void store_screen(void);
9353 +#define DO_STORE() store_screen()
9354 +#else
9355 +#define DO_STORE() ((void)0)
9356 +#endif /* CONFIG_VIDEO_RETAIN */
9357 +
9358 +/*
9359 + * Mode table structures
9360 + */
9361 +
9362 +struct mode_info {
9363 + u16 mode; /* Mode number (vga= style) */
9364 + u8 x, y; /* Width, height */
9365 +};
9366 +
9367 +struct card_info {
9368 + const char *card_name;
9369 + int (*set_mode)(struct mode_info *mode);
9370 + int (*probe)(void);
9371 + struct mode_info *modes;
9372 + int nmodes; /* Number of probed modes so far */
9373 + int unsafe; /* Probing is unsafe, only do after "scan" */
9374 + u16 xmode_first; /* Unprobed modes to try to call anyway */
9375 + u16 xmode_n; /* Size of unprobed mode range */
9376 +};
9377 +
9378 +#define __videocard struct card_info __attribute__((section(".videocards")))
9379 +extern struct card_info video_cards[], video_cards_end[];
9380 +
9381 +int mode_defined(u16 mode); /* video.c */
9382 +
9383 +/* Basic video information */
9384 +#define ADAPTER_CGA 0 /* CGA/MDA/HGC */
9385 +#define ADAPTER_EGA 1
9386 +#define ADAPTER_VGA 2
9387 +
9388 +extern int adapter;
9389 +extern u16 video_segment;
9390 +extern int force_x, force_y; /* Don't query the BIOS for cols/rows */
9391 +extern int do_restore; /* Restore screen contents */
9392 +extern int graphic_mode; /* Graphics mode with linear frame buffer */
9393 +
9394 +/*
9395 + * int $0x10 is notorious for touching registers it shouldn't.
9396 + * gcc doesn't like %ebp being clobbered, so define it as a push/pop
9397 + * sequence here.
9398 + */
9399 +#define INT10 "pushl %%ebp; int $0x10; popl %%ebp"
9400 +
9401 +/* Accessing VGA indexed registers */
9402 +static inline u8 in_idx(u16 port, u8 index)
9403 +{
9404 + outb(index, port);
9405 + return inb(port+1);
9406 +}
9407 +
9408 +static inline void out_idx(u8 v, u16 port, u8 index)
9409 +{
9410 + outw(index+(v << 8), port);
9411 +}
9412 +
9413 +/* Writes a value to an indexed port and then reads the port again */
9414 +static inline u8 tst_idx(u8 v, u16 port, u8 index)
9415 +{
9416 + out_idx(port, index, v);
9417 + return in_idx(port, index);
9418 +}
9419 +
9420 +/* Get the I/O port of the VGA CRTC */
9421 +u16 vga_crtc(void); /* video-vga.c */
9422 +
9423 +#endif /* BOOT_VIDEO_H */
9424 Index: linux-2.6.22.19/arch/i386/boot/voyager.c
9425 ===================================================================
9426 --- /dev/null
9427 +++ linux-2.6.22.19/arch/i386/boot/voyager.c
9428 @@ -0,0 +1,46 @@
9429 +/* -*- linux-c -*- ------------------------------------------------------- *
9430 + *
9431 + * Copyright (C) 1991, 1992 Linus Torvalds
9432 + * Copyright 2007 rPath, Inc. - All Rights Reserved
9433 + *
9434 + * This file is part of the Linux kernel, and is made available under
9435 + * the terms of the GNU General Public License version 2.
9436 + *
9437 + * ----------------------------------------------------------------------- */
9438 +
9439 +/*
9440 + * arch/i386/boot/voyager.c
9441 + *
9442 + * Get the Voyager config information
9443 + */
9444 +
9445 +#include "boot.h"
9446 +
9447 +#ifdef CONFIG_X86_VOYAGER
9448 +
9449 +int query_voyager(void)
9450 +{
9451 + u8 err;
9452 + u16 es, di;
9453 + /* Abuse the apm_bios_info area for this */
9454 + u8 *data_ptr = (u8 *)&boot_params.apm_bios_info;
9455 +
9456 + data_ptr[0] = 0xff; /* Flag on config not found(?) */
9457 +
9458 + asm("pushw %%es ; "
9459 + "int $0x15 ; "
9460 + "setc %0 ; "
9461 + "movw %%es, %1 ; "
9462 + "popw %%es"
9463 + : "=qm" (err), "=rm" (es), "=D" (di)
9464 + : "a" (0xffc0));
9465 +
9466 + if (err)
9467 + return -1; /* Not Voyager */
9468 +
9469 + set_fs(es);
9470 + copy_from_fs(data_ptr, di, 7); /* Table is 7 bytes apparently */
9471 + return 0;
9472 +}
9473 +
9474 +#endif /* CONFIG_X86_VOYAGER */
9475 Index: linux-2.6.22.19/arch/i386/kernel/cpu/addon_cpuid_features.c
9476 ===================================================================
9477 --- /dev/null
9478 +++ linux-2.6.22.19/arch/i386/kernel/cpu/addon_cpuid_features.c
9479 @@ -0,0 +1,50 @@
9480 +
9481 +/*
9482 + * Routines to indentify additional cpu features that are scattered in
9483 + * cpuid space.
9484 + */
9485 +
9486 +#include <linux/cpu.h>
9487 +
9488 +#include <asm/processor.h>
9489 +
9490 +struct cpuid_bit {
9491 + u16 feature;
9492 + u8 reg;
9493 + u8 bit;
9494 + u32 level;
9495 +};
9496 +
9497 +enum cpuid_regs {
9498 + CR_EAX = 0,
9499 + CR_ECX,
9500 + CR_EDX,
9501 + CR_EBX
9502 +};
9503 +
9504 +void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)
9505 +{
9506 + u32 max_level;
9507 + u32 regs[4];
9508 + const struct cpuid_bit *cb;
9509 +
9510 + static const struct cpuid_bit cpuid_bits[] = {
9511 + { X86_FEATURE_IDA, CR_EAX, 1, 0x00000006 },
9512 + { 0, 0, 0, 0 }
9513 + };
9514 +
9515 + for (cb = cpuid_bits; cb->feature; cb++) {
9516 +
9517 + /* Verify that the level is valid */
9518 + max_level = cpuid_eax(cb->level & 0xffff0000);
9519 + if (max_level < cb->level ||
9520 + max_level > (cb->level | 0xffff))
9521 + continue;
9522 +
9523 + cpuid(cb->level, &regs[CR_EAX], &regs[CR_EBX],
9524 + &regs[CR_ECX], &regs[CR_EDX]);
9525 +
9526 + if (regs[cb->reg] & (1 << cb->bit))
9527 + set_bit(cb->feature, c->x86_capability);
9528 + }
9529 +}
9530 Index: linux-2.6.22.19/arch/i386/kernel/cpu/common.c
9531 ===================================================================
9532 --- linux-2.6.22.19.orig/arch/i386/kernel/cpu/common.c
9533 +++ linux-2.6.22.19/arch/i386/kernel/cpu/common.c
9534 @@ -353,6 +353,8 @@ static void __cpuinit generic_identify(s
9535 if ( xlvl >= 0x80000004 )
9536 get_model_name(c); /* Default name */
9537 }
9538 +
9539 + init_scattered_cpuid_features(c);
9540 }
9541
9542 early_intel_workaround(c);
9543 Index: linux-2.6.22.19/arch/i386/kernel/cpu/proc.c
9544 ===================================================================
9545 --- linux-2.6.22.19.orig/arch/i386/kernel/cpu/proc.c
9546 +++ linux-2.6.22.19/arch/i386/kernel/cpu/proc.c
9547 @@ -29,7 +29,8 @@ static int show_cpuinfo(struct seq_file
9548 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9549 NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
9550 NULL, NULL, NULL, "mp", "nx", NULL, "mmxext", NULL,
9551 - NULL, "fxsr_opt", "pdpe1gb", "rdtscp", NULL, "lm", "3dnowext", "3dnow",
9552 + NULL, "fxsr_opt", "pdpe1gb", "rdtscp", NULL, "lm",
9553 + "3dnowext", "3dnow",
9554
9555 /* Transmeta-defined */
9556 "recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
9557 @@ -40,8 +41,9 @@ static int show_cpuinfo(struct seq_file
9558 /* Other (Linux-defined) */
9559 "cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr",
9560 NULL, NULL, NULL, NULL,
9561 - "constant_tsc", "up", NULL, NULL, NULL, NULL, NULL, NULL,
9562 - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9563 + "constant_tsc", "up", NULL, "arch_perfmon",
9564 + "pebs", "bts", NULL, "sync_rdtsc",
9565 + "rep_good", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9566 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9567
9568 /* Intel-defined (#2) */
9569 @@ -57,9 +59,16 @@ static int show_cpuinfo(struct seq_file
9570 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9571
9572 /* AMD-defined (#2) */
9573 - "lahf_lm", "cmp_legacy", "svm", "extapic", "cr8legacy", "abm",
9574 - "sse4a", "misalignsse",
9575 - "3dnowprefetch", "osvw", "ibs", NULL, NULL, NULL, NULL, NULL,
9576 + "lahf_lm", "cmp_legacy", "svm", "extapic", "cr8_legacy",
9577 + "altmovcr8", "abm", "sse4a",
9578 + "misalignsse", "3dnowprefetch",
9579 + "osvw", "ibs", NULL, NULL, NULL, NULL,
9580 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9581 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9582 +
9583 + /* Auxiliary (Linux-defined) */
9584 + "ida", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9585 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9586 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9587 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9588 };
9589 Index: linux-2.6.22.19/arch/i386/kernel/e820.c
9590 ===================================================================
9591 --- linux-2.6.22.19.orig/arch/i386/kernel/e820.c
9592 +++ linux-2.6.22.19/arch/i386/kernel/e820.c
9593 @@ -734,7 +734,7 @@ void __init print_memory_map(char *who)
9594 case E820_NVS:
9595 printk("(ACPI NVS)\n");
9596 break;
9597 - default: printk("type %lu\n", e820.map[i].type);
9598 + default: printk("type %u\n", e820.map[i].type);
9599 break;
9600 }
9601 }
9602 Index: linux-2.6.22.19/arch/i386/kernel/setup.c
9603 ===================================================================
9604 --- linux-2.6.22.19.orig/arch/i386/kernel/setup.c
9605 +++ linux-2.6.22.19/arch/i386/kernel/setup.c
9606 @@ -102,19 +102,10 @@ static unsigned int highmem_pages = -1;
9607 /*
9608 * Setup options
9609 */
9610 -struct drive_info_struct { char dummy[32]; } drive_info;
9611 -#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_HD) || \
9612 - defined(CONFIG_BLK_DEV_IDE_MODULE) || defined(CONFIG_BLK_DEV_HD_MODULE)
9613 -EXPORT_SYMBOL(drive_info);
9614 -#endif
9615 struct screen_info screen_info;
9616 EXPORT_SYMBOL(screen_info);
9617 struct apm_info apm_info;
9618 EXPORT_SYMBOL(apm_info);
9619 -struct sys_desc_table_struct {
9620 - unsigned short length;
9621 - unsigned char table[0];
9622 -};
9623 struct edid_info edid_info;
9624 EXPORT_SYMBOL_GPL(edid_info);
9625 struct ist_info ist_info;
9626 @@ -134,7 +125,7 @@ unsigned long saved_videomode;
9627
9628 static char __initdata command_line[COMMAND_LINE_SIZE];
9629
9630 -unsigned char __initdata boot_params[PARAM_SIZE];
9631 +struct boot_params __initdata boot_params;
9632
9633 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
9634 struct edd edd;
9635 @@ -528,7 +519,6 @@ void __init setup_arch(char **cmdline_p)
9636 #endif
9637
9638 ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
9639 - drive_info = DRIVE_INFO;
9640 screen_info = SCREEN_INFO;
9641 edid_info = EDID_INFO;
9642 apm_info.bios = APM_BIOS_INFO;
9643 Index: linux-2.6.22.19/arch/i386/kernel/verify_cpu.S
9644 ===================================================================
9645 --- linux-2.6.22.19.orig/arch/i386/kernel/verify_cpu.S
9646 +++ /dev/null
9647 @@ -1,94 +0,0 @@
9648 -/* Check if CPU has some minimum CPUID bits
9649 - This runs in 16bit mode so that the caller can still use the BIOS
9650 - to output errors on the screen */
9651 -#include <asm/cpufeature.h>
9652 -#include <asm/msr.h>
9653 -
9654 -verify_cpu:
9655 - pushfl # Save caller passed flags
9656 - pushl $0 # Kill any dangerous flags
9657 - popfl
9658 -
9659 -#if CONFIG_X86_MINIMUM_CPU_MODEL >= 4
9660 - pushfl
9661 - pop %eax
9662 - orl $(1<<18),%eax # try setting AC
9663 - push %eax
9664 - popfl
9665 - pushfl
9666 - popl %eax
9667 - testl $(1<<18),%eax
9668 - jz bad
9669 -#endif
9670 -#if REQUIRED_MASK1 != 0
9671 - pushfl # standard way to check for cpuid
9672 - popl %eax
9673 - movl %eax,%ebx
9674 - xorl $0x200000,%eax
9675 - pushl %eax
9676 - popfl
9677 - pushfl
9678 - popl %eax
9679 - cmpl %eax,%ebx
9680 - pushfl # standard way to check for cpuid
9681 - popl %eax
9682 - movl %eax,%ebx
9683 - xorl $0x200000,%eax
9684 - pushl %eax
9685 - popfl
9686 - pushfl
9687 - popl %eax
9688 - cmpl %eax,%ebx
9689 - jz bad # REQUIRED_MASK1 != 0 requires CPUID
9690 -
9691 - movl $0x0,%eax # See if cpuid 1 is implemented
9692 - cpuid
9693 - cmpl $0x1,%eax
9694 - jb bad # no cpuid 1
9695 -
9696 -#if REQUIRED_MASK1 & NEED_CMPXCHG64
9697 - /* Some VIA C3s need magic MSRs to enable CX64. Do this here */
9698 - cmpl $0x746e6543,%ebx # Cent
9699 - jne 1f
9700 - cmpl $0x48727561,%edx # aurH
9701 - jne 1f
9702 - cmpl $0x736c7561,%ecx # auls
9703 - jne 1f
9704 - movl $1,%eax # check model
9705 - cpuid
9706 - movl %eax,%ebx
9707 - shr $8,%ebx
9708 - andl $0xf,%ebx
9709 - cmp $6,%ebx # check family == 6
9710 - jne 1f
9711 - shr $4,%eax
9712 - andl $0xf,%eax
9713 - cmpl $6,%eax # check model >= 6
9714 - jb 1f
9715 - # assume models >= 6 all support this MSR
9716 - movl $MSR_VIA_FCR,%ecx
9717 - rdmsr
9718 - orl $((1<<1)|(1<<7)),%eax # enable CMPXCHG64 and PGE
9719 - wrmsr
9720 -1:
9721 -#endif
9722 - movl $0x1,%eax # Does the cpu have what it takes
9723 - cpuid
9724 -
9725 -#if CONFIG_X86_MINIMUM_CPU_MODEL > 4
9726 -#error add proper model checking here
9727 -#endif
9728 -
9729 - andl $REQUIRED_MASK1,%edx
9730 - xorl $REQUIRED_MASK1,%edx
9731 - jnz bad
9732 -#endif /* REQUIRED_MASK1 */
9733 -
9734 - popfl
9735 - xor %eax,%eax
9736 - ret
9737 -
9738 -bad:
9739 - popfl
9740 - movl $1,%eax
9741 - ret
9742 Index: linux-2.6.22.19/arch/x86_64/Kconfig
9743 ===================================================================
9744 --- linux-2.6.22.19.orig/arch/x86_64/Kconfig
9745 +++ linux-2.6.22.19/arch/x86_64/Kconfig
9746 @@ -427,6 +427,10 @@ config NR_CPUS
9747 This is purely to save memory - each supported CPU requires
9748 memory in the static kernel configuration.
9749
9750 +config PHYSICAL_ALIGN
9751 + hex
9752 + default "0x200000"
9753 +
9754 config HOTPLUG_CPU
9755 bool "Support for suspend on SMP and hot-pluggable CPUs (EXPERIMENTAL)"
9756 depends on SMP && HOTPLUG && EXPERIMENTAL
9757 Index: linux-2.6.22.19/arch/x86_64/boot/Makefile
9758 ===================================================================
9759 --- linux-2.6.22.19.orig/arch/x86_64/boot/Makefile
9760 +++ linux-2.6.22.19/arch/x86_64/boot/Makefile
9761 @@ -1,135 +1,9 @@
9762 #
9763 # arch/x86_64/boot/Makefile
9764 #
9765 -# This file is subject to the terms and conditions of the GNU General Public
9766 -# License. See the file "COPYING" in the main directory of this archive
9767 -# for more details.
9768 -#
9769 -# Copyright (C) 1994 by Linus Torvalds
9770 -#
9771 -
9772 -# ROOT_DEV specifies the default root-device when making the image.
9773 -# This can be either FLOPPY, CURRENT, /dev/xxxx or empty, in which case
9774 -# the default of FLOPPY is used by 'build'.
9775 -
9776 -ROOT_DEV := CURRENT
9777 -
9778 -# If you want to preset the SVGA mode, uncomment the next line and
9779 -# set SVGA_MODE to whatever number you want.
9780 -# Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
9781 -# The number is the same as you would ordinarily press at bootup.
9782 -
9783 -SVGA_MODE := -DSVGA_MODE=NORMAL_VGA
9784 -
9785 -# If you want the RAM disk device, define this to be the size in blocks.
9786 -
9787 -#RAMDISK := -DRAMDISK=512
9788 -
9789 -targets := vmlinux.bin bootsect bootsect.o \
9790 - setup setup.o bzImage mtools.conf
9791 -
9792 -EXTRA_CFLAGS := -m32
9793 -
9794 -hostprogs-y := tools/build
9795 -HOST_EXTRACFLAGS += $(LINUXINCLUDE)
9796 -subdir- := compressed/ #Let make clean descend in compressed/
9797 -# ---------------------------------------------------------------------------
9798 -
9799 -$(obj)/bzImage: IMAGE_OFFSET := 0x100000
9800 -$(obj)/bzImage: EXTRA_AFLAGS := $(SVGA_MODE) $(RAMDISK) -D__BIG_KERNEL__
9801 -$(obj)/bzImage: BUILDFLAGS := -b
9802 -
9803 -quiet_cmd_image = BUILD $@
9804 -cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/bootsect $(obj)/setup \
9805 - $(obj)/vmlinux.bin $(ROOT_DEV) > $@
9806 -
9807 -$(obj)/bzImage: $(obj)/bootsect $(obj)/setup \
9808 - $(obj)/vmlinux.bin $(obj)/tools/build FORCE
9809 - $(call if_changed,image)
9810 - @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
9811 -
9812 -$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
9813 - $(call if_changed,objcopy)
9814 -
9815 -LDFLAGS_bootsect := -Ttext 0x0 -s --oformat binary
9816 -LDFLAGS_setup := -Ttext 0x0 -s --oformat binary -e begtext
9817 -
9818 -$(obj)/setup $(obj)/bootsect: %: %.o FORCE
9819 - $(call if_changed,ld)
9820 -
9821 -$(obj)/compressed/vmlinux: FORCE
9822 - $(Q)$(MAKE) $(build)=$(obj)/compressed IMAGE_OFFSET=$(IMAGE_OFFSET) $@
9823 -
9824 -# Set this if you want to pass append arguments to the zdisk/fdimage/isoimage kernel
9825 -FDARGS =
9826 -# Set this if you want an initrd included with the zdisk/fdimage/isoimage kernel
9827 -FDINITRD =
9828 -
9829 -image_cmdline = default linux $(FDARGS) $(if $(FDINITRD),initrd=initrd.img,)
9830 -
9831 -$(obj)/mtools.conf: $(src)/mtools.conf.in
9832 - sed -e 's|@OBJ@|$(obj)|g' < $< > $@
9833 -
9834 -# This requires write access to /dev/fd0
9835 -zdisk: $(BOOTIMAGE) $(obj)/mtools.conf
9836 - MTOOLSRC=$(obj)/mtools.conf mformat a: ; sync
9837 - syslinux /dev/fd0 ; sync
9838 - echo '$(image_cmdline)' | \
9839 - MTOOLSRC=$(obj)/mtools.conf mcopy - a:syslinux.cfg
9840 - if [ -f '$(FDINITRD)' ] ; then \
9841 - MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' a:initrd.img ; \
9842 - fi
9843 - MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) a:linux ; sync
9844 -
9845 -# These require being root or having syslinux 2.02 or higher installed
9846 -fdimage fdimage144: $(BOOTIMAGE) $(obj)/mtools.conf
9847 - dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440
9848 - MTOOLSRC=$(obj)/mtools.conf mformat v: ; sync
9849 - syslinux $(obj)/fdimage ; sync
9850 - echo '$(image_cmdline)' | \
9851 - MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg
9852 - if [ -f '$(FDINITRD)' ] ; then \
9853 - MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' v:initrd.img ; \
9854 - fi
9855 - MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) v:linux ; sync
9856 -
9857 -fdimage288: $(BOOTIMAGE) $(obj)/mtools.conf
9858 - dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880
9859 - MTOOLSRC=$(obj)/mtools.conf mformat w: ; sync
9860 - syslinux $(obj)/fdimage ; sync
9861 - echo '$(image_cmdline)' | \
9862 - MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg
9863 - if [ -f '$(FDINITRD)' ] ; then \
9864 - MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' w:initrd.img ; \
9865 - fi
9866 - MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) w:linux ; sync
9867 -
9868 -isoimage: $(BOOTIMAGE)
9869 - -rm -rf $(obj)/isoimage
9870 - mkdir $(obj)/isoimage
9871 - for i in lib lib64 share end ; do \
9872 - if [ -f /usr/$$i/syslinux/isolinux.bin ] ; then \
9873 - cp /usr/$$i/syslinux/isolinux.bin $(obj)/isoimage ; \
9874 - break ; \
9875 - fi ; \
9876 - if [ $$i = end ] ; then exit 1 ; fi ; \
9877 - done
9878 - cp $(BOOTIMAGE) $(obj)/isoimage/linux
9879 - echo '$(image_cmdline)' > $(obj)/isoimage/isolinux.cfg
9880 - if [ -f '$(FDINITRD)' ] ; then \
9881 - cp '$(FDINITRD)' $(obj)/isoimage/initrd.img ; \
9882 - fi
9883 - mkisofs -J -r -o $(obj)/image.iso -b isolinux.bin -c boot.cat \
9884 - -no-emul-boot -boot-load-size 4 -boot-info-table \
9885 - $(obj)/isoimage
9886 - rm -rf $(obj)/isoimage
9887 -
9888 -zlilo: $(BOOTIMAGE)
9889 - if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
9890 - if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
9891 - cat $(BOOTIMAGE) > $(INSTALL_PATH)/vmlinuz
9892 - cp System.map $(INSTALL_PATH)/
9893 - if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
9894 +# The actual boot code is shared with i386 including the Makefile.
9895 +# So tell kbuild that we fetch the code from i386 and include the
9896 +# Makefile from i386 too.
9897
9898 -install:
9899 - sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"
9900 +src := arch/i386/boot
9901 +include $(src)/Makefile
9902 Index: linux-2.6.22.19/arch/x86_64/boot/bootsect.S
9903 ===================================================================
9904 --- linux-2.6.22.19.orig/arch/x86_64/boot/bootsect.S
9905 +++ /dev/null
9906 @@ -1,98 +0,0 @@
9907 -/*
9908 - * bootsect.S Copyright (C) 1991, 1992 Linus Torvalds
9909 - *
9910 - * modified by Drew Eckhardt
9911 - * modified by Bruce Evans (bde)
9912 - * modified by Chris Noe (May 1999) (as86 -> gas)
9913 - * gutted by H. Peter Anvin (Jan 2003)
9914 - *
9915 - * BIG FAT NOTE: We're in real mode using 64k segments. Therefore segment
9916 - * addresses must be multiplied by 16 to obtain their respective linear
9917 - * addresses. To avoid confusion, linear addresses are written using leading
9918 - * hex while segment addresses are written as segment:offset.
9919 - *
9920 - */
9921 -
9922 -#include <asm/boot.h>
9923 -
9924 -SETUPSECTS = 4 /* default nr of setup-sectors */
9925 -BOOTSEG = 0x07C0 /* original address of boot-sector */
9926 -INITSEG = DEF_INITSEG /* we move boot here - out of the way */
9927 -SETUPSEG = DEF_SETUPSEG /* setup starts here */
9928 -SYSSEG = DEF_SYSSEG /* system loaded at 0x10000 (65536) */
9929 -SYSSIZE = DEF_SYSSIZE /* system size: # of 16-byte clicks */
9930 - /* to be loaded */
9931 -ROOT_DEV = 0 /* ROOT_DEV is now written by "build" */
9932 -SWAP_DEV = 0 /* SWAP_DEV is now written by "build" */
9933 -
9934 -#ifndef SVGA_MODE
9935 -#define SVGA_MODE ASK_VGA
9936 -#endif
9937 -
9938 -#ifndef RAMDISK
9939 -#define RAMDISK 0
9940 -#endif
9941 -
9942 -#ifndef ROOT_RDONLY
9943 -#define ROOT_RDONLY 1
9944 -#endif
9945 -
9946 -.code16
9947 -.text
9948 -
9949 -.global _start
9950 -_start:
9951 -
9952 - # Normalize the start address
9953 - jmpl $BOOTSEG, $start2
9954 -
9955 -start2:
9956 - movw %cs, %ax
9957 - movw %ax, %ds
9958 - movw %ax, %es
9959 - movw %ax, %ss
9960 - movw $0x7c00, %sp
9961 - sti
9962 - cld
9963 -
9964 - movw $bugger_off_msg, %si
9965 -
9966 -msg_loop:
9967 - lodsb
9968 - andb %al, %al
9969 - jz die
9970 - movb $0xe, %ah
9971 - movw $7, %bx
9972 - int $0x10
9973 - jmp msg_loop
9974 -
9975 -die:
9976 - # Allow the user to press a key, then reboot
9977 - xorw %ax, %ax
9978 - int $0x16
9979 - int $0x19
9980 -
9981 - # int 0x19 should never return. In case it does anyway,
9982 - # invoke the BIOS reset code...
9983 - ljmp $0xf000,$0xfff0
9984 -
9985 -
9986 -bugger_off_msg:
9987 - .ascii "Direct booting from floppy is no longer supported.\r\n"
9988 - .ascii "Please use a boot loader program instead.\r\n"
9989 - .ascii "\n"
9990 - .ascii "Remove disk and press any key to reboot . . .\r\n"
9991 - .byte 0
9992 -
9993 -
9994 - # Kernel attributes; used by setup
9995 -
9996 - .org 497
9997 -setup_sects: .byte SETUPSECTS
9998 -root_flags: .word ROOT_RDONLY
9999 -syssize: .word SYSSIZE
10000 -swap_dev: .word SWAP_DEV
10001 -ram_size: .word RAMDISK
10002 -vid_mode: .word SVGA_MODE
10003 -root_dev: .word ROOT_DEV
10004 -boot_flag: .word 0xAA55
10005 Index: linux-2.6.22.19/arch/x86_64/boot/compressed/Makefile
10006 ===================================================================
10007 --- linux-2.6.22.19.orig/arch/x86_64/boot/compressed/Makefile
10008 +++ linux-2.6.22.19/arch/x86_64/boot/compressed/Makefile
10009 @@ -7,11 +7,12 @@
10010 #
10011
10012 targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o
10013 -EXTRA_AFLAGS := -traditional
10014
10015 -# cannot use EXTRA_CFLAGS because base CFLAGS contains -mkernel which conflicts with
10016 -# -m32
10017 -CFLAGS := -m64 -D__KERNEL__ -Iinclude -O2 -fno-strict-aliasing -fPIC -mcmodel=small -fno-builtin
10018 +CFLAGS := -m64 -D__KERNEL__ $(LINUXINCLUDE) -O2 \
10019 + -fno-strict-aliasing -fPIC -mcmodel=small \
10020 + $(call cc-option, -ffreestanding) \
10021 + $(call cc-option, -fno-stack-protector)
10022 +AFLAGS := $(CFLAGS) -D__ASSEMBLY__
10023 LDFLAGS := -m elf_x86_64
10024
10025 LDFLAGS_vmlinux := -T
10026 Index: linux-2.6.22.19/arch/x86_64/boot/compressed/head.S
10027 ===================================================================
10028 --- linux-2.6.22.19.orig/arch/x86_64/boot/compressed/head.S
10029 +++ linux-2.6.22.19/arch/x86_64/boot/compressed/head.S
10030 @@ -46,10 +46,10 @@ startup_32:
10031 * at and where we were actually loaded at. This can only be done
10032 * with a short local call on x86. Nothing else will tell us what
10033 * address we are running at. The reserved chunk of the real-mode
10034 - * data at 0x34-0x3f are used as the stack for this calculation.
10035 - * Only 4 bytes are needed.
10036 + * data at 0x1e4 (defined as a scratch field) are used as the stack
10037 + * for this calculation. Only 4 bytes are needed.
10038 */
10039 - leal 0x40(%esi), %esp
10040 + leal (0x1e4+4)(%esi), %esp
10041 call 1f
10042 1: popl %ebp
10043 subl $1b, %ebp
10044 Index: linux-2.6.22.19/arch/x86_64/boot/install.sh
10045 ===================================================================
10046 --- linux-2.6.22.19.orig/arch/x86_64/boot/install.sh
10047 +++ /dev/null
10048 @@ -1,2 +0,0 @@
10049 -#!/bin/sh
10050 -. $srctree/arch/i386/boot/install.sh
10051 Index: linux-2.6.22.19/arch/x86_64/boot/mtools.conf.in
10052 ===================================================================
10053 --- linux-2.6.22.19.orig/arch/x86_64/boot/mtools.conf.in
10054 +++ /dev/null
10055 @@ -1,17 +0,0 @@
10056 -#
10057 -# mtools configuration file for "make (b)zdisk"
10058 -#
10059 -
10060 -# Actual floppy drive
10061 -drive a:
10062 - file="/dev/fd0"
10063 -
10064 -# 1.44 MB floppy disk image
10065 -drive v:
10066 - file="@OBJ@/fdimage" cylinders=80 heads=2 sectors=18 filter
10067 -
10068 -# 2.88 MB floppy disk image (mostly for virtual uses)
10069 -drive w:
10070 - file="@OBJ@/fdimage" cylinders=80 heads=2 sectors=36 filter
10071 -
10072 -
10073 Index: linux-2.6.22.19/arch/x86_64/boot/setup.S
10074 ===================================================================
10075 --- linux-2.6.22.19.orig/arch/x86_64/boot/setup.S
10076 +++ /dev/null
10077 @@ -1,826 +0,0 @@
10078 -/*
10079 - * setup.S Copyright (C) 1991, 1992 Linus Torvalds
10080 - *
10081 - * setup.s is responsible for getting the system data from the BIOS,
10082 - * and putting them into the appropriate places in system memory.
10083 - * both setup.s and system has been loaded by the bootblock.
10084 - *
10085 - * This code asks the bios for memory/disk/other parameters, and
10086 - * puts them in a "safe" place: 0x90000-0x901FF, ie where the
10087 - * boot-block used to be. It is then up to the protected mode
10088 - * system to read them from there before the area is overwritten
10089 - * for buffer-blocks.
10090 - *
10091 - * Move PS/2 aux init code to psaux.c
10092 - * (troyer@saifr00.cfsat.Honeywell.COM) 03Oct92
10093 - *
10094 - * some changes and additional features by Christoph Niemann,
10095 - * March 1993/June 1994 (Christoph.Niemann@linux.org)
10096 - *
10097 - * add APM BIOS checking by Stephen Rothwell, May 1994
10098 - * (sfr@canb.auug.org.au)
10099 - *
10100 - * High load stuff, initrd support and position independency
10101 - * by Hans Lermen & Werner Almesberger, February 1996
10102 - * <lermen@elserv.ffm.fgan.de>, <almesber@lrc.epfl.ch>
10103 - *
10104 - * Video handling moved to video.S by Martin Mares, March 1996
10105 - * <mj@k332.feld.cvut.cz>
10106 - *
10107 - * Extended memory detection scheme retwiddled by orc@pell.chi.il.us (david
10108 - * parsons) to avoid loadlin confusion, July 1997
10109 - *
10110 - * Transcribed from Intel (as86) -> AT&T (gas) by Chris Noe, May 1999.
10111 - * <stiker@northlink.com>
10112 - *
10113 - * Fix to work around buggy BIOSes which don't use carry bit correctly
10114 - * and/or report extended memory in CX/DX for e801h memory size detection
10115 - * call. As a result the kernel got wrong figures. The int15/e801h docs
10116 - * from Ralf Brown interrupt list seem to indicate AX/BX should be used
10117 - * anyway. So to avoid breaking many machines (presumably there was a reason
10118 - * to orginally use CX/DX instead of AX/BX), we do a kludge to see
10119 - * if CX/DX have been changed in the e801 call and if so use AX/BX .
10120 - * Michael Miller, April 2001 <michaelm@mjmm.org>
10121 - *
10122 - * Added long mode checking and SSE force. March 2003, Andi Kleen.
10123 - */
10124 -
10125 -#include <asm/segment.h>
10126 -#include <linux/utsrelease.h>
10127 -#include <linux/compile.h>
10128 -#include <asm/boot.h>
10129 -#include <asm/e820.h>
10130 -#include <asm/page.h>
10131 -#include <asm/setup.h>
10132 -
10133 -/* Signature words to ensure LILO loaded us right */
10134 -#define SIG1 0xAA55
10135 -#define SIG2 0x5A5A
10136 -
10137 -INITSEG = DEF_INITSEG # 0x9000, we move boot here, out of the way
10138 -SYSSEG = DEF_SYSSEG # 0x1000, system loaded at 0x10000 (65536).
10139 -SETUPSEG = DEF_SETUPSEG # 0x9020, this is the current segment
10140 - # ... and the former contents of CS
10141 -
10142 -DELTA_INITSEG = SETUPSEG - INITSEG # 0x0020
10143 -
10144 -.code16
10145 -.globl begtext, begdata, begbss, endtext, enddata, endbss
10146 -
10147 -.text
10148 -begtext:
10149 -.data
10150 -begdata:
10151 -.bss
10152 -begbss:
10153 -.text
10154 -
10155 -start:
10156 - jmp trampoline
10157 -
10158 -# This is the setup header, and it must start at %cs:2 (old 0x9020:2)
10159 -
10160 - .ascii "HdrS" # header signature
10161 - .word 0x0206 # header version number (>= 0x0105)
10162 - # or else old loadlin-1.5 will fail)
10163 -realmode_swtch: .word 0, 0 # default_switch, SETUPSEG
10164 -start_sys_seg: .word SYSSEG
10165 - .word kernel_version # pointing to kernel version string
10166 - # above section of header is compatible
10167 - # with loadlin-1.5 (header v1.5). Don't
10168 - # change it.
10169 -
10170 -type_of_loader: .byte 0 # = 0, old one (LILO, Loadlin,
10171 - # Bootlin, SYSLX, bootsect...)
10172 - # See Documentation/i386/boot.txt for
10173 - # assigned ids
10174 -
10175 -# flags, unused bits must be zero (RFU) bit within loadflags
10176 -loadflags:
10177 -LOADED_HIGH = 1 # If set, the kernel is loaded high
10178 -CAN_USE_HEAP = 0x80 # If set, the loader also has set
10179 - # heap_end_ptr to tell how much
10180 - # space behind setup.S can be used for
10181 - # heap purposes.
10182 - # Only the loader knows what is free
10183 -#ifndef __BIG_KERNEL__
10184 - .byte 0
10185 -#else
10186 - .byte LOADED_HIGH
10187 -#endif
10188 -
10189 -setup_move_size: .word 0x8000 # size to move, when setup is not
10190 - # loaded at 0x90000. We will move setup
10191 - # to 0x90000 then just before jumping
10192 - # into the kernel. However, only the
10193 - # loader knows how much data behind
10194 - # us also needs to be loaded.
10195 -
10196 -code32_start: # here loaders can put a different
10197 - # start address for 32-bit code.
10198 -#ifndef __BIG_KERNEL__
10199 - .long 0x1000 # 0x1000 = default for zImage
10200 -#else
10201 - .long 0x100000 # 0x100000 = default for big kernel
10202 -#endif
10203 -
10204 -ramdisk_image: .long 0 # address of loaded ramdisk image
10205 - # Here the loader puts the 32-bit
10206 - # address where it loaded the image.
10207 - # This only will be read by the kernel.
10208 -
10209 -ramdisk_size: .long 0 # its size in bytes
10210 -
10211 -bootsect_kludge:
10212 - .long 0 # obsolete
10213 -
10214 -heap_end_ptr: .word modelist+1024 # (Header version 0x0201 or later)
10215 - # space from here (exclusive) down to
10216 - # end of setup code can be used by setup
10217 - # for local heap purposes.
10218 -
10219 -pad1: .word 0
10220 -cmd_line_ptr: .long 0 # (Header version 0x0202 or later)
10221 - # If nonzero, a 32-bit pointer
10222 - # to the kernel command line.
10223 - # The command line should be
10224 - # located between the start of
10225 - # setup and the end of low
10226 - # memory (0xa0000), or it may
10227 - # get overwritten before it
10228 - # gets read. If this field is
10229 - # used, there is no longer
10230 - # anything magical about the
10231 - # 0x90000 segment; the setup
10232 - # can be located anywhere in
10233 - # low memory 0x10000 or higher.
10234 -
10235 -ramdisk_max: .long 0xffffffff
10236 -kernel_alignment: .long 0x200000 # physical addr alignment required for
10237 - # protected mode relocatable kernel
10238 -#ifdef CONFIG_RELOCATABLE
10239 -relocatable_kernel: .byte 1
10240 -#else
10241 -relocatable_kernel: .byte 0
10242 -#endif
10243 -pad2: .byte 0
10244 -pad3: .word 0
10245 -
10246 -cmdline_size: .long COMMAND_LINE_SIZE-1 #length of the command line,
10247 - #added with boot protocol
10248 - #version 2.06
10249 -
10250 -trampoline: call start_of_setup
10251 - .align 16
10252 - # The offset at this point is 0x240
10253 - .space (0xeff-0x240+1) # E820 & EDD space (ending at 0xeff)
10254 -# End of setup header #####################################################
10255 -
10256 -start_of_setup:
10257 -# Bootlin depends on this being done early
10258 - movw $0x01500, %ax
10259 - movb $0x81, %dl
10260 - int $0x13
10261 -
10262 -#ifdef SAFE_RESET_DISK_CONTROLLER
10263 -# Reset the disk controller.
10264 - movw $0x0000, %ax
10265 - movb $0x80, %dl
10266 - int $0x13
10267 -#endif
10268 -
10269 -# Set %ds = %cs, we know that SETUPSEG = %cs at this point
10270 - movw %cs, %ax # aka SETUPSEG
10271 - movw %ax, %ds
10272 -# Check signature at end of setup
10273 - cmpw $SIG1, setup_sig1
10274 - jne bad_sig
10275 -
10276 - cmpw $SIG2, setup_sig2
10277 - jne bad_sig
10278 -
10279 - jmp good_sig1
10280 -
10281 -# Routine to print asciiz string at ds:si
10282 -prtstr:
10283 - lodsb
10284 - andb %al, %al
10285 - jz fin
10286 -
10287 - call prtchr
10288 - jmp prtstr
10289 -
10290 -fin: ret
10291 -
10292 -# Space printing
10293 -prtsp2: call prtspc # Print double space
10294 -prtspc: movb $0x20, %al # Print single space (note: fall-thru)
10295 -
10296 -prtchr:
10297 - pushw %ax
10298 - pushw %cx
10299 - movw $0007,%bx
10300 - movw $0x01, %cx
10301 - movb $0x0e, %ah
10302 - int $0x10
10303 - popw %cx
10304 - popw %ax
10305 - ret
10306 -
10307 -beep: movb $0x07, %al
10308 - jmp prtchr
10309 -
10310 -no_sig_mess: .string "No setup signature found ..."
10311 -
10312 -good_sig1:
10313 - jmp good_sig
10314 -
10315 -# We now have to find the rest of the setup code/data
10316 -bad_sig:
10317 - movw %cs, %ax # SETUPSEG
10318 - subw $DELTA_INITSEG, %ax # INITSEG
10319 - movw %ax, %ds
10320 - xorb %bh, %bh
10321 - movb (497), %bl # get setup sect from bootsect
10322 - subw $4, %bx # LILO loads 4 sectors of setup
10323 - shlw $8, %bx # convert to words (1sect=2^8 words)
10324 - movw %bx, %cx
10325 - shrw $3, %bx # convert to segment
10326 - addw $SYSSEG, %bx
10327 - movw %bx, %cs:start_sys_seg
10328 -# Move rest of setup code/data to here
10329 - movw $2048, %di # four sectors loaded by LILO
10330 - subw %si, %si
10331 - movw %cs, %ax # aka SETUPSEG
10332 - movw %ax, %es
10333 - movw $SYSSEG, %ax
10334 - movw %ax, %ds
10335 - rep
10336 - movsw
10337 - movw %cs, %ax # aka SETUPSEG
10338 - movw %ax, %ds
10339 - cmpw $SIG1, setup_sig1
10340 - jne no_sig
10341 -
10342 - cmpw $SIG2, setup_sig2
10343 - jne no_sig
10344 -
10345 - jmp good_sig
10346 -
10347 -no_sig:
10348 - lea no_sig_mess, %si
10349 - call prtstr
10350 -
10351 -no_sig_loop:
10352 - jmp no_sig_loop
10353 -
10354 -good_sig:
10355 - movw %cs, %ax # aka SETUPSEG
10356 - subw $DELTA_INITSEG, %ax # aka INITSEG
10357 - movw %ax, %ds
10358 -# Check if an old loader tries to load a big-kernel
10359 - testb $LOADED_HIGH, %cs:loadflags # Do we have a big kernel?
10360 - jz loader_ok # No, no danger for old loaders.
10361 -
10362 - cmpb $0, %cs:type_of_loader # Do we have a loader that
10363 - # can deal with us?
10364 - jnz loader_ok # Yes, continue.
10365 -
10366 - pushw %cs # No, we have an old loader,
10367 - popw %ds # die.
10368 - lea loader_panic_mess, %si
10369 - call prtstr
10370 -
10371 - jmp no_sig_loop
10372 -
10373 -loader_panic_mess: .string "Wrong loader, giving up..."
10374 -
10375 -loader_ok:
10376 - /* check for long mode. */
10377 - /* we have to do this before the VESA setup, otherwise the user
10378 - can't see the error message. */
10379 -
10380 - pushw %ds
10381 - movw %cs,%ax
10382 - movw %ax,%ds
10383 -
10384 - call verify_cpu
10385 - testl %eax,%eax
10386 - jz sse_ok
10387 -
10388 -no_longmode:
10389 - call beep
10390 - lea long_mode_panic,%si
10391 - call prtstr
10392 -no_longmode_loop:
10393 - jmp no_longmode_loop
10394 -long_mode_panic:
10395 - .string "Your CPU does not support long mode. Use a 32bit distribution."
10396 - .byte 0
10397 -
10398 -#include "../kernel/verify_cpu.S"
10399 -sse_ok:
10400 - popw %ds
10401 -
10402 -# tell BIOS we want to go to long mode
10403 - movl $0xec00,%eax # declare target operating mode
10404 - movl $2,%ebx # long mode
10405 - int $0x15
10406 -
10407 -# Get memory size (extended mem, kB)
10408 -
10409 - xorl %eax, %eax
10410 - movl %eax, (0x1e0)
10411 -#ifndef STANDARD_MEMORY_BIOS_CALL
10412 - movb %al, (E820NR)
10413 -# Try three different memory detection schemes. First, try
10414 -# e820h, which lets us assemble a memory map, then try e801h,
10415 -# which returns a 32-bit memory size, and finally 88h, which
10416 -# returns 0-64m
10417 -
10418 -# method E820H:
10419 -# the memory map from hell. e820h returns memory classified into
10420 -# a whole bunch of different types, and allows memory holes and
10421 -# everything. We scan through this memory map and build a list
10422 -# of the first 32 memory areas, which we return at [E820MAP].
10423 -# This is documented at http://www.acpi.info/, in the ACPI 2.0 specification.
10424 -
10425 -#define SMAP 0x534d4150
10426 -
10427 -meme820:
10428 - xorl %ebx, %ebx # continuation counter
10429 - movw $E820MAP, %di # point into the whitelist
10430 - # so we can have the bios
10431 - # directly write into it.
10432 -
10433 -jmpe820:
10434 - movl $0x0000e820, %eax # e820, upper word zeroed
10435 - movl $SMAP, %edx # ascii 'SMAP'
10436 - movl $20, %ecx # size of the e820rec
10437 - pushw %ds # data record.
10438 - popw %es
10439 - int $0x15 # make the call
10440 - jc bail820 # fall to e801 if it fails
10441 -
10442 - cmpl $SMAP, %eax # check the return is `SMAP'
10443 - jne bail820 # fall to e801 if it fails
10444 -
10445 -# cmpl $1, 16(%di) # is this usable memory?
10446 -# jne again820
10447 -
10448 - # If this is usable memory, we save it by simply advancing %di by
10449 - # sizeof(e820rec).
10450 - #
10451 -good820:
10452 - movb (E820NR), %al # up to 128 entries
10453 - cmpb $E820MAX, %al
10454 - jae bail820
10455 -
10456 - incb (E820NR)
10457 - movw %di, %ax
10458 - addw $20, %ax
10459 - movw %ax, %di
10460 -again820:
10461 - cmpl $0, %ebx # check to see if
10462 - jne jmpe820 # %ebx is set to EOF
10463 -bail820:
10464 -
10465 -
10466 -# method E801H:
10467 -# memory size is in 1k chunksizes, to avoid confusing loadlin.
10468 -# we store the 0xe801 memory size in a completely different place,
10469 -# because it will most likely be longer than 16 bits.
10470 -# (use 1e0 because that's what Larry Augustine uses in his
10471 -# alternative new memory detection scheme, and it's sensible
10472 -# to write everything into the same place.)
10473 -
10474 -meme801:
10475 - stc # fix to work around buggy
10476 - xorw %cx,%cx # BIOSes which don't clear/set
10477 - xorw %dx,%dx # carry on pass/error of
10478 - # e801h memory size call
10479 - # or merely pass cx,dx though
10480 - # without changing them.
10481 - movw $0xe801, %ax
10482 - int $0x15
10483 - jc mem88
10484 -
10485 - cmpw $0x0, %cx # Kludge to handle BIOSes
10486 - jne e801usecxdx # which report their extended
10487 - cmpw $0x0, %dx # memory in AX/BX rather than
10488 - jne e801usecxdx # CX/DX. The spec I have read
10489 - movw %ax, %cx # seems to indicate AX/BX
10490 - movw %bx, %dx # are more reasonable anyway...
10491 -
10492 -e801usecxdx:
10493 - andl $0xffff, %edx # clear sign extend
10494 - shll $6, %edx # and go from 64k to 1k chunks
10495 - movl %edx, (0x1e0) # store extended memory size
10496 - andl $0xffff, %ecx # clear sign extend
10497 - addl %ecx, (0x1e0) # and add lower memory into
10498 - # total size.
10499 -
10500 -# Ye Olde Traditional Methode. Returns the memory size (up to 16mb or
10501 -# 64mb, depending on the bios) in ax.
10502 -mem88:
10503 -
10504 -#endif
10505 - movb $0x88, %ah
10506 - int $0x15
10507 - movw %ax, (2)
10508 -
10509 -# Set the keyboard repeat rate to the max
10510 - movw $0x0305, %ax
10511 - xorw %bx, %bx
10512 - int $0x16
10513 -
10514 -# Check for video adapter and its parameters and allow the
10515 -# user to browse video modes.
10516 - call video # NOTE: we need %ds pointing
10517 - # to bootsector
10518 -
10519 -# Get hd0 data...
10520 - xorw %ax, %ax
10521 - movw %ax, %ds
10522 - ldsw (4 * 0x41), %si
10523 - movw %cs, %ax # aka SETUPSEG
10524 - subw $DELTA_INITSEG, %ax # aka INITSEG
10525 - pushw %ax
10526 - movw %ax, %es
10527 - movw $0x0080, %di
10528 - movw $0x10, %cx
10529 - pushw %cx
10530 - cld
10531 - rep
10532 - movsb
10533 -# Get hd1 data...
10534 - xorw %ax, %ax
10535 - movw %ax, %ds
10536 - ldsw (4 * 0x46), %si
10537 - popw %cx
10538 - popw %es
10539 - movw $0x0090, %di
10540 - rep
10541 - movsb
10542 -# Check that there IS a hd1 :-)
10543 - movw $0x01500, %ax
10544 - movb $0x81, %dl
10545 - int $0x13
10546 - jc no_disk1
10547 -
10548 - cmpb $3, %ah
10549 - je is_disk1
10550 -
10551 -no_disk1:
10552 - movw %cs, %ax # aka SETUPSEG
10553 - subw $DELTA_INITSEG, %ax # aka INITSEG
10554 - movw %ax, %es
10555 - movw $0x0090, %di
10556 - movw $0x10, %cx
10557 - xorw %ax, %ax
10558 - cld
10559 - rep
10560 - stosb
10561 -is_disk1:
10562 -
10563 -# Check for PS/2 pointing device
10564 - movw %cs, %ax # aka SETUPSEG
10565 - subw $DELTA_INITSEG, %ax # aka INITSEG
10566 - movw %ax, %ds
10567 - movb $0, (0x1ff) # default is no pointing device
10568 - int $0x11 # int 0x11: equipment list
10569 - testb $0x04, %al # check if mouse installed
10570 - jz no_psmouse
10571 -
10572 - movb $0xAA, (0x1ff) # device present
10573 -no_psmouse:
10574 -
10575 -#include "../../i386/boot/edd.S"
10576 -
10577 -# Now we want to move to protected mode ...
10578 - cmpw $0, %cs:realmode_swtch
10579 - jz rmodeswtch_normal
10580 -
10581 - lcall *%cs:realmode_swtch
10582 -
10583 - jmp rmodeswtch_end
10584 -
10585 -rmodeswtch_normal:
10586 - pushw %cs
10587 - call default_switch
10588 -
10589 -rmodeswtch_end:
10590 -# we get the code32 start address and modify the below 'jmpi'
10591 -# (loader may have changed it)
10592 - movl %cs:code32_start, %eax
10593 - movl %eax, %cs:code32
10594 -
10595 -# Now we move the system to its rightful place ... but we check if we have a
10596 -# big-kernel. In that case we *must* not move it ...
10597 - testb $LOADED_HIGH, %cs:loadflags
10598 - jz do_move0 # .. then we have a normal low
10599 - # loaded zImage
10600 - # .. or else we have a high
10601 - # loaded bzImage
10602 - jmp end_move # ... and we skip moving
10603 -
10604 -do_move0:
10605 - movw $0x100, %ax # start of destination segment
10606 - movw %cs, %bp # aka SETUPSEG
10607 - subw $DELTA_INITSEG, %bp # aka INITSEG
10608 - movw %cs:start_sys_seg, %bx # start of source segment
10609 - cld
10610 -do_move:
10611 - movw %ax, %es # destination segment
10612 - incb %ah # instead of add ax,#0x100
10613 - movw %bx, %ds # source segment
10614 - addw $0x100, %bx
10615 - subw %di, %di
10616 - subw %si, %si
10617 - movw $0x800, %cx
10618 - rep
10619 - movsw
10620 - cmpw %bp, %bx # assume start_sys_seg > 0x200,
10621 - # so we will perhaps read one
10622 - # page more than needed, but
10623 - # never overwrite INITSEG
10624 - # because destination is a
10625 - # minimum one page below source
10626 - jb do_move
10627 -
10628 -end_move:
10629 -# then we load the segment descriptors
10630 - movw %cs, %ax # aka SETUPSEG
10631 - movw %ax, %ds
10632 -
10633 -# Check whether we need to be downward compatible with version <=201
10634 - cmpl $0, cmd_line_ptr
10635 - jne end_move_self # loader uses version >=202 features
10636 - cmpb $0x20, type_of_loader
10637 - je end_move_self # bootsect loader, we know of it
10638 -
10639 -# Boot loader doesnt support boot protocol version 2.02.
10640 -# If we have our code not at 0x90000, we need to move it there now.
10641 -# We also then need to move the params behind it (commandline)
10642 -# Because we would overwrite the code on the current IP, we move
10643 -# it in two steps, jumping high after the first one.
10644 - movw %cs, %ax
10645 - cmpw $SETUPSEG, %ax
10646 - je end_move_self
10647 -
10648 - cli # make sure we really have
10649 - # interrupts disabled !
10650 - # because after this the stack
10651 - # should not be used
10652 - subw $DELTA_INITSEG, %ax # aka INITSEG
10653 - movw %ss, %dx
10654 - cmpw %ax, %dx
10655 - jb move_self_1
10656 -
10657 - addw $INITSEG, %dx
10658 - subw %ax, %dx # this will go into %ss after
10659 - # the move
10660 -move_self_1:
10661 - movw %ax, %ds
10662 - movw $INITSEG, %ax # real INITSEG
10663 - movw %ax, %es
10664 - movw %cs:setup_move_size, %cx
10665 - std # we have to move up, so we use
10666 - # direction down because the
10667 - # areas may overlap
10668 - movw %cx, %di
10669 - decw %di
10670 - movw %di, %si
10671 - subw $move_self_here+0x200, %cx
10672 - rep
10673 - movsb
10674 - ljmp $SETUPSEG, $move_self_here
10675 -
10676 -move_self_here:
10677 - movw $move_self_here+0x200, %cx
10678 - rep
10679 - movsb
10680 - movw $SETUPSEG, %ax
10681 - movw %ax, %ds
10682 - movw %dx, %ss
10683 -end_move_self: # now we are at the right place
10684 - lidt idt_48 # load idt with 0,0
10685 - xorl %eax, %eax # Compute gdt_base
10686 - movw %ds, %ax # (Convert %ds:gdt to a linear ptr)
10687 - shll $4, %eax
10688 - addl $gdt, %eax
10689 - movl %eax, (gdt_48+2)
10690 - lgdt gdt_48 # load gdt with whatever is
10691 - # appropriate
10692 -
10693 -# that was painless, now we enable a20
10694 - call empty_8042
10695 -
10696 - movb $0xD1, %al # command write
10697 - outb %al, $0x64
10698 - call empty_8042
10699 -
10700 - movb $0xDF, %al # A20 on
10701 - outb %al, $0x60
10702 - call empty_8042
10703 -
10704 -#
10705 -# You must preserve the other bits here. Otherwise embarrasing things
10706 -# like laptops powering off on boot happen. Corrected version by Kira
10707 -# Brown from Linux 2.2
10708 -#
10709 - inb $0x92, %al #
10710 - orb $02, %al # "fast A20" version
10711 - outb %al, $0x92 # some chips have only this
10712 -
10713 -# wait until a20 really *is* enabled; it can take a fair amount of
10714 -# time on certain systems; Toshiba Tecras are known to have this
10715 -# problem. The memory location used here (0x200) is the int 0x80
10716 -# vector, which should be safe to use.
10717 -
10718 - xorw %ax, %ax # segment 0x0000
10719 - movw %ax, %fs
10720 - decw %ax # segment 0xffff (HMA)
10721 - movw %ax, %gs
10722 -a20_wait:
10723 - incw %ax # unused memory location <0xfff0
10724 - movw %ax, %fs:(0x200) # we use the "int 0x80" vector
10725 - cmpw %gs:(0x210), %ax # and its corresponding HMA addr
10726 - je a20_wait # loop until no longer aliased
10727 -
10728 -# make sure any possible coprocessor is properly reset..
10729 - xorw %ax, %ax
10730 - outb %al, $0xf0
10731 - call delay
10732 -
10733 - outb %al, $0xf1
10734 - call delay
10735 -
10736 -# well, that went ok, I hope. Now we mask all interrupts - the rest
10737 -# is done in init_IRQ().
10738 - movb $0xFF, %al # mask all interrupts for now
10739 - outb %al, $0xA1
10740 - call delay
10741 -
10742 - movb $0xFB, %al # mask all irq's but irq2 which
10743 - outb %al, $0x21 # is cascaded
10744 -
10745 -# Well, that certainly wasn't fun :-(. Hopefully it works, and we don't
10746 -# need no steenking BIOS anyway (except for the initial loading :-).
10747 -# The BIOS-routine wants lots of unnecessary data, and it's less
10748 -# "interesting" anyway. This is how REAL programmers do it.
10749 -#
10750 -# Well, now's the time to actually move into protected mode. To make
10751 -# things as simple as possible, we do no register set-up or anything,
10752 -# we let the gnu-compiled 32-bit programs do that. We just jump to
10753 -# absolute address 0x1000 (or the loader supplied one),
10754 -# in 32-bit protected mode.
10755 -#
10756 -# Note that the short jump isn't strictly needed, although there are
10757 -# reasons why it might be a good idea. It won't hurt in any case.
10758 - movw $1, %ax # protected mode (PE) bit
10759 - lmsw %ax # This is it!
10760 - jmp flush_instr
10761 -
10762 -flush_instr:
10763 - xorw %bx, %bx # Flag to indicate a boot
10764 - xorl %esi, %esi # Pointer to real-mode code
10765 - movw %cs, %si
10766 - subw $DELTA_INITSEG, %si
10767 - shll $4, %esi # Convert to 32-bit pointer
10768 -# NOTE: For high loaded big kernels we need a
10769 -# jmpi 0x100000,__KERNEL_CS
10770 -#
10771 -# but we yet haven't reloaded the CS register, so the default size
10772 -# of the target offset still is 16 bit.
10773 -# However, using an operand prefix (0x66), the CPU will properly
10774 -# take our 48 bit far pointer. (INTeL 80386 Programmer's Reference
10775 -# Manual, Mixing 16-bit and 32-bit code, page 16-6)
10776 -
10777 - .byte 0x66, 0xea # prefix + jmpi-opcode
10778 -code32: .long 0x1000 # will be set to 0x100000
10779 - # for big kernels
10780 - .word __KERNEL_CS
10781 -
10782 -# Here's a bunch of information about your current kernel..
10783 -kernel_version: .ascii UTS_RELEASE
10784 - .ascii " ("
10785 - .ascii LINUX_COMPILE_BY
10786 - .ascii "@"
10787 - .ascii LINUX_COMPILE_HOST
10788 - .ascii ") "
10789 - .ascii UTS_VERSION
10790 - .byte 0
10791 -
10792 -# This is the default real mode switch routine.
10793 -# to be called just before protected mode transition
10794 -default_switch:
10795 - cli # no interrupts allowed !
10796 - movb $0x80, %al # disable NMI for bootup
10797 - # sequence
10798 - outb %al, $0x70
10799 - lret
10800 -
10801 -
10802 -# This routine checks that the keyboard command queue is empty
10803 -# (after emptying the output buffers)
10804 -#
10805 -# Some machines have delusions that the keyboard buffer is always full
10806 -# with no keyboard attached...
10807 -#
10808 -# If there is no keyboard controller, we will usually get 0xff
10809 -# to all the reads. With each IO taking a microsecond and
10810 -# a timeout of 100,000 iterations, this can take about half a
10811 -# second ("delay" == outb to port 0x80). That should be ok,
10812 -# and should also be plenty of time for a real keyboard controller
10813 -# to empty.
10814 -#
10815 -
10816 -empty_8042:
10817 - pushl %ecx
10818 - movl $100000, %ecx
10819 -
10820 -empty_8042_loop:
10821 - decl %ecx
10822 - jz empty_8042_end_loop
10823 -
10824 - call delay
10825 -
10826 - inb $0x64, %al # 8042 status port
10827 - testb $1, %al # output buffer?
10828 - jz no_output
10829 -
10830 - call delay
10831 - inb $0x60, %al # read it
10832 - jmp empty_8042_loop
10833 -
10834 -no_output:
10835 - testb $2, %al # is input buffer full?
10836 - jnz empty_8042_loop # yes - loop
10837 -empty_8042_end_loop:
10838 - popl %ecx
10839 - ret
10840 -
10841 -# Read the cmos clock. Return the seconds in al
10842 -gettime:
10843 - pushw %cx
10844 - movb $0x02, %ah
10845 - int $0x1a
10846 - movb %dh, %al # %dh contains the seconds
10847 - andb $0x0f, %al
10848 - movb %dh, %ah
10849 - movb $0x04, %cl
10850 - shrb %cl, %ah
10851 - aad
10852 - popw %cx
10853 - ret
10854 -
10855 -# Delay is needed after doing I/O
10856 -delay:
10857 - outb %al,$0x80
10858 - ret
10859 -
10860 -# Descriptor tables
10861 -gdt:
10862 - .word 0, 0, 0, 0 # dummy
10863 -
10864 - .word 0, 0, 0, 0 # unused
10865 -
10866 - .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb)
10867 - .word 0 # base address = 0
10868 - .word 0x9A00 # code read/exec
10869 - .word 0x00CF # granularity = 4096, 386
10870 - # (+5th nibble of limit)
10871 -
10872 - .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb)
10873 - .word 0 # base address = 0
10874 - .word 0x9200 # data read/write
10875 - .word 0x00CF # granularity = 4096, 386
10876 - # (+5th nibble of limit)
10877 -gdt_end:
10878 -idt_48:
10879 - .word 0 # idt limit = 0
10880 - .word 0, 0 # idt base = 0L
10881 -gdt_48:
10882 - .word gdt_end-gdt-1 # gdt limit
10883 - .word 0, 0 # gdt base (filled in later)
10884 -
10885 -# Include video setup & detection code
10886 -
10887 -#include "../../i386/boot/video.S"
10888 -
10889 -# Setup signature -- must be last
10890 -setup_sig1: .word SIG1
10891 -setup_sig2: .word SIG2
10892 -
10893 -# After this point, there is some free space which is used by the video mode
10894 -# handling code to store the temporary mode table (not used by the kernel).
10895 -
10896 -modelist:
10897 -
10898 -.text
10899 -endtext:
10900 -.data
10901 -enddata:
10902 -.bss
10903 -endbss:
10904 Index: linux-2.6.22.19/arch/x86_64/boot/tools/build.c
10905 ===================================================================
10906 --- linux-2.6.22.19.orig/arch/x86_64/boot/tools/build.c
10907 +++ /dev/null
10908 @@ -1,185 +0,0 @@
10909 -/*
10910 - * Copyright (C) 1991, 1992 Linus Torvalds
10911 - * Copyright (C) 1997 Martin Mares
10912 - */
10913 -
10914 -/*
10915 - * This file builds a disk-image from three different files:
10916 - *
10917 - * - bootsect: compatibility mbr which prints an error message if
10918 - * someone tries to boot the kernel directly.
10919 - * - setup: 8086 machine code, sets up system parm
10920 - * - system: 80386 code for actual system
10921 - *
10922 - * It does some checking that all files are of the correct type, and
10923 - * just writes the result to stdout, removing headers and padding to
10924 - * the right amount. It also writes some system data to stderr.
10925 - */
10926 -
10927 -/*
10928 - * Changes by tytso to allow root device specification
10929 - * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
10930 - * Cross compiling fixes by Gertjan van Wingerde, July 1996
10931 - * Rewritten by Martin Mares, April 1997
10932 - */
10933 -
10934 -#include <stdio.h>
10935 -#include <string.h>
10936 -#include <stdlib.h>
10937 -#include <stdarg.h>
10938 -#include <sys/types.h>
10939 -#include <sys/stat.h>
10940 -#include <sys/sysmacros.h>
10941 -#include <unistd.h>
10942 -#include <fcntl.h>
10943 -#include <asm/boot.h>
10944 -
10945 -typedef unsigned char byte;
10946 -typedef unsigned short word;
10947 -typedef unsigned long u32;
10948 -
10949 -#define DEFAULT_MAJOR_ROOT 0
10950 -#define DEFAULT_MINOR_ROOT 0
10951 -
10952 -/* Minimal number of setup sectors (see also bootsect.S) */
10953 -#define SETUP_SECTS 4
10954 -
10955 -byte buf[1024];
10956 -int fd;
10957 -int is_big_kernel;
10958 -
10959 -void die(const char * str, ...)
10960 -{
10961 - va_list args;
10962 - va_start(args, str);
10963 - vfprintf(stderr, str, args);
10964 - fputc('\n', stderr);
10965 - exit(1);
10966 -}
10967 -
10968 -void file_open(const char *name)
10969 -{
10970 - if ((fd = open(name, O_RDONLY, 0)) < 0)
10971 - die("Unable to open `%s': %m", name);
10972 -}
10973 -
10974 -void usage(void)
10975 -{
10976 - die("Usage: build [-b] bootsect setup system [rootdev] [> image]");
10977 -}
10978 -
10979 -int main(int argc, char ** argv)
10980 -{
10981 - unsigned int i, c, sz, setup_sectors;
10982 - u32 sys_size;
10983 - byte major_root, minor_root;
10984 - struct stat sb;
10985 -
10986 - if (argc > 2 && !strcmp(argv[1], "-b"))
10987 - {
10988 - is_big_kernel = 1;
10989 - argc--, argv++;
10990 - }
10991 - if ((argc < 4) || (argc > 5))
10992 - usage();
10993 - if (argc > 4) {
10994 - if (!strcmp(argv[4], "CURRENT")) {
10995 - if (stat("/", &sb)) {
10996 - perror("/");
10997 - die("Couldn't stat /");
10998 - }
10999 - major_root = major(sb.st_dev);
11000 - minor_root = minor(sb.st_dev);
11001 - } else if (strcmp(argv[4], "FLOPPY")) {
11002 - if (stat(argv[4], &sb)) {
11003 - perror(argv[4]);
11004 - die("Couldn't stat root device.");
11005 - }
11006 - major_root = major(sb.st_rdev);
11007 - minor_root = minor(sb.st_rdev);
11008 - } else {
11009 - major_root = 0;
11010 - minor_root = 0;
11011 - }
11012 - } else {
11013 - major_root = DEFAULT_MAJOR_ROOT;
11014 - minor_root = DEFAULT_MINOR_ROOT;
11015 - }
11016 - fprintf(stderr, "Root device is (%d, %d)\n", major_root, minor_root);
11017 -
11018 - file_open(argv[1]);
11019 - i = read(fd, buf, sizeof(buf));
11020 - fprintf(stderr,"Boot sector %d bytes.\n",i);
11021 - if (i != 512)
11022 - die("Boot block must be exactly 512 bytes");
11023 - if (buf[510] != 0x55 || buf[511] != 0xaa)
11024 - die("Boot block hasn't got boot flag (0xAA55)");
11025 - buf[508] = minor_root;
11026 - buf[509] = major_root;
11027 - if (write(1, buf, 512) != 512)
11028 - die("Write call failed");
11029 - close (fd);
11030 -
11031 - file_open(argv[2]); /* Copy the setup code */
11032 - for (i=0 ; (c=read(fd, buf, sizeof(buf)))>0 ; i+=c )
11033 - if (write(1, buf, c) != c)
11034 - die("Write call failed");
11035 - if (c != 0)
11036 - die("read-error on `setup'");
11037 - close (fd);
11038 -
11039 - setup_sectors = (i + 511) / 512; /* Pad unused space with zeros */
11040 - /* for compatibility with ancient versions of LILO. */
11041 - if (setup_sectors < SETUP_SECTS)
11042 - setup_sectors = SETUP_SECTS;
11043 - fprintf(stderr, "Setup is %d bytes.\n", i);
11044 - memset(buf, 0, sizeof(buf));
11045 - while (i < setup_sectors * 512) {
11046 - c = setup_sectors * 512 - i;
11047 - if (c > sizeof(buf))
11048 - c = sizeof(buf);
11049 - if (write(1, buf, c) != c)
11050 - die("Write call failed");
11051 - i += c;
11052 - }
11053 -
11054 - file_open(argv[3]);
11055 - if (fstat (fd, &sb))
11056 - die("Unable to stat `%s': %m", argv[3]);
11057 - sz = sb.st_size;
11058 - fprintf (stderr, "System is %d kB\n", sz/1024);
11059 - sys_size = (sz + 15) / 16;
11060 - if (!is_big_kernel && sys_size > DEF_SYSSIZE)
11061 - die("System is too big. Try using bzImage or modules.");
11062 - while (sz > 0) {
11063 - int l, n;
11064 -
11065 - l = (sz > sizeof(buf)) ? sizeof(buf) : sz;
11066 - if ((n=read(fd, buf, l)) != l) {
11067 - if (n < 0)
11068 - die("Error reading %s: %m", argv[3]);
11069 - else
11070 - die("%s: Unexpected EOF", argv[3]);
11071 - }
11072 - if (write(1, buf, l) != l)
11073 - die("Write failed");
11074 - sz -= l;
11075 - }
11076 - close(fd);
11077 -
11078 - if (lseek(1, 497, SEEK_SET) != 497) /* Write sizes to the bootsector */
11079 - die("Output: seek failed");
11080 - buf[0] = setup_sectors;
11081 - if (write(1, buf, 1) != 1)
11082 - die("Write of setup sector count failed");
11083 - if (lseek(1, 500, SEEK_SET) != 500)
11084 - die("Output: seek failed");
11085 - buf[0] = (sys_size & 0xff);
11086 - buf[1] = ((sys_size >> 8) & 0xff);
11087 - buf[2] = ((sys_size >> 16) & 0xff);
11088 - buf[3] = ((sys_size >> 24) & 0xff);
11089 - if (write(1, buf, 4) != 4)
11090 - die("Write of image length failed");
11091 -
11092 - return 0; /* Everything is OK */
11093 -}
11094 Index: linux-2.6.22.19/arch/x86_64/kernel/Makefile
11095 ===================================================================
11096 --- linux-2.6.22.19.orig/arch/x86_64/kernel/Makefile
11097 +++ linux-2.6.22.19/arch/x86_64/kernel/Makefile
11098 @@ -43,6 +43,7 @@ obj-$(CONFIG_PCI) += early-quirks.o
11099
11100 obj-y += topology.o
11101 obj-y += intel_cacheinfo.o
11102 +obj-y += addon_cpuid_features.o
11103 obj-y += pcspeaker.o
11104
11105 CFLAGS_vsyscall.o := $(PROFILING) -g0
11106 @@ -53,6 +54,7 @@ cpuid-$(subst m,y,$(CONFIG_X86_CPUID))
11107 topology-y += ../../i386/kernel/topology.o
11108 microcode-$(subst m,y,$(CONFIG_MICROCODE)) += ../../i386/kernel/microcode.o
11109 intel_cacheinfo-y += ../../i386/kernel/cpu/intel_cacheinfo.o
11110 +addon_cpuid_features-y += ../../i386/kernel/cpu/addon_cpuid_features.o
11111 quirks-y += ../../i386/kernel/quirks.o
11112 i8237-y += ../../i386/kernel/i8237.o
11113 msr-$(subst m,y,$(CONFIG_X86_MSR)) += ../../i386/kernel/msr.o
11114 Index: linux-2.6.22.19/arch/x86_64/kernel/setup.c
11115 ===================================================================
11116 --- linux-2.6.22.19.orig/arch/x86_64/kernel/setup.c
11117 +++ linux-2.6.22.19/arch/x86_64/kernel/setup.c
11118 @@ -846,6 +846,8 @@ void __cpuinit identify_cpu(struct cpuin
11119 c->x86_capability[2] = cpuid_edx(0x80860001);
11120 }
11121
11122 + init_scattered_cpuid_features(c);
11123 +
11124 c->apicid = phys_pkg_id(0);
11125
11126 /*
11127 @@ -931,7 +933,7 @@ static int show_cpuinfo(struct seq_file
11128 "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
11129 "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
11130 "pat", "pse36", "pn", "clflush", NULL, "dts", "acpi", "mmx",
11131 - "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", NULL,
11132 + "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", "pbe",
11133
11134 /* AMD-defined */
11135 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11136 @@ -947,10 +949,11 @@ static int show_cpuinfo(struct seq_file
11137 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11138
11139 /* Other (Linux-defined) */
11140 - "cxmmx", NULL, "cyrix_arr", "centaur_mcr", NULL,
11141 - "constant_tsc", NULL, NULL,
11142 - "up", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11143 - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11144 + "cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr",
11145 + NULL, NULL, NULL, NULL,
11146 + "constant_tsc", "up", NULL, "arch_perfmon",
11147 + "pebs", "bts", NULL, "sync_rdtsc",
11148 + "rep_good", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11149 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11150
11151 /* Intel-defined (#2) */
11152 @@ -961,7 +964,7 @@ static int show_cpuinfo(struct seq_file
11153
11154 /* VIA/Cyrix/Centaur-defined */
11155 NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
11156 - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11157 + "ace2", "ace2_en", "phe", "phe_en", "pmm", "pmm_en", NULL, NULL,
11158 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11159 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11160
11161 @@ -972,6 +975,12 @@ static int show_cpuinfo(struct seq_file
11162 "osvw", "ibs", NULL, NULL, NULL, NULL,
11163 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11164 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11165 +
11166 + /* Auxiliary (Linux-defined) */
11167 + "ida", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11168 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11169 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11170 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11171 };
11172 static char *x86_power_flags[] = {
11173 "ts", /* temperature sensor */
11174 Index: linux-2.6.22.19/arch/x86_64/kernel/verify_cpu.S
11175 ===================================================================
11176 --- linux-2.6.22.19.orig/arch/x86_64/kernel/verify_cpu.S
11177 +++ linux-2.6.22.19/arch/x86_64/kernel/verify_cpu.S
11178 @@ -37,20 +37,6 @@ verify_cpu:
11179 pushl $0 # Kill any dangerous flags
11180 popfl
11181
11182 - /* minimum CPUID flags for x86-64 as defined by AMD */
11183 -#define M(x) (1<<(x))
11184 -#define M2(a,b) M(a)|M(b)
11185 -#define M4(a,b,c,d) M(a)|M(b)|M(c)|M(d)
11186 -
11187 -#define SSE_MASK \
11188 - (M2(X86_FEATURE_XMM,X86_FEATURE_XMM2))
11189 -#define REQUIRED_MASK1 \
11190 - (M4(X86_FEATURE_FPU,X86_FEATURE_PSE,X86_FEATURE_TSC,X86_FEATURE_MSR)|\
11191 - M4(X86_FEATURE_PAE,X86_FEATURE_CX8,X86_FEATURE_PGE,X86_FEATURE_CMOV)|\
11192 - M(X86_FEATURE_FXSR))
11193 -#define REQUIRED_MASK2 \
11194 - (M(X86_FEATURE_LM - 32))
11195 -
11196 pushfl # standard way to check for cpuid
11197 popl %eax
11198 movl %eax,%ebx
11199 @@ -79,8 +65,8 @@ verify_cpu:
11200 verify_cpu_noamd:
11201 movl $0x1,%eax # Does the cpu have what it takes
11202 cpuid
11203 - andl $REQUIRED_MASK1,%edx
11204 - xorl $REQUIRED_MASK1,%edx
11205 + andl $REQUIRED_MASK0,%edx
11206 + xorl $REQUIRED_MASK0,%edx
11207 jnz verify_cpu_no_longmode
11208
11209 movl $0x80000000,%eax # See if extended cpuid is implemented
11210 @@ -90,8 +76,8 @@ verify_cpu_noamd:
11211
11212 movl $0x80000001,%eax # Does the cpu have what it takes
11213 cpuid
11214 - andl $REQUIRED_MASK2,%edx
11215 - xorl $REQUIRED_MASK2,%edx
11216 + andl $REQUIRED_MASK1,%edx
11217 + xorl $REQUIRED_MASK1,%edx
11218 jnz verify_cpu_no_longmode
11219
11220 verify_cpu_sse_test:
11221 Index: linux-2.6.22.19/drivers/ide/legacy/hd.c
11222 ===================================================================
11223 --- linux-2.6.22.19.orig/drivers/ide/legacy/hd.c
11224 +++ linux-2.6.22.19/drivers/ide/legacy/hd.c
11225 @@ -718,74 +718,25 @@ static int __init hd_init(void)
11226 device_timer.function = hd_times_out;
11227 blk_queue_hardsect_size(hd_queue, 512);
11228
11229 -#ifdef __i386__
11230 if (!NR_HD) {
11231 - extern struct drive_info drive_info;
11232 - unsigned char *BIOS = (unsigned char *) &drive_info;
11233 - unsigned long flags;
11234 - int cmos_disks;
11235 -
11236 - for (drive=0 ; drive<2 ; drive++) {
11237 - hd_info[drive].cyl = *(unsigned short *) BIOS;
11238 - hd_info[drive].head = *(2+BIOS);
11239 - hd_info[drive].wpcom = *(unsigned short *) (5+BIOS);
11240 - hd_info[drive].ctl = *(8+BIOS);
11241 - hd_info[drive].lzone = *(unsigned short *) (12+BIOS);
11242 - hd_info[drive].sect = *(14+BIOS);
11243 -#ifdef does_not_work_for_everybody_with_scsi_but_helps_ibm_vp
11244 - if (hd_info[drive].cyl && NR_HD == drive)
11245 - NR_HD++;
11246 -#endif
11247 - BIOS += 16;
11248 - }
11249 -
11250 - /*
11251 - We query CMOS about hard disks : it could be that
11252 - we have a SCSI/ESDI/etc controller that is BIOS
11253 - compatible with ST-506, and thus showing up in our
11254 - BIOS table, but not register compatible, and therefore
11255 - not present in CMOS.
11256 -
11257 - Furthermore, we will assume that our ST-506 drives
11258 - <if any> are the primary drives in the system, and
11259 - the ones reflected as drive 1 or 2.
11260 -
11261 - The first drive is stored in the high nibble of CMOS
11262 - byte 0x12, the second in the low nibble. This will be
11263 - either a 4 bit drive type or 0xf indicating use byte 0x19
11264 - for an 8 bit type, drive 1, 0x1a for drive 2 in CMOS.
11265 -
11266 - Needless to say, a non-zero value means we have
11267 - an AT controller hard disk for that drive.
11268 -
11269 - Currently the rtc_lock is a bit academic since this
11270 - driver is non-modular, but someday... ? Paul G.
11271 - */
11272 -
11273 - spin_lock_irqsave(&rtc_lock, flags);
11274 - cmos_disks = CMOS_READ(0x12);
11275 - spin_unlock_irqrestore(&rtc_lock, flags);
11276 -
11277 - if (cmos_disks & 0xf0) {
11278 - if (cmos_disks & 0x0f)
11279 - NR_HD = 2;
11280 - else
11281 - NR_HD = 1;
11282 - }
11283 - }
11284 -#endif /* __i386__ */
11285 -#ifdef __arm__
11286 - if (!NR_HD) {
11287 - /* We don't know anything about the drive. This means
11288 + /*
11289 + * We don't know anything about the drive. This means
11290 * that you *MUST* specify the drive parameters to the
11291 * kernel yourself.
11292 + *
11293 + * If we were on an i386, we used to read this info from
11294 + * the BIOS or CMOS. This doesn't work all that well,
11295 + * since this assumes that this is a primary or secondary
11296 + * drive, and if we're using this legacy driver, it's
11297 + * probably an auxilliary controller added to recover
11298 + * legacy data off an ST-506 drive. Either way, it's
11299 + * definitely safest to have the user explicitly specify
11300 + * the information.
11301 */
11302 printk("hd: no drives specified - use hd=cyl,head,sectors"
11303 " on kernel command line\n");
11304 - }
11305 -#endif
11306 - if (!NR_HD)
11307 goto out;
11308 + }
11309
11310 for (drive=0 ; drive < NR_HD ; drive++) {
11311 struct gendisk *disk = alloc_disk(64);
11312 Index: linux-2.6.22.19/include/asm-i386/boot.h
11313 ===================================================================
11314 --- linux-2.6.22.19.orig/include/asm-i386/boot.h
11315 +++ linux-2.6.22.19/include/asm-i386/boot.h
11316 @@ -1,5 +1,5 @@
11317 -#ifndef _LINUX_BOOT_H
11318 -#define _LINUX_BOOT_H
11319 +#ifndef _ASM_BOOT_H
11320 +#define _ASM_BOOT_H
11321
11322 /* Don't touch these, unless you really know what you're doing. */
11323 #define DEF_INITSEG 0x9000
11324 @@ -17,4 +17,4 @@
11325 + (CONFIG_PHYSICAL_ALIGN - 1)) \
11326 & ~(CONFIG_PHYSICAL_ALIGN - 1))
11327
11328 -#endif /* _LINUX_BOOT_H */
11329 +#endif /* _ASM_BOOT_H */
11330 Index: linux-2.6.22.19/include/asm-i386/bootparam.h
11331 ===================================================================
11332 --- /dev/null
11333 +++ linux-2.6.22.19/include/asm-i386/bootparam.h
11334 @@ -0,0 +1,85 @@
11335 +#ifndef _ASM_BOOTPARAM_H
11336 +#define _ASM_BOOTPARAM_H
11337 +
11338 +#include <linux/types.h>
11339 +#include <linux/screen_info.h>
11340 +#include <linux/apm_bios.h>
11341 +#include <asm/e820.h>
11342 +#include <linux/edd.h>
11343 +#include <video/edid.h>
11344 +
11345 +struct setup_header {
11346 + u8 setup_sects;
11347 + u16 root_flags;
11348 + u32 syssize;
11349 + u16 ram_size;
11350 + u16 vid_mode;
11351 + u16 root_dev;
11352 + u16 boot_flag;
11353 + u16 jump;
11354 + u32 header;
11355 + u16 version;
11356 + u32 realmode_swtch;
11357 + u16 start_sys;
11358 + u16 kernel_version;
11359 + u8 type_of_loader;
11360 + u8 loadflags;
11361 +#define LOADED_HIGH 0x01
11362 +#define CAN_USE_HEAP 0x80
11363 + u16 setup_move_size;
11364 + u32 code32_start;
11365 + u32 ramdisk_image;
11366 + u32 ramdisk_size;
11367 + u32 bootsect_kludge;
11368 + u16 heap_end_ptr;
11369 + u16 _pad1;
11370 + u32 cmd_line_ptr;
11371 + u32 initrd_addr_max;
11372 + u32 kernel_alignment;
11373 + u8 relocatable_kernel;
11374 +} __attribute__((packed));
11375 +
11376 +struct sys_desc_table {
11377 + u16 length;
11378 + u8 table[14];
11379 +};
11380 +
11381 +struct efi_info {
11382 + u32 _pad1;
11383 + u32 efi_systab;
11384 + u32 efi_memdesc_size;
11385 + u32 efi_memdec_version;
11386 + u32 efi_memmap;
11387 + u32 fi_memmap_size;
11388 + u32 _pad2[2];
11389 +};
11390 +
11391 +/* The so-called "zeropage" */
11392 +struct boot_params {
11393 + struct screen_info screen_info; /* 0x000 */
11394 + struct apm_bios_info apm_bios_info; /* 0x040 */
11395 + u8 _pad2[12]; /* 0x054 */
11396 + u32 speedstep_info[4]; /* 0x060 */
11397 + u8 _pad3[16]; /* 0x070 */
11398 + u8 hd0_info[16]; /* obsolete! */ /* 0x080 */
11399 + u8 hd1_info[16]; /* obsolete! */ /* 0x090 */
11400 + struct sys_desc_table sys_desc_table; /* 0x0a0 */
11401 + u8 _pad4[144]; /* 0x0b0 */
11402 + struct edid_info edid_info; /* 0x140 */
11403 + struct efi_info efi_info; /* 0x1c0 */
11404 + u32 alt_mem_k; /* 0x1e0 */
11405 + u32 scratch; /* Scratch field! */ /* 0x1e4 */
11406 + u8 e820_entries; /* 0x1e8 */
11407 + u8 eddbuf_entries; /* 0x1e9 */
11408 + u8 edd_mbr_sig_buf_entries; /* 0x1ea */
11409 + u8 _pad6[6]; /* 0x1eb */
11410 + struct setup_header hdr; /* setup header */ /* 0x1f1 */
11411 + u8 _pad7[0x290-0x1f1-sizeof(struct setup_header)];
11412 + u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX]; /* 0x290 */
11413 + struct e820entry e820_map[E820MAX]; /* 0x2d0 */
11414 + u8 _pad8[48]; /* 0xcd0 */
11415 + struct edd_info eddbuf[EDDMAXNR]; /* 0xd00 */
11416 + u8 _pad9[276]; /* 0xeec */
11417 +} __attribute__((packed));
11418 +
11419 +#endif /* _ASM_BOOTPARAM_H */
11420 Index: linux-2.6.22.19/include/asm-i386/cpufeature.h
11421 ===================================================================
11422 --- linux-2.6.22.19.orig/include/asm-i386/cpufeature.h
11423 +++ linux-2.6.22.19/include/asm-i386/cpufeature.h
11424 @@ -12,7 +12,7 @@
11425 #endif
11426 #include <asm/required-features.h>
11427
11428 -#define NCAPINTS 7 /* N 32-bit words worth of info */
11429 +#define NCAPINTS 8 /* N 32-bit words worth of info */
11430
11431 /* Intel-defined CPU features, CPUID level 0x00000001 (edx), word 0 */
11432 #define X86_FEATURE_FPU (0*32+ 0) /* Onboard FPU */
11433 @@ -81,6 +81,7 @@
11434 #define X86_FEATURE_BTS (3*32+13) /* Branch Trace Store */
11435 /* 14 free */
11436 #define X86_FEATURE_SYNC_RDTSC (3*32+15) /* RDTSC synchronizes the CPU */
11437 +#define X86_FEATURE_REP_GOOD (3*32+16) /* rep microcode works well on this CPU */
11438
11439 /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
11440 #define X86_FEATURE_XMM3 (4*32+ 0) /* Streaming SIMD Extensions-3 */
11441 @@ -108,11 +109,24 @@
11442 #define X86_FEATURE_LAHF_LM (6*32+ 0) /* LAHF/SAHF in long mode */
11443 #define X86_FEATURE_CMP_LEGACY (6*32+ 1) /* If yes HyperThreading not valid */
11444
11445 -#define cpu_has(c, bit) \
11446 - ((__builtin_constant_p(bit) && (bit) < 32 && \
11447 - (1UL << (bit)) & REQUIRED_MASK1) ? \
11448 - 1 : \
11449 - test_bit(bit, (c)->x86_capability))
11450 +/*
11451 + * Auxiliary flags: Linux defined - For features scattered in various
11452 + * CPUID levels like 0x6, 0xA etc
11453 + */
11454 +#define X86_FEATURE_IDA (7*32+ 0) /* Intel Dynamic Acceleration */
11455 +
11456 +#define cpu_has(c, bit) \
11457 + (__builtin_constant_p(bit) && \
11458 + ( (((bit)>>5)==0 && (1UL<<((bit)&31) & REQUIRED_MASK0)) || \
11459 + (((bit)>>5)==1 && (1UL<<((bit)&31) & REQUIRED_MASK1)) || \
11460 + (((bit)>>5)==2 && (1UL<<((bit)&31) & REQUIRED_MASK2)) || \
11461 + (((bit)>>5)==3 && (1UL<<((bit)&31) & REQUIRED_MASK3)) || \
11462 + (((bit)>>5)==4 && (1UL<<((bit)&31) & REQUIRED_MASK4)) || \
11463 + (((bit)>>5)==5 && (1UL<<((bit)&31) & REQUIRED_MASK5)) || \
11464 + (((bit)>>5)==6 && (1UL<<((bit)&31) & REQUIRED_MASK6)) || \
11465 + (((bit)>>5)==7 && (1UL<<((bit)&31) & REQUIRED_MASK7)) ) \
11466 + ? 1 : \
11467 + test_bit(bit, (c)->x86_capability))
11468 #define boot_cpu_has(bit) cpu_has(&boot_cpu_data, bit)
11469
11470 #define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)
11471 Index: linux-2.6.22.19/include/asm-i386/e820.h
11472 ===================================================================
11473 --- linux-2.6.22.19.orig/include/asm-i386/e820.h
11474 +++ linux-2.6.22.19/include/asm-i386/e820.h
11475 @@ -25,13 +25,15 @@
11476
11477 #ifndef __ASSEMBLY__
11478
11479 +struct e820entry {
11480 + u64 addr; /* start of memory segment */
11481 + u64 size; /* size of memory segment */
11482 + u32 type; /* type of memory segment */
11483 +} __attribute__((packed));
11484 +
11485 struct e820map {
11486 - int nr_map;
11487 - struct e820entry {
11488 - unsigned long long addr; /* start of memory segment */
11489 - unsigned long long size; /* size of memory segment */
11490 - unsigned long type; /* type of memory segment */
11491 - } map[E820MAX];
11492 + u32 nr_map;
11493 + struct e820entry map[E820MAX];
11494 };
11495
11496 extern struct e820map e820;
11497 Index: linux-2.6.22.19/include/asm-i386/processor.h
11498 ===================================================================
11499 --- linux-2.6.22.19.orig/include/asm-i386/processor.h
11500 +++ linux-2.6.22.19/include/asm-i386/processor.h
11501 @@ -119,6 +119,7 @@ void __init cpu_detect(struct cpuinfo_x8
11502 extern void identify_boot_cpu(void);
11503 extern void identify_secondary_cpu(struct cpuinfo_x86 *);
11504 extern void print_cpu_info(struct cpuinfo_x86 *);
11505 +extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c);
11506 extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
11507 extern unsigned short num_cache_leaves;
11508
11509 Index: linux-2.6.22.19/include/asm-i386/required-features.h
11510 ===================================================================
11511 --- linux-2.6.22.19.orig/include/asm-i386/required-features.h
11512 +++ linux-2.6.22.19/include/asm-i386/required-features.h
11513 @@ -3,7 +3,7 @@
11514
11515 /* Define minimum CPUID feature set for kernel These bits are checked
11516 really early to actually display a visible error message before the
11517 - kernel dies. Only add word 0 bits here
11518 + kernel dies. Make sure to assign features to the proper mask!
11519
11520 Some requirements that are not in CPUID yet are also in the
11521 CONFIG_X86_MINIMUM_CPU mode which is checked too.
11522 @@ -11,24 +11,45 @@
11523 The real information is in arch/i386/Kconfig.cpu, this just converts
11524 the CONFIGs into a bitmask */
11525
11526 +#ifndef CONFIG_MATH_EMULATION
11527 +# define NEED_FPU (1<<(X86_FEATURE_FPU & 31))
11528 +#else
11529 +# define NEED_FPU 0
11530 +#endif
11531 +
11532 #ifdef CONFIG_X86_PAE
11533 -#define NEED_PAE (1<<X86_FEATURE_PAE)
11534 +# define NEED_PAE (1<<(X86_FEATURE_PAE & 31))
11535 #else
11536 -#define NEED_PAE 0
11537 +# define NEED_PAE 0
11538 #endif
11539
11540 #ifdef CONFIG_X86_CMOV
11541 -#define NEED_CMOV (1<<X86_FEATURE_CMOV)
11542 +# define NEED_CMOV (1<<(X86_FEATURE_CMOV & 31))
11543 #else
11544 -#define NEED_CMOV 0
11545 +# define NEED_CMOV 0
11546 #endif
11547
11548 #ifdef CONFIG_X86_CMPXCHG64
11549 -#define NEED_CMPXCHG64 (1<<X86_FEATURE_CX8)
11550 +# define NEED_CX8 (1<<(X86_FEATURE_CX8 & 31))
11551 +#else
11552 +# define NEED_CX8 0
11553 +#endif
11554 +
11555 +#define REQUIRED_MASK0 (NEED_FPU|NEED_PAE|NEED_CMOV|NEED_CX8)
11556 +
11557 +#ifdef CONFIG_X86_USE_3DNOW
11558 +# define NEED_3DNOW (1<<(X86_FEATURE_3DNOW & 31))
11559 #else
11560 -#define NEED_CMPXCHG64 0
11561 +# define NEED_3DNOW 0
11562 #endif
11563
11564 -#define REQUIRED_MASK1 (NEED_PAE|NEED_CMOV|NEED_CMPXCHG64)
11565 +#define REQUIRED_MASK1 (NEED_3DNOW)
11566 +
11567 +#define REQUIRED_MASK2 0
11568 +#define REQUIRED_MASK3 0
11569 +#define REQUIRED_MASK4 0
11570 +#define REQUIRED_MASK5 0
11571 +#define REQUIRED_MASK6 0
11572 +#define REQUIRED_MASK7 0
11573
11574 #endif
11575 Index: linux-2.6.22.19/include/asm-i386/setup.h
11576 ===================================================================
11577 --- linux-2.6.22.19.orig/include/asm-i386/setup.h
11578 +++ linux-2.6.22.19/include/asm-i386/setup.h
11579 @@ -26,12 +26,15 @@
11580 #define NEW_CL_POINTER 0x228 /* Relative to real mode data */
11581
11582 #ifndef __ASSEMBLY__
11583 +
11584 +#include <asm/bootparam.h>
11585 +
11586 /*
11587 * This is set up by the setup-routine at boot-time
11588 */
11589 -extern unsigned char boot_params[PARAM_SIZE];
11590 +extern struct boot_params boot_params;
11591
11592 -#define PARAM (boot_params)
11593 +#define PARAM ((char *)&boot_params)
11594 #define SCREEN_INFO (*(struct screen_info *) (PARAM+0))
11595 #define EXT_MEM_K (*(unsigned short *) (PARAM+2))
11596 #define ALT_MEM_K (*(unsigned long *) (PARAM+0x1e0))
11597 @@ -39,8 +42,7 @@ extern unsigned char boot_params[PARAM_S
11598 #define E820_MAP ((struct e820entry *) (PARAM+E820MAP))
11599 #define APM_BIOS_INFO (*(struct apm_bios_info *) (PARAM+0x40))
11600 #define IST_INFO (*(struct ist_info *) (PARAM+0x60))
11601 -#define DRIVE_INFO (*(struct drive_info_struct *) (PARAM+0x80))
11602 -#define SYS_DESC_TABLE (*(struct sys_desc_table_struct*)(PARAM+0xa0))
11603 +#define SYS_DESC_TABLE (*(struct sys_desc_table *)(PARAM+0xa0))
11604 #define EFI_SYSTAB ((efi_system_table_t *) *((unsigned long *)(PARAM+0x1c4)))
11605 #define EFI_MEMDESC_SIZE (*((unsigned long *) (PARAM+0x1c8)))
11606 #define EFI_MEMDESC_VERSION (*((unsigned long *) (PARAM+0x1cc)))
11607 Index: linux-2.6.22.19/include/asm-x86_64/alternative.h
11608 ===================================================================
11609 --- linux-2.6.22.19.orig/include/asm-x86_64/alternative.h
11610 +++ linux-2.6.22.19/include/asm-x86_64/alternative.h
11611 @@ -5,6 +5,41 @@
11612
11613 #include <linux/types.h>
11614 #include <linux/stddef.h>
11615 +
11616 +/*
11617 + * Alternative inline assembly for SMP.
11618 + *
11619 + * The LOCK_PREFIX macro defined here replaces the LOCK and
11620 + * LOCK_PREFIX macros used everywhere in the source tree.
11621 + *
11622 + * SMP alternatives use the same data structures as the other
11623 + * alternatives and the X86_FEATURE_UP flag to indicate the case of a
11624 + * UP system running a SMP kernel. The existing apply_alternatives()
11625 + * works fine for patching a SMP kernel for UP.
11626 + *
11627 + * The SMP alternative tables can be kept after boot and contain both
11628 + * UP and SMP versions of the instructions to allow switching back to
11629 + * SMP at runtime, when hotplugging in a new CPU, which is especially
11630 + * useful in virtualized environments.
11631 + *
11632 + * The very common lock prefix is handled as special case in a
11633 + * separate table which is a pure address list without replacement ptr
11634 + * and size information. That keeps the table sizes small.
11635 + */
11636 +
11637 +#ifdef CONFIG_SMP
11638 +#define LOCK_PREFIX \
11639 + ".section .smp_locks,\"a\"\n" \
11640 + " .align 8\n" \
11641 + " .quad 661f\n" /* address */ \
11642 + ".previous\n" \
11643 + "661:\n\tlock; "
11644 +
11645 +#else /* ! CONFIG_SMP */
11646 +#define LOCK_PREFIX ""
11647 +#endif
11648 +
11649 +/* This must be included *after* the definition of LOCK_PREFIX */
11650 #include <asm/cpufeature.h>
11651
11652 struct alt_instr {
11653 @@ -108,39 +143,6 @@ static inline void alternatives_smp_swit
11654 */
11655 #define ASM_OUTPUT2(a, b) a, b
11656
11657 -/*
11658 - * Alternative inline assembly for SMP.
11659 - *
11660 - * The LOCK_PREFIX macro defined here replaces the LOCK and
11661 - * LOCK_PREFIX macros used everywhere in the source tree.
11662 - *
11663 - * SMP alternatives use the same data structures as the other
11664 - * alternatives and the X86_FEATURE_UP flag to indicate the case of a
11665 - * UP system running a SMP kernel. The existing apply_alternatives()
11666 - * works fine for patching a SMP kernel for UP.
11667 - *
11668 - * The SMP alternative tables can be kept after boot and contain both
11669 - * UP and SMP versions of the instructions to allow switching back to
11670 - * SMP at runtime, when hotplugging in a new CPU, which is especially
11671 - * useful in virtualized environments.
11672 - *
11673 - * The very common lock prefix is handled as special case in a
11674 - * separate table which is a pure address list without replacement ptr
11675 - * and size information. That keeps the table sizes small.
11676 - */
11677 -
11678 -#ifdef CONFIG_SMP
11679 -#define LOCK_PREFIX \
11680 - ".section .smp_locks,\"a\"\n" \
11681 - " .align 8\n" \
11682 - " .quad 661f\n" /* address */ \
11683 - ".previous\n" \
11684 - "661:\n\tlock; "
11685 -
11686 -#else /* ! CONFIG_SMP */
11687 -#define LOCK_PREFIX ""
11688 -#endif
11689 -
11690 struct paravirt_patch;
11691 #ifdef CONFIG_PARAVIRT
11692 void apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end);
11693 Index: linux-2.6.22.19/include/asm-x86_64/boot.h
11694 ===================================================================
11695 --- linux-2.6.22.19.orig/include/asm-x86_64/boot.h
11696 +++ linux-2.6.22.19/include/asm-x86_64/boot.h
11697 @@ -1,15 +1 @@
11698 -#ifndef _LINUX_BOOT_H
11699 -#define _LINUX_BOOT_H
11700 -
11701 -/* Don't touch these, unless you really know what you're doing. */
11702 -#define DEF_INITSEG 0x9000
11703 -#define DEF_SYSSEG 0x1000
11704 -#define DEF_SETUPSEG 0x9020
11705 -#define DEF_SYSSIZE 0x7F00
11706 -
11707 -/* Internal svga startup constants */
11708 -#define NORMAL_VGA 0xffff /* 80x25 mode */
11709 -#define EXTENDED_VGA 0xfffe /* 80x50 mode */
11710 -#define ASK_VGA 0xfffd /* ask for it at bootup */
11711 -
11712 -#endif
11713 +#include <asm-i386/boot.h>
11714 Index: linux-2.6.22.19/include/asm-x86_64/bootparam.h
11715 ===================================================================
11716 --- /dev/null
11717 +++ linux-2.6.22.19/include/asm-x86_64/bootparam.h
11718 @@ -0,0 +1 @@
11719 +#include <asm-i386/bootparam.h>
11720 Index: linux-2.6.22.19/include/asm-x86_64/cpufeature.h
11721 ===================================================================
11722 --- linux-2.6.22.19.orig/include/asm-x86_64/cpufeature.h
11723 +++ linux-2.6.22.19/include/asm-x86_64/cpufeature.h
11724 @@ -7,115 +7,24 @@
11725 #ifndef __ASM_X8664_CPUFEATURE_H
11726 #define __ASM_X8664_CPUFEATURE_H
11727
11728 -#define NCAPINTS 7 /* N 32-bit words worth of info */
11729 +#include <asm-i386/cpufeature.h>
11730
11731 -/* Intel-defined CPU features, CPUID level 0x00000001, word 0 */
11732 -#define X86_FEATURE_FPU (0*32+ 0) /* Onboard FPU */
11733 -#define X86_FEATURE_VME (0*32+ 1) /* Virtual Mode Extensions */
11734 -#define X86_FEATURE_DE (0*32+ 2) /* Debugging Extensions */
11735 -#define X86_FEATURE_PSE (0*32+ 3) /* Page Size Extensions */
11736 -#define X86_FEATURE_TSC (0*32+ 4) /* Time Stamp Counter */
11737 -#define X86_FEATURE_MSR (0*32+ 5) /* Model-Specific Registers, RDMSR, WRMSR */
11738 -#define X86_FEATURE_PAE (0*32+ 6) /* Physical Address Extensions */
11739 -#define X86_FEATURE_MCE (0*32+ 7) /* Machine Check Architecture */
11740 -#define X86_FEATURE_CX8 (0*32+ 8) /* CMPXCHG8 instruction */
11741 -#define X86_FEATURE_APIC (0*32+ 9) /* Onboard APIC */
11742 -#define X86_FEATURE_SEP (0*32+11) /* SYSENTER/SYSEXIT */
11743 -#define X86_FEATURE_MTRR (0*32+12) /* Memory Type Range Registers */
11744 -#define X86_FEATURE_PGE (0*32+13) /* Page Global Enable */
11745 -#define X86_FEATURE_MCA (0*32+14) /* Machine Check Architecture */
11746 -#define X86_FEATURE_CMOV (0*32+15) /* CMOV instruction (FCMOVCC and FCOMI too if FPU present) */
11747 -#define X86_FEATURE_PAT (0*32+16) /* Page Attribute Table */
11748 -#define X86_FEATURE_PSE36 (0*32+17) /* 36-bit PSEs */
11749 -#define X86_FEATURE_PN (0*32+18) /* Processor serial number */
11750 -#define X86_FEATURE_CLFLSH (0*32+19) /* Supports the CLFLUSH instruction */
11751 -#define X86_FEATURE_DS (0*32+21) /* Debug Store */
11752 -#define X86_FEATURE_ACPI (0*32+22) /* ACPI via MSR */
11753 -#define X86_FEATURE_MMX (0*32+23) /* Multimedia Extensions */
11754 -#define X86_FEATURE_FXSR (0*32+24) /* FXSAVE and FXRSTOR instructions (fast save and restore */
11755 - /* of FPU context), and CR4.OSFXSR available */
11756 -#define X86_FEATURE_XMM (0*32+25) /* Streaming SIMD Extensions */
11757 -#define X86_FEATURE_XMM2 (0*32+26) /* Streaming SIMD Extensions-2 */
11758 -#define X86_FEATURE_SELFSNOOP (0*32+27) /* CPU self snoop */
11759 -#define X86_FEATURE_HT (0*32+28) /* Hyper-Threading */
11760 -#define X86_FEATURE_ACC (0*32+29) /* Automatic clock control */
11761 -#define X86_FEATURE_IA64 (0*32+30) /* IA-64 processor */
11762 -
11763 -/* AMD-defined CPU features, CPUID level 0x80000001, word 1 */
11764 -/* Don't duplicate feature flags which are redundant with Intel! */
11765 -#define X86_FEATURE_SYSCALL (1*32+11) /* SYSCALL/SYSRET */
11766 -#define X86_FEATURE_MMXEXT (1*32+22) /* AMD MMX extensions */
11767 -#define X86_FEATURE_FXSR_OPT (1*32+25) /* FXSR optimizations */
11768 -#define X86_FEATURE_RDTSCP (1*32+27) /* RDTSCP */
11769 -#define X86_FEATURE_LM (1*32+29) /* Long Mode (x86-64) */
11770 -#define X86_FEATURE_3DNOWEXT (1*32+30) /* AMD 3DNow! extensions */
11771 -#define X86_FEATURE_3DNOW (1*32+31) /* 3DNow! */
11772 -
11773 -/* Transmeta-defined CPU features, CPUID level 0x80860001, word 2 */
11774 -#define X86_FEATURE_RECOVERY (2*32+ 0) /* CPU in recovery mode */
11775 -#define X86_FEATURE_LONGRUN (2*32+ 1) /* Longrun power control */
11776 -#define X86_FEATURE_LRTI (2*32+ 3) /* LongRun table interface */
11777 -
11778 -/* Other features, Linux-defined mapping, word 3 */
11779 -/* This range is used for feature bits which conflict or are synthesized */
11780 -#define X86_FEATURE_CXMMX (3*32+ 0) /* Cyrix MMX extensions */
11781 -#define X86_FEATURE_K6_MTRR (3*32+ 1) /* AMD K6 nonstandard MTRRs */
11782 -#define X86_FEATURE_CYRIX_ARR (3*32+ 2) /* Cyrix ARRs (= MTRRs) */
11783 -#define X86_FEATURE_CENTAUR_MCR (3*32+ 3) /* Centaur MCRs (= MTRRs) */
11784 -#define X86_FEATURE_REP_GOOD (3*32+ 4) /* rep microcode works well on this CPU */
11785 -#define X86_FEATURE_CONSTANT_TSC (3*32+5) /* TSC runs at constant rate */
11786 -#define X86_FEATURE_SYNC_RDTSC (3*32+6) /* RDTSC syncs CPU core */
11787 -#define X86_FEATURE_FXSAVE_LEAK (3*32+7) /* FIP/FOP/FDP leaks through FXSAVE */
11788 -#define X86_FEATURE_UP (3*32+8) /* SMP kernel running on UP */
11789 -#define X86_FEATURE_ARCH_PERFMON (3*32+9) /* Intel Architectural PerfMon */
11790 -#define X86_FEATURE_PEBS (3*32+10) /* Precise-Event Based Sampling */
11791 -#define X86_FEATURE_BTS (3*32+11) /* Branch Trace Store */
11792 -
11793 -/* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
11794 -#define X86_FEATURE_XMM3 (4*32+ 0) /* Streaming SIMD Extensions-3 */
11795 -#define X86_FEATURE_MWAIT (4*32+ 3) /* Monitor/Mwait support */
11796 -#define X86_FEATURE_DSCPL (4*32+ 4) /* CPL Qualified Debug Store */
11797 -#define X86_FEATURE_EST (4*32+ 7) /* Enhanced SpeedStep */
11798 -#define X86_FEATURE_TM2 (4*32+ 8) /* Thermal Monitor 2 */
11799 -#define X86_FEATURE_CID (4*32+10) /* Context ID */
11800 -#define X86_FEATURE_CX16 (4*32+13) /* CMPXCHG16B */
11801 -#define X86_FEATURE_XTPR (4*32+14) /* Send Task Priority Messages */
11802 -
11803 -/* VIA/Cyrix/Centaur-defined CPU features, CPUID level 0xC0000001, word 5 */
11804 -#define X86_FEATURE_XSTORE (5*32+ 2) /* on-CPU RNG present (xstore insn) */
11805 -#define X86_FEATURE_XSTORE_EN (5*32+ 3) /* on-CPU RNG enabled */
11806 -#define X86_FEATURE_XCRYPT (5*32+ 6) /* on-CPU crypto (xcrypt insn) */
11807 -#define X86_FEATURE_XCRYPT_EN (5*32+ 7) /* on-CPU crypto enabled */
11808 -
11809 -/* More extended AMD flags: CPUID level 0x80000001, ecx, word 6 */
11810 -#define X86_FEATURE_LAHF_LM (6*32+ 0) /* LAHF/SAHF in long mode */
11811 -#define X86_FEATURE_CMP_LEGACY (6*32+ 1) /* If yes HyperThreading not valid */
11812 -
11813 -#define cpu_has(c, bit) test_bit(bit, (c)->x86_capability)
11814 -#define boot_cpu_has(bit) test_bit(bit, boot_cpu_data.x86_capability)
11815 -
11816 -#define cpu_has_fpu 1
11817 +#undef cpu_has_vme
11818 #define cpu_has_vme 0
11819 -#define cpu_has_de 1
11820 -#define cpu_has_pse 1
11821 -#define cpu_has_tsc 1
11822 +
11823 +#undef cpu_has_pae
11824 #define cpu_has_pae ___BUG___
11825 -#define cpu_has_pge 1
11826 -#define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC)
11827 -#define cpu_has_mtrr 1
11828 -#define cpu_has_mmx 1
11829 -#define cpu_has_fxsr 1
11830 -#define cpu_has_xmm 1
11831 -#define cpu_has_xmm2 1
11832 -#define cpu_has_xmm3 boot_cpu_has(X86_FEATURE_XMM3)
11833 -#define cpu_has_ht boot_cpu_has(X86_FEATURE_HT)
11834 +
11835 +#undef cpu_has_mp
11836 #define cpu_has_mp 1 /* XXX */
11837 +
11838 +#undef cpu_has_k6_mtrr
11839 #define cpu_has_k6_mtrr 0
11840 +
11841 +#undef cpu_has_cyrix_arr
11842 #define cpu_has_cyrix_arr 0
11843 +
11844 +#undef cpu_has_centaur_mcr
11845 #define cpu_has_centaur_mcr 0
11846 -#define cpu_has_clflush boot_cpu_has(X86_FEATURE_CLFLSH)
11847 -#define cpu_has_ds boot_cpu_has(X86_FEATURE_DS)
11848 -#define cpu_has_pebs boot_cpu_has(X86_FEATURE_PEBS)
11849 -#define cpu_has_bts boot_cpu_has(X86_FEATURE_BTS)
11850
11851 #endif /* __ASM_X8664_CPUFEATURE_H */
11852 Index: linux-2.6.22.19/include/asm-x86_64/e820.h
11853 ===================================================================
11854 --- linux-2.6.22.19.orig/include/asm-x86_64/e820.h
11855 +++ linux-2.6.22.19/include/asm-x86_64/e820.h
11856 @@ -11,7 +11,9 @@
11857 #ifndef __E820_HEADER
11858 #define __E820_HEADER
11859
11860 -#include <linux/mmzone.h>
11861 +#ifndef _SETUP
11862 +# include <linux/mmzone.h>
11863 +#endif
11864
11865 #define E820MAP 0x2d0 /* our map */
11866 #define E820MAX 128 /* number of entries in E820MAP */
11867 @@ -30,7 +32,7 @@ struct e820entry {
11868 } __attribute__((packed));
11869
11870 struct e820map {
11871 - int nr_map;
11872 + u32 nr_map;
11873 struct e820entry map[E820MAX];
11874 };
11875
11876 Index: linux-2.6.22.19/include/asm-x86_64/processor.h
11877 ===================================================================
11878 --- linux-2.6.22.19.orig/include/asm-x86_64/processor.h
11879 +++ linux-2.6.22.19/include/asm-x86_64/processor.h
11880 @@ -100,6 +100,7 @@ extern char ignore_irq13;
11881
11882 extern void identify_cpu(struct cpuinfo_x86 *);
11883 extern void print_cpu_info(struct cpuinfo_x86 *);
11884 +extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c);
11885 extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
11886 extern unsigned short num_cache_leaves;
11887
11888 @@ -368,8 +369,6 @@ static inline void sync_core(void)
11889 asm volatile("cpuid" : "=a" (tmp) : "0" (1) : "ebx","ecx","edx","memory");
11890 }
11891
11892 -#define cpu_has_fpu 1
11893 -
11894 #define ARCH_HAS_PREFETCH
11895 static inline void prefetch(void *x)
11896 {
11897 Index: linux-2.6.22.19/include/asm-x86_64/required-features.h
11898 ===================================================================
11899 --- /dev/null
11900 +++ linux-2.6.22.19/include/asm-x86_64/required-features.h
11901 @@ -0,0 +1,46 @@
11902 +#ifndef _ASM_REQUIRED_FEATURES_H
11903 +#define _ASM_REQUIRED_FEATURES_H 1
11904 +
11905 +/* Define minimum CPUID feature set for kernel These bits are checked
11906 + really early to actually display a visible error message before the
11907 + kernel dies. Make sure to assign features to the proper mask!
11908 +
11909 + The real information is in arch/x86_64/Kconfig.cpu, this just converts
11910 + the CONFIGs into a bitmask */
11911 +
11912 +/* x86-64 baseline features */
11913 +#define NEED_FPU (1<<(X86_FEATURE_FPU & 31))
11914 +#define NEED_PSE (1<<(X86_FEATURE_PSE & 31))
11915 +#define NEED_MSR (1<<(X86_FEATURE_MSR & 31))
11916 +#define NEED_PAE (1<<(X86_FEATURE_PAE & 31))
11917 +#define NEED_CX8 (1<<(X86_FEATURE_CX8 & 31))
11918 +#define NEED_PGE (1<<(X86_FEATURE_PGE & 31))
11919 +#define NEED_FXSR (1<<(X86_FEATURE_FXSR & 31))
11920 +#define NEED_CMOV (1<<(X86_FEATURE_CMOV & 31))
11921 +#define NEED_XMM (1<<(X86_FEATURE_XMM & 31))
11922 +#define NEED_XMM2 (1<<(X86_FEATURE_XMM2 & 31))
11923 +
11924 +#define REQUIRED_MASK0 (NEED_FPU|NEED_PSE|NEED_MSR|NEED_PAE|\
11925 + NEED_CX8|NEED_PGE|NEED_FXSR|NEED_CMOV|\
11926 + NEED_XMM|NEED_XMM2)
11927 +#define SSE_MASK (NEED_XMM|NEED_XMM2)
11928 +
11929 +/* x86-64 baseline features */
11930 +#define NEED_LM (1<<(X86_FEATURE_LM & 31))
11931 +
11932 +#ifdef CONFIG_X86_USE_3DNOW
11933 +# define NEED_3DNOW (1<<(X86_FEATURE_3DNOW & 31))
11934 +#else
11935 +# define NEED_3DNOW 0
11936 +#endif
11937 +
11938 +#define REQUIRED_MASK1 (NEED_LM|NEED_3DNOW)
11939 +
11940 +#define REQUIRED_MASK2 0
11941 +#define REQUIRED_MASK3 0
11942 +#define REQUIRED_MASK4 0
11943 +#define REQUIRED_MASK5 0
11944 +#define REQUIRED_MASK6 0
11945 +#define REQUIRED_MASK7 0
11946 +
11947 +#endif
11948 Index: linux-2.6.22.19/include/asm-x86_64/segment.h
11949 ===================================================================
11950 --- linux-2.6.22.19.orig/include/asm-x86_64/segment.h
11951 +++ linux-2.6.22.19/include/asm-x86_64/segment.h
11952 @@ -3,6 +3,14 @@
11953
11954 #include <asm/cache.h>
11955
11956 +/* Simple and small GDT entries for booting only */
11957 +
11958 +#define GDT_ENTRY_BOOT_CS 2
11959 +#define __BOOT_CS (GDT_ENTRY_BOOT_CS * 8)
11960 +
11961 +#define GDT_ENTRY_BOOT_DS (GDT_ENTRY_BOOT_CS + 1)
11962 +#define __BOOT_DS (GDT_ENTRY_BOOT_DS * 8)
11963 +
11964 #define __KERNEL_CS 0x10
11965 #define __KERNEL_DS 0x18
11966
11967 Index: linux-2.6.22.19/include/linux/edd.h
11968 ===================================================================
11969 --- linux-2.6.22.19.orig/include/linux/edd.h
11970 +++ linux-2.6.22.19/include/linux/edd.h
11971 @@ -49,10 +49,6 @@
11972 #define EDD_MBR_SIG_MAX 16 /* max number of signatures to store */
11973 #define EDD_MBR_SIG_NR_BUF 0x1ea /* addr of number of MBR signtaures at EDD_MBR_SIG_BUF
11974 in boot_params - treat this as 1 byte */
11975 -#define EDD_CL_EQUALS 0x3d646465 /* "edd=" */
11976 -#define EDD_CL_OFF 0x666f /* "of" for off */
11977 -#define EDD_CL_SKIP 0x6b73 /* "sk" for skipmbr */
11978 -#define EDD_CL_ON 0x6e6f /* "on" for on */
11979
11980 #ifndef __ASSEMBLY__
11981
11982 Index: linux-2.6.22.19/include/linux/screen_info.h
11983 ===================================================================
11984 --- linux-2.6.22.19.orig/include/linux/screen_info.h
11985 +++ linux-2.6.22.19/include/linux/screen_info.h
11986 @@ -10,7 +10,7 @@
11987 struct screen_info {
11988 u8 orig_x; /* 0x00 */
11989 u8 orig_y; /* 0x01 */
11990 - u16 dontuse1; /* 0x02 -- EXT_MEM_K sits here */
11991 + u16 ext_mem_k; /* 0x02 */
11992 u16 orig_video_page; /* 0x04 */
11993 u8 orig_video_mode; /* 0x06 */
11994 u8 orig_video_cols; /* 0x07 */
11995 @@ -27,7 +27,7 @@ struct screen_info {
11996 u16 lfb_depth; /* 0x16 */
11997 u32 lfb_base; /* 0x18 */
11998 u32 lfb_size; /* 0x1c */
11999 - u16 dontuse2, dontuse3; /* 0x20 -- CL_MAGIC and CL_OFFSET here */
12000 + u16 cl_magic, cl_offset; /* 0x20 */
12001 u16 lfb_linelength; /* 0x24 */
12002 u8 red_size; /* 0x26 */
12003 u8 red_pos; /* 0x27 */
12004 @@ -42,9 +42,8 @@ struct screen_info {
12005 u16 pages; /* 0x32 */
12006 u16 vesa_attributes; /* 0x34 */
12007 u32 capabilities; /* 0x36 */
12008 - /* 0x3a -- 0x3b reserved for future expansion */
12009 - /* 0x3c -- 0x3f micro stack for relocatable kernels */
12010 -};
12011 + u8 _reserved[6]; /* 0x3a */
12012 +} __attribute__((packed));
12013
12014 extern struct screen_info screen_info;
12015
This page took 0.715776 seconds and 5 git commands to generate.