[adm5120] swap I/O space if running in big-endian mode
[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 --- a/MAINTAINERS
1366 +++ b/MAINTAINERS
1367 @@ -1750,8 +1750,8 @@
1368 S: Maintained
1369
1370 i386 BOOT CODE
1371 -P: Riley H. Williams
1372 -M: Riley@Williams.Name
1373 +P: H. Peter Anvin
1374 +M: hpa@zytor.com
1375 L: Linux-Kernel@vger.kernel.org
1376 S: Maintained
1377
1378 --- a/arch/i386/Kconfig.cpu
1379 +++ b/arch/i386/Kconfig.cpu
1380 @@ -346,6 +346,6 @@
1381
1382 config X86_MINIMUM_CPU_MODEL
1383 int
1384 - default "4" if X86_XADD || X86_CMPXCHG || X86_BSWAP
1385 - default "0"
1386 + default "4" if X86_XADD || X86_CMPXCHG || X86_BSWAP || X86_WP_WORKS_OK
1387 + default "3"
1388
1389 --- a/arch/i386/boot/Makefile
1390 +++ b/arch/i386/boot/Makefile
1391 @@ -25,27 +25,53 @@
1392
1393 #RAMDISK := -DRAMDISK=512
1394
1395 -targets := vmlinux.bin bootsect bootsect.o \
1396 - setup setup.o zImage bzImage
1397 +targets := vmlinux.bin setup.bin setup.elf zImage bzImage
1398 subdir- := compressed
1399
1400 +setup-y += a20.o apm.o cmdline.o copy.o cpu.o cpucheck.o edd.o
1401 +setup-y += header.o main.o mca.o memory.o pm.o pmjump.o
1402 +setup-y += printf.o string.o tty.o video.o version.o voyager.o
1403 +
1404 +# The link order of the video-*.o modules can matter. In particular,
1405 +# video-vga.o *must* be listed first, followed by video-vesa.o.
1406 +# Hardware-specific drivers should follow in the order they should be
1407 +# probed, and video-bios.o should typically be last.
1408 +setup-y += video-vga.o
1409 +setup-y += video-vesa.o
1410 +setup-y += video-bios.o
1411 +
1412 hostprogs-y := tools/build
1413
1414 HOSTCFLAGS_build.o := $(LINUXINCLUDE)
1415
1416 # ---------------------------------------------------------------------------
1417
1418 +# How to compile the 16-bit code. Note we always compile for -march=i386,
1419 +# that way we can complain to the user if the CPU is insufficient.
1420 +cflags-i386 :=
1421 +cflags-x86_64 := -m32
1422 +CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
1423 + $(cflags-$(ARCH)) \
1424 + -Wall -Wstrict-prototypes \
1425 + -march=i386 -mregparm=3 \
1426 + -include $(srctree)/$(src)/code16gcc.h \
1427 + -fno-strict-aliasing -fomit-frame-pointer \
1428 + $(call cc-option, -ffreestanding) \
1429 + $(call cc-option, -fno-stack-protector)
1430 +AFLAGS := $(CFLAGS) -D__ASSEMBLY__
1431 +
1432 $(obj)/zImage: IMAGE_OFFSET := 0x1000
1433 $(obj)/zImage: EXTRA_AFLAGS := $(SVGA_MODE) $(RAMDISK)
1434 $(obj)/bzImage: IMAGE_OFFSET := 0x100000
1435 +$(obj)/bzImage: EXTRA_CFLAGS := -D__BIG_KERNEL__
1436 $(obj)/bzImage: EXTRA_AFLAGS := $(SVGA_MODE) $(RAMDISK) -D__BIG_KERNEL__
1437 $(obj)/bzImage: BUILDFLAGS := -b
1438
1439 quiet_cmd_image = BUILD $@
1440 -cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/bootsect $(obj)/setup \
1441 +cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/setup.bin \
1442 $(obj)/vmlinux.bin $(ROOT_DEV) > $@
1443
1444 -$(obj)/zImage $(obj)/bzImage: $(obj)/bootsect $(obj)/setup \
1445 +$(obj)/zImage $(obj)/bzImage: $(obj)/setup.bin \
1446 $(obj)/vmlinux.bin $(obj)/tools/build FORCE
1447 $(call if_changed,image)
1448 @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
1449 @@ -53,12 +79,17 @@
1450 $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
1451 $(call if_changed,objcopy)
1452
1453 -LDFLAGS_bootsect := -Ttext 0x0 -s --oformat binary
1454 -LDFLAGS_setup := -Ttext 0x0 -s --oformat binary -e begtext
1455 +SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
1456
1457 -$(obj)/setup $(obj)/bootsect: %: %.o FORCE
1458 +LDFLAGS_setup.elf := -T
1459 +$(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
1460 $(call if_changed,ld)
1461
1462 +OBJCOPYFLAGS_setup.bin := -O binary
1463 +
1464 +$(obj)/setup.bin: $(obj)/setup.elf FORCE
1465 + $(call if_changed,objcopy)
1466 +
1467 $(obj)/compressed/vmlinux: FORCE
1468 $(Q)$(MAKE) $(build)=$(obj)/compressed IMAGE_OFFSET=$(IMAGE_OFFSET) $@
1469
1470 --- /dev/null
1471 +++ b/arch/i386/boot/a20.c
1472 @@ -0,0 +1,161 @@
1473 +/* -*- linux-c -*- ------------------------------------------------------- *
1474 + *
1475 + * Copyright (C) 1991, 1992 Linus Torvalds
1476 + * Copyright 2007 rPath, Inc. - All Rights Reserved
1477 + *
1478 + * This file is part of the Linux kernel, and is made available under
1479 + * the terms of the GNU General Public License version 2.
1480 + *
1481 + * ----------------------------------------------------------------------- */
1482 +
1483 +/*
1484 + * arch/i386/boot/a20.c
1485 + *
1486 + * Enable A20 gate (return -1 on failure)
1487 + */
1488 +
1489 +#include "boot.h"
1490 +
1491 +#define MAX_8042_LOOPS 100000
1492 +
1493 +static int empty_8042(void)
1494 +{
1495 + u8 status;
1496 + int loops = MAX_8042_LOOPS;
1497 +
1498 + while (loops--) {
1499 + io_delay();
1500 +
1501 + status = inb(0x64);
1502 + if (status & 1) {
1503 + /* Read and discard input data */
1504 + io_delay();
1505 + (void)inb(0x60);
1506 + } else if (!(status & 2)) {
1507 + /* Buffers empty, finished! */
1508 + return 0;
1509 + }
1510 + }
1511 +
1512 + return -1;
1513 +}
1514 +
1515 +/* Returns nonzero if the A20 line is enabled. The memory address
1516 + used as a test is the int $0x80 vector, which should be safe. */
1517 +
1518 +#define A20_TEST_ADDR (4*0x80)
1519 +#define A20_TEST_SHORT 32
1520 +#define A20_TEST_LONG 2097152 /* 2^21 */
1521 +
1522 +static int a20_test(int loops)
1523 +{
1524 + int ok = 0;
1525 + int saved, ctr;
1526 +
1527 + set_fs(0x0000);
1528 + set_gs(0xffff);
1529 +
1530 + saved = ctr = rdfs32(A20_TEST_ADDR);
1531 +
1532 + while (loops--) {
1533 + wrfs32(++ctr, A20_TEST_ADDR);
1534 + io_delay(); /* Serialize and make delay constant */
1535 + ok = rdgs32(A20_TEST_ADDR+0x10) ^ ctr;
1536 + if (ok)
1537 + break;
1538 + }
1539 +
1540 + wrfs32(saved, A20_TEST_ADDR);
1541 + return ok;
1542 +}
1543 +
1544 +/* Quick test to see if A20 is already enabled */
1545 +static int a20_test_short(void)
1546 +{
1547 + return a20_test(A20_TEST_SHORT);
1548 +}
1549 +
1550 +/* Longer test that actually waits for A20 to come on line; this
1551 + is useful when dealing with the KBC or other slow external circuitry. */
1552 +static int a20_test_long(void)
1553 +{
1554 + return a20_test(A20_TEST_LONG);
1555 +}
1556 +
1557 +static void enable_a20_bios(void)
1558 +{
1559 + asm volatile("pushfl; int $0x15; popfl"
1560 + : : "a" ((u16)0x2401));
1561 +}
1562 +
1563 +static void enable_a20_kbc(void)
1564 +{
1565 + empty_8042();
1566 +
1567 + outb(0xd1, 0x64); /* Command write */
1568 + empty_8042();
1569 +
1570 + outb(0xdf, 0x60); /* A20 on */
1571 + empty_8042();
1572 +}
1573 +
1574 +static void enable_a20_fast(void)
1575 +{
1576 + u8 port_a;
1577 +
1578 + port_a = inb(0x92); /* Configuration port A */
1579 + port_a |= 0x02; /* Enable A20 */
1580 + port_a &= ~0x01; /* Do not reset machine */
1581 + outb(port_a, 0x92);
1582 +}
1583 +
1584 +/*
1585 + * Actual routine to enable A20; return 0 on ok, -1 on failure
1586 + */
1587 +
1588 +#define A20_ENABLE_LOOPS 255 /* Number of times to try */
1589 +
1590 +int enable_a20(void)
1591 +{
1592 + int loops = A20_ENABLE_LOOPS;
1593 +
1594 +#if defined(CONFIG_X86_ELAN)
1595 + /* Elan croaks if we try to touch the KBC */
1596 + enable_a20_fast();
1597 + while (!a20_test_long())
1598 + ;
1599 + return 0;
1600 +#elif defined(CONFIG_X86_VOYAGER)
1601 + /* On Voyager, a20_test() is unsafe? */
1602 + enable_a20_kbc();
1603 + return 0;
1604 +#else
1605 + while (loops--) {
1606 + /* First, check to see if A20 is already enabled
1607 + (legacy free, etc.) */
1608 + if (a20_test_short())
1609 + return 0;
1610 +
1611 + /* Next, try the BIOS (INT 0x15, AX=0x2401) */
1612 + enable_a20_bios();
1613 + if (a20_test_short())
1614 + return 0;
1615 +
1616 + /* Try enabling A20 through the keyboard controller */
1617 + empty_8042();
1618 + if (a20_test_short())
1619 + return 0; /* BIOS worked, but with delayed reaction */
1620 +
1621 + enable_a20_kbc();
1622 + if (a20_test_long())
1623 + return 0;
1624 +
1625 + /* Finally, try enabling the "fast A20 gate" */
1626 + enable_a20_fast();
1627 + if (a20_test_long())
1628 + return 0;
1629 + }
1630 +
1631 + return -1;
1632 +#endif
1633 +}
1634 --- /dev/null
1635 +++ b/arch/i386/boot/apm.c
1636 @@ -0,0 +1,97 @@
1637 +/* -*- linux-c -*- ------------------------------------------------------- *
1638 + *
1639 + * Copyright (C) 1991, 1992 Linus Torvalds
1640 + * Copyright 2007 rPath, Inc. - All Rights Reserved
1641 + *
1642 + * Original APM BIOS checking by Stephen Rothwell, May 1994
1643 + * (sfr@canb.auug.org.au)
1644 + *
1645 + * This file is part of the Linux kernel, and is made available under
1646 + * the terms of the GNU General Public License version 2.
1647 + *
1648 + * ----------------------------------------------------------------------- */
1649 +
1650 +/*
1651 + * arch/i386/boot/apm.c
1652 + *
1653 + * Get APM BIOS information
1654 + */
1655 +
1656 +#include "boot.h"
1657 +
1658 +#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
1659 +
1660 +int query_apm_bios(void)
1661 +{
1662 + u16 ax, bx, cx, dx, di;
1663 + u32 ebx, esi;
1664 + u8 err;
1665 +
1666 + /* APM BIOS installation check */
1667 + ax = 0x5300;
1668 + bx = cx = 0;
1669 + asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp ; setc %0"
1670 + : "=d" (err), "+a" (ax), "+b" (bx), "+c" (cx)
1671 + : : "esi", "edi");
1672 +
1673 + if (err)
1674 + return -1; /* No APM BIOS */
1675 +
1676 + if (bx != 0x504d) /* "PM" signature */
1677 + return -1;
1678 +
1679 + if (cx & 0x02) /* 32 bits supported? */
1680 + return -1;
1681 +
1682 + /* Disconnect first, just in case */
1683 + ax = 0x5304;
1684 + asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp"
1685 + : "+a" (ax)
1686 + : : "ebx", "ecx", "edx", "esi", "edi");
1687 +
1688 + /* Paranoia */
1689 + ebx = esi = 0;
1690 + cx = dx = di = 0;
1691 +
1692 + /* 32-bit connect */
1693 + asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp ; setc %6"
1694 + : "=a" (ax), "+b" (ebx), "+c" (cx), "+d" (dx),
1695 + "+S" (esi), "+D" (di), "=m" (err)
1696 + : "a" (0x5303));
1697 +
1698 + boot_params.apm_bios_info.cseg = ax;
1699 + boot_params.apm_bios_info.offset = ebx;
1700 + boot_params.apm_bios_info.cseg_16 = cx;
1701 + boot_params.apm_bios_info.dseg = dx;
1702 + boot_params.apm_bios_info.cseg_len = (u16)esi;
1703 + boot_params.apm_bios_info.cseg_16_len = esi >> 16;
1704 + boot_params.apm_bios_info.dseg_len = di;
1705 +
1706 + if (err)
1707 + return -1;
1708 +
1709 + /* Redo the installation check as the 32-bit connect;
1710 + some BIOSes return different flags this way... */
1711 +
1712 + ax = 0x5300;
1713 + bx = cx = 0;
1714 + asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp ; setc %0"
1715 + : "=d" (err), "+a" (ax), "+b" (bx), "+c" (cx)
1716 + : : "esi", "edi");
1717 +
1718 + if (err || bx != 0x504d) {
1719 + /* Failure with 32-bit connect, try to disconect and ignore */
1720 + ax = 0x5304;
1721 + bx = 0;
1722 + asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp"
1723 + : "+a" (ax), "+b" (bx)
1724 + : : "ecx", "edx", "esi", "edi");
1725 + return -1;
1726 + }
1727 +
1728 + boot_params.apm_bios_info.version = ax;
1729 + boot_params.apm_bios_info.flags = cx;
1730 + return 0;
1731 +}
1732 +
1733 +#endif
1734 --- /dev/null
1735 +++ b/arch/i386/boot/bitops.h
1736 @@ -0,0 +1,45 @@
1737 +/* -*- linux-c -*- ------------------------------------------------------- *
1738 + *
1739 + * Copyright (C) 1991, 1992 Linus Torvalds
1740 + * Copyright 2007 rPath, Inc. - All Rights Reserved
1741 + *
1742 + * This file is part of the Linux kernel, and is made available under
1743 + * the terms of the GNU General Public License version 2.
1744 + *
1745 + * ----------------------------------------------------------------------- */
1746 +
1747 +/*
1748 + * arch/i386/boot/bitops.h
1749 + *
1750 + * Very simple bitops for the boot code.
1751 + */
1752 +
1753 +#ifndef BOOT_BITOPS_H
1754 +#define BOOT_BITOPS_H
1755 +#define _LINUX_BITOPS_H /* Inhibit inclusion of <linux/bitops.h> */
1756 +
1757 +static inline int constant_test_bit(int nr, const void *addr)
1758 +{
1759 + const u32 *p = (const u32 *)addr;
1760 + return ((1UL << (nr & 31)) & (p[nr >> 5])) != 0;
1761 +}
1762 +static inline int variable_test_bit(int nr, const void *addr)
1763 +{
1764 + u8 v;
1765 + const u32 *p = (const u32 *)addr;
1766 +
1767 + asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
1768 + return v;
1769 +}
1770 +
1771 +#define test_bit(nr,addr) \
1772 +(__builtin_constant_p(nr) ? \
1773 + constant_test_bit((nr),(addr)) : \
1774 + variable_test_bit((nr),(addr)))
1775 +
1776 +static inline void set_bit(int nr, void *addr)
1777 +{
1778 + asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
1779 +}
1780 +
1781 +#endif /* BOOT_BITOPS_H */
1782 --- /dev/null
1783 +++ b/arch/i386/boot/boot.h
1784 @@ -0,0 +1,290 @@
1785 +/* -*- linux-c -*- ------------------------------------------------------- *
1786 + *
1787 + * Copyright (C) 1991, 1992 Linus Torvalds
1788 + * Copyright 2007 rPath, Inc. - All Rights Reserved
1789 + *
1790 + * This file is part of the Linux kernel, and is made available under
1791 + * the terms of the GNU General Public License version 2.
1792 + *
1793 + * ----------------------------------------------------------------------- */
1794 +
1795 +/*
1796 + * arch/i386/boot/boot.h
1797 + *
1798 + * Header file for the real-mode kernel code
1799 + */
1800 +
1801 +#ifndef BOOT_BOOT_H
1802 +#define BOOT_BOOT_H
1803 +
1804 +#ifndef __ASSEMBLY__
1805 +
1806 +#include <stdarg.h>
1807 +#include <linux/types.h>
1808 +#include <linux/edd.h>
1809 +#include <asm/boot.h>
1810 +#include <asm/bootparam.h>
1811 +
1812 +/* Useful macros */
1813 +#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
1814 +
1815 +extern struct setup_header hdr;
1816 +extern struct boot_params boot_params;
1817 +
1818 +/* Basic port I/O */
1819 +static inline void outb(u8 v, u16 port)
1820 +{
1821 + asm volatile("outb %0,%1" : : "a" (v), "dN" (port));
1822 +}
1823 +static inline u8 inb(u16 port)
1824 +{
1825 + u8 v;
1826 + asm volatile("inb %1,%0" : "=a" (v) : "dN" (port));
1827 + return v;
1828 +}
1829 +
1830 +static inline void outw(u16 v, u16 port)
1831 +{
1832 + asm volatile("outw %0,%1" : : "a" (v), "dN" (port));
1833 +}
1834 +static inline u16 inw(u16 port)
1835 +{
1836 + u16 v;
1837 + asm volatile("inw %1,%0" : "=a" (v) : "dN" (port));
1838 + return v;
1839 +}
1840 +
1841 +static inline void outl(u32 v, u16 port)
1842 +{
1843 + asm volatile("outl %0,%1" : : "a" (v), "dn" (port));
1844 +}
1845 +static inline u32 inl(u32 port)
1846 +{
1847 + u32 v;
1848 + asm volatile("inl %1,%0" : "=a" (v) : "dN" (port));
1849 + return v;
1850 +}
1851 +
1852 +static inline void io_delay(void)
1853 +{
1854 + const u16 DELAY_PORT = 0x80;
1855 + asm volatile("outb %%al,%0" : : "dN" (DELAY_PORT));
1856 +}
1857 +
1858 +/* These functions are used to reference data in other segments. */
1859 +
1860 +static inline u16 ds(void)
1861 +{
1862 + u16 seg;
1863 + asm("movw %%ds,%0" : "=rm" (seg));
1864 + return seg;
1865 +}
1866 +
1867 +static inline void set_fs(u16 seg)
1868 +{
1869 + asm volatile("movw %0,%%fs" : : "rm" (seg));
1870 +}
1871 +static inline u16 fs(void)
1872 +{
1873 + u16 seg;
1874 + asm("movw %%fs,%0" : "=rm" (seg));
1875 + return seg;
1876 +}
1877 +
1878 +static inline void set_gs(u16 seg)
1879 +{
1880 + asm volatile("movw %0,%%gs" : : "rm" (seg));
1881 +}
1882 +static inline u16 gs(void)
1883 +{
1884 + u16 seg;
1885 + asm("movw %%gs,%0" : "=rm" (seg));
1886 + return seg;
1887 +}
1888 +
1889 +typedef unsigned int addr_t;
1890 +
1891 +static inline u8 rdfs8(addr_t addr)
1892 +{
1893 + u8 v;
1894 + asm("movb %%fs:%1,%0" : "=r" (v) : "m" (*(u8 *)addr));
1895 + return v;
1896 +}
1897 +static inline u16 rdfs16(addr_t addr)
1898 +{
1899 + u16 v;
1900 + asm("movw %%fs:%1,%0" : "=r" (v) : "m" (*(u16 *)addr));
1901 + return v;
1902 +}
1903 +static inline u32 rdfs32(addr_t addr)
1904 +{
1905 + u32 v;
1906 + asm("movl %%fs:%1,%0" : "=r" (v) : "m" (*(u32 *)addr));
1907 + return v;
1908 +}
1909 +
1910 +static inline void wrfs8(u8 v, addr_t addr)
1911 +{
1912 + asm volatile("movb %1,%%fs:%0" : "+m" (*(u8 *)addr) : "r" (v));
1913 +}
1914 +static inline void wrfs16(u16 v, addr_t addr)
1915 +{
1916 + asm volatile("movw %1,%%fs:%0" : "+m" (*(u16 *)addr) : "r" (v));
1917 +}
1918 +static inline void wrfs32(u32 v, addr_t addr)
1919 +{
1920 + asm volatile("movl %1,%%fs:%0" : "+m" (*(u32 *)addr) : "r" (v));
1921 +}
1922 +
1923 +static inline u8 rdgs8(addr_t addr)
1924 +{
1925 + u8 v;
1926 + asm("movb %%gs:%1,%0" : "=r" (v) : "m" (*(u8 *)addr));
1927 + return v;
1928 +}
1929 +static inline u16 rdgs16(addr_t addr)
1930 +{
1931 + u16 v;
1932 + asm("movw %%gs:%1,%0" : "=r" (v) : "m" (*(u16 *)addr));
1933 + return v;
1934 +}
1935 +static inline u32 rdgs32(addr_t addr)
1936 +{
1937 + u32 v;
1938 + asm("movl %%gs:%1,%0" : "=r" (v) : "m" (*(u32 *)addr));
1939 + return v;
1940 +}
1941 +
1942 +static inline void wrgs8(u8 v, addr_t addr)
1943 +{
1944 + asm volatile("movb %1,%%gs:%0" : "+m" (*(u8 *)addr) : "r" (v));
1945 +}
1946 +static inline void wrgs16(u16 v, addr_t addr)
1947 +{
1948 + asm volatile("movw %1,%%gs:%0" : "+m" (*(u16 *)addr) : "r" (v));
1949 +}
1950 +static inline void wrgs32(u32 v, addr_t addr)
1951 +{
1952 + asm volatile("movl %1,%%gs:%0" : "+m" (*(u32 *)addr) : "r" (v));
1953 +}
1954 +
1955 +/* Note: these only return true/false, not a signed return value! */
1956 +static inline int memcmp(const void *s1, const void *s2, size_t len)
1957 +{
1958 + u8 diff;
1959 + asm("repe; cmpsb; setnz %0"
1960 + : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
1961 + return diff;
1962 +}
1963 +
1964 +static inline int memcmp_fs(const void *s1, addr_t s2, size_t len)
1965 +{
1966 + u8 diff;
1967 + asm("fs; repe; cmpsb; setnz %0"
1968 + : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
1969 + return diff;
1970 +}
1971 +static inline int memcmp_gs(const void *s1, addr_t s2, size_t len)
1972 +{
1973 + u8 diff;
1974 + asm("gs; repe; cmpsb; setnz %0"
1975 + : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
1976 + return diff;
1977 +}
1978 +
1979 +/* Heap -- available for dynamic lists. */
1980 +#define STACK_SIZE 512 /* Minimum number of bytes for stack */
1981 +
1982 +extern char _end[];
1983 +extern char *HEAP;
1984 +extern char *heap_end;
1985 +#define RESET_HEAP() ((void *)( HEAP = _end ))
1986 +static inline char *__get_heap(size_t s, size_t a, size_t n)
1987 +{
1988 + char *tmp;
1989 +
1990 + HEAP = (char *)(((size_t)HEAP+(a-1)) & ~(a-1));
1991 + tmp = HEAP;
1992 + HEAP += s*n;
1993 + return tmp;
1994 +}
1995 +#define GET_HEAP(type, n) \
1996 + ((type *)__get_heap(sizeof(type),__alignof__(type),(n)))
1997 +
1998 +static inline int heap_free(void)
1999 +{
2000 + return heap_end-HEAP;
2001 +}
2002 +
2003 +/* copy.S */
2004 +
2005 +void copy_to_fs(addr_t dst, void *src, size_t len);
2006 +void *copy_from_fs(void *dst, addr_t src, size_t len);
2007 +void copy_to_gs(addr_t dst, void *src, size_t len);
2008 +void *copy_from_gs(void *dst, addr_t src, size_t len);
2009 +void *memcpy(void *dst, void *src, size_t len);
2010 +void *memset(void *dst, int c, size_t len);
2011 +
2012 +#define memcpy(d,s,l) __builtin_memcpy(d,s,l)
2013 +#define memset(d,c,l) __builtin_memset(d,c,l)
2014 +
2015 +/* a20.c */
2016 +int enable_a20(void);
2017 +
2018 +/* apm.c */
2019 +int query_apm_bios(void);
2020 +
2021 +/* cmdline.c */
2022 +int cmdline_find_option(const char *option, char *buffer, int bufsize);
2023 +
2024 +/* cpu.c, cpucheck.c */
2025 +int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr);
2026 +int validate_cpu(void);
2027 +
2028 +/* edd.c */
2029 +void query_edd(void);
2030 +
2031 +/* header.S */
2032 +void __attribute__((noreturn)) die(void);
2033 +
2034 +/* mca.c */
2035 +int query_mca(void);
2036 +
2037 +/* memory.c */
2038 +int detect_memory(void);
2039 +
2040 +/* pm.c */
2041 +void __attribute__((noreturn)) go_to_protected_mode(void);
2042 +
2043 +/* pmjump.S */
2044 +void __attribute__((noreturn))
2045 + protected_mode_jump(u32 entrypoint, u32 bootparams);
2046 +
2047 +/* printf.c */
2048 +unsigned int atou(const char *s);
2049 +int sprintf(char *buf, const char *fmt, ...);
2050 +int vsprintf(char *buf, const char *fmt, va_list args);
2051 +int printf(const char *fmt, ...);
2052 +
2053 +/* string.c */
2054 +int strcmp(const char *str1, const char *str2);
2055 +
2056 +/* tty.c */
2057 +void puts(const char *);
2058 +void putchar(int);
2059 +int getchar(void);
2060 +void kbd_flush(void);
2061 +int getchar_timeout(void);
2062 +
2063 +/* video.c */
2064 +void set_video(void);
2065 +
2066 +/* video-vesa.c */
2067 +void vesa_store_edid(void);
2068 +
2069 +/* voyager.c */
2070 +int query_voyager(void);
2071 +
2072 +#endif /* __ASSEMBLY__ */
2073 +
2074 +#endif /* BOOT_BOOT_H */
2075 --- a/arch/i386/boot/bootsect.S
2076 +++ /dev/null
2077 @@ -1,98 +0,0 @@
2078 -/*
2079 - * bootsect.S Copyright (C) 1991, 1992 Linus Torvalds
2080 - *
2081 - * modified by Drew Eckhardt
2082 - * modified by Bruce Evans (bde)
2083 - * modified by Chris Noe (May 1999) (as86 -> gas)
2084 - * gutted by H. Peter Anvin (Jan 2003)
2085 - *
2086 - * BIG FAT NOTE: We're in real mode using 64k segments. Therefore segment
2087 - * addresses must be multiplied by 16 to obtain their respective linear
2088 - * addresses. To avoid confusion, linear addresses are written using leading
2089 - * hex while segment addresses are written as segment:offset.
2090 - *
2091 - */
2092 -
2093 -#include <asm/boot.h>
2094 -
2095 -SETUPSECTS = 4 /* default nr of setup-sectors */
2096 -BOOTSEG = 0x07C0 /* original address of boot-sector */
2097 -INITSEG = DEF_INITSEG /* we move boot here - out of the way */
2098 -SETUPSEG = DEF_SETUPSEG /* setup starts here */
2099 -SYSSEG = DEF_SYSSEG /* system loaded at 0x10000 (65536) */
2100 -SYSSIZE = DEF_SYSSIZE /* system size: # of 16-byte clicks */
2101 - /* to be loaded */
2102 -ROOT_DEV = 0 /* ROOT_DEV is now written by "build" */
2103 -SWAP_DEV = 0 /* SWAP_DEV is now written by "build" */
2104 -
2105 -#ifndef SVGA_MODE
2106 -#define SVGA_MODE ASK_VGA
2107 -#endif
2108 -
2109 -#ifndef RAMDISK
2110 -#define RAMDISK 0
2111 -#endif
2112 -
2113 -#ifndef ROOT_RDONLY
2114 -#define ROOT_RDONLY 1
2115 -#endif
2116 -
2117 -.code16
2118 -.text
2119 -
2120 -.global _start
2121 -_start:
2122 -
2123 - # Normalize the start address
2124 - jmpl $BOOTSEG, $start2
2125 -
2126 -start2:
2127 - movw %cs, %ax
2128 - movw %ax, %ds
2129 - movw %ax, %es
2130 - movw %ax, %ss
2131 - movw $0x7c00, %sp
2132 - sti
2133 - cld
2134 -
2135 - movw $bugger_off_msg, %si
2136 -
2137 -msg_loop:
2138 - lodsb
2139 - andb %al, %al
2140 - jz die
2141 - movb $0xe, %ah
2142 - movw $7, %bx
2143 - int $0x10
2144 - jmp msg_loop
2145 -
2146 -die:
2147 - # Allow the user to press a key, then reboot
2148 - xorw %ax, %ax
2149 - int $0x16
2150 - int $0x19
2151 -
2152 - # int 0x19 should never return. In case it does anyway,
2153 - # invoke the BIOS reset code...
2154 - ljmp $0xf000,$0xfff0
2155 -
2156 -
2157 -bugger_off_msg:
2158 - .ascii "Direct booting from floppy is no longer supported.\r\n"
2159 - .ascii "Please use a boot loader program instead.\r\n"
2160 - .ascii "\n"
2161 - .ascii "Remove disk and press any key to reboot . . .\r\n"
2162 - .byte 0
2163 -
2164 -
2165 - # Kernel attributes; used by setup
2166 -
2167 - .org 497
2168 -setup_sects: .byte SETUPSECTS
2169 -root_flags: .word ROOT_RDONLY
2170 -syssize: .word SYSSIZE
2171 -swap_dev: .word SWAP_DEV
2172 -ram_size: .word RAMDISK
2173 -vid_mode: .word SVGA_MODE
2174 -root_dev: .word ROOT_DEV
2175 -boot_flag: .word 0xAA55
2176 --- /dev/null
2177 +++ b/arch/i386/boot/cmdline.c
2178 @@ -0,0 +1,97 @@
2179 +/* -*- linux-c -*- ------------------------------------------------------- *
2180 + *
2181 + * Copyright (C) 1991, 1992 Linus Torvalds
2182 + * Copyright 2007 rPath, Inc. - All Rights Reserved
2183 + *
2184 + * This file is part of the Linux kernel, and is made available under
2185 + * the terms of the GNU General Public License version 2.
2186 + *
2187 + * ----------------------------------------------------------------------- */
2188 +
2189 +/*
2190 + * arch/i386/boot/cmdline.c
2191 + *
2192 + * Simple command-line parser for early boot.
2193 + */
2194 +
2195 +#include "boot.h"
2196 +
2197 +static inline int myisspace(u8 c)
2198 +{
2199 + return c <= ' '; /* Close enough approximation */
2200 +}
2201 +
2202 +/*
2203 + * Find a non-boolean option, that is, "option=argument". In accordance
2204 + * with standard Linux practice, if this option is repeated, this returns
2205 + * the last instance on the command line.
2206 + *
2207 + * Returns the length of the argument (regardless of if it was
2208 + * truncated to fit in the buffer), or -1 on not found.
2209 + */
2210 +int cmdline_find_option(const char *option, char *buffer, int bufsize)
2211 +{
2212 + u32 cmdline_ptr = boot_params.hdr.cmd_line_ptr;
2213 + addr_t cptr;
2214 + char c;
2215 + int len = -1;
2216 + const char *opptr = NULL;
2217 + char *bufptr = buffer;
2218 + enum {
2219 + st_wordstart, /* Start of word/after whitespace */
2220 + st_wordcmp, /* Comparing this word */
2221 + st_wordskip, /* Miscompare, skip */
2222 + st_bufcpy /* Copying this to buffer */
2223 + } state = st_wordstart;
2224 +
2225 + if (!cmdline_ptr || cmdline_ptr >= 0x100000)
2226 + return -1; /* No command line, or inaccessible */
2227 +
2228 + cptr = cmdline_ptr & 0xf;
2229 + set_fs(cmdline_ptr >> 4);
2230 +
2231 + while (cptr < 0x10000 && (c = rdfs8(cptr++))) {
2232 + switch (state) {
2233 + case st_wordstart:
2234 + if (myisspace(c))
2235 + break;
2236 +
2237 + /* else */
2238 + state = st_wordcmp;
2239 + opptr = option;
2240 + /* fall through */
2241 +
2242 + case st_wordcmp:
2243 + if (c == '=' && !*opptr) {
2244 + len = 0;
2245 + bufptr = buffer;
2246 + state = st_bufcpy;
2247 + } else if (myisspace(c)) {
2248 + state = st_wordstart;
2249 + } else if (c != *opptr++) {
2250 + state = st_wordskip;
2251 + }
2252 + break;
2253 +
2254 + case st_wordskip:
2255 + if (myisspace(c))
2256 + state = st_wordstart;
2257 + break;
2258 +
2259 + case st_bufcpy:
2260 + if (myisspace(c)) {
2261 + state = st_wordstart;
2262 + } else {
2263 + if (len < bufsize-1)
2264 + *bufptr++ = c;
2265 + len++;
2266 + }
2267 + break;
2268 + }
2269 + }
2270 +
2271 + if (bufsize)
2272 + *bufptr = '\0';
2273 +
2274 + return len;
2275 +}
2276 --- /dev/null
2277 +++ b/arch/i386/boot/code16gcc.h
2278 @@ -0,0 +1,9 @@
2279 +/*
2280 + * code16gcc.h
2281 + *
2282 + * This file is -include'd when compiling 16-bit C code.
2283 + */
2284 +
2285 +#ifndef __ASSEMBLY__
2286 +asm(".code16gcc");
2287 +#endif
2288 --- a/arch/i386/boot/compressed/Makefile
2289 +++ b/arch/i386/boot/compressed/Makefile
2290 @@ -9,9 +9,14 @@
2291 EXTRA_AFLAGS := -traditional
2292
2293 LDFLAGS_vmlinux := -T
2294 -CFLAGS_misc.o += -fPIC
2295 hostprogs-y := relocs
2296
2297 +CFLAGS := -m32 -D__KERNEL__ $(LINUX_INCLUDE) -O2 \
2298 + -fno-strict-aliasing -fPIC \
2299 + $(call cc-option,-ffreestanding) \
2300 + $(call cc-option,-fno-stack-protector)
2301 +LDFLAGS := -m elf_i386
2302 +
2303 $(obj)/vmlinux: $(src)/vmlinux.lds $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE
2304 $(call if_changed,ld)
2305 @:
2306 --- a/arch/i386/boot/compressed/head.S
2307 +++ b/arch/i386/boot/compressed/head.S
2308 @@ -45,10 +45,10 @@
2309 * at and where we were actually loaded at. This can only be done
2310 * with a short local call on x86. Nothing else will tell us what
2311 * address we are running at. The reserved chunk of the real-mode
2312 - * data at 0x34-0x3f are used as the stack for this calculation.
2313 - * Only 4 bytes are needed.
2314 + * data at 0x1e4 (defined as a scratch field) are used as the stack
2315 + * for this calculation. Only 4 bytes are needed.
2316 */
2317 - leal 0x40(%esi), %esp
2318 + leal (0x1e4+4)(%esi), %esp
2319 call 1f
2320 1: popl %ebp
2321 subl $1b, %ebp
2322 --- a/arch/i386/boot/compressed/misc.c
2323 +++ b/arch/i386/boot/compressed/misc.c
2324 @@ -11,7 +11,6 @@
2325
2326 #undef CONFIG_PARAVIRT
2327 #include <linux/linkage.h>
2328 -#include <linux/vmalloc.h>
2329 #include <linux/screen_info.h>
2330 #include <asm/io.h>
2331 #include <asm/page.h>
2332 @@ -364,8 +363,10 @@
2333
2334 if ((u32)output & (CONFIG_PHYSICAL_ALIGN -1))
2335 error("Destination address not CONFIG_PHYSICAL_ALIGN aligned");
2336 +#ifndef CONFIG_X86_64
2337 if (end > ((-__PAGE_OFFSET-(512 <<20)-1) & 0x7fffffff))
2338 error("Destination address too large");
2339 +#endif
2340 #ifndef CONFIG_RELOCATABLE
2341 if ((u32)output != LOAD_PHYSICAL_ADDR)
2342 error("Wrong destination address");
2343 --- /dev/null
2344 +++ b/arch/i386/boot/copy.S
2345 @@ -0,0 +1,101 @@
2346 +/* ----------------------------------------------------------------------- *
2347 + *
2348 + * Copyright (C) 1991, 1992 Linus Torvalds
2349 + * Copyright 2007 rPath, Inc. - All Rights Reserved
2350 + *
2351 + * This file is part of the Linux kernel, and is made available under
2352 + * the terms of the GNU General Public License version 2.
2353 + *
2354 + * ----------------------------------------------------------------------- */
2355 +
2356 +/*
2357 + * arch/i386/boot/copy.S
2358 + *
2359 + * Memory copy routines
2360 + */
2361 +
2362 + .code16gcc
2363 + .text
2364 +
2365 + .globl memcpy
2366 + .type memcpy, @function
2367 +memcpy:
2368 + pushw %si
2369 + pushw %di
2370 + movw %ax, %di
2371 + movw %dx, %si
2372 + pushw %cx
2373 + shrw $2, %cx
2374 + rep; movsl
2375 + popw %cx
2376 + andw $3, %cx
2377 + rep; movsb
2378 + popw %di
2379 + popw %si
2380 + ret
2381 + .size memcpy, .-memcpy
2382 +
2383 + .globl memset
2384 + .type memset, @function
2385 +memset:
2386 + pushw %di
2387 + movw %ax, %di
2388 + movzbl %dl, %eax
2389 + imull $0x01010101,%eax
2390 + pushw %cx
2391 + shrw $2, %cx
2392 + rep; stosl
2393 + popw %cx
2394 + andw $3, %cx
2395 + rep; stosb
2396 + popw %di
2397 + ret
2398 + .size memset, .-memset
2399 +
2400 + .globl copy_from_fs
2401 + .type copy_from_fs, @function
2402 +copy_from_fs:
2403 + pushw %ds
2404 + pushw %fs
2405 + popw %ds
2406 + call memcpy
2407 + popw %ds
2408 + ret
2409 + .size copy_from_fs, .-copy_from_fs
2410 +
2411 + .globl copy_to_fs
2412 + .type copy_to_fs, @function
2413 +copy_to_fs:
2414 + pushw %es
2415 + pushw %fs
2416 + popw %es
2417 + call memcpy
2418 + popw %es
2419 + ret
2420 + .size copy_to_fs, .-copy_to_fs
2421 +
2422 +#if 0 /* Not currently used, but can be enabled as needed */
2423 +
2424 + .globl copy_from_gs
2425 + .type copy_from_gs, @function
2426 +copy_from_gs:
2427 + pushw %ds
2428 + pushw %gs
2429 + popw %ds
2430 + call memcpy
2431 + popw %ds
2432 + ret
2433 + .size copy_from_gs, .-copy_from_gs
2434 + .globl copy_to_gs
2435 +
2436 + .type copy_to_gs, @function
2437 +copy_to_gs:
2438 + pushw %es
2439 + pushw %gs
2440 + popw %es
2441 + call memcpy
2442 + popw %es
2443 + ret
2444 + .size copy_to_gs, .-copy_to_gs
2445 +
2446 +#endif
2447 --- /dev/null
2448 +++ b/arch/i386/boot/cpu.c
2449 @@ -0,0 +1,69 @@
2450 +/* -*- linux-c -*- ------------------------------------------------------- *
2451 + *
2452 + * Copyright (C) 1991, 1992 Linus Torvalds
2453 + * Copyright 2007 rPath, Inc. - All Rights Reserved
2454 + *
2455 + * This file is part of the Linux kernel, and is made available under
2456 + * the terms of the GNU General Public License version 2.
2457 + *
2458 + * ----------------------------------------------------------------------- */
2459 +
2460 +/*
2461 + * arch/i386/boot/cpucheck.c
2462 + *
2463 + * Check for obligatory CPU features and abort if the features are not
2464 + * present.
2465 + */
2466 +
2467 +#include "boot.h"
2468 +#include "bitops.h"
2469 +#include <asm/cpufeature.h>
2470 +
2471 +static char *cpu_name(int level)
2472 +{
2473 + static char buf[6];
2474 +
2475 + if (level == 64) {
2476 + return "x86-64";
2477 + } else {
2478 + sprintf(buf, "i%d86", level);
2479 + return buf;
2480 + }
2481 +}
2482 +
2483 +int validate_cpu(void)
2484 +{
2485 + u32 *err_flags;
2486 + int cpu_level, req_level;
2487 +
2488 + check_cpu(&cpu_level, &req_level, &err_flags);
2489 +
2490 + if (cpu_level < req_level) {
2491 + printf("This kernel requires an %s CPU, ",
2492 + cpu_name(req_level));
2493 + printf("but only detected an %s CPU.\n",
2494 + cpu_name(cpu_level));
2495 + return -1;
2496 + }
2497 +
2498 + if (err_flags) {
2499 + int i, j;
2500 + puts("This kernel requires the following features "
2501 + "not present on the CPU:\n");
2502 +
2503 + for (i = 0; i < NCAPINTS; i++) {
2504 + u32 e = err_flags[i];
2505 +
2506 + for (j = 0; j < 32; j++) {
2507 + if (e & 1)
2508 + printf("%d:%d ", i, j);
2509 +
2510 + e >>= 1;
2511 + }
2512 + }
2513 + putchar('\n');
2514 + return -1;
2515 + } else {
2516 + return 0;
2517 + }
2518 +}
2519 --- /dev/null
2520 +++ b/arch/i386/boot/cpucheck.c
2521 @@ -0,0 +1,266 @@
2522 +/* -*- linux-c -*- ------------------------------------------------------- *
2523 + *
2524 + * Copyright (C) 1991, 1992 Linus Torvalds
2525 + * Copyright 2007 rPath, Inc. - All Rights Reserved
2526 + *
2527 + * This file is part of the Linux kernel, and is made available under
2528 + * the terms of the GNU General Public License version 2.
2529 + *
2530 + * ----------------------------------------------------------------------- */
2531 +
2532 +/*
2533 + * arch/i386/boot/cpu.c
2534 + *
2535 + * Check for obligatory CPU features and abort if the features are not
2536 + * present. This code should be compilable as 16-, 32- or 64-bit
2537 + * code, so be very careful with types and inline assembly.
2538 + *
2539 + * This code should not contain any messages; that requires an
2540 + * additional wrapper.
2541 + *
2542 + * As written, this code is not safe for inclusion into the kernel
2543 + * proper (after FPU initialization, in particular).
2544 + */
2545 +
2546 +#ifdef _SETUP
2547 +# include "boot.h"
2548 +# include "bitops.h"
2549 +#endif
2550 +#include <linux/types.h>
2551 +#include <asm/cpufeature.h>
2552 +#include <asm/processor-flags.h>
2553 +#include <asm/required-features.h>
2554 +#include <asm/msr-index.h>
2555 +
2556 +struct cpu_features {
2557 + int level;
2558 + int model;
2559 + u32 flags[NCAPINTS];
2560 +};
2561 +
2562 +static struct cpu_features cpu;
2563 +static u32 cpu_vendor[3];
2564 +static u32 err_flags[NCAPINTS];
2565 +
2566 +#ifdef CONFIG_X86_64
2567 +static const int req_level = 64;
2568 +#elif defined(CONFIG_X86_MINIMUM_CPU_MODEL)
2569 +static const int req_level = CONFIG_X86_MINIMUM_CPU_MODEL;
2570 +#else
2571 +static const int req_level = 3;
2572 +#endif
2573 +
2574 +static const u32 req_flags[NCAPINTS] =
2575 +{
2576 + REQUIRED_MASK0,
2577 + REQUIRED_MASK1,
2578 + REQUIRED_MASK2,
2579 + REQUIRED_MASK3,
2580 + REQUIRED_MASK4,
2581 + REQUIRED_MASK5,
2582 + REQUIRED_MASK6,
2583 +};
2584 +
2585 +#define A32(a,b,c,d) (((d) << 24)+((c) << 16)+((b) << 8)+(a))
2586 +
2587 +static int is_amd(void)
2588 +{
2589 + return cpu_vendor[0] == A32('A','u','t','h') &&
2590 + cpu_vendor[1] == A32('e','n','t','i') &&
2591 + cpu_vendor[2] == A32('c','A','M','D');
2592 +}
2593 +
2594 +static int is_centaur(void)
2595 +{
2596 + return cpu_vendor[0] == A32('C','e','n','t') &&
2597 + cpu_vendor[1] == A32('a','u','r','H') &&
2598 + cpu_vendor[2] == A32('a','u','l','s');
2599 +}
2600 +
2601 +static int is_transmeta(void)
2602 +{
2603 + return cpu_vendor[0] == A32('G','e','n','u') &&
2604 + cpu_vendor[1] == A32('i','n','e','T') &&
2605 + cpu_vendor[2] == A32('M','x','8','6');
2606 +}
2607 +
2608 +static int has_fpu(void)
2609 +{
2610 + u16 fcw = -1, fsw = -1;
2611 + u32 cr0;
2612 +
2613 + asm("movl %%cr0,%0" : "=r" (cr0));
2614 + if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
2615 + cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
2616 + asm volatile("movl %0,%%cr0" : : "r" (cr0));
2617 + }
2618 +
2619 + asm("fninit ; fnstsw %0 ; fnstcw %1" : "+m" (fsw), "+m" (fcw));
2620 +
2621 + return fsw == 0 && (fcw & 0x103f) == 0x003f;
2622 +}
2623 +
2624 +static int has_eflag(u32 mask)
2625 +{
2626 + u32 f0, f1;
2627 +
2628 + asm("pushfl ; "
2629 + "pushfl ; "
2630 + "popl %0 ; "
2631 + "movl %0,%1 ; "
2632 + "xorl %2,%1 ; "
2633 + "pushl %1 ; "
2634 + "popfl ; "
2635 + "pushfl ; "
2636 + "popl %1 ; "
2637 + "popfl"
2638 + : "=r" (f0), "=r" (f1)
2639 + : "g" (mask));
2640 +
2641 + return !!((f0^f1) & mask);
2642 +}
2643 +
2644 +static void get_flags(void)
2645 +{
2646 + u32 max_intel_level, max_amd_level;
2647 + u32 tfms;
2648 +
2649 + if (has_fpu())
2650 + set_bit(X86_FEATURE_FPU, cpu.flags);
2651 +
2652 + if (has_eflag(X86_EFLAGS_ID)) {
2653 + asm("cpuid"
2654 + : "=a" (max_intel_level),
2655 + "=b" (cpu_vendor[0]),
2656 + "=d" (cpu_vendor[1]),
2657 + "=c" (cpu_vendor[2])
2658 + : "a" (0));
2659 +
2660 + if (max_intel_level >= 0x00000001 &&
2661 + max_intel_level <= 0x0000ffff) {
2662 + asm("cpuid"
2663 + : "=a" (tfms),
2664 + "=c" (cpu.flags[4]),
2665 + "=d" (cpu.flags[0])
2666 + : "a" (0x00000001)
2667 + : "ebx");
2668 + cpu.level = (tfms >> 8) & 15;
2669 + cpu.model = (tfms >> 4) & 15;
2670 + if (cpu.level >= 6)
2671 + cpu.model += ((tfms >> 16) & 0xf) << 4;
2672 + }
2673 +
2674 + asm("cpuid"
2675 + : "=a" (max_amd_level)
2676 + : "a" (0x80000000)
2677 + : "ebx", "ecx", "edx");
2678 +
2679 + if (max_amd_level >= 0x80000001 &&
2680 + max_amd_level <= 0x8000ffff) {
2681 + u32 eax = 0x80000001;
2682 + asm("cpuid"
2683 + : "+a" (eax),
2684 + "=c" (cpu.flags[6]),
2685 + "=d" (cpu.flags[1])
2686 + : : "ebx");
2687 + }
2688 + }
2689 +}
2690 +
2691 +/* Returns a bitmask of which words we have error bits in */
2692 +static int check_flags(void)
2693 +{
2694 + u32 err;
2695 + int i;
2696 +
2697 + err = 0;
2698 + for (i = 0; i < NCAPINTS; i++) {
2699 + err_flags[i] = req_flags[i] & ~cpu.flags[i];
2700 + if (err_flags[i])
2701 + err |= 1 << i;
2702 + }
2703 +
2704 + return err;
2705 +}
2706 +
2707 +/*
2708 + * Returns -1 on error.
2709 + *
2710 + * *cpu_level is set to the current CPU level; *req_level to the required
2711 + * level. x86-64 is considered level 64 for this purpose.
2712 + *
2713 + * *err_flags_ptr is set to the flags error array if there are flags missing.
2714 + */
2715 +int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
2716 +{
2717 + int err;
2718 +
2719 + memset(&cpu.flags, 0, sizeof cpu.flags);
2720 + cpu.level = 3;
2721 +
2722 + if (has_eflag(X86_EFLAGS_AC))
2723 + cpu.level = 4;
2724 +
2725 + get_flags();
2726 + err = check_flags();
2727 +
2728 + if (test_bit(X86_FEATURE_LM, cpu.flags))
2729 + cpu.level = 64;
2730 +
2731 + if (err == 0x01 &&
2732 + !(err_flags[0] &
2733 + ~((1 << X86_FEATURE_XMM)|(1 << X86_FEATURE_XMM2))) &&
2734 + is_amd()) {
2735 + /* If this is an AMD and we're only missing SSE+SSE2, try to
2736 + turn them on */
2737 +
2738 + u32 ecx = MSR_K7_HWCR;
2739 + u32 eax, edx;
2740 +
2741 + asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
2742 + eax &= ~(1 << 15);
2743 + asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
2744 +
2745 + get_flags(); /* Make sure it really did something */
2746 + err = check_flags();
2747 + } else if (err == 0x01 &&
2748 + !(err_flags[0] & ~(1 << X86_FEATURE_CX8)) &&
2749 + is_centaur() && cpu.model >= 6) {
2750 + /* If this is a VIA C3, we might have to enable CX8
2751 + explicitly */
2752 +
2753 + u32 ecx = MSR_VIA_FCR;
2754 + u32 eax, edx;
2755 +
2756 + asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
2757 + eax |= (1<<1)|(1<<7);
2758 + asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
2759 +
2760 + set_bit(X86_FEATURE_CX8, cpu.flags);
2761 + err = check_flags();
2762 + } else if (err == 0x01 && is_transmeta()) {
2763 + /* Transmeta might have masked feature bits in word 0 */
2764 +
2765 + u32 ecx = 0x80860004;
2766 + u32 eax, edx;
2767 + u32 level = 1;
2768 +
2769 + asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
2770 + asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
2771 + asm("cpuid"
2772 + : "+a" (level), "=d" (cpu.flags[0])
2773 + : : "ecx", "ebx");
2774 + asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
2775 +
2776 + err = check_flags();
2777 + }
2778 +
2779 + if (err_flags_ptr)
2780 + *err_flags_ptr = err ? err_flags : NULL;
2781 + if (cpu_level_ptr)
2782 + *cpu_level_ptr = cpu.level;
2783 + if (req_level_ptr)
2784 + *req_level_ptr = req_level;
2785 +
2786 + return (cpu.level < req_level || err) ? -1 : 0;
2787 +}
2788 --- a/arch/i386/boot/edd.S
2789 +++ /dev/null
2790 @@ -1,231 +0,0 @@
2791 -/*
2792 - * BIOS Enhanced Disk Drive support
2793 - * Copyright (C) 2002, 2003, 2004 Dell, Inc.
2794 - * by Matt Domsch <Matt_Domsch@dell.com> October 2002
2795 - * conformant to T13 Committee www.t13.org
2796 - * projects 1572D, 1484D, 1386D, 1226DT
2797 - * disk signature read by Matt Domsch <Matt_Domsch@dell.com>
2798 - * and Andrew Wilks <Andrew_Wilks@dell.com> September 2003, June 2004
2799 - * legacy CHS retrieval by Patrick J. LoPresti <patl@users.sourceforge.net>
2800 - * March 2004
2801 - * Command line option parsing, Matt Domsch, November 2004
2802 - */
2803 -
2804 -#include <linux/edd.h>
2805 -#include <asm/setup.h>
2806 -
2807 -#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
2808 -
2809 -# It is assumed that %ds == INITSEG here
2810 -
2811 - movb $0, (EDD_MBR_SIG_NR_BUF)
2812 - movb $0, (EDDNR)
2813 -
2814 -# Check the command line for options:
2815 -# edd=of disables EDD completely (edd=off)
2816 -# edd=sk skips the MBR test (edd=skipmbr)
2817 -# edd=on re-enables EDD (edd=on)
2818 -
2819 - pushl %esi
2820 - movw $edd_mbr_sig_start, %di # Default to edd=on
2821 -
2822 - movl %cs:(cmd_line_ptr), %esi
2823 - andl %esi, %esi
2824 - jz old_cl # Old boot protocol?
2825 -
2826 -# Convert to a real-mode pointer in fs:si
2827 - movl %esi, %eax
2828 - shrl $4, %eax
2829 - movw %ax, %fs
2830 - andw $0xf, %si
2831 - jmp have_cl_pointer
2832 -
2833 -# Old-style boot protocol?
2834 -old_cl:
2835 - push %ds # aka INITSEG
2836 - pop %fs
2837 -
2838 - cmpw $0xa33f, (0x20)
2839 - jne done_cl # No command line at all?
2840 - movw (0x22), %si # Pointer relative to INITSEG
2841 -
2842 -# fs:si has the pointer to the command line now
2843 -have_cl_pointer:
2844 -
2845 -# Loop through kernel command line one byte at a time. Just in
2846 -# case the loader is buggy and failed to null-terminate the command line
2847 -# terminate if we get close enough to the end of the segment that we
2848 -# cannot fit "edd=XX"...
2849 -cl_atspace:
2850 - cmpw $-5, %si # Watch for segment wraparound
2851 - jae done_cl
2852 - movl %fs:(%si), %eax
2853 - andb %al, %al # End of line?
2854 - jz done_cl
2855 - cmpl $EDD_CL_EQUALS, %eax
2856 - jz found_edd_equals
2857 - cmpb $0x20, %al # <= space consider whitespace
2858 - ja cl_skipword
2859 - incw %si
2860 - jmp cl_atspace
2861 -
2862 -cl_skipword:
2863 - cmpw $-5, %si # Watch for segment wraparound
2864 - jae done_cl
2865 - movb %fs:(%si), %al # End of string?
2866 - andb %al, %al
2867 - jz done_cl
2868 - cmpb $0x20, %al
2869 - jbe cl_atspace
2870 - incw %si
2871 - jmp cl_skipword
2872 -
2873 -found_edd_equals:
2874 -# only looking at first two characters after equals
2875 -# late overrides early on the command line, so keep going after finding something
2876 - movw %fs:4(%si), %ax
2877 - cmpw $EDD_CL_OFF, %ax # edd=of
2878 - je do_edd_off
2879 - cmpw $EDD_CL_SKIP, %ax # edd=sk
2880 - je do_edd_skipmbr
2881 - cmpw $EDD_CL_ON, %ax # edd=on
2882 - je do_edd_on
2883 - jmp cl_skipword
2884 -do_edd_skipmbr:
2885 - movw $edd_start, %di
2886 - jmp cl_skipword
2887 -do_edd_off:
2888 - movw $edd_done, %di
2889 - jmp cl_skipword
2890 -do_edd_on:
2891 - movw $edd_mbr_sig_start, %di
2892 - jmp cl_skipword
2893 -
2894 -done_cl:
2895 - popl %esi
2896 - jmpw *%di
2897 -
2898 -# Read the first sector of each BIOS disk device and store the 4-byte signature
2899 -edd_mbr_sig_start:
2900 - movb $0x80, %dl # from device 80
2901 - movw $EDD_MBR_SIG_BUF, %bx # store buffer ptr in bx
2902 -edd_mbr_sig_read:
2903 - movl $0xFFFFFFFF, %eax
2904 - movl %eax, (%bx) # assume failure
2905 - pushw %bx
2906 - movb $READ_SECTORS, %ah
2907 - movb $1, %al # read 1 sector
2908 - movb $0, %dh # at head 0
2909 - movw $1, %cx # cylinder 0, sector 0
2910 - pushw %es
2911 - pushw %ds
2912 - popw %es
2913 - movw $EDDBUF, %bx # disk's data goes into EDDBUF
2914 - pushw %dx # work around buggy BIOSes
2915 - stc # work around buggy BIOSes
2916 - int $0x13
2917 - sti # work around buggy BIOSes
2918 - popw %dx
2919 - popw %es
2920 - popw %bx
2921 - jc edd_mbr_sig_done # on failure, we're done.
2922 - cmpb $0, %ah # some BIOSes do not set CF
2923 - jne edd_mbr_sig_done # on failure, we're done.
2924 - movl (EDDBUF+EDD_MBR_SIG_OFFSET), %eax # read sig out of the MBR
2925 - movl %eax, (%bx) # store success
2926 - incb (EDD_MBR_SIG_NR_BUF) # note that we stored something
2927 - incb %dl # increment to next device
2928 - addw $4, %bx # increment sig buffer ptr
2929 - cmpb $EDD_MBR_SIG_MAX, (EDD_MBR_SIG_NR_BUF) # Out of space?
2930 - jb edd_mbr_sig_read # keep looping
2931 -edd_mbr_sig_done:
2932 -
2933 -# Do the BIOS Enhanced Disk Drive calls
2934 -# This consists of two calls:
2935 -# int 13h ah=41h "Check Extensions Present"
2936 -# int 13h ah=48h "Get Device Parameters"
2937 -# int 13h ah=08h "Legacy Get Device Parameters"
2938 -#
2939 -# A buffer of size EDDMAXNR*(EDDEXTSIZE+EDDPARMSIZE) is reserved for our use
2940 -# in the boot_params at EDDBUF. The first four bytes of which are
2941 -# used to store the device number, interface support map and version
2942 -# results from fn41. The next four bytes are used to store the legacy
2943 -# cylinders, heads, and sectors from fn08. The following 74 bytes are used to
2944 -# store the results from fn48. Starting from device 80h, fn41, then fn48
2945 -# are called and their results stored in EDDBUF+n*(EDDEXTSIZE+EDDPARMIZE).
2946 -# Then the pointer is incremented to store the data for the next call.
2947 -# This repeats until either a device doesn't exist, or until EDDMAXNR
2948 -# devices have been stored.
2949 -# The one tricky part is that ds:si always points EDDEXTSIZE bytes into
2950 -# the structure, and the fn41 and fn08 results are stored at offsets
2951 -# from there. This removes the need to increment the pointer for
2952 -# every store, and leaves it ready for the fn48 call.
2953 -# A second one-byte buffer, EDDNR, in the boot_params stores
2954 -# the number of BIOS devices which exist, up to EDDMAXNR.
2955 -# In setup.c, copy_edd() stores both boot_params buffers away
2956 -# for later use, as they would get overwritten otherwise.
2957 -# This code is sensitive to the size of the structs in edd.h
2958 -edd_start:
2959 - # %ds points to the bootsector
2960 - # result buffer for fn48
2961 - movw $EDDBUF+EDDEXTSIZE, %si # in ds:si, fn41 results
2962 - # kept just before that
2963 - movb $0x80, %dl # BIOS device 0x80
2964 -
2965 -edd_check_ext:
2966 - movb $CHECKEXTENSIONSPRESENT, %ah # Function 41
2967 - movw $EDDMAGIC1, %bx # magic
2968 - int $0x13 # make the call
2969 - jc edd_done # no more BIOS devices
2970 -
2971 - cmpw $EDDMAGIC2, %bx # is magic right?
2972 - jne edd_next # nope, next...
2973 -
2974 - movb %dl, %ds:-8(%si) # store device number
2975 - movb %ah, %ds:-7(%si) # store version
2976 - movw %cx, %ds:-6(%si) # store extensions
2977 - incb (EDDNR) # note that we stored something
2978 -
2979 -edd_get_device_params:
2980 - movw $EDDPARMSIZE, %ds:(%si) # put size
2981 - movw $0x0, %ds:2(%si) # work around buggy BIOSes
2982 - movb $GETDEVICEPARAMETERS, %ah # Function 48
2983 - int $0x13 # make the call
2984 - # Don't check for fail return
2985 - # it doesn't matter.
2986 -edd_get_legacy_chs:
2987 - xorw %ax, %ax
2988 - movw %ax, %ds:-4(%si)
2989 - movw %ax, %ds:-2(%si)
2990 - # Ralf Brown's Interrupt List says to set ES:DI to
2991 - # 0000h:0000h "to guard against BIOS bugs"
2992 - pushw %es
2993 - movw %ax, %es
2994 - movw %ax, %di
2995 - pushw %dx # legacy call clobbers %dl
2996 - movb $LEGACYGETDEVICEPARAMETERS, %ah # Function 08
2997 - int $0x13 # make the call
2998 - jc edd_legacy_done # failed
2999 - movb %cl, %al # Low 6 bits are max
3000 - andb $0x3F, %al # sector number
3001 - movb %al, %ds:-1(%si) # Record max sect
3002 - movb %dh, %ds:-2(%si) # Record max head number
3003 - movb %ch, %al # Low 8 bits of max cyl
3004 - shr $6, %cl
3005 - movb %cl, %ah # High 2 bits of max cyl
3006 - movw %ax, %ds:-4(%si)
3007 -
3008 -edd_legacy_done:
3009 - popw %dx
3010 - popw %es
3011 - movw %si, %ax # increment si
3012 - addw $EDDPARMSIZE+EDDEXTSIZE, %ax
3013 - movw %ax, %si
3014 -
3015 -edd_next:
3016 - incb %dl # increment to next device
3017 - cmpb $EDDMAXNR, (EDDNR) # Out of space?
3018 - jb edd_check_ext # keep looping
3019 -
3020 -edd_done:
3021 -#endif
3022 --- /dev/null
3023 +++ b/arch/i386/boot/edd.c
3024 @@ -0,0 +1,196 @@
3025 +/* -*- linux-c -*- ------------------------------------------------------- *
3026 + *
3027 + * Copyright (C) 1991, 1992 Linus Torvalds
3028 + * Copyright 2007 rPath, Inc. - All Rights Reserved
3029 + *
3030 + * This file is part of the Linux kernel, and is made available under
3031 + * the terms of the GNU General Public License version 2.
3032 + *
3033 + * ----------------------------------------------------------------------- */
3034 +
3035 +/*
3036 + * arch/i386/boot/edd.c
3037 + *
3038 + * Get EDD BIOS disk information
3039 + */
3040 +
3041 +#include "boot.h"
3042 +#include <linux/edd.h>
3043 +
3044 +#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
3045 +
3046 +struct edd_dapa {
3047 + u8 pkt_size;
3048 + u8 rsvd;
3049 + u16 sector_cnt;
3050 + u16 buf_off, buf_seg;
3051 + u64 lba;
3052 + u64 buf_lin_addr;
3053 +};
3054 +
3055 +/*
3056 + * Note: this uses the heap to hold the loaded sector.
3057 + */
3058 +static int read_sector(u8 devno, u64 lba, void *buf)
3059 +{
3060 + struct edd_dapa dapa;
3061 + u16 ax, bx, cx, dx, si;
3062 +
3063 + memset(&dapa, 0, sizeof dapa);
3064 + dapa.pkt_size = sizeof(dapa);
3065 + dapa.sector_cnt = 1;
3066 + dapa.buf_off = (size_t)buf;
3067 + dapa.buf_seg = ds();
3068 + dapa.lba = lba;
3069 +
3070 + ax = 0x4200; /* Extended Read */
3071 + si = (size_t)&dapa;
3072 + dx = devno;
3073 + asm("pushfl; stc; int $0x13; setc %%al; popfl"
3074 + : "+a" (ax), "+S" (si), "+d" (dx)
3075 + : "m" (dapa)
3076 + : "ebx", "ecx", "edi", "memory");
3077 +
3078 + if (!(u8)ax)
3079 + return 0; /* OK */
3080 +
3081 + ax = 0x0201; /* Legacy Read, one sector */
3082 + cx = 0x0001; /* Sector 0-0-1 */
3083 + dx = devno;
3084 + bx = (size_t)buf;
3085 + asm("pushfl; stc; int $0x13; setc %%al; popfl"
3086 + : "+a" (ax), "+c" (cx), "+d" (dx), "+b" (bx)
3087 + : : "esi", "edi", "memory");
3088 +
3089 + return -(u8)ax; /* 0 or -1 */
3090 +}
3091 +
3092 +static u32 read_mbr_sig(u8 devno, struct edd_info *ei)
3093 +{
3094 + int sector_size;
3095 + char *mbrbuf_ptr, *mbrbuf_end;
3096 + u32 mbrsig;
3097 + u32 buf_base, mbr_base;
3098 + extern char _end[];
3099 + static char mbr_buf[1024];
3100 +
3101 + sector_size = ei->params.bytes_per_sector;
3102 + if (!sector_size)
3103 + sector_size = 512; /* Best available guess */
3104 +
3105 + buf_base = (ds() << 4) + (u32)&_end;
3106 + mbr_base = (buf_base+sector_size-1) & ~(sector_size-1);
3107 + mbrbuf_ptr = mbr_buf + (mbr_base-buf_base);
3108 + mbrbuf_end = mbrbuf_ptr + sector_size;
3109 +
3110 + if (!(boot_params.hdr.loadflags & CAN_USE_HEAP))
3111 + return 0;
3112 + if (mbrbuf_end > (char *)(size_t)boot_params.hdr.heap_end_ptr)
3113 + return 0;
3114 +
3115 + if (read_sector(devno, 0, mbrbuf_ptr))
3116 + return 0;
3117 +
3118 + mbrsig = *(u32 *)&mbrbuf_ptr[EDD_MBR_SIG_OFFSET];
3119 + return mbrsig;
3120 +}
3121 +
3122 +static int get_edd_info(u8 devno, struct edd_info *ei)
3123 +{
3124 + u16 ax, bx, cx, dx, di;
3125 +
3126 + memset(ei, 0, sizeof *ei);
3127 +
3128 + /* Check Extensions Present */
3129 +
3130 + ax = 0x4100;
3131 + bx = EDDMAGIC1;
3132 + dx = devno;
3133 + asm("pushfl; stc; int $0x13; setc %%al; popfl"
3134 + : "+a" (ax), "+b" (bx), "=c" (cx), "+d" (dx)
3135 + : : "esi", "edi");
3136 +
3137 + if ((u8)ax)
3138 + return -1; /* No extended information */
3139 +
3140 + if (bx != EDDMAGIC2)
3141 + return -1;
3142 +
3143 + ei->device = devno;
3144 + ei->version = ax >> 8; /* EDD version number */
3145 + ei->interface_support = cx; /* EDD functionality subsets */
3146 +
3147 + /* Extended Get Device Parameters */
3148 +
3149 + ei->params.length = sizeof(ei->params);
3150 + ax = 0x4800;
3151 + dx = devno;
3152 + asm("pushfl; int $0x13; popfl"
3153 + : "+a" (ax), "+d" (dx)
3154 + : "S" (&ei->params)
3155 + : "ebx", "ecx", "edi");
3156 +
3157 + /* Get legacy CHS parameters */
3158 +
3159 + /* Ralf Brown recommends setting ES:DI to 0:0 */
3160 + ax = 0x0800;
3161 + dx = devno;
3162 + di = 0;
3163 + asm("pushw %%es; "
3164 + "movw %%di,%%es; "
3165 + "pushfl; stc; int $0x13; setc %%al; popfl; "
3166 + "popw %%es"
3167 + : "+a" (ax), "=b" (bx), "=c" (cx), "+d" (dx), "+D" (di)
3168 + : : "esi");
3169 +
3170 + if ((u8)ax == 0) {
3171 + ei->legacy_max_cylinder = (cx >> 8) + ((cx & 0xc0) << 2);
3172 + ei->legacy_max_head = dx >> 8;
3173 + ei->legacy_sectors_per_track = cx & 0x3f;
3174 + }
3175 +
3176 + return 0;
3177 +}
3178 +
3179 +void query_edd(void)
3180 +{
3181 + char eddarg[8];
3182 + int do_mbr = 1;
3183 + int do_edd = 1;
3184 + int devno;
3185 + struct edd_info ei, *edp;
3186 +
3187 + if (cmdline_find_option("edd", eddarg, sizeof eddarg) > 0) {
3188 + if (!strcmp(eddarg, "skipmbr") || !strcmp(eddarg, "skip"))
3189 + do_mbr = 0;
3190 + else if (!strcmp(eddarg, "off"))
3191 + do_edd = 0;
3192 + }
3193 +
3194 + edp = (struct edd_info *)boot_params.eddbuf;
3195 +
3196 + if (!do_edd)
3197 + return;
3198 +
3199 + for (devno = 0x80; devno < 0x80+EDD_MBR_SIG_MAX; devno++) {
3200 + /*
3201 + * Scan the BIOS-supported hard disks and query EDD
3202 + * information...
3203 + */
3204 + get_edd_info(devno, &ei);
3205 +
3206 + if (boot_params.eddbuf_entries < EDDMAXNR) {
3207 + memcpy(edp, &ei, sizeof ei);
3208 + edp++;
3209 + boot_params.eddbuf_entries++;
3210 + }
3211 +
3212 + if (do_mbr) {
3213 + u32 mbr_sig;
3214 + mbr_sig = read_mbr_sig(devno, &ei);
3215 + boot_params.edd_mbr_sig_buffer[devno-0x80] = mbr_sig;
3216 + }
3217 + }
3218 +}
3219 +
3220 +#endif
3221 --- /dev/null
3222 +++ b/arch/i386/boot/header.S
3223 @@ -0,0 +1,283 @@
3224 +/*
3225 + * header.S
3226 + *
3227 + * Copyright (C) 1991, 1992 Linus Torvalds
3228 + *
3229 + * Based on bootsect.S and setup.S
3230 + * modified by more people than can be counted
3231 + *
3232 + * Rewritten as a common file by H. Peter Anvin (Apr 2007)
3233 + *
3234 + * BIG FAT NOTE: We're in real mode using 64k segments. Therefore segment
3235 + * addresses must be multiplied by 16 to obtain their respective linear
3236 + * addresses. To avoid confusion, linear addresses are written using leading
3237 + * hex while segment addresses are written as segment:offset.
3238 + *
3239 + */
3240 +
3241 +#include <asm/segment.h>
3242 +#include <linux/utsrelease.h>
3243 +#include <asm/boot.h>
3244 +#include <asm/e820.h>
3245 +#include <asm/page.h>
3246 +#include <asm/setup.h>
3247 +#include "boot.h"
3248 +
3249 +SETUPSECTS = 4 /* default nr of setup-sectors */
3250 +BOOTSEG = 0x07C0 /* original address of boot-sector */
3251 +SYSSEG = DEF_SYSSEG /* system loaded at 0x10000 (65536) */
3252 +SYSSIZE = DEF_SYSSIZE /* system size: # of 16-byte clicks */
3253 + /* to be loaded */
3254 +ROOT_DEV = 0 /* ROOT_DEV is now written by "build" */
3255 +SWAP_DEV = 0 /* SWAP_DEV is now written by "build" */
3256 +
3257 +#ifndef SVGA_MODE
3258 +#define SVGA_MODE ASK_VGA
3259 +#endif
3260 +
3261 +#ifndef RAMDISK
3262 +#define RAMDISK 0
3263 +#endif
3264 +
3265 +#ifndef ROOT_RDONLY
3266 +#define ROOT_RDONLY 1
3267 +#endif
3268 +
3269 + .code16
3270 + .section ".bstext", "ax"
3271 +
3272 + .global bootsect_start
3273 +bootsect_start:
3274 +
3275 + # Normalize the start address
3276 + ljmp $BOOTSEG, $start2
3277 +
3278 +start2:
3279 + movw %cs, %ax
3280 + movw %ax, %ds
3281 + movw %ax, %es
3282 + movw %ax, %ss
3283 + xorw %sp, %sp
3284 + sti
3285 + cld
3286 +
3287 + movw $bugger_off_msg, %si
3288 +
3289 +msg_loop:
3290 + lodsb
3291 + andb %al, %al
3292 + jz bs_die
3293 + movb $0xe, %ah
3294 + movw $7, %bx
3295 + int $0x10
3296 + jmp msg_loop
3297 +
3298 +bs_die:
3299 + # Allow the user to press a key, then reboot
3300 + xorw %ax, %ax
3301 + int $0x16
3302 + int $0x19
3303 +
3304 + # int 0x19 should never return. In case it does anyway,
3305 + # invoke the BIOS reset code...
3306 + ljmp $0xf000,$0xfff0
3307 +
3308 + .section ".bsdata", "a"
3309 +bugger_off_msg:
3310 + .ascii "Direct booting from floppy is no longer supported.\r\n"
3311 + .ascii "Please use a boot loader program instead.\r\n"
3312 + .ascii "\n"
3313 + .ascii "Remove disk and press any key to reboot . . .\r\n"
3314 + .byte 0
3315 +
3316 +
3317 + # Kernel attributes; used by setup. This is part 1 of the
3318 + # header, from the old boot sector.
3319 +
3320 + .section ".header", "a"
3321 + .globl hdr
3322 +hdr:
3323 +setup_sects: .byte SETUPSECTS
3324 +root_flags: .word ROOT_RDONLY
3325 +syssize: .long SYSSIZE
3326 +ram_size: .word RAMDISK
3327 +vid_mode: .word SVGA_MODE
3328 +root_dev: .word ROOT_DEV
3329 +boot_flag: .word 0xAA55
3330 +
3331 + # offset 512, entry point
3332 +
3333 + .globl _start
3334 +_start:
3335 + # Explicitly enter this as bytes, or the assembler
3336 + # tries to generate a 3-byte jump here, which causes
3337 + # everything else to push off to the wrong offset.
3338 + .byte 0xeb # short (2-byte) jump
3339 + .byte start_of_setup-1f
3340 +1:
3341 +
3342 + # Part 2 of the header, from the old setup.S
3343 +
3344 + .ascii "HdrS" # header signature
3345 + .word 0x0206 # header version number (>= 0x0105)
3346 + # or else old loadlin-1.5 will fail)
3347 + .globl realmode_swtch
3348 +realmode_swtch: .word 0, 0 # default_switch, SETUPSEG
3349 +start_sys_seg: .word SYSSEG
3350 + .word kernel_version-512 # pointing to kernel version string
3351 + # above section of header is compatible
3352 + # with loadlin-1.5 (header v1.5). Don't
3353 + # change it.
3354 +
3355 +type_of_loader: .byte 0 # = 0, old one (LILO, Loadlin,
3356 + # Bootlin, SYSLX, bootsect...)
3357 + # See Documentation/i386/boot.txt for
3358 + # assigned ids
3359 +
3360 +# flags, unused bits must be zero (RFU) bit within loadflags
3361 +loadflags:
3362 +LOADED_HIGH = 1 # If set, the kernel is loaded high
3363 +CAN_USE_HEAP = 0x80 # If set, the loader also has set
3364 + # heap_end_ptr to tell how much
3365 + # space behind setup.S can be used for
3366 + # heap purposes.
3367 + # Only the loader knows what is free
3368 +#ifndef __BIG_KERNEL__
3369 + .byte 0
3370 +#else
3371 + .byte LOADED_HIGH
3372 +#endif
3373 +
3374 +setup_move_size: .word 0x8000 # size to move, when setup is not
3375 + # loaded at 0x90000. We will move setup
3376 + # to 0x90000 then just before jumping
3377 + # into the kernel. However, only the
3378 + # loader knows how much data behind
3379 + # us also needs to be loaded.
3380 +
3381 +code32_start: # here loaders can put a different
3382 + # start address for 32-bit code.
3383 +#ifndef __BIG_KERNEL__
3384 + .long 0x1000 # 0x1000 = default for zImage
3385 +#else
3386 + .long 0x100000 # 0x100000 = default for big kernel
3387 +#endif
3388 +
3389 +ramdisk_image: .long 0 # address of loaded ramdisk image
3390 + # Here the loader puts the 32-bit
3391 + # address where it loaded the image.
3392 + # This only will be read by the kernel.
3393 +
3394 +ramdisk_size: .long 0 # its size in bytes
3395 +
3396 +bootsect_kludge:
3397 + .long 0 # obsolete
3398 +
3399 +heap_end_ptr: .word _end+1024 # (Header version 0x0201 or later)
3400 + # space from here (exclusive) down to
3401 + # end of setup code can be used by setup
3402 + # for local heap purposes.
3403 +
3404 +pad1: .word 0
3405 +cmd_line_ptr: .long 0 # (Header version 0x0202 or later)
3406 + # If nonzero, a 32-bit pointer
3407 + # to the kernel command line.
3408 + # The command line should be
3409 + # located between the start of
3410 + # setup and the end of low
3411 + # memory (0xa0000), or it may
3412 + # get overwritten before it
3413 + # gets read. If this field is
3414 + # used, there is no longer
3415 + # anything magical about the
3416 + # 0x90000 segment; the setup
3417 + # can be located anywhere in
3418 + # low memory 0x10000 or higher.
3419 +
3420 +ramdisk_max: .long (-__PAGE_OFFSET-(512 << 20)-1) & 0x7fffffff
3421 + # (Header version 0x0203 or later)
3422 + # The highest safe address for
3423 + # the contents of an initrd
3424 +
3425 +kernel_alignment: .long CONFIG_PHYSICAL_ALIGN #physical addr alignment
3426 + #required for protected mode
3427 + #kernel
3428 +#ifdef CONFIG_RELOCATABLE
3429 +relocatable_kernel: .byte 1
3430 +#else
3431 +relocatable_kernel: .byte 0
3432 +#endif
3433 +pad2: .byte 0
3434 +pad3: .word 0
3435 +
3436 +cmdline_size: .long COMMAND_LINE_SIZE-1 #length of the command line,
3437 + #added with boot protocol
3438 + #version 2.06
3439 +
3440 +# End of setup header #####################################################
3441 +
3442 + .section ".inittext", "ax"
3443 +start_of_setup:
3444 +#ifdef SAFE_RESET_DISK_CONTROLLER
3445 +# Reset the disk controller.
3446 + movw $0x0000, %ax # Reset disk controller
3447 + movb $0x80, %dl # All disks
3448 + int $0x13
3449 +#endif
3450 +
3451 +# We will have entired with %cs = %ds+0x20, normalize %cs so
3452 +# it is on par with the other segments.
3453 + pushw %ds
3454 + pushw $setup2
3455 + lretw
3456 +
3457 +setup2:
3458 +# Force %es = %ds
3459 + movw %ds, %ax
3460 + movw %ax, %es
3461 + cld
3462 +
3463 +# Stack paranoia: align the stack and make sure it is good
3464 +# for both 16- and 32-bit references. In particular, if we
3465 +# were meant to have been using the full 16-bit segment, the
3466 +# caller might have set %sp to zero, which breaks %esp-based
3467 +# references.
3468 + andw $~3, %sp # dword align (might as well...)
3469 + jnz 1f
3470 + movw $0xfffc, %sp # Make sure we're not zero
3471 +1: movzwl %sp, %esp # Clear upper half of %esp
3472 + sti
3473 +
3474 +# Check signature at end of setup
3475 + cmpl $0x5a5aaa55, setup_sig
3476 + jne setup_bad
3477 +
3478 +# Zero the bss
3479 + movw $__bss_start, %di
3480 + movw $_end+3, %cx
3481 + xorl %eax, %eax
3482 + subw %di, %cx
3483 + shrw $2, %cx
3484 + rep; stosl
3485 +
3486 +# Jump to C code (should not return)
3487 + calll main
3488 +
3489 +# Setup corrupt somehow...
3490 +setup_bad:
3491 + movl $setup_corrupt, %eax
3492 + calll puts
3493 + # Fall through...
3494 +
3495 + .globl die
3496 + .type die, @function
3497 +die:
3498 + hlt
3499 + jmp die
3500 +
3501 + .size die, .-due
3502 +
3503 + .section ".initdata", "a"
3504 +setup_corrupt:
3505 + .byte 7
3506 + .string "No setup signature found..."
3507 --- /dev/null
3508 +++ b/arch/i386/boot/main.c
3509 @@ -0,0 +1,161 @@
3510 +/* -*- linux-c -*- ------------------------------------------------------- *
3511 + *
3512 + * Copyright (C) 1991, 1992 Linus Torvalds
3513 + * Copyright 2007 rPath, Inc. - All Rights Reserved
3514 + *
3515 + * This file is part of the Linux kernel, and is made available under
3516 + * the terms of the GNU General Public License version 2.
3517 + *
3518 + * ----------------------------------------------------------------------- */
3519 +
3520 +/*
3521 + * arch/i386/boot/main.c
3522 + *
3523 + * Main module for the real-mode kernel code
3524 + */
3525 +
3526 +#include "boot.h"
3527 +
3528 +struct boot_params boot_params __attribute__((aligned(16)));
3529 +
3530 +char *HEAP = _end;
3531 +char *heap_end = _end; /* Default end of heap = no heap */
3532 +
3533 +/*
3534 + * Copy the header into the boot parameter block. Since this
3535 + * screws up the old-style command line protocol, adjust by
3536 + * filling in the new-style command line pointer instead.
3537 + */
3538 +#define OLD_CL_MAGIC 0xA33F
3539 +#define OLD_CL_ADDRESS 0x20
3540 +
3541 +static void copy_boot_params(void)
3542 +{
3543 + struct old_cmdline {
3544 + u16 cl_magic;
3545 + u16 cl_offset;
3546 + };
3547 + const struct old_cmdline * const oldcmd =
3548 + (const struct old_cmdline *)OLD_CL_ADDRESS;
3549 +
3550 + BUILD_BUG_ON(sizeof boot_params != 4096);
3551 + memcpy(&boot_params.hdr, &hdr, sizeof hdr);
3552 +
3553 + if (!boot_params.hdr.cmd_line_ptr &&
3554 + oldcmd->cl_magic == OLD_CL_MAGIC) {
3555 + /* Old-style command line protocol. */
3556 + u16 cmdline_seg;
3557 +
3558 + /* Figure out if the command line falls in the region
3559 + of memory that an old kernel would have copied up
3560 + to 0x90000... */
3561 + if (oldcmd->cl_offset < boot_params.hdr.setup_move_size)
3562 + cmdline_seg = ds();
3563 + else
3564 + cmdline_seg = 0x9000;
3565 +
3566 + boot_params.hdr.cmd_line_ptr =
3567 + (cmdline_seg << 4) + oldcmd->cl_offset;
3568 + }
3569 +}
3570 +
3571 +/*
3572 + * Set the keyboard repeat rate to maximum. Unclear why this
3573 + * is done here; this might be possible to kill off as stale code.
3574 + */
3575 +static void keyboard_set_repeat(void)
3576 +{
3577 + u16 ax = 0x0305;
3578 + u16 bx = 0;
3579 + asm volatile("int $0x16"
3580 + : "+a" (ax), "+b" (bx)
3581 + : : "ecx", "edx", "esi", "edi");
3582 +}
3583 +
3584 +/*
3585 + * Get Intel SpeedStep IST information.
3586 + */
3587 +static void query_speedstep_ist(void)
3588 +{
3589 + asm("int $0x15"
3590 + : "=a" (boot_params.speedstep_info[0]),
3591 + "=b" (boot_params.speedstep_info[1]),
3592 + "=c" (boot_params.speedstep_info[2]),
3593 + "=d" (boot_params.speedstep_info[3])
3594 + : "a" (0x0000e980), /* IST Support */
3595 + "d" (0x47534943)); /* Request value */
3596 +}
3597 +
3598 +/*
3599 + * Tell the BIOS what CPU mode we intend to run in.
3600 + */
3601 +static void set_bios_mode(void)
3602 +{
3603 +#ifdef CONFIG_X86_64
3604 + u32 eax, ebx;
3605 +
3606 + eax = 0xec00;
3607 + ebx = 2;
3608 + asm volatile("int $0x15"
3609 + : "+a" (eax), "+b" (ebx)
3610 + : : "ecx", "edx", "esi", "edi");
3611 +#endif
3612 +}
3613 +
3614 +void main(void)
3615 +{
3616 + /* First, copy the boot header into the "zeropage" */
3617 + copy_boot_params();
3618 +
3619 + /* End of heap check */
3620 + if (boot_params.hdr.loadflags & CAN_USE_HEAP) {
3621 + heap_end = (char *)(boot_params.hdr.heap_end_ptr
3622 + +0x200-STACK_SIZE);
3623 + } else {
3624 + /* Boot protocol 2.00 only, no heap available */
3625 + puts("WARNING: Ancient bootloader, some functionality "
3626 + "may be limited!\n");
3627 + }
3628 +
3629 + /* Make sure we have all the proper CPU support */
3630 + if (validate_cpu()) {
3631 + puts("Unable to boot - please use a kernel appropriate "
3632 + "for your CPU.\n");
3633 + die();
3634 + }
3635 +
3636 + /* Tell the BIOS what CPU mode we intend to run in. */
3637 + set_bios_mode();
3638 +
3639 + /* Detect memory layout */
3640 + detect_memory();
3641 +
3642 + /* Set keyboard repeat rate (why?) */
3643 + keyboard_set_repeat();
3644 +
3645 + /* Set the video mode */
3646 + set_video();
3647 +
3648 + /* Query MCA information */
3649 + query_mca();
3650 +
3651 + /* Voyager */
3652 +#ifdef CONFIG_X86_VOYAGER
3653 + query_voyager();
3654 +#endif
3655 +
3656 + /* Query SpeedStep IST information */
3657 + query_speedstep_ist();
3658 +
3659 + /* Query APM information */
3660 +#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
3661 + query_apm_bios();
3662 +#endif
3663 +
3664 + /* Query EDD information */
3665 +#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
3666 + query_edd();
3667 +#endif
3668 + /* Do the last things and invoke protected mode */
3669 + go_to_protected_mode();
3670 +}
3671 --- /dev/null
3672 +++ b/arch/i386/boot/mca.c
3673 @@ -0,0 +1,43 @@
3674 +/* -*- linux-c -*- ------------------------------------------------------- *
3675 + *
3676 + * Copyright (C) 1991, 1992 Linus Torvalds
3677 + * Copyright 2007 rPath, Inc. - All Rights Reserved
3678 + *
3679 + * This file is part of the Linux kernel, and is made available under
3680 + * the terms of the GNU General Public License version 2.
3681 + *
3682 + * ----------------------------------------------------------------------- */
3683 +
3684 +/*
3685 + * arch/i386/boot/mca.c
3686 + *
3687 + * Get the MCA system description table
3688 + */
3689 +
3690 +#include "boot.h"
3691 +
3692 +int query_mca(void)
3693 +{
3694 + u8 err;
3695 + u16 es, bx, len;
3696 +
3697 + asm("pushw %%es ; "
3698 + "int $0x15 ; "
3699 + "setc %0 ; "
3700 + "movw %%es, %1 ; "
3701 + "popw %%es"
3702 + : "=acdSDm" (err), "=acdSDm" (es), "=b" (bx)
3703 + : "a" (0xc000));
3704 +
3705 + if (err)
3706 + return -1; /* No MCA present */
3707 +
3708 + set_fs(es);
3709 + len = rdfs16(bx);
3710 +
3711 + if (len > sizeof(boot_params.sys_desc_table))
3712 + len = sizeof(boot_params.sys_desc_table);
3713 +
3714 + copy_from_fs(&boot_params.sys_desc_table, bx, len);
3715 + return 0;
3716 +}
3717 --- /dev/null
3718 +++ b/arch/i386/boot/memory.c
3719 @@ -0,0 +1,99 @@
3720 +/* -*- linux-c -*- ------------------------------------------------------- *
3721 + *
3722 + * Copyright (C) 1991, 1992 Linus Torvalds
3723 + * Copyright 2007 rPath, Inc. - All Rights Reserved
3724 + *
3725 + * This file is part of the Linux kernel, and is made available under
3726 + * the terms of the GNU General Public License version 2.
3727 + *
3728 + * ----------------------------------------------------------------------- */
3729 +
3730 +/*
3731 + * arch/i386/boot/memory.c
3732 + *
3733 + * Memory detection code
3734 + */
3735 +
3736 +#include "boot.h"
3737 +
3738 +#define SMAP 0x534d4150 /* ASCII "SMAP" */
3739 +
3740 +static int detect_memory_e820(void)
3741 +{
3742 + u32 next = 0;
3743 + u32 size, id;
3744 + u8 err;
3745 + struct e820entry *desc = boot_params.e820_map;
3746 +
3747 + do {
3748 + size = sizeof(struct e820entry);
3749 + id = SMAP;
3750 + asm("int $0x15; setc %0"
3751 + : "=am" (err), "+b" (next), "+d" (id), "+c" (size),
3752 + "=m" (*desc)
3753 + : "D" (desc), "a" (0xe820));
3754 +
3755 + if (err || id != SMAP)
3756 + break;
3757 +
3758 + boot_params.e820_entries++;
3759 + desc++;
3760 + } while (next && boot_params.e820_entries < E820MAX);
3761 +
3762 + return boot_params.e820_entries;
3763 +}
3764 +
3765 +static int detect_memory_e801(void)
3766 +{
3767 + u16 ax, bx, cx, dx;
3768 + u8 err;
3769 +
3770 + bx = cx = dx = 0;
3771 + ax = 0xe801;
3772 + asm("stc; int $0x15; setc %0"
3773 + : "=m" (err), "+a" (ax), "+b" (bx), "+c" (cx), "+d" (dx));
3774 +
3775 + if (err)
3776 + return -1;
3777 +
3778 + /* Do we really need to do this? */
3779 + if (cx || dx) {
3780 + ax = cx;
3781 + bx = dx;
3782 + }
3783 +
3784 + if (ax > 15*1024)
3785 + return -1; /* Bogus! */
3786 +
3787 + /* This ignores memory above 16MB if we have a memory hole
3788 + there. If someone actually finds a machine with a memory
3789 + hole at 16MB and no support for 0E820h they should probably
3790 + generate a fake e820 map. */
3791 + boot_params.alt_mem_k = (ax == 15*1024) ? (dx << 6)+ax : ax;
3792 +
3793 + return 0;
3794 +}
3795 +
3796 +static int detect_memory_88(void)
3797 +{
3798 + u16 ax;
3799 + u8 err;
3800 +
3801 + ax = 0x8800;
3802 + asm("stc; int $0x15; setc %0" : "=bcdm" (err), "+a" (ax));
3803 +
3804 + boot_params.screen_info.ext_mem_k = ax;
3805 +
3806 + return -err;
3807 +}
3808 +
3809 +int detect_memory(void)
3810 +{
3811 + if (detect_memory_e820() > 0)
3812 + return 0;
3813 +
3814 + if (!detect_memory_e801())
3815 + return 0;
3816 +
3817 + return detect_memory_88();
3818 +}
3819 --- /dev/null
3820 +++ b/arch/i386/boot/pm.c
3821 @@ -0,0 +1,170 @@
3822 +/* -*- linux-c -*- ------------------------------------------------------- *
3823 + *
3824 + * Copyright (C) 1991, 1992 Linus Torvalds
3825 + * Copyright 2007 rPath, Inc. - All Rights Reserved
3826 + *
3827 + * This file is part of the Linux kernel, and is made available under
3828 + * the terms of the GNU General Public License version 2.
3829 + *
3830 + * ----------------------------------------------------------------------- */
3831 +
3832 +/*
3833 + * arch/i386/boot/pm.c
3834 + *
3835 + * Prepare the machine for transition to protected mode.
3836 + */
3837 +
3838 +#include "boot.h"
3839 +#include <asm/segment.h>
3840 +
3841 +/*
3842 + * Invoke the realmode switch hook if present; otherwise
3843 + * disable all interrupts.
3844 + */
3845 +static void realmode_switch_hook(void)
3846 +{
3847 + if (boot_params.hdr.realmode_swtch) {
3848 + asm volatile("lcallw *%0"
3849 + : : "m" (boot_params.hdr.realmode_swtch)
3850 + : "eax", "ebx", "ecx", "edx");
3851 + } else {
3852 + asm volatile("cli");
3853 + outb(0x80, 0x70); /* Disable NMI */
3854 + io_delay();
3855 + }
3856 +}
3857 +
3858 +/*
3859 + * A zImage kernel is loaded at 0x10000 but wants to run at 0x1000.
3860 + * A bzImage kernel is loaded and runs at 0x100000.
3861 + */
3862 +static void move_kernel_around(void)
3863 +{
3864 + /* Note: rely on the compile-time option here rather than
3865 + the LOADED_HIGH flag. The Qemu kernel loader unconditionally
3866 + sets the loadflags to zero. */
3867 +#ifndef __BIG_KERNEL__
3868 + u16 dst_seg, src_seg;
3869 + u32 syssize;
3870 +
3871 + dst_seg = 0x1000 >> 4;
3872 + src_seg = 0x10000 >> 4;
3873 + syssize = boot_params.hdr.syssize; /* Size in 16-byte paragraps */
3874 +
3875 + while (syssize) {
3876 + int paras = (syssize >= 0x1000) ? 0x1000 : syssize;
3877 + int dwords = paras << 2;
3878 +
3879 + asm volatile("pushw %%es ; "
3880 + "pushw %%ds ; "
3881 + "movw %1,%%es ; "
3882 + "movw %2,%%ds ; "
3883 + "xorw %%di,%%di ; "
3884 + "xorw %%si,%%si ; "
3885 + "rep;movsl ; "
3886 + "popw %%ds ; "
3887 + "popw %%es"
3888 + : "+c" (dwords)
3889 + : "rm" (dst_seg), "rm" (src_seg)
3890 + : "esi", "edi");
3891 +
3892 + syssize -= paras;
3893 + dst_seg += paras;
3894 + src_seg += paras;
3895 + }
3896 +#endif
3897 +}
3898 +
3899 +/*
3900 + * Disable all interrupts at the legacy PIC.
3901 + */
3902 +static void mask_all_interrupts(void)
3903 +{
3904 + outb(0xff, 0xa1); /* Mask all interrupts on the seconday PIC */
3905 + io_delay();
3906 + outb(0xfb, 0x21); /* Mask all but cascade on the primary PIC */
3907 + io_delay();
3908 +}
3909 +
3910 +/*
3911 + * Reset IGNNE# if asserted in the FPU.
3912 + */
3913 +static void reset_coprocessor(void)
3914 +{
3915 + outb(0, 0xf0);
3916 + io_delay();
3917 + outb(0, 0xf1);
3918 + io_delay();
3919 +}
3920 +
3921 +/*
3922 + * Set up the GDT
3923 + */
3924 +#define GDT_ENTRY(flags,base,limit) \
3925 + (((u64)(base & 0xff000000) << 32) | \
3926 + ((u64)flags << 40) | \
3927 + ((u64)(limit & 0x00ff0000) << 32) | \
3928 + ((u64)(base & 0x00ffff00) << 16) | \
3929 + ((u64)(limit & 0x0000ffff)))
3930 +
3931 +struct gdt_ptr {
3932 + u16 len;
3933 + u32 ptr;
3934 +} __attribute__((packed));
3935 +
3936 +static void setup_gdt(void)
3937 +{
3938 + /* There are machines which are known to not boot with the GDT
3939 + being 8-byte unaligned. Intel recommends 16 byte alignment. */
3940 + static const u64 boot_gdt[] __attribute__((aligned(16))) = {
3941 + /* CS: code, read/execute, 4 GB, base 0 */
3942 + [GDT_ENTRY_BOOT_CS] = GDT_ENTRY(0xc09b, 0, 0xfffff),
3943 + /* DS: data, read/write, 4 GB, base 0 */
3944 + [GDT_ENTRY_BOOT_DS] = GDT_ENTRY(0xc093, 0, 0xfffff),
3945 + };
3946 + struct gdt_ptr gdt;
3947 +
3948 + gdt.len = sizeof(boot_gdt)-1;
3949 + gdt.ptr = (u32)&boot_gdt + (ds() << 4);
3950 +
3951 + asm volatile("lgdtl %0" : : "m" (gdt));
3952 +}
3953 +
3954 +/*
3955 + * Set up the IDT
3956 + */
3957 +static void setup_idt(void)
3958 +{
3959 + static const struct gdt_ptr null_idt = {0, 0};
3960 + asm volatile("lidtl %0" : : "m" (null_idt));
3961 +}
3962 +
3963 +/*
3964 + * Actual invocation sequence
3965 + */
3966 +void go_to_protected_mode(void)
3967 +{
3968 + /* Hook before leaving real mode, also disables interrupts */
3969 + realmode_switch_hook();
3970 +
3971 + /* Move the kernel/setup to their final resting places */
3972 + move_kernel_around();
3973 +
3974 + /* Enable the A20 gate */
3975 + if (enable_a20()) {
3976 + puts("A20 gate not responding, unable to boot...\n");
3977 + die();
3978 + }
3979 +
3980 + /* Reset coprocessor (IGNNE#) */
3981 + reset_coprocessor();
3982 +
3983 + /* Mask all interrupts in the PIC */
3984 + mask_all_interrupts();
3985 +
3986 + /* Actual transition to protected mode... */
3987 + setup_idt();
3988 + setup_gdt();
3989 + protected_mode_jump(boot_params.hdr.code32_start,
3990 + (u32)&boot_params + (ds() << 4));
3991 +}
3992 --- /dev/null
3993 +++ b/arch/i386/boot/pmjump.S
3994 @@ -0,0 +1,54 @@
3995 +/* ----------------------------------------------------------------------- *
3996 + *
3997 + * Copyright (C) 1991, 1992 Linus Torvalds
3998 + * Copyright 2007 rPath, Inc. - All Rights Reserved
3999 + *
4000 + * This file is part of the Linux kernel, and is made available under
4001 + * the terms of the GNU General Public License version 2.
4002 + *
4003 + * ----------------------------------------------------------------------- */
4004 +
4005 +/*
4006 + * arch/i386/boot/pmjump.S
4007 + *
4008 + * The actual transition into protected mode
4009 + */
4010 +
4011 +#include <asm/boot.h>
4012 +#include <asm/segment.h>
4013 +
4014 + .text
4015 +
4016 + .globl protected_mode_jump
4017 + .type protected_mode_jump, @function
4018 +
4019 + .code16
4020 +
4021 +/*
4022 + * void protected_mode_jump(u32 entrypoint, u32 bootparams);
4023 + */
4024 +protected_mode_jump:
4025 + xorl %ebx, %ebx # Flag to indicate this is a boot
4026 + movl %edx, %esi # Pointer to boot_params table
4027 + movl %eax, 2f # Patch ljmpl instruction
4028 + jmp 1f # Short jump to flush instruction q.
4029 +
4030 +1:
4031 + movw $__BOOT_DS, %cx
4032 +
4033 + movl %cr0, %edx
4034 + orb $1, %dl # Protected mode (PE) bit
4035 + movl %edx, %cr0
4036 +
4037 + movw %cx, %ds
4038 + movw %cx, %es
4039 + movw %cx, %fs
4040 + movw %cx, %gs
4041 + movw %cx, %ss
4042 +
4043 + # Jump to the 32-bit entrypoint
4044 + .byte 0x66, 0xea # ljmpl opcode
4045 +2: .long 0 # offset
4046 + .word __BOOT_CS # segment
4047 +
4048 + .size protected_mode_jump, .-protected_mode_jump
4049 --- /dev/null
4050 +++ b/arch/i386/boot/printf.c
4051 @@ -0,0 +1,331 @@
4052 +/* -*- linux-c -*- ------------------------------------------------------- *
4053 + *
4054 + * Copyright (C) 1991, 1992 Linus Torvalds
4055 + * Copyright 2007 rPath, Inc. - All Rights Reserved
4056 + *
4057 + * This file is part of the Linux kernel, and is made available under
4058 + * the terms of the GNU General Public License version 2.
4059 + *
4060 + * ----------------------------------------------------------------------- */
4061 +
4062 +/*
4063 + * arch/i386/boot/printf.c
4064 + *
4065 + * Oh, it's a waste of space, but oh-so-yummy for debugging. This
4066 + * version of printf() does not include 64-bit support. "Live with
4067 + * it."
4068 + *
4069 + */
4070 +
4071 +#include "boot.h"
4072 +
4073 +static inline int isdigit(int ch)
4074 +{
4075 + return (ch >= '0') && (ch <= '9');
4076 +}
4077 +
4078 +static int skip_atoi(const char **s)
4079 +{
4080 + int i = 0;
4081 +
4082 + while (isdigit(**s))
4083 + i = i * 10 + *((*s)++) - '0';
4084 + return i;
4085 +}
4086 +
4087 +unsigned int atou(const char *s)
4088 +{
4089 + unsigned int i = 0;
4090 + while (isdigit(*s))
4091 + i = i * 10 + (*s++ - '0');
4092 + return i;
4093 +}
4094 +
4095 +static int strnlen(const char *s, int maxlen)
4096 +{
4097 + const char *es = s;
4098 + while (*es && maxlen) {
4099 + es++;
4100 + maxlen--;
4101 + }
4102 +
4103 + return (es - s);
4104 +}
4105 +
4106 +#define ZEROPAD 1 /* pad with zero */
4107 +#define SIGN 2 /* unsigned/signed long */
4108 +#define PLUS 4 /* show plus */
4109 +#define SPACE 8 /* space if plus */
4110 +#define LEFT 16 /* left justified */
4111 +#define SPECIAL 32 /* 0x */
4112 +#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
4113 +
4114 +#define do_div(n,base) ({ \
4115 +int __res; \
4116 +__res = ((unsigned long) n) % (unsigned) base; \
4117 +n = ((unsigned long) n) / (unsigned) base; \
4118 +__res; })
4119 +
4120 +static char *number(char *str, long num, int base, int size, int precision,
4121 + int type)
4122 +{
4123 + char c, sign, tmp[66];
4124 + const char *digits = "0123456789abcdefghijklmnopqrstuvwxyz";
4125 + int i;
4126 +
4127 + if (type & LARGE)
4128 + digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
4129 + if (type & LEFT)
4130 + type &= ~ZEROPAD;
4131 + if (base < 2 || base > 36)
4132 + return 0;
4133 + c = (type & ZEROPAD) ? '0' : ' ';
4134 + sign = 0;
4135 + if (type & SIGN) {
4136 + if (num < 0) {
4137 + sign = '-';
4138 + num = -num;
4139 + size--;
4140 + } else if (type & PLUS) {
4141 + sign = '+';
4142 + size--;
4143 + } else if (type & SPACE) {
4144 + sign = ' ';
4145 + size--;
4146 + }
4147 + }
4148 + if (type & SPECIAL) {
4149 + if (base == 16)
4150 + size -= 2;
4151 + else if (base == 8)
4152 + size--;
4153 + }
4154 + i = 0;
4155 + if (num == 0)
4156 + tmp[i++] = '0';
4157 + else
4158 + while (num != 0)
4159 + tmp[i++] = digits[do_div(num, base)];
4160 + if (i > precision)
4161 + precision = i;
4162 + size -= precision;
4163 + if (!(type & (ZEROPAD + LEFT)))
4164 + while (size-- > 0)
4165 + *str++ = ' ';
4166 + if (sign)
4167 + *str++ = sign;
4168 + if (type & SPECIAL) {
4169 + if (base == 8)
4170 + *str++ = '0';
4171 + else if (base == 16) {
4172 + *str++ = '0';
4173 + *str++ = digits[33];
4174 + }
4175 + }
4176 + if (!(type & LEFT))
4177 + while (size-- > 0)
4178 + *str++ = c;
4179 + while (i < precision--)
4180 + *str++ = '0';
4181 + while (i-- > 0)
4182 + *str++ = tmp[i];
4183 + while (size-- > 0)
4184 + *str++ = ' ';
4185 + return str;
4186 +}
4187 +
4188 +int vsprintf(char *buf, const char *fmt, va_list args)
4189 +{
4190 + int len;
4191 + unsigned long num;
4192 + int i, base;
4193 + char *str;
4194 + const char *s;
4195 +
4196 + int flags; /* flags to number() */
4197 +
4198 + int field_width; /* width of output field */
4199 + int precision; /* min. # of digits for integers; max
4200 + number of chars for from string */
4201 + int qualifier; /* 'h', 'l', or 'L' for integer fields */
4202 +
4203 + for (str = buf; *fmt; ++fmt) {
4204 + if (*fmt != '%') {
4205 + *str++ = *fmt;
4206 + continue;
4207 + }
4208 +
4209 + /* process flags */
4210 + flags = 0;
4211 + repeat:
4212 + ++fmt; /* this also skips first '%' */
4213 + switch (*fmt) {
4214 + case '-':
4215 + flags |= LEFT;
4216 + goto repeat;
4217 + case '+':
4218 + flags |= PLUS;
4219 + goto repeat;
4220 + case ' ':
4221 + flags |= SPACE;
4222 + goto repeat;
4223 + case '#':
4224 + flags |= SPECIAL;
4225 + goto repeat;
4226 + case '0':
4227 + flags |= ZEROPAD;
4228 + goto repeat;
4229 + }
4230 +
4231 + /* get field width */
4232 + field_width = -1;
4233 + if (isdigit(*fmt))
4234 + field_width = skip_atoi(&fmt);
4235 + else if (*fmt == '*') {
4236 + ++fmt;
4237 + /* it's the next argument */
4238 + field_width = va_arg(args, int);
4239 + if (field_width < 0) {
4240 + field_width = -field_width;
4241 + flags |= LEFT;
4242 + }
4243 + }
4244 +
4245 + /* get the precision */
4246 + precision = -1;
4247 + if (*fmt == '.') {
4248 + ++fmt;
4249 + if (isdigit(*fmt))
4250 + precision = skip_atoi(&fmt);
4251 + else if (*fmt == '*') {
4252 + ++fmt;
4253 + /* it's the next argument */
4254 + precision = va_arg(args, int);
4255 + }
4256 + if (precision < 0)
4257 + precision = 0;
4258 + }
4259 +
4260 + /* get the conversion qualifier */
4261 + qualifier = -1;
4262 + if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
4263 + qualifier = *fmt;
4264 + ++fmt;
4265 + }
4266 +
4267 + /* default base */
4268 + base = 10;
4269 +
4270 + switch (*fmt) {
4271 + case 'c':
4272 + if (!(flags & LEFT))
4273 + while (--field_width > 0)
4274 + *str++ = ' ';
4275 + *str++ = (unsigned char)va_arg(args, int);
4276 + while (--field_width > 0)
4277 + *str++ = ' ';
4278 + continue;
4279 +
4280 + case 's':
4281 + s = va_arg(args, char *);
4282 + len = strnlen(s, precision);
4283 +
4284 + if (!(flags & LEFT))
4285 + while (len < field_width--)
4286 + *str++ = ' ';
4287 + for (i = 0; i < len; ++i)
4288 + *str++ = *s++;
4289 + while (len < field_width--)
4290 + *str++ = ' ';
4291 + continue;
4292 +
4293 + case 'p':
4294 + if (field_width == -1) {
4295 + field_width = 2 * sizeof(void *);
4296 + flags |= ZEROPAD;
4297 + }
4298 + str = number(str,
4299 + (unsigned long)va_arg(args, void *), 16,
4300 + field_width, precision, flags);
4301 + continue;
4302 +
4303 + case 'n':
4304 + if (qualifier == 'l') {
4305 + long *ip = va_arg(args, long *);
4306 + *ip = (str - buf);
4307 + } else {
4308 + int *ip = va_arg(args, int *);
4309 + *ip = (str - buf);
4310 + }
4311 + continue;
4312 +
4313 + case '%':
4314 + *str++ = '%';
4315 + continue;
4316 +
4317 + /* integer number formats - set up the flags and "break" */
4318 + case 'o':
4319 + base = 8;
4320 + break;
4321 +
4322 + case 'X':
4323 + flags |= LARGE;
4324 + case 'x':
4325 + base = 16;
4326 + break;
4327 +
4328 + case 'd':
4329 + case 'i':
4330 + flags |= SIGN;
4331 + case 'u':
4332 + break;
4333 +
4334 + default:
4335 + *str++ = '%';
4336 + if (*fmt)
4337 + *str++ = *fmt;
4338 + else
4339 + --fmt;
4340 + continue;
4341 + }
4342 + if (qualifier == 'l')
4343 + num = va_arg(args, unsigned long);
4344 + else if (qualifier == 'h') {
4345 + num = (unsigned short)va_arg(args, int);
4346 + if (flags & SIGN)
4347 + num = (short)num;
4348 + } else if (flags & SIGN)
4349 + num = va_arg(args, int);
4350 + else
4351 + num = va_arg(args, unsigned int);
4352 + str = number(str, num, base, field_width, precision, flags);
4353 + }
4354 + *str = '\0';
4355 + return str - buf;
4356 +}
4357 +
4358 +int sprintf(char *buf, const char *fmt, ...)
4359 +{
4360 + va_list args;
4361 + int i;
4362 +
4363 + va_start(args, fmt);
4364 + i = vsprintf(buf, fmt, args);
4365 + va_end(args);
4366 + return i;
4367 +}
4368 +
4369 +int printf(const char *fmt, ...)
4370 +{
4371 + char printf_buf[1024];
4372 + va_list args;
4373 + int printed;
4374 +
4375 + va_start(args, fmt);
4376 + printed = vsprintf(printf_buf, fmt, args);
4377 + va_end(args);
4378 +
4379 + puts(printf_buf);
4380 +
4381 + return printed;
4382 +}
4383 --- a/arch/i386/boot/setup.S
4384 +++ /dev/null
4385 @@ -1,1075 +0,0 @@
4386 -/*
4387 - * setup.S Copyright (C) 1991, 1992 Linus Torvalds
4388 - *
4389 - * setup.s is responsible for getting the system data from the BIOS,
4390 - * and putting them into the appropriate places in system memory.
4391 - * both setup.s and system has been loaded by the bootblock.
4392 - *
4393 - * This code asks the bios for memory/disk/other parameters, and
4394 - * puts them in a "safe" place: 0x90000-0x901FF, ie where the
4395 - * boot-block used to be. It is then up to the protected mode
4396 - * system to read them from there before the area is overwritten
4397 - * for buffer-blocks.
4398 - *
4399 - * Move PS/2 aux init code to psaux.c
4400 - * (troyer@saifr00.cfsat.Honeywell.COM) 03Oct92
4401 - *
4402 - * some changes and additional features by Christoph Niemann,
4403 - * March 1993/June 1994 (Christoph.Niemann@linux.org)
4404 - *
4405 - * add APM BIOS checking by Stephen Rothwell, May 1994
4406 - * (sfr@canb.auug.org.au)
4407 - *
4408 - * High load stuff, initrd support and position independency
4409 - * by Hans Lermen & Werner Almesberger, February 1996
4410 - * <lermen@elserv.ffm.fgan.de>, <almesber@lrc.epfl.ch>
4411 - *
4412 - * Video handling moved to video.S by Martin Mares, March 1996
4413 - * <mj@k332.feld.cvut.cz>
4414 - *
4415 - * Extended memory detection scheme retwiddled by orc@pell.chi.il.us (david
4416 - * parsons) to avoid loadlin confusion, July 1997
4417 - *
4418 - * Transcribed from Intel (as86) -> AT&T (gas) by Chris Noe, May 1999.
4419 - * <stiker@northlink.com>
4420 - *
4421 - * Fix to work around buggy BIOSes which don't use carry bit correctly
4422 - * and/or report extended memory in CX/DX for e801h memory size detection
4423 - * call. As a result the kernel got wrong figures. The int15/e801h docs
4424 - * from Ralf Brown interrupt list seem to indicate AX/BX should be used
4425 - * anyway. So to avoid breaking many machines (presumably there was a reason
4426 - * to orginally use CX/DX instead of AX/BX), we do a kludge to see
4427 - * if CX/DX have been changed in the e801 call and if so use AX/BX .
4428 - * Michael Miller, April 2001 <michaelm@mjmm.org>
4429 - *
4430 - * New A20 code ported from SYSLINUX by H. Peter Anvin. AMD Elan bugfixes
4431 - * by Robert Schwebel, December 2001 <robert@schwebel.de>
4432 - */
4433 -
4434 -#include <asm/segment.h>
4435 -#include <linux/utsrelease.h>
4436 -#include <linux/compile.h>
4437 -#include <asm/boot.h>
4438 -#include <asm/e820.h>
4439 -#include <asm/page.h>
4440 -#include <asm/setup.h>
4441 -
4442 -/* Signature words to ensure LILO loaded us right */
4443 -#define SIG1 0xAA55
4444 -#define SIG2 0x5A5A
4445 -
4446 -INITSEG = DEF_INITSEG # 0x9000, we move boot here, out of the way
4447 -SYSSEG = DEF_SYSSEG # 0x1000, system loaded at 0x10000 (65536).
4448 -SETUPSEG = DEF_SETUPSEG # 0x9020, this is the current segment
4449 - # ... and the former contents of CS
4450 -
4451 -DELTA_INITSEG = SETUPSEG - INITSEG # 0x0020
4452 -
4453 -.code16
4454 -.globl begtext, begdata, begbss, endtext, enddata, endbss
4455 -
4456 -.text
4457 -begtext:
4458 -.data
4459 -begdata:
4460 -.bss
4461 -begbss:
4462 -.text
4463 -
4464 -start:
4465 - jmp trampoline
4466 -
4467 -# This is the setup header, and it must start at %cs:2 (old 0x9020:2)
4468 -
4469 - .ascii "HdrS" # header signature
4470 - .word 0x0206 # header version number (>= 0x0105)
4471 - # or else old loadlin-1.5 will fail)
4472 -realmode_swtch: .word 0, 0 # default_switch, SETUPSEG
4473 -start_sys_seg: .word SYSSEG
4474 - .word kernel_version # pointing to kernel version string
4475 - # above section of header is compatible
4476 - # with loadlin-1.5 (header v1.5). Don't
4477 - # change it.
4478 -
4479 -type_of_loader: .byte 0 # = 0, old one (LILO, Loadlin,
4480 - # Bootlin, SYSLX, bootsect...)
4481 - # See Documentation/i386/boot.txt for
4482 - # assigned ids
4483 -
4484 -# flags, unused bits must be zero (RFU) bit within loadflags
4485 -loadflags:
4486 -LOADED_HIGH = 1 # If set, the kernel is loaded high
4487 -CAN_USE_HEAP = 0x80 # If set, the loader also has set
4488 - # heap_end_ptr to tell how much
4489 - # space behind setup.S can be used for
4490 - # heap purposes.
4491 - # Only the loader knows what is free
4492 -#ifndef __BIG_KERNEL__
4493 - .byte 0
4494 -#else
4495 - .byte LOADED_HIGH
4496 -#endif
4497 -
4498 -setup_move_size: .word 0x8000 # size to move, when setup is not
4499 - # loaded at 0x90000. We will move setup
4500 - # to 0x90000 then just before jumping
4501 - # into the kernel. However, only the
4502 - # loader knows how much data behind
4503 - # us also needs to be loaded.
4504 -
4505 -code32_start: # here loaders can put a different
4506 - # start address for 32-bit code.
4507 -#ifndef __BIG_KERNEL__
4508 - .long 0x1000 # 0x1000 = default for zImage
4509 -#else
4510 - .long 0x100000 # 0x100000 = default for big kernel
4511 -#endif
4512 -
4513 -ramdisk_image: .long 0 # address of loaded ramdisk image
4514 - # Here the loader puts the 32-bit
4515 - # address where it loaded the image.
4516 - # This only will be read by the kernel.
4517 -
4518 -ramdisk_size: .long 0 # its size in bytes
4519 -
4520 -bootsect_kludge:
4521 - .long 0 # obsolete
4522 -
4523 -heap_end_ptr: .word modelist+1024 # (Header version 0x0201 or later)
4524 - # space from here (exclusive) down to
4525 - # end of setup code can be used by setup
4526 - # for local heap purposes.
4527 -
4528 -pad1: .word 0
4529 -cmd_line_ptr: .long 0 # (Header version 0x0202 or later)
4530 - # If nonzero, a 32-bit pointer
4531 - # to the kernel command line.
4532 - # The command line should be
4533 - # located between the start of
4534 - # setup and the end of low
4535 - # memory (0xa0000), or it may
4536 - # get overwritten before it
4537 - # gets read. If this field is
4538 - # used, there is no longer
4539 - # anything magical about the
4540 - # 0x90000 segment; the setup
4541 - # can be located anywhere in
4542 - # low memory 0x10000 or higher.
4543 -
4544 -ramdisk_max: .long (-__PAGE_OFFSET-(512 << 20)-1) & 0x7fffffff
4545 - # (Header version 0x0203 or later)
4546 - # The highest safe address for
4547 - # the contents of an initrd
4548 -
4549 -kernel_alignment: .long CONFIG_PHYSICAL_ALIGN #physical addr alignment
4550 - #required for protected mode
4551 - #kernel
4552 -#ifdef CONFIG_RELOCATABLE
4553 -relocatable_kernel: .byte 1
4554 -#else
4555 -relocatable_kernel: .byte 0
4556 -#endif
4557 -pad2: .byte 0
4558 -pad3: .word 0
4559 -
4560 -cmdline_size: .long COMMAND_LINE_SIZE-1 #length of the command line,
4561 - #added with boot protocol
4562 - #version 2.06
4563 -
4564 -trampoline: call start_of_setup
4565 - .align 16
4566 - # The offset at this point is 0x240
4567 - .space (0xeff-0x240+1) # E820 & EDD space (ending at 0xeff)
4568 -# End of setup header #####################################################
4569 -
4570 -start_of_setup:
4571 -# Bootlin depends on this being done early
4572 - movw $0x01500, %ax
4573 - movb $0x81, %dl
4574 - int $0x13
4575 -
4576 -#ifdef SAFE_RESET_DISK_CONTROLLER
4577 -# Reset the disk controller.
4578 - movw $0x0000, %ax
4579 - movb $0x80, %dl
4580 - int $0x13
4581 -#endif
4582 -
4583 -# Set %ds = %cs, we know that SETUPSEG = %cs at this point
4584 - movw %cs, %ax # aka SETUPSEG
4585 - movw %ax, %ds
4586 -# Check signature at end of setup
4587 - cmpw $SIG1, setup_sig1
4588 - jne bad_sig
4589 -
4590 - cmpw $SIG2, setup_sig2
4591 - jne bad_sig
4592 -
4593 - jmp good_sig1
4594 -
4595 -# Routine to print asciiz string at ds:si
4596 -prtstr:
4597 - lodsb
4598 - andb %al, %al
4599 - jz fin
4600 -
4601 - call prtchr
4602 - jmp prtstr
4603 -
4604 -fin: ret
4605 -
4606 -# Space printing
4607 -prtsp2: call prtspc # Print double space
4608 -prtspc: movb $0x20, %al # Print single space (note: fall-thru)
4609 -
4610 -# Part of above routine, this one just prints ascii al
4611 -prtchr: pushw %ax
4612 - pushw %cx
4613 - movw $7,%bx
4614 - movw $0x01, %cx
4615 - movb $0x0e, %ah
4616 - int $0x10
4617 - popw %cx
4618 - popw %ax
4619 - ret
4620 -
4621 -beep: movb $0x07, %al
4622 - jmp prtchr
4623 -
4624 -no_sig_mess: .string "No setup signature found ..."
4625 -
4626 -good_sig1:
4627 - jmp good_sig
4628 -
4629 -# We now have to find the rest of the setup code/data
4630 -bad_sig:
4631 - movw %cs, %ax # SETUPSEG
4632 - subw $DELTA_INITSEG, %ax # INITSEG
4633 - movw %ax, %ds
4634 - xorb %bh, %bh
4635 - movb (497), %bl # get setup sect from bootsect
4636 - subw $4, %bx # LILO loads 4 sectors of setup
4637 - shlw $8, %bx # convert to words (1sect=2^8 words)
4638 - movw %bx, %cx
4639 - shrw $3, %bx # convert to segment
4640 - addw $SYSSEG, %bx
4641 - movw %bx, %cs:start_sys_seg
4642 -# Move rest of setup code/data to here
4643 - movw $2048, %di # four sectors loaded by LILO
4644 - subw %si, %si
4645 - pushw %cs
4646 - popw %es
4647 - movw $SYSSEG, %ax
4648 - movw %ax, %ds
4649 - rep
4650 - movsw
4651 - movw %cs, %ax # aka SETUPSEG
4652 - movw %ax, %ds
4653 - cmpw $SIG1, setup_sig1
4654 - jne no_sig
4655 -
4656 - cmpw $SIG2, setup_sig2
4657 - jne no_sig
4658 -
4659 - jmp good_sig
4660 -
4661 -no_sig:
4662 - lea no_sig_mess, %si
4663 - call prtstr
4664 -
4665 -no_sig_loop:
4666 - hlt
4667 - jmp no_sig_loop
4668 -
4669 -good_sig:
4670 - movw %cs, %ax # aka SETUPSEG
4671 - subw $DELTA_INITSEG, %ax # aka INITSEG
4672 - movw %ax, %ds
4673 -# Check if an old loader tries to load a big-kernel
4674 - testb $LOADED_HIGH, %cs:loadflags # Do we have a big kernel?
4675 - jz loader_ok # No, no danger for old loaders.
4676 -
4677 - cmpb $0, %cs:type_of_loader # Do we have a loader that
4678 - # can deal with us?
4679 - jnz loader_ok # Yes, continue.
4680 -
4681 - pushw %cs # No, we have an old loader,
4682 - popw %ds # die.
4683 - lea loader_panic_mess, %si
4684 - call prtstr
4685 -
4686 - jmp no_sig_loop
4687 -
4688 -loader_panic_mess: .string "Wrong loader, giving up..."
4689 -
4690 -# check minimum cpuid
4691 -# we do this here because it is the last place we can actually
4692 -# show a user visible error message. Later the video modus
4693 -# might be already messed up.
4694 -loader_ok:
4695 - call verify_cpu
4696 - testl %eax,%eax
4697 - jz cpu_ok
4698 - movw %cs,%ax # aka SETUPSEG
4699 - movw %ax,%ds
4700 - lea cpu_panic_mess,%si
4701 - call prtstr
4702 -1: jmp 1b
4703 -
4704 -cpu_panic_mess:
4705 - .asciz "PANIC: CPU too old for this kernel."
4706 -
4707 -#include "../kernel/verify_cpu.S"
4708 -
4709 -cpu_ok:
4710 -# Get memory size (extended mem, kB)
4711 -
4712 - xorl %eax, %eax
4713 - movl %eax, (0x1e0)
4714 -#ifndef STANDARD_MEMORY_BIOS_CALL
4715 - movb %al, (E820NR)
4716 -# Try three different memory detection schemes. First, try
4717 -# e820h, which lets us assemble a memory map, then try e801h,
4718 -# which returns a 32-bit memory size, and finally 88h, which
4719 -# returns 0-64m
4720 -
4721 -# method E820H:
4722 -# the memory map from hell. e820h returns memory classified into
4723 -# a whole bunch of different types, and allows memory holes and
4724 -# everything. We scan through this memory map and build a list
4725 -# of the first 32 memory areas, which we return at [E820MAP].
4726 -# This is documented at http://www.acpi.info/, in the ACPI 2.0 specification.
4727 -
4728 -#define SMAP 0x534d4150
4729 -
4730 -meme820:
4731 - xorl %ebx, %ebx # continuation counter
4732 - movw $E820MAP, %di # point into the whitelist
4733 - # so we can have the bios
4734 - # directly write into it.
4735 -
4736 -jmpe820:
4737 - movl $0x0000e820, %eax # e820, upper word zeroed
4738 - movl $SMAP, %edx # ascii 'SMAP'
4739 - movl $20, %ecx # size of the e820rec
4740 - pushw %ds # data record.
4741 - popw %es
4742 - int $0x15 # make the call
4743 - jc bail820 # fall to e801 if it fails
4744 -
4745 - cmpl $SMAP, %eax # check the return is `SMAP'
4746 - jne bail820 # fall to e801 if it fails
4747 -
4748 -# cmpl $1, 16(%di) # is this usable memory?
4749 -# jne again820
4750 -
4751 - # If this is usable memory, we save it by simply advancing %di by
4752 - # sizeof(e820rec).
4753 - #
4754 -good820:
4755 - movb (E820NR), %al # up to 128 entries
4756 - cmpb $E820MAX, %al
4757 - jae bail820
4758 -
4759 - incb (E820NR)
4760 - movw %di, %ax
4761 - addw $20, %ax
4762 - movw %ax, %di
4763 -again820:
4764 - cmpl $0, %ebx # check to see if
4765 - jne jmpe820 # %ebx is set to EOF
4766 -bail820:
4767 -
4768 -
4769 -# method E801H:
4770 -# memory size is in 1k chunksizes, to avoid confusing loadlin.
4771 -# we store the 0xe801 memory size in a completely different place,
4772 -# because it will most likely be longer than 16 bits.
4773 -# (use 1e0 because that's what Larry Augustine uses in his
4774 -# alternative new memory detection scheme, and it's sensible
4775 -# to write everything into the same place.)
4776 -
4777 -meme801:
4778 - stc # fix to work around buggy
4779 - xorw %cx,%cx # BIOSes which don't clear/set
4780 - xorw %dx,%dx # carry on pass/error of
4781 - # e801h memory size call
4782 - # or merely pass cx,dx though
4783 - # without changing them.
4784 - movw $0xe801, %ax
4785 - int $0x15
4786 - jc mem88
4787 -
4788 - cmpw $0x0, %cx # Kludge to handle BIOSes
4789 - jne e801usecxdx # which report their extended
4790 - cmpw $0x0, %dx # memory in AX/BX rather than
4791 - jne e801usecxdx # CX/DX. The spec I have read
4792 - movw %ax, %cx # seems to indicate AX/BX
4793 - movw %bx, %dx # are more reasonable anyway...
4794 -
4795 -e801usecxdx:
4796 - andl $0xffff, %edx # clear sign extend
4797 - shll $6, %edx # and go from 64k to 1k chunks
4798 - movl %edx, (0x1e0) # store extended memory size
4799 - andl $0xffff, %ecx # clear sign extend
4800 - addl %ecx, (0x1e0) # and add lower memory into
4801 - # total size.
4802 -
4803 -# Ye Olde Traditional Methode. Returns the memory size (up to 16mb or
4804 -# 64mb, depending on the bios) in ax.
4805 -mem88:
4806 -
4807 -#endif
4808 - movb $0x88, %ah
4809 - int $0x15
4810 - movw %ax, (2)
4811 -
4812 -# Set the keyboard repeat rate to the max
4813 - movw $0x0305, %ax
4814 - xorw %bx, %bx
4815 - int $0x16
4816 -
4817 -# Check for video adapter and its parameters and allow the
4818 -# user to browse video modes.
4819 - call video # NOTE: we need %ds pointing
4820 - # to bootsector
4821 -
4822 -# Get hd0 data...
4823 - xorw %ax, %ax
4824 - movw %ax, %ds
4825 - ldsw (4 * 0x41), %si
4826 - movw %cs, %ax # aka SETUPSEG
4827 - subw $DELTA_INITSEG, %ax # aka INITSEG
4828 - pushw %ax
4829 - movw %ax, %es
4830 - movw $0x0080, %di
4831 - movw $0x10, %cx
4832 - pushw %cx
4833 - cld
4834 - rep
4835 - movsb
4836 -# Get hd1 data...
4837 - xorw %ax, %ax
4838 - movw %ax, %ds
4839 - ldsw (4 * 0x46), %si
4840 - popw %cx
4841 - popw %es
4842 - movw $0x0090, %di
4843 - rep
4844 - movsb
4845 -# Check that there IS a hd1 :-)
4846 - movw $0x01500, %ax
4847 - movb $0x81, %dl
4848 - int $0x13
4849 - jc no_disk1
4850 -
4851 - cmpb $3, %ah
4852 - je is_disk1
4853 -
4854 -no_disk1:
4855 - movw %cs, %ax # aka SETUPSEG
4856 - subw $DELTA_INITSEG, %ax # aka INITSEG
4857 - movw %ax, %es
4858 - movw $0x0090, %di
4859 - movw $0x10, %cx
4860 - xorw %ax, %ax
4861 - cld
4862 - rep
4863 - stosb
4864 -is_disk1:
4865 -# check for Micro Channel (MCA) bus
4866 - movw %cs, %ax # aka SETUPSEG
4867 - subw $DELTA_INITSEG, %ax # aka INITSEG
4868 - movw %ax, %ds
4869 - xorw %ax, %ax
4870 - movw %ax, (0xa0) # set table length to 0
4871 - movb $0xc0, %ah
4872 - stc
4873 - int $0x15 # moves feature table to es:bx
4874 - jc no_mca
4875 -
4876 - pushw %ds
4877 - movw %es, %ax
4878 - movw %ax, %ds
4879 - movw %cs, %ax # aka SETUPSEG
4880 - subw $DELTA_INITSEG, %ax # aka INITSEG
4881 - movw %ax, %es
4882 - movw %bx, %si
4883 - movw $0xa0, %di
4884 - movw (%si), %cx
4885 - addw $2, %cx # table length is a short
4886 - cmpw $0x10, %cx
4887 - jc sysdesc_ok
4888 -
4889 - movw $0x10, %cx # we keep only first 16 bytes
4890 -sysdesc_ok:
4891 - rep
4892 - movsb
4893 - popw %ds
4894 -no_mca:
4895 -#ifdef CONFIG_X86_VOYAGER
4896 - movb $0xff, 0x40 # flag on config found
4897 - movb $0xc0, %al
4898 - mov $0xff, %ah
4899 - int $0x15 # put voyager config info at es:di
4900 - jc no_voyager
4901 - movw $0x40, %si # place voyager info in apm table
4902 - cld
4903 - movw $7, %cx
4904 -voyager_rep:
4905 - movb %es:(%di), %al
4906 - movb %al,(%si)
4907 - incw %di
4908 - incw %si
4909 - decw %cx
4910 - jnz voyager_rep
4911 -no_voyager:
4912 -#endif
4913 -# Check for PS/2 pointing device
4914 - movw %cs, %ax # aka SETUPSEG
4915 - subw $DELTA_INITSEG, %ax # aka INITSEG
4916 - movw %ax, %ds
4917 - movb $0, (0x1ff) # default is no pointing device
4918 - int $0x11 # int 0x11: equipment list
4919 - testb $0x04, %al # check if mouse installed
4920 - jz no_psmouse
4921 -
4922 - movb $0xAA, (0x1ff) # device present
4923 -no_psmouse:
4924 -
4925 -#if defined(CONFIG_X86_SPEEDSTEP_SMI) || defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE)
4926 - movl $0x0000E980, %eax # IST Support
4927 - movl $0x47534943, %edx # Request value
4928 - int $0x15
4929 -
4930 - movl %eax, (96)
4931 - movl %ebx, (100)
4932 - movl %ecx, (104)
4933 - movl %edx, (108)
4934 -#endif
4935 -
4936 -#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
4937 -# Then check for an APM BIOS...
4938 - # %ds points to the bootsector
4939 - movw $0, 0x40 # version = 0 means no APM BIOS
4940 - movw $0x05300, %ax # APM BIOS installation check
4941 - xorw %bx, %bx
4942 - int $0x15
4943 - jc done_apm_bios # Nope, no APM BIOS
4944 -
4945 - cmpw $0x0504d, %bx # Check for "PM" signature
4946 - jne done_apm_bios # No signature, no APM BIOS
4947 -
4948 - andw $0x02, %cx # Is 32 bit supported?
4949 - je done_apm_bios # No 32-bit, no (good) APM BIOS
4950 -
4951 - movw $0x05304, %ax # Disconnect first just in case
4952 - xorw %bx, %bx
4953 - int $0x15 # ignore return code
4954 - movw $0x05303, %ax # 32 bit connect
4955 - xorl %ebx, %ebx
4956 - xorw %cx, %cx # paranoia :-)
4957 - xorw %dx, %dx # ...
4958 - xorl %esi, %esi # ...
4959 - xorw %di, %di # ...
4960 - int $0x15
4961 - jc no_32_apm_bios # Ack, error.
4962 -
4963 - movw %ax, (66) # BIOS code segment
4964 - movl %ebx, (68) # BIOS entry point offset
4965 - movw %cx, (72) # BIOS 16 bit code segment
4966 - movw %dx, (74) # BIOS data segment
4967 - movl %esi, (78) # BIOS code segment lengths
4968 - movw %di, (82) # BIOS data segment length
4969 -# Redo the installation check as the 32 bit connect
4970 -# modifies the flags returned on some BIOSs
4971 - movw $0x05300, %ax # APM BIOS installation check
4972 - xorw %bx, %bx
4973 - xorw %cx, %cx # paranoia
4974 - int $0x15
4975 - jc apm_disconnect # error -> shouldn't happen
4976 -
4977 - cmpw $0x0504d, %bx # check for "PM" signature
4978 - jne apm_disconnect # no sig -> shouldn't happen
4979 -
4980 - movw %ax, (64) # record the APM BIOS version
4981 - movw %cx, (76) # and flags
4982 - jmp done_apm_bios
4983 -
4984 -apm_disconnect: # Tidy up
4985 - movw $0x05304, %ax # Disconnect
4986 - xorw %bx, %bx
4987 - int $0x15 # ignore return code
4988 -
4989 - jmp done_apm_bios
4990 -
4991 -no_32_apm_bios:
4992 - andw $0xfffd, (76) # remove 32 bit support bit
4993 -done_apm_bios:
4994 -#endif
4995 -
4996 -#include "edd.S"
4997 -
4998 -# Now we want to move to protected mode ...
4999 - cmpw $0, %cs:realmode_swtch
5000 - jz rmodeswtch_normal
5001 -
5002 - lcall *%cs:realmode_swtch
5003 -
5004 - jmp rmodeswtch_end
5005 -
5006 -rmodeswtch_normal:
5007 - pushw %cs
5008 - call default_switch
5009 -
5010 -rmodeswtch_end:
5011 -# Now we move the system to its rightful place ... but we check if we have a
5012 -# big-kernel. In that case we *must* not move it ...
5013 - testb $LOADED_HIGH, %cs:loadflags
5014 - jz do_move0 # .. then we have a normal low
5015 - # loaded zImage
5016 - # .. or else we have a high
5017 - # loaded bzImage
5018 - jmp end_move # ... and we skip moving
5019 -
5020 -do_move0:
5021 - movw $0x100, %ax # start of destination segment
5022 - movw %cs, %bp # aka SETUPSEG
5023 - subw $DELTA_INITSEG, %bp # aka INITSEG
5024 - movw %cs:start_sys_seg, %bx # start of source segment
5025 - cld
5026 -do_move:
5027 - movw %ax, %es # destination segment
5028 - incb %ah # instead of add ax,#0x100
5029 - movw %bx, %ds # source segment
5030 - addw $0x100, %bx
5031 - subw %di, %di
5032 - subw %si, %si
5033 - movw $0x800, %cx
5034 - rep
5035 - movsw
5036 - cmpw %bp, %bx # assume start_sys_seg > 0x200,
5037 - # so we will perhaps read one
5038 - # page more than needed, but
5039 - # never overwrite INITSEG
5040 - # because destination is a
5041 - # minimum one page below source
5042 - jb do_move
5043 -
5044 -end_move:
5045 -# then we load the segment descriptors
5046 - movw %cs, %ax # aka SETUPSEG
5047 - movw %ax, %ds
5048 -
5049 -# Check whether we need to be downward compatible with version <=201
5050 - cmpl $0, cmd_line_ptr
5051 - jne end_move_self # loader uses version >=202 features
5052 - cmpb $0x20, type_of_loader
5053 - je end_move_self # bootsect loader, we know of it
5054 -
5055 -# Boot loader doesnt support boot protocol version 2.02.
5056 -# If we have our code not at 0x90000, we need to move it there now.
5057 -# We also then need to move the params behind it (commandline)
5058 -# Because we would overwrite the code on the current IP, we move
5059 -# it in two steps, jumping high after the first one.
5060 - movw %cs, %ax
5061 - cmpw $SETUPSEG, %ax
5062 - je end_move_self
5063 -
5064 - cli # make sure we really have
5065 - # interrupts disabled !
5066 - # because after this the stack
5067 - # should not be used
5068 - subw $DELTA_INITSEG, %ax # aka INITSEG
5069 - movw %ss, %dx
5070 - cmpw %ax, %dx
5071 - jb move_self_1
5072 -
5073 - addw $INITSEG, %dx
5074 - subw %ax, %dx # this will go into %ss after
5075 - # the move
5076 -move_self_1:
5077 - movw %ax, %ds
5078 - movw $INITSEG, %ax # real INITSEG
5079 - movw %ax, %es
5080 - movw %cs:setup_move_size, %cx
5081 - std # we have to move up, so we use
5082 - # direction down because the
5083 - # areas may overlap
5084 - movw %cx, %di
5085 - decw %di
5086 - movw %di, %si
5087 - subw $move_self_here+0x200, %cx
5088 - rep
5089 - movsb
5090 - ljmp $SETUPSEG, $move_self_here
5091 -
5092 -move_self_here:
5093 - movw $move_self_here+0x200, %cx
5094 - rep
5095 - movsb
5096 - movw $SETUPSEG, %ax
5097 - movw %ax, %ds
5098 - movw %dx, %ss
5099 -end_move_self: # now we are at the right place
5100 -
5101 -#
5102 -# Enable A20. This is at the very best an annoying procedure.
5103 -# A20 code ported from SYSLINUX 1.52-1.63 by H. Peter Anvin.
5104 -# AMD Elan bug fix by Robert Schwebel.
5105 -#
5106 -
5107 -#if defined(CONFIG_X86_ELAN)
5108 - movb $0x02, %al # alternate A20 gate
5109 - outb %al, $0x92 # this works on SC410/SC520
5110 -a20_elan_wait:
5111 - call a20_test
5112 - jz a20_elan_wait
5113 - jmp a20_done
5114 -#endif
5115 -
5116 -
5117 -A20_TEST_LOOPS = 32 # Iterations per wait
5118 -A20_ENABLE_LOOPS = 255 # Total loops to try
5119 -
5120 -
5121 -#ifndef CONFIG_X86_VOYAGER
5122 -a20_try_loop:
5123 -
5124 - # First, see if we are on a system with no A20 gate.
5125 -a20_none:
5126 - call a20_test
5127 - jnz a20_done
5128 -
5129 - # Next, try the BIOS (INT 0x15, AX=0x2401)
5130 -a20_bios:
5131 - movw $0x2401, %ax
5132 - pushfl # Be paranoid about flags
5133 - int $0x15
5134 - popfl
5135 -
5136 - call a20_test
5137 - jnz a20_done
5138 -
5139 - # Try enabling A20 through the keyboard controller
5140 -#endif /* CONFIG_X86_VOYAGER */
5141 -a20_kbc:
5142 - call empty_8042
5143 -
5144 -#ifndef CONFIG_X86_VOYAGER
5145 - call a20_test # Just in case the BIOS worked
5146 - jnz a20_done # but had a delayed reaction.
5147 -#endif
5148 -
5149 - movb $0xD1, %al # command write
5150 - outb %al, $0x64
5151 - call empty_8042
5152 -
5153 - movb $0xDF, %al # A20 on
5154 - outb %al, $0x60
5155 - call empty_8042
5156 -
5157 -#ifndef CONFIG_X86_VOYAGER
5158 - # Wait until a20 really *is* enabled; it can take a fair amount of
5159 - # time on certain systems; Toshiba Tecras are known to have this
5160 - # problem.
5161 -a20_kbc_wait:
5162 - xorw %cx, %cx
5163 -a20_kbc_wait_loop:
5164 - call a20_test
5165 - jnz a20_done
5166 - loop a20_kbc_wait_loop
5167 -
5168 - # Final attempt: use "configuration port A"
5169 -a20_fast:
5170 - inb $0x92, %al # Configuration Port A
5171 - orb $0x02, %al # "fast A20" version
5172 - andb $0xFE, %al # don't accidentally reset
5173 - outb %al, $0x92
5174 -
5175 - # Wait for configuration port A to take effect
5176 -a20_fast_wait:
5177 - xorw %cx, %cx
5178 -a20_fast_wait_loop:
5179 - call a20_test
5180 - jnz a20_done
5181 - loop a20_fast_wait_loop
5182 -
5183 - # A20 is still not responding. Try frobbing it again.
5184 - #
5185 - decb (a20_tries)
5186 - jnz a20_try_loop
5187 -
5188 - movw $a20_err_msg, %si
5189 - call prtstr
5190 -
5191 -a20_die:
5192 - hlt
5193 - jmp a20_die
5194 -
5195 -a20_tries:
5196 - .byte A20_ENABLE_LOOPS
5197 -
5198 -a20_err_msg:
5199 - .ascii "linux: fatal error: A20 gate not responding!"
5200 - .byte 13, 10, 0
5201 -
5202 - # If we get here, all is good
5203 -a20_done:
5204 -
5205 -#endif /* CONFIG_X86_VOYAGER */
5206 -# set up gdt and idt and 32bit start address
5207 - lidt idt_48 # load idt with 0,0
5208 - xorl %eax, %eax # Compute gdt_base
5209 - movw %ds, %ax # (Convert %ds:gdt to a linear ptr)
5210 - shll $4, %eax
5211 - addl %eax, code32
5212 - addl $gdt, %eax
5213 - movl %eax, (gdt_48+2)
5214 - lgdt gdt_48 # load gdt with whatever is
5215 - # appropriate
5216 -
5217 -# make sure any possible coprocessor is properly reset..
5218 - xorw %ax, %ax
5219 - outb %al, $0xf0
5220 - call delay
5221 -
5222 - outb %al, $0xf1
5223 - call delay
5224 -
5225 -# well, that went ok, I hope. Now we mask all interrupts - the rest
5226 -# is done in init_IRQ().
5227 - movb $0xFF, %al # mask all interrupts for now
5228 - outb %al, $0xA1
5229 - call delay
5230 -
5231 - movb $0xFB, %al # mask all irq's but irq2 which
5232 - outb %al, $0x21 # is cascaded
5233 -
5234 -# Well, that certainly wasn't fun :-(. Hopefully it works, and we don't
5235 -# need no steenking BIOS anyway (except for the initial loading :-).
5236 -# The BIOS-routine wants lots of unnecessary data, and it's less
5237 -# "interesting" anyway. This is how REAL programmers do it.
5238 -#
5239 -# Well, now's the time to actually move into protected mode. To make
5240 -# things as simple as possible, we do no register set-up or anything,
5241 -# we let the gnu-compiled 32-bit programs do that. We just jump to
5242 -# absolute address 0x1000 (or the loader supplied one),
5243 -# in 32-bit protected mode.
5244 -#
5245 -# Note that the short jump isn't strictly needed, although there are
5246 -# reasons why it might be a good idea. It won't hurt in any case.
5247 - movw $1, %ax # protected mode (PE) bit
5248 - lmsw %ax # This is it!
5249 - jmp flush_instr
5250 -
5251 -flush_instr:
5252 - xorw %bx, %bx # Flag to indicate a boot
5253 - xorl %esi, %esi # Pointer to real-mode code
5254 - movw %cs, %si
5255 - subw $DELTA_INITSEG, %si
5256 - shll $4, %esi # Convert to 32-bit pointer
5257 -
5258 -# jump to startup_32 in arch/i386/boot/compressed/head.S
5259 -#
5260 -# NOTE: For high loaded big kernels we need a
5261 -# jmpi 0x100000,__BOOT_CS
5262 -#
5263 -# but we yet haven't reloaded the CS register, so the default size
5264 -# of the target offset still is 16 bit.
5265 -# However, using an operand prefix (0x66), the CPU will properly
5266 -# take our 48 bit far pointer. (INTeL 80386 Programmer's Reference
5267 -# Manual, Mixing 16-bit and 32-bit code, page 16-6)
5268 -
5269 - .byte 0x66, 0xea # prefix + jmpi-opcode
5270 -code32: .long startup_32 # will be set to %cs+startup_32
5271 - .word __BOOT_CS
5272 -.code32
5273 -startup_32:
5274 - movl $(__BOOT_DS), %eax
5275 - movl %eax, %ds
5276 - movl %eax, %es
5277 - movl %eax, %fs
5278 - movl %eax, %gs
5279 - movl %eax, %ss
5280 -
5281 - xorl %eax, %eax
5282 -1: incl %eax # check that A20 really IS enabled
5283 - movl %eax, 0x00000000 # loop forever if it isn't
5284 - cmpl %eax, 0x00100000
5285 - je 1b
5286 -
5287 - # Jump to the 32bit entry point
5288 - jmpl *(code32_start - start + (DELTA_INITSEG << 4))(%esi)
5289 -.code16
5290 -
5291 -# Here's a bunch of information about your current kernel..
5292 -kernel_version: .ascii UTS_RELEASE
5293 - .ascii " ("
5294 - .ascii LINUX_COMPILE_BY
5295 - .ascii "@"
5296 - .ascii LINUX_COMPILE_HOST
5297 - .ascii ") "
5298 - .ascii UTS_VERSION
5299 - .byte 0
5300 -
5301 -# This is the default real mode switch routine.
5302 -# to be called just before protected mode transition
5303 -default_switch:
5304 - cli # no interrupts allowed !
5305 - movb $0x80, %al # disable NMI for bootup
5306 - # sequence
5307 - outb %al, $0x70
5308 - lret
5309 -
5310 -
5311 -#ifndef CONFIG_X86_VOYAGER
5312 -# This routine tests whether or not A20 is enabled. If so, it
5313 -# exits with zf = 0.
5314 -#
5315 -# The memory address used, 0x200, is the int $0x80 vector, which
5316 -# should be safe.
5317 -
5318 -A20_TEST_ADDR = 4*0x80
5319 -
5320 -a20_test:
5321 - pushw %cx
5322 - pushw %ax
5323 - xorw %cx, %cx
5324 - movw %cx, %fs # Low memory
5325 - decw %cx
5326 - movw %cx, %gs # High memory area
5327 - movw $A20_TEST_LOOPS, %cx
5328 - movw %fs:(A20_TEST_ADDR), %ax
5329 - pushw %ax
5330 -a20_test_wait:
5331 - incw %ax
5332 - movw %ax, %fs:(A20_TEST_ADDR)
5333 - call delay # Serialize and make delay constant
5334 - cmpw %gs:(A20_TEST_ADDR+0x10), %ax
5335 - loope a20_test_wait
5336 -
5337 - popw %fs:(A20_TEST_ADDR)
5338 - popw %ax
5339 - popw %cx
5340 - ret
5341 -
5342 -#endif /* CONFIG_X86_VOYAGER */
5343 -
5344 -# This routine checks that the keyboard command queue is empty
5345 -# (after emptying the output buffers)
5346 -#
5347 -# Some machines have delusions that the keyboard buffer is always full
5348 -# with no keyboard attached...
5349 -#
5350 -# If there is no keyboard controller, we will usually get 0xff
5351 -# to all the reads. With each IO taking a microsecond and
5352 -# a timeout of 100,000 iterations, this can take about half a
5353 -# second ("delay" == outb to port 0x80). That should be ok,
5354 -# and should also be plenty of time for a real keyboard controller
5355 -# to empty.
5356 -#
5357 -
5358 -empty_8042:
5359 - pushl %ecx
5360 - movl $100000, %ecx
5361 -
5362 -empty_8042_loop:
5363 - decl %ecx
5364 - jz empty_8042_end_loop
5365 -
5366 - call delay
5367 -
5368 - inb $0x64, %al # 8042 status port
5369 - testb $1, %al # output buffer?
5370 - jz no_output
5371 -
5372 - call delay
5373 - inb $0x60, %al # read it
5374 - jmp empty_8042_loop
5375 -
5376 -no_output:
5377 - testb $2, %al # is input buffer full?
5378 - jnz empty_8042_loop # yes - loop
5379 -empty_8042_end_loop:
5380 - popl %ecx
5381 - ret
5382 -
5383 -# Read the cmos clock. Return the seconds in al
5384 -gettime:
5385 - pushw %cx
5386 - movb $0x02, %ah
5387 - int $0x1a
5388 - movb %dh, %al # %dh contains the seconds
5389 - andb $0x0f, %al
5390 - movb %dh, %ah
5391 - movb $0x04, %cl
5392 - shrb %cl, %ah
5393 - aad
5394 - popw %cx
5395 - ret
5396 -
5397 -# Delay is needed after doing I/O
5398 -delay:
5399 - outb %al,$0x80
5400 - ret
5401 -
5402 -# Descriptor tables
5403 -#
5404 -# NOTE: The intel manual says gdt should be sixteen bytes aligned for
5405 -# efficiency reasons. However, there are machines which are known not
5406 -# to boot with misaligned GDTs, so alter this at your peril! If you alter
5407 -# GDT_ENTRY_BOOT_CS (in asm/segment.h) remember to leave at least two
5408 -# empty GDT entries (one for NULL and one reserved).
5409 -#
5410 -# NOTE: On some CPUs, the GDT must be 8 byte aligned. This is
5411 -# true for the Voyager Quad CPU card which will not boot without
5412 -# This directive. 16 byte aligment is recommended by intel.
5413 -#
5414 - .align 16
5415 -gdt:
5416 - .fill GDT_ENTRY_BOOT_CS,8,0
5417 -
5418 - .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb)
5419 - .word 0 # base address = 0
5420 - .word 0x9A00 # code read/exec
5421 - .word 0x00CF # granularity = 4096, 386
5422 - # (+5th nibble of limit)
5423 -
5424 - .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb)
5425 - .word 0 # base address = 0
5426 - .word 0x9200 # data read/write
5427 - .word 0x00CF # granularity = 4096, 386
5428 - # (+5th nibble of limit)
5429 -gdt_end:
5430 - .align 4
5431 -
5432 - .word 0 # alignment byte
5433 -idt_48:
5434 - .word 0 # idt limit = 0
5435 - .word 0, 0 # idt base = 0L
5436 -
5437 - .word 0 # alignment byte
5438 -gdt_48:
5439 - .word gdt_end - gdt - 1 # gdt limit
5440 - .word 0, 0 # gdt base (filled in later)
5441 -
5442 -# Include video setup & detection code
5443 -
5444 -#include "video.S"
5445 -
5446 -# Setup signature -- must be last
5447 -setup_sig1: .word SIG1
5448 -setup_sig2: .word SIG2
5449 -
5450 -# After this point, there is some free space which is used by the video mode
5451 -# handling code to store the temporary mode table (not used by the kernel).
5452 -
5453 -modelist:
5454 -
5455 -.text
5456 -endtext:
5457 -.data
5458 -enddata:
5459 -.bss
5460 -endbss:
5461 --- /dev/null
5462 +++ b/arch/i386/boot/setup.ld
5463 @@ -0,0 +1,54 @@
5464 +/*
5465 + * setup.ld
5466 + *
5467 + * Linker script for the i386 setup code
5468 + */
5469 +OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
5470 +OUTPUT_ARCH(i386)
5471 +ENTRY(_start)
5472 +
5473 +SECTIONS
5474 +{
5475 + . = 0;
5476 + .bstext : { *(.bstext) }
5477 + .bsdata : { *(.bsdata) }
5478 +
5479 + . = 497;
5480 + .header : { *(.header) }
5481 + .inittext : { *(.inittext) }
5482 + .initdata : { *(.initdata) }
5483 + .text : { *(.text*) }
5484 +
5485 + . = ALIGN(16);
5486 + .rodata : { *(.rodata*) }
5487 +
5488 + .videocards : {
5489 + video_cards = .;
5490 + *(.videocards)
5491 + video_cards_end = .;
5492 + }
5493 +
5494 + . = ALIGN(16);
5495 + .data : { *(.data*) }
5496 +
5497 + .signature : {
5498 + setup_sig = .;
5499 + LONG(0x5a5aaa55)
5500 + }
5501 +
5502 +
5503 + . = ALIGN(16);
5504 + .bss :
5505 + {
5506 + __bss_start = .;
5507 + *(.bss)
5508 + __bss_end = .;
5509 + }
5510 + . = ALIGN(16);
5511 + _end = .;
5512 +
5513 + /DISCARD/ : { *(.note*) }
5514 +
5515 + . = ASSERT(_end <= 0x8000, "Setup too big!");
5516 + . = ASSERT(hdr == 0x1f1, "The setup header has the wrong offset!");
5517 +}
5518 --- /dev/null
5519 +++ b/arch/i386/boot/string.c
5520 @@ -0,0 +1,34 @@
5521 +/* -*- linux-c -*- ------------------------------------------------------- *
5522 + *
5523 + * Copyright (C) 1991, 1992 Linus Torvalds
5524 + * Copyright 2007 rPath, Inc. - All Rights Reserved
5525 + *
5526 + * This file is part of the Linux kernel, and is made available under
5527 + * the terms of the GNU General Public License version 2.
5528 + *
5529 + * ----------------------------------------------------------------------- */
5530 +
5531 +/*
5532 + * arch/i386/boot/string.c
5533 + *
5534 + * Very basic string functions
5535 + */
5536 +
5537 +#include "boot.h"
5538 +#include <linux/edd.h>
5539 +
5540 +int strcmp(const char *str1, const char *str2)
5541 +{
5542 + const unsigned char *s1 = (const unsigned char *)str1;
5543 + const unsigned char *s2 = (const unsigned char *)str2;
5544 + int delta = 0;
5545 +
5546 + while (*s1 || *s2) {
5547 + delta = *s2 - *s1;
5548 + if (delta)
5549 + return delta;
5550 + s1++;
5551 + s2++;
5552 + }
5553 + return 0;
5554 +}
5555 --- a/arch/i386/boot/tools/build.c
5556 +++ b/arch/i386/boot/tools/build.c
5557 @@ -1,13 +1,12 @@
5558 /*
5559 * Copyright (C) 1991, 1992 Linus Torvalds
5560 * Copyright (C) 1997 Martin Mares
5561 + * Copyright (C) 2007 H. Peter Anvin
5562 */
5563
5564 /*
5565 * This file builds a disk-image from three different files:
5566 *
5567 - * - bootsect: compatibility mbr which prints an error message if
5568 - * someone tries to boot the kernel directly.
5569 * - setup: 8086 machine code, sets up system parm
5570 * - system: 80386 code for actual system
5571 *
5572 @@ -21,6 +20,7 @@
5573 * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
5574 * Cross compiling fixes by Gertjan van Wingerde, July 1996
5575 * Rewritten by Martin Mares, April 1997
5576 + * Substantially overhauled by H. Peter Anvin, April 2007
5577 */
5578
5579 #include <stdio.h>
5580 @@ -32,23 +32,25 @@
5581 #include <sys/sysmacros.h>
5582 #include <unistd.h>
5583 #include <fcntl.h>
5584 +#include <sys/mman.h>
5585 #include <asm/boot.h>
5586
5587 -typedef unsigned char byte;
5588 -typedef unsigned short word;
5589 -typedef unsigned long u32;
5590 +typedef unsigned char u8;
5591 +typedef unsigned short u16;
5592 +typedef unsigned long u32;
5593
5594 #define DEFAULT_MAJOR_ROOT 0
5595 #define DEFAULT_MINOR_ROOT 0
5596
5597 -/* Minimal number of setup sectors (see also bootsect.S) */
5598 -#define SETUP_SECTS 4
5599 +/* Minimal number of setup sectors */
5600 +#define SETUP_SECT_MIN 5
5601 +#define SETUP_SECT_MAX 64
5602
5603 -byte buf[1024];
5604 -int fd;
5605 +/* This must be large enough to hold the entire setup */
5606 +u8 buf[SETUP_SECT_MAX*512];
5607 int is_big_kernel;
5608
5609 -void die(const char * str, ...)
5610 +static void die(const char * str, ...)
5611 {
5612 va_list args;
5613 va_start(args, str);
5614 @@ -57,15 +59,9 @@
5615 exit(1);
5616 }
5617
5618 -void file_open(const char *name)
5619 +static void usage(void)
5620 {
5621 - if ((fd = open(name, O_RDONLY, 0)) < 0)
5622 - die("Unable to open `%s': %m", name);
5623 -}
5624 -
5625 -void usage(void)
5626 -{
5627 - die("Usage: build [-b] bootsect setup system [rootdev] [> image]");
5628 + die("Usage: build [-b] setup system [rootdev] [> image]");
5629 }
5630
5631 int main(int argc, char ** argv)
5632 @@ -73,27 +69,30 @@
5633 unsigned int i, sz, setup_sectors;
5634 int c;
5635 u32 sys_size;
5636 - byte major_root, minor_root;
5637 + u8 major_root, minor_root;
5638 struct stat sb;
5639 + FILE *file;
5640 + int fd;
5641 + void *kernel;
5642
5643 if (argc > 2 && !strcmp(argv[1], "-b"))
5644 {
5645 is_big_kernel = 1;
5646 argc--, argv++;
5647 }
5648 - if ((argc < 4) || (argc > 5))
5649 + if ((argc < 3) || (argc > 4))
5650 usage();
5651 - if (argc > 4) {
5652 - if (!strcmp(argv[4], "CURRENT")) {
5653 + if (argc > 3) {
5654 + if (!strcmp(argv[3], "CURRENT")) {
5655 if (stat("/", &sb)) {
5656 perror("/");
5657 die("Couldn't stat /");
5658 }
5659 major_root = major(sb.st_dev);
5660 minor_root = minor(sb.st_dev);
5661 - } else if (strcmp(argv[4], "FLOPPY")) {
5662 - if (stat(argv[4], &sb)) {
5663 - perror(argv[4]);
5664 + } else if (strcmp(argv[3], "FLOPPY")) {
5665 + if (stat(argv[3], &sb)) {
5666 + perror(argv[3]);
5667 die("Couldn't stat root device.");
5668 }
5669 major_root = major(sb.st_rdev);
5670 @@ -108,79 +107,62 @@
5671 }
5672 fprintf(stderr, "Root device is (%d, %d)\n", major_root, minor_root);
5673
5674 - file_open(argv[1]);
5675 - i = read(fd, buf, sizeof(buf));
5676 - fprintf(stderr,"Boot sector %d bytes.\n",i);
5677 - if (i != 512)
5678 - die("Boot block must be exactly 512 bytes");
5679 + /* Copy the setup code */
5680 + file = fopen(argv[1], "r");
5681 + if (!file)
5682 + die("Unable to open `%s': %m", argv[1]);
5683 + c = fread(buf, 1, sizeof(buf), file);
5684 + if (ferror(file))
5685 + die("read-error on `setup'");
5686 + if (c < 1024)
5687 + die("The setup must be at least 1024 bytes");
5688 if (buf[510] != 0x55 || buf[511] != 0xaa)
5689 die("Boot block hasn't got boot flag (0xAA55)");
5690 + fclose(file);
5691 +
5692 + /* Pad unused space with zeros */
5693 + setup_sectors = (c + 511) / 512;
5694 + if (setup_sectors < SETUP_SECT_MIN)
5695 + setup_sectors = SETUP_SECT_MIN;
5696 + i = setup_sectors*512;
5697 + memset(buf+c, 0, i-c);
5698 +
5699 + /* Set the default root device */
5700 buf[508] = minor_root;
5701 buf[509] = major_root;
5702 - if (write(1, buf, 512) != 512)
5703 - die("Write call failed");
5704 - close (fd);
5705 -
5706 - file_open(argv[2]); /* Copy the setup code */
5707 - for (i=0 ; (c=read(fd, buf, sizeof(buf)))>0 ; i+=c )
5708 - if (write(1, buf, c) != c)
5709 - die("Write call failed");
5710 - if (c != 0)
5711 - die("read-error on `setup'");
5712 - close (fd);
5713
5714 - setup_sectors = (i + 511) / 512; /* Pad unused space with zeros */
5715 - /* for compatibility with ancient versions of LILO. */
5716 - if (setup_sectors < SETUP_SECTS)
5717 - setup_sectors = SETUP_SECTS;
5718 - fprintf(stderr, "Setup is %d bytes.\n", i);
5719 - memset(buf, 0, sizeof(buf));
5720 - while (i < setup_sectors * 512) {
5721 - c = setup_sectors * 512 - i;
5722 - if (c > sizeof(buf))
5723 - c = sizeof(buf);
5724 - if (write(1, buf, c) != c)
5725 - die("Write call failed");
5726 - i += c;
5727 - }
5728 + fprintf(stderr, "Setup is %d bytes (padded to %d bytes).\n", c, i);
5729
5730 - file_open(argv[3]);
5731 - if (fstat (fd, &sb))
5732 - die("Unable to stat `%s': %m", argv[3]);
5733 + /* Open and stat the kernel file */
5734 + fd = open(argv[2], O_RDONLY);
5735 + if (fd < 0)
5736 + die("Unable to open `%s': %m", argv[2]);
5737 + if (fstat(fd, &sb))
5738 + die("Unable to stat `%s': %m", argv[2]);
5739 sz = sb.st_size;
5740 - fprintf (stderr, "System is %d kB\n", sz/1024);
5741 + fprintf (stderr, "System is %d kB\n", (sz+1023)/1024);
5742 + kernel = mmap(NULL, sz, PROT_READ, MAP_SHARED, fd, 0);
5743 + if (kernel == MAP_FAILED)
5744 + die("Unable to mmap '%s': %m", argv[2]);
5745 sys_size = (sz + 15) / 16;
5746 if (!is_big_kernel && sys_size > DEF_SYSSIZE)
5747 die("System is too big. Try using bzImage or modules.");
5748 - while (sz > 0) {
5749 - int l, n;
5750
5751 - l = (sz > sizeof(buf)) ? sizeof(buf) : sz;
5752 - if ((n=read(fd, buf, l)) != l) {
5753 - if (n < 0)
5754 - die("Error reading %s: %m", argv[3]);
5755 - else
5756 - die("%s: Unexpected EOF", argv[3]);
5757 - }
5758 - if (write(1, buf, l) != l)
5759 - die("Write failed");
5760 - sz -= l;
5761 - }
5762 + /* Patch the setup code with the appropriate size parameters */
5763 + buf[0x1f1] = setup_sectors-1;
5764 + buf[0x1f4] = sys_size;
5765 + buf[0x1f5] = sys_size >> 8;
5766 + buf[0x1f6] = sys_size >> 16;
5767 + buf[0x1f7] = sys_size >> 24;
5768 +
5769 + if (fwrite(buf, 1, i, stdout) != i)
5770 + die("Writing setup failed");
5771 +
5772 + /* Copy the kernel code */
5773 + if (fwrite(kernel, 1, sz, stdout) != sz)
5774 + die("Writing kernel failed");
5775 close(fd);
5776
5777 - if (lseek(1, 497, SEEK_SET) != 497) /* Write sizes to the bootsector */
5778 - die("Output: seek failed");
5779 - buf[0] = setup_sectors;
5780 - if (write(1, buf, 1) != 1)
5781 - die("Write of setup sector count failed");
5782 - if (lseek(1, 500, SEEK_SET) != 500)
5783 - die("Output: seek failed");
5784 - buf[0] = (sys_size & 0xff);
5785 - buf[1] = ((sys_size >> 8) & 0xff);
5786 - buf[2] = ((sys_size >> 16) & 0xff);
5787 - buf[3] = ((sys_size >> 24) & 0xff);
5788 - if (write(1, buf, 4) != 4)
5789 - die("Write of image length failed");
5790 -
5791 - return 0; /* Everything is OK */
5792 + /* Everything is OK */
5793 + return 0;
5794 }
5795 --- /dev/null
5796 +++ b/arch/i386/boot/tty.c
5797 @@ -0,0 +1,112 @@
5798 +/* -*- linux-c -*- ------------------------------------------------------- *
5799 + *
5800 + * Copyright (C) 1991, 1992 Linus Torvalds
5801 + * Copyright 2007 rPath, Inc. - All Rights Reserved
5802 + *
5803 + * This file is part of the Linux kernel, and is made available under
5804 + * the terms of the GNU General Public License version 2.
5805 + *
5806 + * ----------------------------------------------------------------------- */
5807 +
5808 +/*
5809 + * arch/i386/boot/tty.c
5810 + *
5811 + * Very simple screen I/O
5812 + * XXX: Probably should add very simple serial I/O?
5813 + */
5814 +
5815 +#include "boot.h"
5816 +
5817 +/*
5818 + * These functions are in .inittext so they can be used to signal
5819 + * error during initialization.
5820 + */
5821 +
5822 +void __attribute__((section(".inittext"))) putchar(int ch)
5823 +{
5824 + unsigned char c = ch;
5825 +
5826 + if (c == '\n')
5827 + putchar('\r'); /* \n -> \r\n */
5828 +
5829 + /* int $0x10 is known to have bugs involving touching registers
5830 + it shouldn't. Be extra conservative... */
5831 + asm volatile("pushal; int $0x10; popal"
5832 + : : "b" (0x0007), "c" (0x0001), "a" (0x0e00|ch));
5833 +}
5834 +
5835 +void __attribute__((section(".inittext"))) puts(const char *str)
5836 +{
5837 + int n = 0;
5838 + while (*str) {
5839 + putchar(*str++);
5840 + n++;
5841 + }
5842 +}
5843 +
5844 +/*
5845 + * Read the CMOS clock through the BIOS, and return the
5846 + * seconds in BCD.
5847 + */
5848 +
5849 +static u8 gettime(void)
5850 +{
5851 + u16 ax = 0x0200;
5852 + u16 cx, dx;
5853 +
5854 + asm("int $0x1a"
5855 + : "+a" (ax), "=c" (cx), "=d" (dx)
5856 + : : "ebx", "esi", "edi");
5857 +
5858 + return dx >> 8;
5859 +}
5860 +
5861 +/*
5862 + * Read from the keyboard
5863 + */
5864 +int getchar(void)
5865 +{
5866 + u16 ax = 0;
5867 + asm("int $0x16" : "+a" (ax));
5868 +
5869 + return ax & 0xff;
5870 +}
5871 +
5872 +static int kbd_pending(void)
5873 +{
5874 + u8 pending;
5875 + asm("int $0x16; setnz %0"
5876 + : "=rm" (pending)
5877 + : "a" (0x0100));
5878 + return pending;
5879 +}
5880 +
5881 +void kbd_flush(void)
5882 +{
5883 + for (;;) {
5884 + if (!kbd_pending())
5885 + break;
5886 + getchar();
5887 + }
5888 +}
5889 +
5890 +int getchar_timeout(void)
5891 +{
5892 + int cnt = 30;
5893 + int t0, t1;
5894 +
5895 + t0 = gettime();
5896 +
5897 + while (cnt) {
5898 + if (kbd_pending())
5899 + return getchar();
5900 +
5901 + t1 = gettime();
5902 + if (t0 != t1) {
5903 + cnt--;
5904 + t0 = t1;
5905 + }
5906 + }
5907 +
5908 + return 0; /* Timeout! */
5909 +}
5910 --- /dev/null
5911 +++ b/arch/i386/boot/version.c
5912 @@ -0,0 +1,23 @@
5913 +/* -*- linux-c -*- ------------------------------------------------------- *
5914 + *
5915 + * Copyright (C) 1991, 1992 Linus Torvalds
5916 + * Copyright 2007 rPath, Inc. - All Rights Reserved
5917 + *
5918 + * This file is part of the Linux kernel, and is made available under
5919 + * the terms of the GNU General Public License version 2.
5920 + *
5921 + * ----------------------------------------------------------------------- */
5922 +
5923 +/*
5924 + * arch/i386/boot/version.c
5925 + *
5926 + * Kernel version string
5927 + */
5928 +
5929 +#include "boot.h"
5930 +#include <linux/utsrelease.h>
5931 +#include <linux/compile.h>
5932 +
5933 +const char kernel_version[] =
5934 + UTS_RELEASE " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ") "
5935 + UTS_VERSION;
5936 --- /dev/null
5937 +++ b/arch/i386/boot/vesa.h
5938 @@ -0,0 +1,79 @@
5939 +/* ----------------------------------------------------------------------- *
5940 + *
5941 + * Copyright 1999-2007 H. Peter Anvin - All Rights Reserved
5942 + *
5943 + * This program is free software; you can redistribute it and/or modify
5944 + * it under the terms of the GNU General Public License as published by
5945 + * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
5946 + * Boston MA 02111-1307, USA; either version 2 of the License, or
5947 + * (at your option) any later version; incorporated herein by reference.
5948 + *
5949 + * ----------------------------------------------------------------------- */
5950 +
5951 +#ifndef BOOT_VESA_H
5952 +#define BOOT_VESA_H
5953 +
5954 +typedef struct {
5955 + u16 off, seg;
5956 +} far_ptr;
5957 +
5958 +/* VESA General Information table */
5959 +struct vesa_general_info {
5960 + u32 signature; /* 0 Magic number = "VESA" */
5961 + u16 version; /* 4 */
5962 + far_ptr vendor_string; /* 6 */
5963 + u32 capabilities; /* 10 */
5964 + far_ptr video_mode_ptr; /* 14 */
5965 + u16 total_memory; /* 18 */
5966 +
5967 + u16 oem_software_rev; /* 20 */
5968 + far_ptr oem_vendor_name_ptr; /* 22 */
5969 + far_ptr oem_product_name_ptr; /* 26 */
5970 + far_ptr oem_product_rev_ptr; /* 30 */
5971 +
5972 + u8 reserved[222]; /* 34 */
5973 + u8 oem_data[256]; /* 256 */
5974 +} __attribute__((packed));
5975 +
5976 +#define VESA_MAGIC ('V' + ('E' << 8) + ('S' << 16) + ('A' << 24))
5977 +#define VBE2_MAGIC ('V' + ('B' << 8) + ('E' << 16) + ('2' << 24))
5978 +
5979 +struct vesa_mode_info {
5980 + u16 mode_attr; /* 0 */
5981 + u8 win_attr[2]; /* 2 */
5982 + u16 win_grain; /* 4 */
5983 + u16 win_size; /* 6 */
5984 + u16 win_seg[2]; /* 8 */
5985 + far_ptr win_scheme; /* 12 */
5986 + u16 logical_scan; /* 16 */
5987 +
5988 + u16 h_res; /* 18 */
5989 + u16 v_res; /* 20 */
5990 + u8 char_width; /* 22 */
5991 + u8 char_height; /* 23 */
5992 + u8 memory_planes; /* 24 */
5993 + u8 bpp; /* 25 */
5994 + u8 banks; /* 26 */
5995 + u8 memory_layout; /* 27 */
5996 + u8 bank_size; /* 28 */
5997 + u8 image_planes; /* 29 */
5998 + u8 page_function; /* 30 */
5999 +
6000 + u8 rmask; /* 31 */
6001 + u8 rpos; /* 32 */
6002 + u8 gmask; /* 33 */
6003 + u8 gpos; /* 34 */
6004 + u8 bmask; /* 35 */
6005 + u8 bpos; /* 36 */
6006 + u8 resv_mask; /* 37 */
6007 + u8 resv_pos; /* 38 */
6008 + u8 dcm_info; /* 39 */
6009 +
6010 + u32 lfb_ptr; /* 40 Linear frame buffer address */
6011 + u32 offscreen_ptr; /* 44 Offscreen memory address */
6012 + u16 offscreen_size; /* 48 */
6013 +
6014 + u8 reserved[206]; /* 50 */
6015 +} __attribute__((packed));
6016 +
6017 +#endif /* LIB_SYS_VESA_H */
6018 --- /dev/null
6019 +++ b/arch/i386/boot/video-bios.c
6020 @@ -0,0 +1,125 @@
6021 +/* -*- linux-c -*- ------------------------------------------------------- *
6022 + *
6023 + * Copyright (C) 1991, 1992 Linus Torvalds
6024 + * Copyright 2007 rPath, Inc. - All Rights Reserved
6025 + *
6026 + * This file is part of the Linux kernel, and is made available under
6027 + * the terms of the GNU General Public License version 2.
6028 + *
6029 + * ----------------------------------------------------------------------- */
6030 +
6031 +/*
6032 + * arch/i386/boot/video-bios.c
6033 + *
6034 + * Standard video BIOS modes
6035 + *
6036 + * We have two options for this; silent and scanned.
6037 + */
6038 +
6039 +#include "boot.h"
6040 +#include "video.h"
6041 +
6042 +__videocard video_bios;
6043 +
6044 +/* Set a conventional BIOS mode */
6045 +static int set_bios_mode(u8 mode);
6046 +
6047 +static int bios_set_mode(struct mode_info *mi)
6048 +{
6049 + return set_bios_mode(mi->mode - VIDEO_FIRST_BIOS);
6050 +}
6051 +
6052 +static int set_bios_mode(u8 mode)
6053 +{
6054 + u16 ax;
6055 + u8 new_mode;
6056 +
6057 + ax = mode; /* AH=0x00 Set Video Mode */
6058 + asm volatile(INT10
6059 + : "+a" (ax)
6060 + : : "ebx", "ecx", "edx", "esi", "edi");
6061 +
6062 + ax = 0x0f00; /* Get Current Video Mode */
6063 + asm volatile(INT10
6064 + : "+a" (ax)
6065 + : : "ebx", "ecx", "edx", "esi", "edi");
6066 +
6067 + do_restore = 1; /* Assume video contents was lost */
6068 + new_mode = ax & 0x7f; /* Not all BIOSes are clean with the top bit */
6069 +
6070 + if (new_mode == mode)
6071 + return 0; /* Mode change OK */
6072 +
6073 + if (new_mode != boot_params.screen_info.orig_video_mode) {
6074 + /* Mode setting failed, but we didn't end up where we
6075 + started. That's bad. Try to revert to the original
6076 + video mode. */
6077 + ax = boot_params.screen_info.orig_video_mode;
6078 + asm volatile(INT10
6079 + : "+a" (ax)
6080 + : : "ebx", "ecx", "edx", "esi", "edi");
6081 + }
6082 + return -1;
6083 +}
6084 +
6085 +static int bios_probe(void)
6086 +{
6087 + u8 mode;
6088 + u8 saved_mode = boot_params.screen_info.orig_video_mode;
6089 + u16 crtc;
6090 + struct mode_info *mi;
6091 + int nmodes = 0;
6092 +
6093 + if (adapter != ADAPTER_EGA && adapter != ADAPTER_VGA)
6094 + return 0;
6095 +
6096 + set_fs(0);
6097 + crtc = vga_crtc();
6098 +
6099 + video_bios.modes = GET_HEAP(struct mode_info, 0);
6100 +
6101 + for (mode = 0x14; mode <= 0x7f; mode++) {
6102 + if (heap_free() < sizeof(struct mode_info))
6103 + break;
6104 +
6105 + if (mode_defined(VIDEO_FIRST_BIOS+mode))
6106 + continue;
6107 +
6108 + if (set_bios_mode(mode))
6109 + continue;
6110 +
6111 + /* Try to verify that it's a text mode. */
6112 +
6113 + /* Attribute Controller: make graphics controller disabled */
6114 + if (in_idx(0x3c0, 0x10) & 0x01)
6115 + continue;
6116 +
6117 + /* Graphics Controller: verify Alpha addressing enabled */
6118 + if (in_idx(0x3ce, 0x06) & 0x01)
6119 + continue;
6120 +
6121 + /* CRTC cursor location low should be zero(?) */
6122 + if (in_idx(crtc, 0x0f))
6123 + continue;
6124 +
6125 + mi = GET_HEAP(struct mode_info, 1);
6126 + mi->mode = VIDEO_FIRST_BIOS+mode;
6127 + mi->x = rdfs16(0x44a);
6128 + mi->y = rdfs8(0x484)+1;
6129 + nmodes++;
6130 + }
6131 +
6132 + set_bios_mode(saved_mode);
6133 +
6134 + return nmodes;
6135 +}
6136 +
6137 +__videocard video_bios =
6138 +{
6139 + .card_name = "BIOS (scanned)",
6140 + .probe = bios_probe,
6141 + .set_mode = bios_set_mode,
6142 + .unsafe = 1,
6143 + .xmode_first = VIDEO_FIRST_BIOS,
6144 + .xmode_n = 0x80,
6145 +};
6146 --- /dev/null
6147 +++ b/arch/i386/boot/video-vesa.c
6148 @@ -0,0 +1,283 @@
6149 +/* -*- linux-c -*- ------------------------------------------------------- *
6150 + *
6151 + * Copyright (C) 1991, 1992 Linus Torvalds
6152 + * Copyright 2007 rPath, Inc. - All Rights Reserved
6153 + *
6154 + * This file is part of the Linux kernel, and is made available under
6155 + * the terms of the GNU General Public License version 2.
6156 + *
6157 + * ----------------------------------------------------------------------- */
6158 +
6159 +/*
6160 + * arch/i386/boot/video-vesa.c
6161 + *
6162 + * VESA text modes
6163 + */
6164 +
6165 +#include "boot.h"
6166 +#include "video.h"
6167 +#include "vesa.h"
6168 +
6169 +/* VESA information */
6170 +static struct vesa_general_info vginfo;
6171 +static struct vesa_mode_info vminfo;
6172 +
6173 +__videocard video_vesa;
6174 +
6175 +static void vesa_store_mode_params_graphics(void);
6176 +
6177 +static int vesa_probe(void)
6178 +{
6179 +#ifdef CONFIG_VIDEO_VESA
6180 + u16 ax;
6181 + u16 mode;
6182 + addr_t mode_ptr;
6183 + struct mode_info *mi;
6184 + int nmodes = 0;
6185 +
6186 + video_vesa.modes = GET_HEAP(struct mode_info, 0);
6187 +
6188 + vginfo.signature = VBE2_MAGIC;
6189 +
6190 + /* Optimistically assume a VESA BIOS is register-clean... */
6191 + ax = 0x4f00;
6192 + asm("int $0x10" : "+a" (ax), "=m" (vginfo) : "D" (&vginfo));
6193 +
6194 + if (ax != 0x004f ||
6195 + vginfo.signature != VESA_MAGIC ||
6196 + vginfo.version < 0x0102)
6197 + return 0; /* Not present */
6198 +
6199 + set_fs(vginfo.video_mode_ptr.seg);
6200 + mode_ptr = vginfo.video_mode_ptr.off;
6201 +
6202 + while ((mode = rdfs16(mode_ptr)) != 0xffff) {
6203 + mode_ptr += 2;
6204 +
6205 + if (heap_free() < sizeof(struct mode_info))
6206 + break; /* Heap full, can't save mode info */
6207 +
6208 + if (mode & ~0x1ff)
6209 + continue;
6210 +
6211 + memset(&vminfo, 0, sizeof vminfo); /* Just in case... */
6212 +
6213 + ax = 0x4f01;
6214 + asm("int $0x10"
6215 + : "+a" (ax), "=m" (vminfo)
6216 + : "c" (mode), "D" (&vminfo));
6217 +
6218 + if (ax != 0x004f)
6219 + continue;
6220 +
6221 + if ((vminfo.mode_attr & 0x15) == 0x05) {
6222 + /* Text Mode, TTY BIOS supported,
6223 + supported by hardware */
6224 + mi = GET_HEAP(struct mode_info, 1);
6225 + mi->mode = mode + VIDEO_FIRST_VESA;
6226 + mi->x = vminfo.h_res;
6227 + mi->y = vminfo.v_res;
6228 + nmodes++;
6229 + } else if ((vminfo.mode_attr & 0x99) == 0x99) {
6230 +#ifdef CONFIG_FB
6231 + /* Graphics mode, color, linear frame buffer
6232 + supported -- register the mode but hide from
6233 + the menu. Only do this if framebuffer is
6234 + configured, however, otherwise the user will
6235 + be left without a screen. */
6236 + mi = GET_HEAP(struct mode_info, 1);
6237 + mi->mode = mode + VIDEO_FIRST_VESA;
6238 + mi->x = mi->y = 0;
6239 + nmodes++;
6240 +#endif
6241 + }
6242 + }
6243 +
6244 + return nmodes;
6245 +#else
6246 + return 0;
6247 +#endif
6248 +}
6249 +
6250 +static int vesa_set_mode(struct mode_info *mode)
6251 +{
6252 + u16 ax;
6253 + int is_graphic;
6254 + u16 vesa_mode = mode->mode - VIDEO_FIRST_VESA;
6255 +
6256 + memset(&vminfo, 0, sizeof vminfo); /* Just in case... */
6257 +
6258 + ax = 0x4f01;
6259 + asm("int $0x10"
6260 + : "+a" (ax), "=m" (vminfo)
6261 + : "c" (vesa_mode), "D" (&vminfo));
6262 +
6263 + if (ax != 0x004f)
6264 + return -1;
6265 +
6266 + if ((vminfo.mode_attr & 0x15) == 0x05) {
6267 + /* It's a supported text mode */
6268 + is_graphic = 0;
6269 + } else if ((vminfo.mode_attr & 0x99) == 0x99) {
6270 + /* It's a graphics mode with linear frame buffer */
6271 + is_graphic = 1;
6272 + vesa_mode |= 0x4000; /* Request linear frame buffer */
6273 + } else {
6274 + return -1; /* Invalid mode */
6275 + }
6276 +
6277 +
6278 + ax = 0x4f02;
6279 + asm volatile("int $0x10"
6280 + : "+a" (ax)
6281 + : "b" (vesa_mode), "D" (0));
6282 +
6283 + if (ax != 0x004f)
6284 + return -1;
6285 +
6286 + graphic_mode = is_graphic;
6287 + if (!is_graphic) {
6288 + /* Text mode */
6289 + force_x = mode->x;
6290 + force_y = mode->y;
6291 + do_restore = 1;
6292 + } else {
6293 + /* Graphics mode */
6294 + vesa_store_mode_params_graphics();
6295 + }
6296 +
6297 + return 0;
6298 +}
6299 +
6300 +
6301 +/* Switch DAC to 8-bit mode */
6302 +static void vesa_dac_set_8bits(void)
6303 +{
6304 + u8 dac_size = 6;
6305 +
6306 + /* If possible, switch the DAC to 8-bit mode */
6307 + if (vginfo.capabilities & 1) {
6308 + u16 ax, bx;
6309 +
6310 + ax = 0x4f08;
6311 + bx = 0x0800;
6312 + asm volatile(INT10
6313 + : "+a" (ax), "+b" (bx)
6314 + : : "ecx", "edx", "esi", "edi");
6315 +
6316 + if (ax == 0x004f)
6317 + dac_size = bx >> 8;
6318 + }
6319 +
6320 + /* Set the color sizes to the DAC size, and offsets to 0 */
6321 + boot_params.screen_info.red_size = dac_size;
6322 + boot_params.screen_info.green_size = dac_size;
6323 + boot_params.screen_info.blue_size = dac_size;
6324 + boot_params.screen_info.rsvd_size = dac_size;
6325 +
6326 + boot_params.screen_info.red_pos = 0;
6327 + boot_params.screen_info.green_pos = 0;
6328 + boot_params.screen_info.blue_pos = 0;
6329 + boot_params.screen_info.rsvd_pos = 0;
6330 +}
6331 +
6332 +/* Save the VESA protected mode info */
6333 +static void vesa_store_pm_info(void)
6334 +{
6335 + u16 ax, bx, di, es;
6336 +
6337 + ax = 0x4f0a;
6338 + bx = di = 0;
6339 + asm("pushw %%es; "INT10"; movw %%es,%0; popw %%es"
6340 + : "=d" (es), "+a" (ax), "+b" (bx), "+D" (di)
6341 + : : "ecx", "esi");
6342 +
6343 + if (ax != 0x004f)
6344 + return;
6345 +
6346 + boot_params.screen_info.vesapm_seg = es;
6347 + boot_params.screen_info.vesapm_off = di;
6348 +}
6349 +
6350 +/*
6351 + * Save video mode parameters for graphics mode
6352 + */
6353 +static void vesa_store_mode_params_graphics(void)
6354 +{
6355 + /* Tell the kernel we're in VESA graphics mode */
6356 + boot_params.screen_info.orig_video_isVGA = 0x23;
6357 +
6358 + /* Mode parameters */
6359 + boot_params.screen_info.vesa_attributes = vminfo.mode_attr;
6360 + boot_params.screen_info.lfb_linelength = vminfo.logical_scan;
6361 + boot_params.screen_info.lfb_width = vminfo.h_res;
6362 + boot_params.screen_info.lfb_height = vminfo.v_res;
6363 + boot_params.screen_info.lfb_depth = vminfo.bpp;
6364 + boot_params.screen_info.pages = vminfo.image_planes;
6365 + boot_params.screen_info.lfb_base = vminfo.lfb_ptr;
6366 + memcpy(&boot_params.screen_info.red_size,
6367 + &vminfo.rmask, 8);
6368 +
6369 + /* General parameters */
6370 + boot_params.screen_info.lfb_size = vginfo.total_memory;
6371 +
6372 + if (vminfo.bpp <= 8)
6373 + vesa_dac_set_8bits();
6374 +
6375 + vesa_store_pm_info();
6376 +}
6377 +
6378 +/*
6379 + * Save EDID information for the kernel; this is invoked, separately,
6380 + * after mode-setting.
6381 + */
6382 +void vesa_store_edid(void)
6383 +{
6384 +#ifdef CONFIG_FIRMWARE_EDID
6385 + u16 ax, bx, cx, dx, di;
6386 +
6387 + /* Apparently used as a nonsense token... */
6388 + memset(&boot_params.edid_info, 0x13, sizeof boot_params.edid_info);
6389 +
6390 + if (vginfo.version < 0x0200)
6391 + return; /* EDID requires VBE 2.0+ */
6392 +
6393 + ax = 0x4f15; /* VBE DDC */
6394 + bx = 0x0000; /* Report DDC capabilities */
6395 + cx = 0; /* Controller 0 */
6396 + di = 0; /* ES:DI must be 0 by spec */
6397 +
6398 + /* Note: The VBE DDC spec is different from the main VESA spec;
6399 + we genuinely have to assume all registers are destroyed here. */
6400 +
6401 + asm("pushw %%es; movw %2,%%es; "INT10"; popw %%es"
6402 + : "+a" (ax), "+b" (bx)
6403 + : "c" (cx), "D" (di)
6404 + : "esi");
6405 +
6406 + if (ax != 0x004f)
6407 + return; /* No EDID */
6408 +
6409 + /* BH = time in seconds to transfer EDD information */
6410 + /* BL = DDC level supported */
6411 +
6412 + ax = 0x4f15; /* VBE DDC */
6413 + bx = 0x0001; /* Read EDID */
6414 + cx = 0; /* Controller 0 */
6415 + dx = 0; /* EDID block number */
6416 + di =(size_t) &boot_params.edid_info; /* (ES:)Pointer to block */
6417 + asm(INT10
6418 + : "+a" (ax), "+b" (bx), "+d" (dx)
6419 + : "c" (cx), "D" (di)
6420 + : "esi");
6421 +#endif /* CONFIG_FIRMWARE_EDID */
6422 +}
6423 +
6424 +__videocard video_vesa =
6425 +{
6426 + .card_name = "VESA",
6427 + .probe = vesa_probe,
6428 + .set_mode = vesa_set_mode,
6429 + .xmode_first = VIDEO_FIRST_VESA,
6430 + .xmode_n = 0x200,
6431 +};
6432 --- /dev/null
6433 +++ b/arch/i386/boot/video-vga.c
6434 @@ -0,0 +1,260 @@
6435 +/* -*- linux-c -*- ------------------------------------------------------- *
6436 + *
6437 + * Copyright (C) 1991, 1992 Linus Torvalds
6438 + * Copyright 2007 rPath, Inc. - All Rights Reserved
6439 + *
6440 + * This file is part of the Linux kernel, and is made available under
6441 + * the terms of the GNU General Public License version 2.
6442 + *
6443 + * ----------------------------------------------------------------------- */
6444 +
6445 +/*
6446 + * arch/i386/boot/video-vga.c
6447 + *
6448 + * Common all-VGA modes
6449 + */
6450 +
6451 +#include "boot.h"
6452 +#include "video.h"
6453 +
6454 +static struct mode_info vga_modes[] = {
6455 + { VIDEO_80x25, 80, 25 },
6456 + { VIDEO_8POINT, 80, 50 },
6457 + { VIDEO_80x43, 80, 43 },
6458 + { VIDEO_80x28, 80, 28 },
6459 + { VIDEO_80x30, 80, 30 },
6460 + { VIDEO_80x34, 80, 34 },
6461 + { VIDEO_80x60, 80, 60 },
6462 +};
6463 +
6464 +static struct mode_info ega_modes[] = {
6465 + { VIDEO_80x25, 80, 25 },
6466 + { VIDEO_8POINT, 80, 43 },
6467 +};
6468 +
6469 +static struct mode_info cga_modes[] = {
6470 + { VIDEO_80x25, 80, 25 },
6471 +};
6472 +
6473 +__videocard video_vga;
6474 +
6475 +/* Set basic 80x25 mode */
6476 +static u8 vga_set_basic_mode(void)
6477 +{
6478 + u16 ax;
6479 + u8 rows;
6480 + u8 mode;
6481 +
6482 +#ifdef CONFIG_VIDEO_400_HACK
6483 + if (adapter >= ADAPTER_VGA) {
6484 + asm(INT10
6485 + : : "a" (0x1202), "b" (0x0030)
6486 + : "ecx", "edx", "esi", "edi");
6487 + }
6488 +#endif
6489 +
6490 + ax = 0x0f00;
6491 + asm(INT10
6492 + : "+a" (ax)
6493 + : : "ebx", "ecx", "edx", "esi", "edi");
6494 +
6495 + mode = (u8)ax;
6496 +
6497 + set_fs(0);
6498 + rows = rdfs8(0x484); /* rows minus one */
6499 +
6500 +#ifndef CONFIG_VIDEO_400_HACK
6501 + if ((ax == 0x5003 || ax == 0x5007) &&
6502 + (rows == 0 || rows == 24))
6503 + return mode;
6504 +#endif
6505 +
6506 + if (mode != 3 && mode != 7)
6507 + mode = 3;
6508 +
6509 + /* Set the mode */
6510 + asm volatile(INT10
6511 + : : "a" (mode)
6512 + : "ebx", "ecx", "edx", "esi", "edi");
6513 + do_restore = 1;
6514 + return mode;
6515 +}
6516 +
6517 +static void vga_set_8font(void)
6518 +{
6519 + /* Set 8x8 font - 80x43 on EGA, 80x50 on VGA */
6520 +
6521 + /* Set 8x8 font */
6522 + asm volatile(INT10 : : "a" (0x1112), "b" (0));
6523 +
6524 + /* Use alternate print screen */
6525 + asm volatile(INT10 : : "a" (0x1200), "b" (0x20));
6526 +
6527 + /* Turn off cursor emulation */
6528 + asm volatile(INT10 : : "a" (0x1201), "b" (0x34));
6529 +
6530 + /* Cursor is scan lines 6-7 */
6531 + asm volatile(INT10 : : "a" (0x0100), "c" (0x0607));
6532 +}
6533 +
6534 +static void vga_set_14font(void)
6535 +{
6536 + /* Set 9x14 font - 80x28 on VGA */
6537 +
6538 + /* Set 9x14 font */
6539 + asm volatile(INT10 : : "a" (0x1111), "b" (0));
6540 +
6541 + /* Turn off cursor emulation */
6542 + asm volatile(INT10 : : "a" (0x1201), "b" (0x34));
6543 +
6544 + /* Cursor is scan lines 11-12 */
6545 + asm volatile(INT10 : : "a" (0x0100), "c" (0x0b0c));
6546 +}
6547 +
6548 +static void vga_set_80x43(void)
6549 +{
6550 + /* Set 80x43 mode on VGA (not EGA) */
6551 +
6552 + /* Set 350 scans */
6553 + asm volatile(INT10 : : "a" (0x1201), "b" (0x30));
6554 +
6555 + /* Reset video mode */
6556 + asm volatile(INT10 : : "a" (0x0003));
6557 +
6558 + vga_set_8font();
6559 +}
6560 +
6561 +/* I/O address of the VGA CRTC */
6562 +u16 vga_crtc(void)
6563 +{
6564 + return (inb(0x3cc) & 1) ? 0x3d4 : 0x3b4;
6565 +}
6566 +
6567 +static void vga_set_480_scanlines(int end)
6568 +{
6569 + u16 crtc;
6570 + u8 csel;
6571 +
6572 + crtc = vga_crtc();
6573 +
6574 + out_idx(0x0c, crtc, 0x11); /* Vertical sync end, unlock CR0-7 */
6575 + out_idx(0x0b, crtc, 0x06); /* Vertical total */
6576 + out_idx(0x3e, crtc, 0x07); /* Vertical overflow */
6577 + out_idx(0xea, crtc, 0x10); /* Vertical sync start */
6578 + out_idx(end, crtc, 0x12); /* Vertical display end */
6579 + out_idx(0xe7, crtc, 0x15); /* Vertical blank start */
6580 + out_idx(0x04, crtc, 0x16); /* Vertical blank end */
6581 + csel = inb(0x3cc);
6582 + csel &= 0x0d;
6583 + csel |= 0xe2;
6584 + outb(csel, 0x3cc);
6585 +}
6586 +
6587 +static void vga_set_80x30(void)
6588 +{
6589 + vga_set_480_scanlines(0xdf);
6590 +}
6591 +
6592 +static void vga_set_80x34(void)
6593 +{
6594 + vga_set_14font();
6595 + vga_set_480_scanlines(0xdb);
6596 +}
6597 +
6598 +static void vga_set_80x60(void)
6599 +{
6600 + vga_set_8font();
6601 + vga_set_480_scanlines(0xdf);
6602 +}
6603 +
6604 +static int vga_set_mode(struct mode_info *mode)
6605 +{
6606 + /* Set the basic mode */
6607 + vga_set_basic_mode();
6608 +
6609 + /* Override a possibly broken BIOS */
6610 + force_x = mode->x;
6611 + force_y = mode->y;
6612 +
6613 + switch (mode->mode) {
6614 + case VIDEO_80x25:
6615 + break;
6616 + case VIDEO_8POINT:
6617 + vga_set_8font();
6618 + break;
6619 + case VIDEO_80x43:
6620 + vga_set_80x43();
6621 + break;
6622 + case VIDEO_80x28:
6623 + vga_set_14font();
6624 + break;
6625 + case VIDEO_80x30:
6626 + vga_set_80x30();
6627 + break;
6628 + case VIDEO_80x34:
6629 + vga_set_80x34();
6630 + break;
6631 + case VIDEO_80x60:
6632 + vga_set_80x60();
6633 + break;
6634 + }
6635 +
6636 + return 0;
6637 +}
6638 +
6639 +/*
6640 + * Note: this probe includes basic information required by all
6641 + * systems. It should be executed first, by making sure
6642 + * video-vga.c is listed first in the Makefile.
6643 + */
6644 +static int vga_probe(void)
6645 +{
6646 + static const char *card_name[] = {
6647 + "CGA/MDA/HGC", "EGA", "VGA"
6648 + };
6649 + static struct mode_info *mode_lists[] = {
6650 + cga_modes,
6651 + ega_modes,
6652 + vga_modes,
6653 + };
6654 + static int mode_count[] = {
6655 + sizeof(cga_modes)/sizeof(struct mode_info),
6656 + sizeof(ega_modes)/sizeof(struct mode_info),
6657 + sizeof(vga_modes)/sizeof(struct mode_info),
6658 + };
6659 + u8 vga_flag;
6660 +
6661 + asm(INT10
6662 + : "=b" (boot_params.screen_info.orig_video_ega_bx)
6663 + : "a" (0x1200), "b" (0x10) /* Check EGA/VGA */
6664 + : "ecx", "edx", "esi", "edi");
6665 +
6666 + /* If we have MDA/CGA/HGC then BL will be unchanged at 0x10 */
6667 + if ((u8)boot_params.screen_info.orig_video_ega_bx != 0x10) {
6668 + /* EGA/VGA */
6669 + asm(INT10
6670 + : "=a" (vga_flag)
6671 + : "a" (0x1a00)
6672 + : "ebx", "ecx", "edx", "esi", "edi");
6673 +
6674 + if (vga_flag == 0x1a) {
6675 + adapter = ADAPTER_VGA;
6676 + boot_params.screen_info.orig_video_isVGA = 1;
6677 + } else {
6678 + adapter = ADAPTER_EGA;
6679 + }
6680 + } else {
6681 + adapter = ADAPTER_CGA;
6682 + }
6683 +
6684 + video_vga.modes = mode_lists[adapter];
6685 + video_vga.card_name = card_name[adapter];
6686 + return mode_count[adapter];
6687 +}
6688 +
6689 +__videocard video_vga =
6690 +{
6691 + .card_name = "VGA",
6692 + .probe = vga_probe,
6693 + .set_mode = vga_set_mode,
6694 +};
6695 --- a/arch/i386/boot/video.S
6696 +++ /dev/null
6697 @@ -1,2043 +0,0 @@
6698 -/* video.S
6699 - *
6700 - * Display adapter & video mode setup, version 2.13 (14-May-99)
6701 - *
6702 - * Copyright (C) 1995 -- 1998 Martin Mares <mj@ucw.cz>
6703 - * Based on the original setup.S code (C) Linus Torvalds and Mats Anderson
6704 - *
6705 - * Rewritten to use GNU 'as' by Chris Noe <stiker@northlink.com> May 1999
6706 - *
6707 - * For further information, look at Documentation/svga.txt.
6708 - *
6709 - */
6710 -
6711 -/* Enable autodetection of SVGA adapters and modes. */
6712 -#undef CONFIG_VIDEO_SVGA
6713 -
6714 -/* Enable autodetection of VESA modes */
6715 -#define CONFIG_VIDEO_VESA
6716 -
6717 -/* Enable compacting of mode table */
6718 -#define CONFIG_VIDEO_COMPACT
6719 -
6720 -/* Retain screen contents when switching modes */
6721 -#define CONFIG_VIDEO_RETAIN
6722 -
6723 -/* Enable local mode list */
6724 -#undef CONFIG_VIDEO_LOCAL
6725 -
6726 -/* Force 400 scan lines for standard modes (hack to fix bad BIOS behaviour */
6727 -#undef CONFIG_VIDEO_400_HACK
6728 -
6729 -/* Hack that lets you force specific BIOS mode ID and specific dimensions */
6730 -#undef CONFIG_VIDEO_GFX_HACK
6731 -#define VIDEO_GFX_BIOS_AX 0x4f02 /* 800x600 on ThinkPad */
6732 -#define VIDEO_GFX_BIOS_BX 0x0102
6733 -#define VIDEO_GFX_DUMMY_RESOLUTION 0x6425 /* 100x37 */
6734 -
6735 -/* This code uses an extended set of video mode numbers. These include:
6736 - * Aliases for standard modes
6737 - * NORMAL_VGA (-1)
6738 - * EXTENDED_VGA (-2)
6739 - * ASK_VGA (-3)
6740 - * Video modes numbered by menu position -- NOT RECOMMENDED because of lack
6741 - * of compatibility when extending the table. These are between 0x00 and 0xff.
6742 - */
6743 -#define VIDEO_FIRST_MENU 0x0000
6744 -
6745 -/* Standard BIOS video modes (BIOS number + 0x0100) */
6746 -#define VIDEO_FIRST_BIOS 0x0100
6747 -
6748 -/* VESA BIOS video modes (VESA number + 0x0200) */
6749 -#define VIDEO_FIRST_VESA 0x0200
6750 -
6751 -/* Video7 special modes (BIOS number + 0x0900) */
6752 -#define VIDEO_FIRST_V7 0x0900
6753 -
6754 -/* Special video modes */
6755 -#define VIDEO_FIRST_SPECIAL 0x0f00
6756 -#define VIDEO_80x25 0x0f00
6757 -#define VIDEO_8POINT 0x0f01
6758 -#define VIDEO_80x43 0x0f02
6759 -#define VIDEO_80x28 0x0f03
6760 -#define VIDEO_CURRENT_MODE 0x0f04
6761 -#define VIDEO_80x30 0x0f05
6762 -#define VIDEO_80x34 0x0f06
6763 -#define VIDEO_80x60 0x0f07
6764 -#define VIDEO_GFX_HACK 0x0f08
6765 -#define VIDEO_LAST_SPECIAL 0x0f09
6766 -
6767 -/* Video modes given by resolution */
6768 -#define VIDEO_FIRST_RESOLUTION 0x1000
6769 -
6770 -/* The "recalculate timings" flag */
6771 -#define VIDEO_RECALC 0x8000
6772 -
6773 -/* Positions of various video parameters passed to the kernel */
6774 -/* (see also include/linux/tty.h) */
6775 -#define PARAM_CURSOR_POS 0x00
6776 -#define PARAM_VIDEO_PAGE 0x04
6777 -#define PARAM_VIDEO_MODE 0x06
6778 -#define PARAM_VIDEO_COLS 0x07
6779 -#define PARAM_VIDEO_EGA_BX 0x0a
6780 -#define PARAM_VIDEO_LINES 0x0e
6781 -#define PARAM_HAVE_VGA 0x0f
6782 -#define PARAM_FONT_POINTS 0x10
6783 -
6784 -#define PARAM_LFB_WIDTH 0x12
6785 -#define PARAM_LFB_HEIGHT 0x14
6786 -#define PARAM_LFB_DEPTH 0x16
6787 -#define PARAM_LFB_BASE 0x18
6788 -#define PARAM_LFB_SIZE 0x1c
6789 -#define PARAM_LFB_LINELENGTH 0x24
6790 -#define PARAM_LFB_COLORS 0x26
6791 -#define PARAM_VESAPM_SEG 0x2e
6792 -#define PARAM_VESAPM_OFF 0x30
6793 -#define PARAM_LFB_PAGES 0x32
6794 -#define PARAM_VESA_ATTRIB 0x34
6795 -#define PARAM_CAPABILITIES 0x36
6796 -
6797 -/* Define DO_STORE according to CONFIG_VIDEO_RETAIN */
6798 -#ifdef CONFIG_VIDEO_RETAIN
6799 -#define DO_STORE call store_screen
6800 -#else
6801 -#define DO_STORE
6802 -#endif /* CONFIG_VIDEO_RETAIN */
6803 -
6804 -# This is the main entry point called by setup.S
6805 -# %ds *must* be pointing to the bootsector
6806 -video: pushw %ds # We use different segments
6807 - pushw %ds # FS contains original DS
6808 - popw %fs
6809 - pushw %cs # DS is equal to CS
6810 - popw %ds
6811 - pushw %cs # ES is equal to CS
6812 - popw %es
6813 - xorw %ax, %ax
6814 - movw %ax, %gs # GS is zero
6815 - cld
6816 - call basic_detect # Basic adapter type testing (EGA/VGA/MDA/CGA)
6817 -#ifdef CONFIG_VIDEO_SELECT
6818 - movw %fs:(0x01fa), %ax # User selected video mode
6819 - cmpw $ASK_VGA, %ax # Bring up the menu
6820 - jz vid2
6821 -
6822 - call mode_set # Set the mode
6823 - jc vid1
6824 -
6825 - leaw badmdt, %si # Invalid mode ID
6826 - call prtstr
6827 -vid2: call mode_menu
6828 -vid1:
6829 -#ifdef CONFIG_VIDEO_RETAIN
6830 - call restore_screen # Restore screen contents
6831 -#endif /* CONFIG_VIDEO_RETAIN */
6832 - call store_edid
6833 -#endif /* CONFIG_VIDEO_SELECT */
6834 - call mode_params # Store mode parameters
6835 - popw %ds # Restore original DS
6836 - ret
6837 -
6838 -# Detect if we have CGA, MDA, EGA or VGA and pass it to the kernel.
6839 -basic_detect:
6840 - movb $0, %fs:(PARAM_HAVE_VGA)
6841 - movb $0x12, %ah # Check EGA/VGA
6842 - movb $0x10, %bl
6843 - int $0x10
6844 - movw %bx, %fs:(PARAM_VIDEO_EGA_BX) # Identifies EGA to the kernel
6845 - cmpb $0x10, %bl # No, it's a CGA/MDA/HGA card.
6846 - je basret
6847 -
6848 - incb adapter
6849 - movw $0x1a00, %ax # Check EGA or VGA?
6850 - int $0x10
6851 - cmpb $0x1a, %al # 1a means VGA...
6852 - jne basret # anything else is EGA.
6853 -
6854 - incb %fs:(PARAM_HAVE_VGA) # We've detected a VGA
6855 - incb adapter
6856 -basret: ret
6857 -
6858 -# Store the video mode parameters for later usage by the kernel.
6859 -# This is done by asking the BIOS except for the rows/columns
6860 -# parameters in the default 80x25 mode -- these are set directly,
6861 -# because some very obscure BIOSes supply insane values.
6862 -mode_params:
6863 -#ifdef CONFIG_VIDEO_SELECT
6864 - cmpb $0, graphic_mode
6865 - jnz mopar_gr
6866 -#endif
6867 - movb $0x03, %ah # Read cursor position
6868 - xorb %bh, %bh
6869 - int $0x10
6870 - movw %dx, %fs:(PARAM_CURSOR_POS)
6871 - movb $0x0f, %ah # Read page/mode/width
6872 - int $0x10
6873 - movw %bx, %fs:(PARAM_VIDEO_PAGE)
6874 - movw %ax, %fs:(PARAM_VIDEO_MODE) # Video mode and screen width
6875 - cmpb $0x7, %al # MDA/HGA => segment differs
6876 - jnz mopar0
6877 -
6878 - movw $0xb000, video_segment
6879 -mopar0: movw %gs:(0x485), %ax # Font size
6880 - movw %ax, %fs:(PARAM_FONT_POINTS) # (valid only on EGA/VGA)
6881 - movw force_size, %ax # Forced size?
6882 - orw %ax, %ax
6883 - jz mopar1
6884 -
6885 - movb %ah, %fs:(PARAM_VIDEO_COLS)
6886 - movb %al, %fs:(PARAM_VIDEO_LINES)
6887 - ret
6888 -
6889 -mopar1: movb $25, %al
6890 - cmpb $0, adapter # If we are on CGA/MDA/HGA, the
6891 - jz mopar2 # screen must have 25 lines.
6892 -
6893 - movb %gs:(0x484), %al # On EGA/VGA, use the EGA+ BIOS
6894 - incb %al # location of max lines.
6895 -mopar2: movb %al, %fs:(PARAM_VIDEO_LINES)
6896 - ret
6897 -
6898 -#ifdef CONFIG_VIDEO_SELECT
6899 -# Fetching of VESA frame buffer parameters
6900 -mopar_gr:
6901 - leaw modelist+1024, %di
6902 - movb $0x23, %fs:(PARAM_HAVE_VGA)
6903 - movw 16(%di), %ax
6904 - movw %ax, %fs:(PARAM_LFB_LINELENGTH)
6905 - movw 18(%di), %ax
6906 - movw %ax, %fs:(PARAM_LFB_WIDTH)
6907 - movw 20(%di), %ax
6908 - movw %ax, %fs:(PARAM_LFB_HEIGHT)
6909 - movb 25(%di), %al
6910 - movb $0, %ah
6911 - movw %ax, %fs:(PARAM_LFB_DEPTH)
6912 - movb 29(%di), %al
6913 - movb $0, %ah
6914 - movw %ax, %fs:(PARAM_LFB_PAGES)
6915 - movl 40(%di), %eax
6916 - movl %eax, %fs:(PARAM_LFB_BASE)
6917 - movl 31(%di), %eax
6918 - movl %eax, %fs:(PARAM_LFB_COLORS)
6919 - movl 35(%di), %eax
6920 - movl %eax, %fs:(PARAM_LFB_COLORS+4)
6921 - movw 0(%di), %ax
6922 - movw %ax, %fs:(PARAM_VESA_ATTRIB)
6923 -
6924 -# get video mem size
6925 - leaw modelist+1024, %di
6926 - movw $0x4f00, %ax
6927 - int $0x10
6928 - xorl %eax, %eax
6929 - movw 18(%di), %ax
6930 - movl %eax, %fs:(PARAM_LFB_SIZE)
6931 -
6932 -# store mode capabilities
6933 - movl 10(%di), %eax
6934 - movl %eax, %fs:(PARAM_CAPABILITIES)
6935 -
6936 -# switching the DAC to 8-bit is for <= 8 bpp only
6937 - movw %fs:(PARAM_LFB_DEPTH), %ax
6938 - cmpw $8, %ax
6939 - jg dac_done
6940 -
6941 -# get DAC switching capability
6942 - xorl %eax, %eax
6943 - movb 10(%di), %al
6944 - testb $1, %al
6945 - jz dac_set
6946 -
6947 -# attempt to switch DAC to 8-bit
6948 - movw $0x4f08, %ax
6949 - movw $0x0800, %bx
6950 - int $0x10
6951 - cmpw $0x004f, %ax
6952 - jne dac_set
6953 - movb %bh, dac_size # store actual DAC size
6954 -
6955 -dac_set:
6956 -# set color size to DAC size
6957 - movb dac_size, %al
6958 - movb %al, %fs:(PARAM_LFB_COLORS+0)
6959 - movb %al, %fs:(PARAM_LFB_COLORS+2)
6960 - movb %al, %fs:(PARAM_LFB_COLORS+4)
6961 - movb %al, %fs:(PARAM_LFB_COLORS+6)
6962 -
6963 -# set color offsets to 0
6964 - movb $0, %fs:(PARAM_LFB_COLORS+1)
6965 - movb $0, %fs:(PARAM_LFB_COLORS+3)
6966 - movb $0, %fs:(PARAM_LFB_COLORS+5)
6967 - movb $0, %fs:(PARAM_LFB_COLORS+7)
6968 -
6969 -dac_done:
6970 -# get protected mode interface informations
6971 - movw $0x4f0a, %ax
6972 - xorw %bx, %bx
6973 - xorw %di, %di
6974 - int $0x10
6975 - cmp $0x004f, %ax
6976 - jnz no_pm
6977 -
6978 - movw %es, %fs:(PARAM_VESAPM_SEG)
6979 - movw %di, %fs:(PARAM_VESAPM_OFF)
6980 -no_pm: ret
6981 -
6982 -# The video mode menu
6983 -mode_menu:
6984 - leaw keymsg, %si # "Return/Space/Timeout" message
6985 - call prtstr
6986 - call flush
6987 -nokey: call getkt
6988 -
6989 - cmpb $0x0d, %al # ENTER ?
6990 - je listm # yes - manual mode selection
6991 -
6992 - cmpb $0x20, %al # SPACE ?
6993 - je defmd1 # no - repeat
6994 -
6995 - call beep
6996 - jmp nokey
6997 -
6998 -defmd1: ret # No mode chosen? Default 80x25
6999 -
7000 -listm: call mode_table # List mode table
7001 -listm0: leaw name_bann, %si # Print adapter name
7002 - call prtstr
7003 - movw card_name, %si
7004 - orw %si, %si
7005 - jnz an2
7006 -
7007 - movb adapter, %al
7008 - leaw old_name, %si
7009 - orb %al, %al
7010 - jz an1
7011 -
7012 - leaw ega_name, %si
7013 - decb %al
7014 - jz an1
7015 -
7016 - leaw vga_name, %si
7017 - jmp an1
7018 -
7019 -an2: call prtstr
7020 - leaw svga_name, %si
7021 -an1: call prtstr
7022 - leaw listhdr, %si # Table header
7023 - call prtstr
7024 - movb $0x30, %dl # DL holds mode number
7025 - leaw modelist, %si
7026 -lm1: cmpw $ASK_VGA, (%si) # End?
7027 - jz lm2
7028 -
7029 - movb %dl, %al # Menu selection number
7030 - call prtchr
7031 - call prtsp2
7032 - lodsw
7033 - call prthw # Mode ID
7034 - call prtsp2
7035 - movb 0x1(%si), %al
7036 - call prtdec # Rows
7037 - movb $0x78, %al # the letter 'x'
7038 - call prtchr
7039 - lodsw
7040 - call prtdec # Columns
7041 - movb $0x0d, %al # New line
7042 - call prtchr
7043 - movb $0x0a, %al
7044 - call prtchr
7045 - incb %dl # Next character
7046 - cmpb $0x3a, %dl
7047 - jnz lm1
7048 -
7049 - movb $0x61, %dl
7050 - jmp lm1
7051 -
7052 -lm2: leaw prompt, %si # Mode prompt
7053 - call prtstr
7054 - leaw edit_buf, %di # Editor buffer
7055 -lm3: call getkey
7056 - cmpb $0x0d, %al # Enter?
7057 - jz lment
7058 -
7059 - cmpb $0x08, %al # Backspace?
7060 - jz lmbs
7061 -
7062 - cmpb $0x20, %al # Printable?
7063 - jc lm3
7064 -
7065 - cmpw $edit_buf+4, %di # Enough space?
7066 - jz lm3
7067 -
7068 - stosb
7069 - call prtchr
7070 - jmp lm3
7071 -
7072 -lmbs: cmpw $edit_buf, %di # Backspace
7073 - jz lm3
7074 -
7075 - decw %di
7076 - movb $0x08, %al
7077 - call prtchr
7078 - call prtspc
7079 - movb $0x08, %al
7080 - call prtchr
7081 - jmp lm3
7082 -
7083 -lment: movb $0, (%di)
7084 - leaw crlft, %si
7085 - call prtstr
7086 - leaw edit_buf, %si
7087 - cmpb $0, (%si) # Empty string = default mode
7088 - jz lmdef
7089 -
7090 - cmpb $0, 1(%si) # One character = menu selection
7091 - jz mnusel
7092 -
7093 - cmpw $0x6373, (%si) # "scan" => mode scanning
7094 - jnz lmhx
7095 -
7096 - cmpw $0x6e61, 2(%si)
7097 - jz lmscan
7098 -
7099 -lmhx: xorw %bx, %bx # Else => mode ID in hex
7100 -lmhex: lodsb
7101 - orb %al, %al
7102 - jz lmuse1
7103 -
7104 - subb $0x30, %al
7105 - jc lmbad
7106 -
7107 - cmpb $10, %al
7108 - jc lmhx1
7109 -
7110 - subb $7, %al
7111 - andb $0xdf, %al
7112 - cmpb $10, %al
7113 - jc lmbad
7114 -
7115 - cmpb $16, %al
7116 - jnc lmbad
7117 -
7118 -lmhx1: shlw $4, %bx
7119 - orb %al, %bl
7120 - jmp lmhex
7121 -
7122 -lmuse1: movw %bx, %ax
7123 - jmp lmuse
7124 -
7125 -mnusel: lodsb # Menu selection
7126 - xorb %ah, %ah
7127 - subb $0x30, %al
7128 - jc lmbad
7129 -
7130 - cmpb $10, %al
7131 - jc lmuse
7132 -
7133 - cmpb $0x61-0x30, %al
7134 - jc lmbad
7135 -
7136 - subb $0x61-0x30-10, %al
7137 - cmpb $36, %al
7138 - jnc lmbad
7139 -
7140 -lmuse: call mode_set
7141 - jc lmdef
7142 -
7143 -lmbad: leaw unknt, %si
7144 - call prtstr
7145 - jmp lm2
7146 -lmscan: cmpb $0, adapter # Scanning only on EGA/VGA
7147 - jz lmbad
7148 -
7149 - movw $0, mt_end # Scanning of modes is
7150 - movb $1, scanning # done as new autodetection.
7151 - call mode_table
7152 - jmp listm0
7153 -lmdef: ret
7154 -
7155 -# Additional parts of mode_set... (relative jumps, you know)
7156 -setv7: # Video7 extended modes
7157 - DO_STORE
7158 - subb $VIDEO_FIRST_V7>>8, %bh
7159 - movw $0x6f05, %ax
7160 - int $0x10
7161 - stc
7162 - ret
7163 -
7164 -_setrec: jmp setrec # Ugly...
7165 -_set_80x25: jmp set_80x25
7166 -
7167 -# Aliases for backward compatibility.
7168 -setalias:
7169 - movw $VIDEO_80x25, %ax
7170 - incw %bx
7171 - jz mode_set
7172 -
7173 - movb $VIDEO_8POINT-VIDEO_FIRST_SPECIAL, %al
7174 - incw %bx
7175 - jnz setbad # Fall-through!
7176 -
7177 -# Setting of user mode (AX=mode ID) => CF=success
7178 -mode_set:
7179 - movw %ax, %fs:(0x01fa) # Store mode for use in acpi_wakeup.S
7180 - movw %ax, %bx
7181 - cmpb $0xff, %ah
7182 - jz setalias
7183 -
7184 - testb $VIDEO_RECALC>>8, %ah
7185 - jnz _setrec
7186 -
7187 - cmpb $VIDEO_FIRST_RESOLUTION>>8, %ah
7188 - jnc setres
7189 -
7190 - cmpb $VIDEO_FIRST_SPECIAL>>8, %ah
7191 - jz setspc
7192 -
7193 - cmpb $VIDEO_FIRST_V7>>8, %ah
7194 - jz setv7
7195 -
7196 - cmpb $VIDEO_FIRST_VESA>>8, %ah
7197 - jnc check_vesa
7198 -
7199 - orb %ah, %ah
7200 - jz setmenu
7201 -
7202 - decb %ah
7203 - jz setbios
7204 -
7205 -setbad: clc
7206 - movb $0, do_restore # The screen needn't be restored
7207 - ret
7208 -
7209 -setvesa:
7210 - DO_STORE
7211 - subb $VIDEO_FIRST_VESA>>8, %bh
7212 - movw $0x4f02, %ax # VESA BIOS mode set call
7213 - int $0x10
7214 - cmpw $0x004f, %ax # AL=4f if implemented
7215 - jnz setbad # AH=0 if OK
7216 -
7217 - stc
7218 - ret
7219 -
7220 -setbios:
7221 - DO_STORE
7222 - int $0x10 # Standard BIOS mode set call
7223 - pushw %bx
7224 - movb $0x0f, %ah # Check if really set
7225 - int $0x10
7226 - popw %bx
7227 - cmpb %bl, %al
7228 - jnz setbad
7229 -
7230 - stc
7231 - ret
7232 -
7233 -setspc: xorb %bh, %bh # Set special mode
7234 - cmpb $VIDEO_LAST_SPECIAL-VIDEO_FIRST_SPECIAL, %bl
7235 - jnc setbad
7236 -
7237 - addw %bx, %bx
7238 - jmp *spec_inits(%bx)
7239 -
7240 -setmenu:
7241 - orb %al, %al # 80x25 is an exception
7242 - jz _set_80x25
7243 -
7244 - pushw %bx # Set mode chosen from menu
7245 - call mode_table # Build the mode table
7246 - popw %ax
7247 - shlw $2, %ax
7248 - addw %ax, %si
7249 - cmpw %di, %si
7250 - jnc setbad
7251 -
7252 - movw (%si), %ax # Fetch mode ID
7253 -_m_s: jmp mode_set
7254 -
7255 -setres: pushw %bx # Set mode chosen by resolution
7256 - call mode_table
7257 - popw %bx
7258 - xchgb %bl, %bh
7259 -setr1: lodsw
7260 - cmpw $ASK_VGA, %ax # End of the list?
7261 - jz setbad
7262 -
7263 - lodsw
7264 - cmpw %bx, %ax
7265 - jnz setr1
7266 -
7267 - movw -4(%si), %ax # Fetch mode ID
7268 - jmp _m_s
7269 -
7270 -check_vesa:
7271 -#ifdef CONFIG_FIRMWARE_EDID
7272 - leaw modelist+1024, %di
7273 - movw $0x4f00, %ax
7274 - int $0x10
7275 - cmpw $0x004f, %ax
7276 - jnz setbad
7277 -
7278 - movw 4(%di), %ax
7279 - movw %ax, vbe_version
7280 -#endif
7281 - leaw modelist+1024, %di
7282 - subb $VIDEO_FIRST_VESA>>8, %bh
7283 - movw %bx, %cx # Get mode information structure
7284 - movw $0x4f01, %ax
7285 - int $0x10
7286 - addb $VIDEO_FIRST_VESA>>8, %bh
7287 - cmpw $0x004f, %ax
7288 - jnz setbad
7289 -
7290 - movb (%di), %al # Check capabilities.
7291 - andb $0x19, %al
7292 - cmpb $0x09, %al
7293 - jz setvesa # This is a text mode
7294 -
7295 - movb (%di), %al # Check capabilities.
7296 - andb $0x99, %al
7297 - cmpb $0x99, %al
7298 - jnz _setbad # Doh! No linear frame buffer.
7299 -
7300 - subb $VIDEO_FIRST_VESA>>8, %bh
7301 - orw $0x4000, %bx # Use linear frame buffer
7302 - movw $0x4f02, %ax # VESA BIOS mode set call
7303 - int $0x10
7304 - cmpw $0x004f, %ax # AL=4f if implemented
7305 - jnz _setbad # AH=0 if OK
7306 -
7307 - movb $1, graphic_mode # flag graphic mode
7308 - movb $0, do_restore # no screen restore
7309 - stc
7310 - ret
7311 -
7312 -_setbad: jmp setbad # Ugly...
7313 -
7314 -# Recalculate vertical display end registers -- this fixes various
7315 -# inconsistencies of extended modes on many adapters. Called when
7316 -# the VIDEO_RECALC flag is set in the mode ID.
7317 -
7318 -setrec: subb $VIDEO_RECALC>>8, %ah # Set the base mode
7319 - call mode_set
7320 - jnc rct3
7321 -
7322 - movw %gs:(0x485), %ax # Font size in pixels
7323 - movb %gs:(0x484), %bl # Number of rows
7324 - incb %bl
7325 - mulb %bl # Number of visible
7326 - decw %ax # scan lines - 1
7327 - movw $0x3d4, %dx
7328 - movw %ax, %bx
7329 - movb $0x12, %al # Lower 8 bits
7330 - movb %bl, %ah
7331 - outw %ax, %dx
7332 - movb $0x07, %al # Bits 8 and 9 in the overflow register
7333 - call inidx
7334 - xchgb %al, %ah
7335 - andb $0xbd, %ah
7336 - shrb %bh
7337 - jnc rct1
7338 - orb $0x02, %ah
7339 -rct1: shrb %bh
7340 - jnc rct2
7341 - orb $0x40, %ah
7342 -rct2: movb $0x07, %al
7343 - outw %ax, %dx
7344 - stc
7345 -rct3: ret
7346 -
7347 -# Table of routines for setting of the special modes.
7348 -spec_inits:
7349 - .word set_80x25
7350 - .word set_8pixel
7351 - .word set_80x43
7352 - .word set_80x28
7353 - .word set_current
7354 - .word set_80x30
7355 - .word set_80x34
7356 - .word set_80x60
7357 - .word set_gfx
7358 -
7359 -# Set the 80x25 mode. If already set, do nothing.
7360 -set_80x25:
7361 - movw $0x5019, force_size # Override possibly broken BIOS
7362 -use_80x25:
7363 -#ifdef CONFIG_VIDEO_400_HACK
7364 - movw $0x1202, %ax # Force 400 scan lines
7365 - movb $0x30, %bl
7366 - int $0x10
7367 -#else
7368 - movb $0x0f, %ah # Get current mode ID
7369 - int $0x10
7370 - cmpw $0x5007, %ax # Mode 7 (80x25 mono) is the only one available
7371 - jz st80 # on CGA/MDA/HGA and is also available on EGAM
7372 -
7373 - cmpw $0x5003, %ax # Unknown mode, force 80x25 color
7374 - jnz force3
7375 -
7376 -st80: cmpb $0, adapter # CGA/MDA/HGA => mode 3/7 is always 80x25
7377 - jz set80
7378 -
7379 - movb %gs:(0x0484), %al # This is EGA+ -- beware of 80x50 etc.
7380 - orb %al, %al # Some buggy BIOS'es set 0 rows
7381 - jz set80
7382 -
7383 - cmpb $24, %al # It's hopefully correct
7384 - jz set80
7385 -#endif /* CONFIG_VIDEO_400_HACK */
7386 -force3: DO_STORE
7387 - movw $0x0003, %ax # Forced set
7388 - int $0x10
7389 -set80: stc
7390 - ret
7391 -
7392 -# Set the 80x50/80x43 8-pixel mode. Simple BIOS calls.
7393 -set_8pixel:
7394 - DO_STORE
7395 - call use_80x25 # The base is 80x25
7396 -set_8pt:
7397 - movw $0x1112, %ax # Use 8x8 font
7398 - xorb %bl, %bl
7399 - int $0x10
7400 - movw $0x1200, %ax # Use alternate print screen
7401 - movb $0x20, %bl
7402 - int $0x10
7403 - movw $0x1201, %ax # Turn off cursor emulation
7404 - movb $0x34, %bl
7405 - int $0x10
7406 - movb $0x01, %ah # Define cursor scan lines 6-7
7407 - movw $0x0607, %cx
7408 - int $0x10
7409 -set_current:
7410 - stc
7411 - ret
7412 -
7413 -# Set the 80x28 mode. This mode works on all VGA's, because it's a standard
7414 -# 80x25 mode with 14-point fonts instead of 16-point.
7415 -set_80x28:
7416 - DO_STORE
7417 - call use_80x25 # The base is 80x25
7418 -set14: movw $0x1111, %ax # Use 9x14 font
7419 - xorb %bl, %bl
7420 - int $0x10
7421 - movb $0x01, %ah # Define cursor scan lines 11-12
7422 - movw $0x0b0c, %cx
7423 - int $0x10
7424 - stc
7425 - ret
7426 -
7427 -# Set the 80x43 mode. This mode is works on all VGA's.
7428 -# It's a 350-scanline mode with 8-pixel font.
7429 -set_80x43:
7430 - DO_STORE
7431 - movw $0x1201, %ax # Set 350 scans
7432 - movb $0x30, %bl
7433 - int $0x10
7434 - movw $0x0003, %ax # Reset video mode
7435 - int $0x10
7436 - jmp set_8pt # Use 8-pixel font
7437 -
7438 -# Set the 80x30 mode (all VGA's). 480 scanlines, 16-pixel font.
7439 -set_80x30:
7440 - call use_80x25 # Start with real 80x25
7441 - DO_STORE
7442 - movw $0x3cc, %dx # Get CRTC port
7443 - inb %dx, %al
7444 - movb $0xd4, %dl
7445 - rorb %al # Mono or color?
7446 - jc set48a
7447 -
7448 - movb $0xb4, %dl
7449 -set48a: movw $0x0c11, %ax # Vertical sync end (also unlocks CR0-7)
7450 - call outidx
7451 - movw $0x0b06, %ax # Vertical total
7452 - call outidx
7453 - movw $0x3e07, %ax # (Vertical) overflow
7454 - call outidx
7455 - movw $0xea10, %ax # Vertical sync start
7456 - call outidx
7457 - movw $0xdf12, %ax # Vertical display end
7458 - call outidx
7459 - movw $0xe715, %ax # Vertical blank start
7460 - call outidx
7461 - movw $0x0416, %ax # Vertical blank end
7462 - call outidx
7463 - pushw %dx
7464 - movb $0xcc, %dl # Misc output register (read)
7465 - inb %dx, %al
7466 - movb $0xc2, %dl # (write)
7467 - andb $0x0d, %al # Preserve clock select bits and color bit
7468 - orb $0xe2, %al # Set correct sync polarity
7469 - outb %al, %dx
7470 - popw %dx
7471 - movw $0x501e, force_size
7472 - stc # That's all.
7473 - ret
7474 -
7475 -# Set the 80x34 mode (all VGA's). 480 scans, 14-pixel font.
7476 -set_80x34:
7477 - call set_80x30 # Set 480 scans
7478 - call set14 # And 14-pt font
7479 - movw $0xdb12, %ax # VGA vertical display end
7480 - movw $0x5022, force_size
7481 -setvde: call outidx
7482 - stc
7483 - ret
7484 -
7485 -# Set the 80x60 mode (all VGA's). 480 scans, 8-pixel font.
7486 -set_80x60:
7487 - call set_80x30 # Set 480 scans
7488 - call set_8pt # And 8-pt font
7489 - movw $0xdf12, %ax # VGA vertical display end
7490 - movw $0x503c, force_size
7491 - jmp setvde
7492 -
7493 -# Special hack for ThinkPad graphics
7494 -set_gfx:
7495 -#ifdef CONFIG_VIDEO_GFX_HACK
7496 - movw $VIDEO_GFX_BIOS_AX, %ax
7497 - movw $VIDEO_GFX_BIOS_BX, %bx
7498 - int $0x10
7499 - movw $VIDEO_GFX_DUMMY_RESOLUTION, force_size
7500 - stc
7501 -#endif
7502 - ret
7503 -
7504 -#ifdef CONFIG_VIDEO_RETAIN
7505 -
7506 -# Store screen contents to temporary buffer.
7507 -store_screen:
7508 - cmpb $0, do_restore # Already stored?
7509 - jnz stsr
7510 -
7511 - testb $CAN_USE_HEAP, loadflags # Have we space for storing?
7512 - jz stsr
7513 -
7514 - pushw %ax
7515 - pushw %bx
7516 - pushw force_size # Don't force specific size
7517 - movw $0, force_size
7518 - call mode_params # Obtain params of current mode
7519 - popw force_size
7520 - movb %fs:(PARAM_VIDEO_LINES), %ah
7521 - movb %fs:(PARAM_VIDEO_COLS), %al
7522 - movw %ax, %bx # BX=dimensions
7523 - mulb %ah
7524 - movw %ax, %cx # CX=number of characters
7525 - addw %ax, %ax # Calculate image size
7526 - addw $modelist+1024+4, %ax
7527 - cmpw heap_end_ptr, %ax
7528 - jnc sts1 # Unfortunately, out of memory
7529 -
7530 - movw %fs:(PARAM_CURSOR_POS), %ax # Store mode params
7531 - leaw modelist+1024, %di
7532 - stosw
7533 - movw %bx, %ax
7534 - stosw
7535 - pushw %ds # Store the screen
7536 - movw video_segment, %ds
7537 - xorw %si, %si
7538 - rep
7539 - movsw
7540 - popw %ds
7541 - incb do_restore # Screen will be restored later
7542 -sts1: popw %bx
7543 - popw %ax
7544 -stsr: ret
7545 -
7546 -# Restore screen contents from temporary buffer.
7547 -restore_screen:
7548 - cmpb $0, do_restore # Has the screen been stored?
7549 - jz res1
7550 -
7551 - call mode_params # Get parameters of current mode
7552 - movb %fs:(PARAM_VIDEO_LINES), %cl
7553 - movb %fs:(PARAM_VIDEO_COLS), %ch
7554 - leaw modelist+1024, %si # Screen buffer
7555 - lodsw # Set cursor position
7556 - movw %ax, %dx
7557 - cmpb %cl, %dh
7558 - jc res2
7559 -
7560 - movb %cl, %dh
7561 - decb %dh
7562 -res2: cmpb %ch, %dl
7563 - jc res3
7564 -
7565 - movb %ch, %dl
7566 - decb %dl
7567 -res3: movb $0x02, %ah
7568 - movb $0x00, %bh
7569 - int $0x10
7570 - lodsw # Display size
7571 - movb %ah, %dl # DL=number of lines
7572 - movb $0, %ah # BX=phys. length of orig. line
7573 - movw %ax, %bx
7574 - cmpb %cl, %dl # Too many?
7575 - jc res4
7576 -
7577 - pushw %ax
7578 - movb %dl, %al
7579 - subb %cl, %al
7580 - mulb %bl
7581 - addw %ax, %si
7582 - addw %ax, %si
7583 - popw %ax
7584 - movb %cl, %dl
7585 -res4: cmpb %ch, %al # Too wide?
7586 - jc res5
7587 -
7588 - movb %ch, %al # AX=width of src. line
7589 -res5: movb $0, %cl
7590 - xchgb %ch, %cl
7591 - movw %cx, %bp # BP=width of dest. line
7592 - pushw %es
7593 - movw video_segment, %es
7594 - xorw %di, %di # Move the data
7595 - addw %bx, %bx # Convert BX and BP to _bytes_
7596 - addw %bp, %bp
7597 -res6: pushw %si
7598 - pushw %di
7599 - movw %ax, %cx
7600 - rep
7601 - movsw
7602 - popw %di
7603 - popw %si
7604 - addw %bp, %di
7605 - addw %bx, %si
7606 - decb %dl
7607 - jnz res6
7608 -
7609 - popw %es # Done
7610 -res1: ret
7611 -#endif /* CONFIG_VIDEO_RETAIN */
7612 -
7613 -# Write to indexed VGA register (AL=index, AH=data, DX=index reg. port)
7614 -outidx: outb %al, %dx
7615 - pushw %ax
7616 - movb %ah, %al
7617 - incw %dx
7618 - outb %al, %dx
7619 - decw %dx
7620 - popw %ax
7621 - ret
7622 -
7623 -# Build the table of video modes (stored after the setup.S code at the
7624 -# `modelist' label. Each video mode record looks like:
7625 -# .word MODE-ID (our special mode ID (see above))
7626 -# .byte rows (number of rows)
7627 -# .byte columns (number of columns)
7628 -# Returns address of the end of the table in DI, the end is marked
7629 -# with a ASK_VGA ID.
7630 -mode_table:
7631 - movw mt_end, %di # Already filled?
7632 - orw %di, %di
7633 - jnz mtab1x
7634 -
7635 - leaw modelist, %di # Store standard modes:
7636 - movl $VIDEO_80x25 + 0x50190000, %eax # The 80x25 mode (ALL)
7637 - stosl
7638 - movb adapter, %al # CGA/MDA/HGA -- no more modes
7639 - orb %al, %al
7640 - jz mtabe
7641 -
7642 - decb %al
7643 - jnz mtabv
7644 -
7645 - movl $VIDEO_8POINT + 0x502b0000, %eax # The 80x43 EGA mode
7646 - stosl
7647 - jmp mtabe
7648 -
7649 -mtab1x: jmp mtab1
7650 -
7651 -mtabv: leaw vga_modes, %si # All modes for std VGA
7652 - movw $vga_modes_end-vga_modes, %cx
7653 - rep # I'm unable to use movsw as I don't know how to store a half
7654 - movsb # of the expression above to cx without using explicit shr.
7655 -
7656 - cmpb $0, scanning # Mode scan requested?
7657 - jz mscan1
7658 -
7659 - call mode_scan
7660 -mscan1:
7661 -
7662 -#ifdef CONFIG_VIDEO_LOCAL
7663 - call local_modes
7664 -#endif /* CONFIG_VIDEO_LOCAL */
7665 -
7666 -#ifdef CONFIG_VIDEO_VESA
7667 - call vesa_modes # Detect VESA VGA modes
7668 -#endif /* CONFIG_VIDEO_VESA */
7669 -
7670 -#ifdef CONFIG_VIDEO_SVGA
7671 - cmpb $0, scanning # Bypass when scanning
7672 - jnz mscan2
7673 -
7674 - call svga_modes # Detect SVGA cards & modes
7675 -mscan2:
7676 -#endif /* CONFIG_VIDEO_SVGA */
7677 -
7678 -mtabe:
7679 -
7680 -#ifdef CONFIG_VIDEO_COMPACT
7681 - leaw modelist, %si
7682 - movw %di, %dx
7683 - movw %si, %di
7684 -cmt1: cmpw %dx, %si # Scan all modes
7685 - jz cmt2
7686 -
7687 - leaw modelist, %bx # Find in previous entries
7688 - movw 2(%si), %cx
7689 -cmt3: cmpw %bx, %si
7690 - jz cmt4
7691 -
7692 - cmpw 2(%bx), %cx # Found => don't copy this entry
7693 - jz cmt5
7694 -
7695 - addw $4, %bx
7696 - jmp cmt3
7697 -
7698 -cmt4: movsl # Copy entry
7699 - jmp cmt1
7700 -
7701 -cmt5: addw $4, %si # Skip entry
7702 - jmp cmt1
7703 -
7704 -cmt2:
7705 -#endif /* CONFIG_VIDEO_COMPACT */
7706 -
7707 - movw $ASK_VGA, (%di) # End marker
7708 - movw %di, mt_end
7709 -mtab1: leaw modelist, %si # SI=mode list, DI=list end
7710 -ret0: ret
7711 -
7712 -# Modes usable on all standard VGAs
7713 -vga_modes:
7714 - .word VIDEO_8POINT
7715 - .word 0x5032 # 80x50
7716 - .word VIDEO_80x43
7717 - .word 0x502b # 80x43
7718 - .word VIDEO_80x28
7719 - .word 0x501c # 80x28
7720 - .word VIDEO_80x30
7721 - .word 0x501e # 80x30
7722 - .word VIDEO_80x34
7723 - .word 0x5022 # 80x34
7724 - .word VIDEO_80x60
7725 - .word 0x503c # 80x60
7726 -#ifdef CONFIG_VIDEO_GFX_HACK
7727 - .word VIDEO_GFX_HACK
7728 - .word VIDEO_GFX_DUMMY_RESOLUTION
7729 -#endif
7730 -
7731 -vga_modes_end:
7732 -# Detect VESA modes.
7733 -
7734 -#ifdef CONFIG_VIDEO_VESA
7735 -vesa_modes:
7736 - cmpb $2, adapter # VGA only
7737 - jnz ret0
7738 -
7739 - movw %di, %bp # BP=original mode table end
7740 - addw $0x200, %di # Buffer space
7741 - movw $0x4f00, %ax # VESA Get card info call
7742 - int $0x10
7743 - movw %bp, %di
7744 - cmpw $0x004f, %ax # Successful?
7745 - jnz ret0
7746 -
7747 - cmpw $0x4556, 0x200(%di)
7748 - jnz ret0
7749 -
7750 - cmpw $0x4153, 0x202(%di)
7751 - jnz ret0
7752 -
7753 - movw $vesa_name, card_name # Set name to "VESA VGA"
7754 - pushw %gs
7755 - lgsw 0x20e(%di), %si # GS:SI=mode list
7756 - movw $128, %cx # Iteration limit
7757 -vesa1:
7758 -# gas version 2.9.1, using BFD version 2.9.1.0.23 buggers the next inst.
7759 -# XXX: lodsw %gs:(%si), %ax # Get next mode in the list
7760 - gs; lodsw
7761 - cmpw $0xffff, %ax # End of the table?
7762 - jz vesar
7763 -
7764 - cmpw $0x0080, %ax # Check validity of mode ID
7765 - jc vesa2
7766 -
7767 - orb %ah, %ah # Valid IDs: 0x0000-0x007f/0x0100-0x07ff
7768 - jz vesan # Certain BIOSes report 0x80-0xff!
7769 -
7770 - cmpw $0x0800, %ax
7771 - jnc vesae
7772 -
7773 -vesa2: pushw %cx
7774 - movw %ax, %cx # Get mode information structure
7775 - movw $0x4f01, %ax
7776 - int $0x10
7777 - movw %cx, %bx # BX=mode number
7778 - addb $VIDEO_FIRST_VESA>>8, %bh
7779 - popw %cx
7780 - cmpw $0x004f, %ax
7781 - jnz vesan # Don't report errors (buggy BIOSES)
7782 -
7783 - movb (%di), %al # Check capabilities. We require
7784 - andb $0x19, %al # a color text mode.
7785 - cmpb $0x09, %al
7786 - jnz vesan
7787 -
7788 - cmpw $0xb800, 8(%di) # Standard video memory address required
7789 - jnz vesan
7790 -
7791 - testb $2, (%di) # Mode characteristics supplied?
7792 - movw %bx, (%di) # Store mode number
7793 - jz vesa3
7794 -
7795 - xorw %dx, %dx
7796 - movw 0x12(%di), %bx # Width
7797 - orb %bh, %bh
7798 - jnz vesan
7799 -
7800 - movb %bl, 0x3(%di)
7801 - movw 0x14(%di), %ax # Height
7802 - orb %ah, %ah
7803 - jnz vesan
7804 -
7805 - movb %al, 2(%di)
7806 - mulb %bl
7807 - cmpw $8193, %ax # Small enough for Linux console driver?
7808 - jnc vesan
7809 -
7810 - jmp vesaok
7811 -
7812 -vesa3: subw $0x8108, %bx # This mode has no detailed info specified,
7813 - jc vesan # so it must be a standard VESA mode.
7814 -
7815 - cmpw $5, %bx
7816 - jnc vesan
7817 -
7818 - movw vesa_text_mode_table(%bx), %ax
7819 - movw %ax, 2(%di)
7820 -vesaok: addw $4, %di # The mode is valid. Store it.
7821 -vesan: loop vesa1 # Next mode. Limit exceeded => error
7822 -vesae: leaw vesaer, %si
7823 - call prtstr
7824 - movw %bp, %di # Discard already found modes.
7825 -vesar: popw %gs
7826 - ret
7827 -
7828 -# Dimensions of standard VESA text modes
7829 -vesa_text_mode_table:
7830 - .byte 60, 80 # 0108
7831 - .byte 25, 132 # 0109
7832 - .byte 43, 132 # 010A
7833 - .byte 50, 132 # 010B
7834 - .byte 60, 132 # 010C
7835 -#endif /* CONFIG_VIDEO_VESA */
7836 -
7837 -# Scan for video modes. A bit dirty, but should work.
7838 -mode_scan:
7839 - movw $0x0100, %cx # Start with mode 0
7840 -scm1: movb $0, %ah # Test the mode
7841 - movb %cl, %al
7842 - int $0x10
7843 - movb $0x0f, %ah
7844 - int $0x10
7845 - cmpb %cl, %al
7846 - jnz scm2 # Mode not set
7847 -
7848 - movw $0x3c0, %dx # Test if it's a text mode
7849 - movb $0x10, %al # Mode bits
7850 - call inidx
7851 - andb $0x03, %al
7852 - jnz scm2
7853 -
7854 - movb $0xce, %dl # Another set of mode bits
7855 - movb $0x06, %al
7856 - call inidx
7857 - shrb %al
7858 - jc scm2
7859 -
7860 - movb $0xd4, %dl # Cursor location
7861 - movb $0x0f, %al
7862 - call inidx
7863 - orb %al, %al
7864 - jnz scm2
7865 -
7866 - movw %cx, %ax # Ok, store the mode
7867 - stosw
7868 - movb %gs:(0x484), %al # Number of rows
7869 - incb %al
7870 - stosb
7871 - movw %gs:(0x44a), %ax # Number of columns
7872 - stosb
7873 -scm2: incb %cl
7874 - jns scm1
7875 -
7876 - movw $0x0003, %ax # Return back to mode 3
7877 - int $0x10
7878 - ret
7879 -
7880 -tstidx: outw %ax, %dx # OUT DX,AX and inidx
7881 -inidx: outb %al, %dx # Read from indexed VGA register
7882 - incw %dx # AL=index, DX=index reg port -> AL=data
7883 - inb %dx, %al
7884 - decw %dx
7885 - ret
7886 -
7887 -# Try to detect type of SVGA card and supply (usually approximate) video
7888 -# mode table for it.
7889 -
7890 -#ifdef CONFIG_VIDEO_SVGA
7891 -svga_modes:
7892 - leaw svga_table, %si # Test all known SVGA adapters
7893 -dosvga: lodsw
7894 - movw %ax, %bp # Default mode table
7895 - orw %ax, %ax
7896 - jz didsv1
7897 -
7898 - lodsw # Pointer to test routine
7899 - pushw %si
7900 - pushw %di
7901 - pushw %es
7902 - movw $0xc000, %bx
7903 - movw %bx, %es
7904 - call *%ax # Call test routine
7905 - popw %es
7906 - popw %di
7907 - popw %si
7908 - orw %bp, %bp
7909 - jz dosvga
7910 -
7911 - movw %bp, %si # Found, copy the modes
7912 - movb svga_prefix, %ah
7913 -cpsvga: lodsb
7914 - orb %al, %al
7915 - jz didsv
7916 -
7917 - stosw
7918 - movsw
7919 - jmp cpsvga
7920 -
7921 -didsv: movw %si, card_name # Store pointer to card name
7922 -didsv1: ret
7923 -
7924 -# Table of all known SVGA cards. For each card, we store a pointer to
7925 -# a table of video modes supported by the card and a pointer to a routine
7926 -# used for testing of presence of the card. The video mode table is always
7927 -# followed by the name of the card or the chipset.
7928 -svga_table:
7929 - .word ati_md, ati_test
7930 - .word oak_md, oak_test
7931 - .word paradise_md, paradise_test
7932 - .word realtek_md, realtek_test
7933 - .word s3_md, s3_test
7934 - .word chips_md, chips_test
7935 - .word video7_md, video7_test
7936 - .word cirrus5_md, cirrus5_test
7937 - .word cirrus6_md, cirrus6_test
7938 - .word cirrus1_md, cirrus1_test
7939 - .word ahead_md, ahead_test
7940 - .word everex_md, everex_test
7941 - .word genoa_md, genoa_test
7942 - .word trident_md, trident_test
7943 - .word tseng_md, tseng_test
7944 - .word 0
7945 -
7946 -# Test routines and mode tables:
7947 -
7948 -# S3 - The test algorithm was taken from the SuperProbe package
7949 -# for XFree86 1.2.1. Report bugs to Christoph.Niemann@linux.org
7950 -s3_test:
7951 - movw $0x0f35, %cx # we store some constants in cl/ch
7952 - movw $0x03d4, %dx
7953 - movb $0x38, %al
7954 - call inidx
7955 - movb %al, %bh # store current CRT-register 0x38
7956 - movw $0x0038, %ax
7957 - call outidx # disable writing to special regs
7958 - movb %cl, %al # check whether we can write special reg 0x35
7959 - call inidx
7960 - movb %al, %bl # save the current value of CRT reg 0x35
7961 - andb $0xf0, %al # clear bits 0-3
7962 - movb %al, %ah
7963 - movb %cl, %al # and write it to CRT reg 0x35
7964 - call outidx
7965 - call inidx # now read it back
7966 - andb %ch, %al # clear the upper 4 bits
7967 - jz s3_2 # the first test failed. But we have a
7968 -
7969 - movb %bl, %ah # second chance
7970 - movb %cl, %al
7971 - call outidx
7972 - jmp s3_1 # do the other tests
7973 -
7974 -s3_2: movw %cx, %ax # load ah with 0xf and al with 0x35
7975 - orb %bl, %ah # set the upper 4 bits of ah with the orig value
7976 - call outidx # write ...
7977 - call inidx # ... and reread
7978 - andb %cl, %al # turn off the upper 4 bits
7979 - pushw %ax
7980 - movb %bl, %ah # restore old value in register 0x35
7981 - movb %cl, %al
7982 - call outidx
7983 - popw %ax
7984 - cmpb %ch, %al # setting lower 4 bits was successful => bad
7985 - je no_s3 # writing is allowed => this is not an S3
7986 -
7987 -s3_1: movw $0x4838, %ax # allow writing to special regs by putting
7988 - call outidx # magic number into CRT-register 0x38
7989 - movb %cl, %al # check whether we can write special reg 0x35
7990 - call inidx
7991 - movb %al, %bl
7992 - andb $0xf0, %al
7993 - movb %al, %ah
7994 - movb %cl, %al
7995 - call outidx
7996 - call inidx
7997 - andb %ch, %al
7998 - jnz no_s3 # no, we can't write => no S3
7999 -
8000 - movw %cx, %ax
8001 - orb %bl, %ah
8002 - call outidx
8003 - call inidx
8004 - andb %ch, %al
8005 - pushw %ax
8006 - movb %bl, %ah # restore old value in register 0x35
8007 - movb %cl, %al
8008 - call outidx
8009 - popw %ax
8010 - cmpb %ch, %al
8011 - jne no_s31 # writing not possible => no S3
8012 - movb $0x30, %al
8013 - call inidx # now get the S3 id ...
8014 - leaw idS3, %di
8015 - movw $0x10, %cx
8016 - repne
8017 - scasb
8018 - je no_s31
8019 -
8020 - movb %bh, %ah
8021 - movb $0x38, %al
8022 - jmp s3rest
8023 -
8024 -no_s3: movb $0x35, %al # restore CRT register 0x35
8025 - movb %bl, %ah
8026 - call outidx
8027 -no_s31: xorw %bp, %bp # Detection failed
8028 -s3rest: movb %bh, %ah
8029 - movb $0x38, %al # restore old value of CRT register 0x38
8030 - jmp outidx
8031 -
8032 -idS3: .byte 0x81, 0x82, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95
8033 - .byte 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa8, 0xb0
8034 -
8035 -s3_md: .byte 0x54, 0x2b, 0x84
8036 - .byte 0x55, 0x19, 0x84
8037 - .byte 0
8038 - .ascii "S3"
8039 - .byte 0
8040 -
8041 -# ATI cards.
8042 -ati_test:
8043 - leaw idati, %si
8044 - movw $0x31, %di
8045 - movw $0x09, %cx
8046 - repe
8047 - cmpsb
8048 - je atiok
8049 -
8050 - xorw %bp, %bp
8051 -atiok: ret
8052 -
8053 -idati: .ascii "761295520"
8054 -
8055 -ati_md: .byte 0x23, 0x19, 0x84
8056 - .byte 0x33, 0x2c, 0x84
8057 - .byte 0x22, 0x1e, 0x64
8058 - .byte 0x21, 0x19, 0x64
8059 - .byte 0x58, 0x21, 0x50
8060 - .byte 0x5b, 0x1e, 0x50
8061 - .byte 0
8062 - .ascii "ATI"
8063 - .byte 0
8064 -
8065 -# AHEAD
8066 -ahead_test:
8067 - movw $0x200f, %ax
8068 - movw $0x3ce, %dx
8069 - outw %ax, %dx
8070 - incw %dx
8071 - inb %dx, %al
8072 - cmpb $0x20, %al
8073 - je isahed
8074 -
8075 - cmpb $0x21, %al
8076 - je isahed
8077 -
8078 - xorw %bp, %bp
8079 -isahed: ret
8080 -
8081 -ahead_md:
8082 - .byte 0x22, 0x2c, 0x84
8083 - .byte 0x23, 0x19, 0x84
8084 - .byte 0x24, 0x1c, 0x84
8085 - .byte 0x2f, 0x32, 0xa0
8086 - .byte 0x32, 0x22, 0x50
8087 - .byte 0x34, 0x42, 0x50
8088 - .byte 0
8089 - .ascii "Ahead"
8090 - .byte 0
8091 -
8092 -# Chips & Tech.
8093 -chips_test:
8094 - movw $0x3c3, %dx
8095 - inb %dx, %al
8096 - orb $0x10, %al
8097 - outb %al, %dx
8098 - movw $0x104, %dx
8099 - inb %dx, %al
8100 - movb %al, %bl
8101 - movw $0x3c3, %dx
8102 - inb %dx, %al
8103 - andb $0xef, %al
8104 - outb %al, %dx
8105 - cmpb $0xa5, %bl
8106 - je cantok
8107 -
8108 - xorw %bp, %bp
8109 -cantok: ret
8110 -
8111 -chips_md:
8112 - .byte 0x60, 0x19, 0x84
8113 - .byte 0x61, 0x32, 0x84
8114 - .byte 0
8115 - .ascii "Chips & Technologies"
8116 - .byte 0
8117 -
8118 -# Cirrus Logic 5X0
8119 -cirrus1_test:
8120 - movw $0x3d4, %dx
8121 - movb $0x0c, %al
8122 - outb %al, %dx
8123 - incw %dx
8124 - inb %dx, %al
8125 - movb %al, %bl
8126 - xorb %al, %al
8127 - outb %al, %dx
8128 - decw %dx
8129 - movb $0x1f, %al
8130 - outb %al, %dx
8131 - incw %dx
8132 - inb %dx, %al
8133 - movb %al, %bh
8134 - xorb %ah, %ah
8135 - shlb $4, %al
8136 - movw %ax, %cx
8137 - movb %bh, %al
8138 - shrb $4, %al
8139 - addw %ax, %cx
8140 - shlw $8, %cx
8141 - addw $6, %cx
8142 - movw %cx, %ax
8143 - movw $0x3c4, %dx
8144 - outw %ax, %dx
8145 - incw %dx
8146 - inb %dx, %al
8147 - andb %al, %al
8148 - jnz nocirr
8149 -
8150 - movb %bh, %al
8151 - outb %al, %dx
8152 - inb %dx, %al
8153 - cmpb $0x01, %al
8154 - je iscirr
8155 -
8156 -nocirr: xorw %bp, %bp
8157 -iscirr: movw $0x3d4, %dx
8158 - movb %bl, %al
8159 - xorb %ah, %ah
8160 - shlw $8, %ax
8161 - addw $0x0c, %ax
8162 - outw %ax, %dx
8163 - ret
8164 -
8165 -cirrus1_md:
8166 - .byte 0x1f, 0x19, 0x84
8167 - .byte 0x20, 0x2c, 0x84
8168 - .byte 0x22, 0x1e, 0x84
8169 - .byte 0x31, 0x25, 0x64
8170 - .byte 0
8171 - .ascii "Cirrus Logic 5X0"
8172 - .byte 0
8173 -
8174 -# Cirrus Logic 54XX
8175 -cirrus5_test:
8176 - movw $0x3c4, %dx
8177 - movb $6, %al
8178 - call inidx
8179 - movb %al, %bl # BL=backup
8180 - movw $6, %ax
8181 - call tstidx
8182 - cmpb $0x0f, %al
8183 - jne c5fail
8184 -
8185 - movw $0x1206, %ax
8186 - call tstidx
8187 - cmpb $0x12, %al
8188 - jne c5fail
8189 -
8190 - movb $0x1e, %al
8191 - call inidx
8192 - movb %al, %bh
8193 - movb %bh, %ah
8194 - andb $0xc0, %ah
8195 - movb $0x1e, %al
8196 - call tstidx
8197 - andb $0x3f, %al
8198 - jne c5xx
8199 -
8200 - movb $0x1e, %al
8201 - movb %bh, %ah
8202 - orb $0x3f, %ah
8203 - call tstidx
8204 - xorb $0x3f, %al
8205 - andb $0x3f, %al
8206 -c5xx: pushf
8207 - movb $0x1e, %al
8208 - movb %bh, %ah
8209 - outw %ax, %dx
8210 - popf
8211 - je c5done
8212 -
8213 -c5fail: xorw %bp, %bp
8214 -c5done: movb $6, %al
8215 - movb %bl, %ah
8216 - outw %ax, %dx
8217 - ret
8218 -
8219 -cirrus5_md:
8220 - .byte 0x14, 0x19, 0x84
8221 - .byte 0x54, 0x2b, 0x84
8222 - .byte 0
8223 - .ascii "Cirrus Logic 54XX"
8224 - .byte 0
8225 -
8226 -# Cirrus Logic 64XX -- no known extra modes, but must be identified, because
8227 -# it's misidentified by the Ahead test.
8228 -cirrus6_test:
8229 - movw $0x3ce, %dx
8230 - movb $0x0a, %al
8231 - call inidx
8232 - movb %al, %bl # BL=backup
8233 - movw $0xce0a, %ax
8234 - call tstidx
8235 - orb %al, %al
8236 - jne c2fail
8237 -
8238 - movw $0xec0a, %ax
8239 - call tstidx
8240 - cmpb $0x01, %al
8241 - jne c2fail
8242 -
8243 - movb $0xaa, %al
8244 - call inidx # 4X, 5X, 7X and 8X are valid 64XX chip ID's.
8245 - shrb $4, %al
8246 - subb $4, %al
8247 - jz c6done
8248 -
8249 - decb %al
8250 - jz c6done
8251 -
8252 - subb $2, %al
8253 - jz c6done
8254 -
8255 - decb %al
8256 - jz c6done
8257 -
8258 -c2fail: xorw %bp, %bp
8259 -c6done: movb $0x0a, %al
8260 - movb %bl, %ah
8261 - outw %ax, %dx
8262 - ret
8263 -
8264 -cirrus6_md:
8265 - .byte 0
8266 - .ascii "Cirrus Logic 64XX"
8267 - .byte 0
8268 -
8269 -# Everex / Trident
8270 -everex_test:
8271 - movw $0x7000, %ax
8272 - xorw %bx, %bx
8273 - int $0x10
8274 - cmpb $0x70, %al
8275 - jne noevrx
8276 -
8277 - shrw $4, %dx
8278 - cmpw $0x678, %dx
8279 - je evtrid
8280 -
8281 - cmpw $0x236, %dx
8282 - jne evrxok
8283 -
8284 -evtrid: leaw trident_md, %bp
8285 -evrxok: ret
8286 -
8287 -noevrx: xorw %bp, %bp
8288 - ret
8289 -
8290 -everex_md:
8291 - .byte 0x03, 0x22, 0x50
8292 - .byte 0x04, 0x3c, 0x50
8293 - .byte 0x07, 0x2b, 0x64
8294 - .byte 0x08, 0x4b, 0x64
8295 - .byte 0x0a, 0x19, 0x84
8296 - .byte 0x0b, 0x2c, 0x84
8297 - .byte 0x16, 0x1e, 0x50
8298 - .byte 0x18, 0x1b, 0x64
8299 - .byte 0x21, 0x40, 0xa0
8300 - .byte 0x40, 0x1e, 0x84
8301 - .byte 0
8302 - .ascii "Everex/Trident"
8303 - .byte 0
8304 -
8305 -# Genoa.
8306 -genoa_test:
8307 - leaw idgenoa, %si # Check Genoa 'clues'
8308 - xorw %ax, %ax
8309 - movb %es:(0x37), %al
8310 - movw %ax, %di
8311 - movw $0x04, %cx
8312 - decw %si
8313 - decw %di
8314 -l1: incw %si
8315 - incw %di
8316 - movb (%si), %al
8317 - testb %al, %al
8318 - jz l2
8319 -
8320 - cmpb %es:(%di), %al
8321 -l2: loope l1
8322 - orw %cx, %cx
8323 - je isgen
8324 -
8325 - xorw %bp, %bp
8326 -isgen: ret
8327 -
8328 -idgenoa: .byte 0x77, 0x00, 0x99, 0x66
8329 -
8330 -genoa_md:
8331 - .byte 0x58, 0x20, 0x50
8332 - .byte 0x5a, 0x2a, 0x64
8333 - .byte 0x60, 0x19, 0x84
8334 - .byte 0x61, 0x1d, 0x84
8335 - .byte 0x62, 0x20, 0x84
8336 - .byte 0x63, 0x2c, 0x84
8337 - .byte 0x64, 0x3c, 0x84
8338 - .byte 0x6b, 0x4f, 0x64
8339 - .byte 0x72, 0x3c, 0x50
8340 - .byte 0x74, 0x42, 0x50
8341 - .byte 0x78, 0x4b, 0x64
8342 - .byte 0
8343 - .ascii "Genoa"
8344 - .byte 0
8345 -
8346 -# OAK
8347 -oak_test:
8348 - leaw idoakvga, %si
8349 - movw $0x08, %di
8350 - movw $0x08, %cx
8351 - repe
8352 - cmpsb
8353 - je isoak
8354 -
8355 - xorw %bp, %bp
8356 -isoak: ret
8357 -
8358 -idoakvga: .ascii "OAK VGA "
8359 -
8360 -oak_md: .byte 0x4e, 0x3c, 0x50
8361 - .byte 0x4f, 0x3c, 0x84
8362 - .byte 0x50, 0x19, 0x84
8363 - .byte 0x51, 0x2b, 0x84
8364 - .byte 0
8365 - .ascii "OAK"
8366 - .byte 0
8367 -
8368 -# WD Paradise.
8369 -paradise_test:
8370 - leaw idparadise, %si
8371 - movw $0x7d, %di
8372 - movw $0x04, %cx
8373 - repe
8374 - cmpsb
8375 - je ispara
8376 -
8377 - xorw %bp, %bp
8378 -ispara: ret
8379 -
8380 -idparadise: .ascii "VGA="
8381 -
8382 -paradise_md:
8383 - .byte 0x41, 0x22, 0x50
8384 - .byte 0x47, 0x1c, 0x84
8385 - .byte 0x55, 0x19, 0x84
8386 - .byte 0x54, 0x2c, 0x84
8387 - .byte 0
8388 - .ascii "Paradise"
8389 - .byte 0
8390 -
8391 -# Trident.
8392 -trident_test:
8393 - movw $0x3c4, %dx
8394 - movb $0x0e, %al
8395 - outb %al, %dx
8396 - incw %dx
8397 - inb %dx, %al
8398 - xchgb %al, %ah
8399 - xorb %al, %al
8400 - outb %al, %dx
8401 - inb %dx, %al
8402 - xchgb %ah, %al
8403 - movb %al, %bl # Strange thing ... in the book this wasn't
8404 - andb $0x02, %bl # necessary but it worked on my card which
8405 - jz setb2 # is a trident. Without it the screen goes
8406 - # blurred ...
8407 - andb $0xfd, %al
8408 - jmp clrb2
8409 -
8410 -setb2: orb $0x02, %al
8411 -clrb2: outb %al, %dx
8412 - andb $0x0f, %ah
8413 - cmpb $0x02, %ah
8414 - je istrid
8415 -
8416 - xorw %bp, %bp
8417 -istrid: ret
8418 -
8419 -trident_md:
8420 - .byte 0x50, 0x1e, 0x50
8421 - .byte 0x51, 0x2b, 0x50
8422 - .byte 0x52, 0x3c, 0x50
8423 - .byte 0x57, 0x19, 0x84
8424 - .byte 0x58, 0x1e, 0x84
8425 - .byte 0x59, 0x2b, 0x84
8426 - .byte 0x5a, 0x3c, 0x84
8427 - .byte 0
8428 - .ascii "Trident"
8429 - .byte 0
8430 -
8431 -# Tseng.
8432 -tseng_test:
8433 - movw $0x3cd, %dx
8434 - inb %dx, %al # Could things be this simple ! :-)
8435 - movb %al, %bl
8436 - movb $0x55, %al
8437 - outb %al, %dx
8438 - inb %dx, %al
8439 - movb %al, %ah
8440 - movb %bl, %al
8441 - outb %al, %dx
8442 - cmpb $0x55, %ah
8443 - je istsen
8444 -
8445 -isnot: xorw %bp, %bp
8446 -istsen: ret
8447 -
8448 -tseng_md:
8449 - .byte 0x26, 0x3c, 0x50
8450 - .byte 0x2a, 0x28, 0x64
8451 - .byte 0x23, 0x19, 0x84
8452 - .byte 0x24, 0x1c, 0x84
8453 - .byte 0x22, 0x2c, 0x84
8454 - .byte 0x21, 0x3c, 0x84
8455 - .byte 0
8456 - .ascii "Tseng"
8457 - .byte 0
8458 -
8459 -# Video7.
8460 -video7_test:
8461 - movw $0x3cc, %dx
8462 - inb %dx, %al
8463 - movw $0x3b4, %dx
8464 - andb $0x01, %al
8465 - jz even7
8466 -
8467 - movw $0x3d4, %dx
8468 -even7: movb $0x0c, %al
8469 - outb %al, %dx
8470 - incw %dx
8471 - inb %dx, %al
8472 - movb %al, %bl
8473 - movb $0x55, %al
8474 - outb %al, %dx
8475 - inb %dx, %al
8476 - decw %dx
8477 - movb $0x1f, %al
8478 - outb %al, %dx
8479 - incw %dx
8480 - inb %dx, %al
8481 - movb %al, %bh
8482 - decw %dx
8483 - movb $0x0c, %al
8484 - outb %al, %dx
8485 - incw %dx
8486 - movb %bl, %al
8487 - outb %al, %dx
8488 - movb $0x55, %al
8489 - xorb $0xea, %al
8490 - cmpb %bh, %al
8491 - jne isnot
8492 -
8493 - movb $VIDEO_FIRST_V7>>8, svga_prefix # Use special mode switching
8494 - ret
8495 -
8496 -video7_md:
8497 - .byte 0x40, 0x2b, 0x50
8498 - .byte 0x43, 0x3c, 0x50
8499 - .byte 0x44, 0x3c, 0x64
8500 - .byte 0x41, 0x19, 0x84
8501 - .byte 0x42, 0x2c, 0x84
8502 - .byte 0x45, 0x1c, 0x84
8503 - .byte 0
8504 - .ascii "Video 7"
8505 - .byte 0
8506 -
8507 -# Realtek VGA
8508 -realtek_test:
8509 - leaw idrtvga, %si
8510 - movw $0x45, %di
8511 - movw $0x0b, %cx
8512 - repe
8513 - cmpsb
8514 - je isrt
8515 -
8516 - xorw %bp, %bp
8517 -isrt: ret
8518 -
8519 -idrtvga: .ascii "REALTEK VGA"
8520 -
8521 -realtek_md:
8522 - .byte 0x1a, 0x3c, 0x50
8523 - .byte 0x1b, 0x19, 0x84
8524 - .byte 0x1c, 0x1e, 0x84
8525 - .byte 0x1d, 0x2b, 0x84
8526 - .byte 0x1e, 0x3c, 0x84
8527 - .byte 0
8528 - .ascii "REALTEK"
8529 - .byte 0
8530 -
8531 -#endif /* CONFIG_VIDEO_SVGA */
8532 -
8533 -# User-defined local mode table (VGA only)
8534 -#ifdef CONFIG_VIDEO_LOCAL
8535 -local_modes:
8536 - leaw local_mode_table, %si
8537 -locm1: lodsw
8538 - orw %ax, %ax
8539 - jz locm2
8540 -
8541 - stosw
8542 - movsw
8543 - jmp locm1
8544 -
8545 -locm2: ret
8546 -
8547 -# This is the table of local video modes which can be supplied manually
8548 -# by the user. Each entry consists of mode ID (word) and dimensions
8549 -# (byte for column count and another byte for row count). These modes
8550 -# are placed before all SVGA and VESA modes and override them if table
8551 -# compacting is enabled. The table must end with a zero word followed
8552 -# by NUL-terminated video adapter name.
8553 -local_mode_table:
8554 - .word 0x0100 # Example: 40x25
8555 - .byte 25,40
8556 - .word 0
8557 - .ascii "Local"
8558 - .byte 0
8559 -#endif /* CONFIG_VIDEO_LOCAL */
8560 -
8561 -# Read a key and return the ASCII code in al, scan code in ah
8562 -getkey: xorb %ah, %ah
8563 - int $0x16
8564 - ret
8565 -
8566 -# Read a key with a timeout of 30 seconds.
8567 -# The hardware clock is used to get the time.
8568 -getkt: call gettime
8569 - addb $30, %al # Wait 30 seconds
8570 - cmpb $60, %al
8571 - jl lminute
8572 -
8573 - subb $60, %al
8574 -lminute:
8575 - movb %al, %cl
8576 -again: movb $0x01, %ah
8577 - int $0x16
8578 - jnz getkey # key pressed, so get it
8579 -
8580 - call gettime
8581 - cmpb %cl, %al
8582 - jne again
8583 -
8584 - movb $0x20, %al # timeout, return `space'
8585 - ret
8586 -
8587 -# Flush the keyboard buffer
8588 -flush: movb $0x01, %ah
8589 - int $0x16
8590 - jz empty
8591 -
8592 - xorb %ah, %ah
8593 - int $0x16
8594 - jmp flush
8595 -
8596 -empty: ret
8597 -
8598 -# Print hexadecimal number.
8599 -prthw: pushw %ax
8600 - movb %ah, %al
8601 - call prthb
8602 - popw %ax
8603 -prthb: pushw %ax
8604 - shrb $4, %al
8605 - call prthn
8606 - popw %ax
8607 - andb $0x0f, %al
8608 -prthn: cmpb $0x0a, %al
8609 - jc prth1
8610 -
8611 - addb $0x07, %al
8612 -prth1: addb $0x30, %al
8613 - jmp prtchr
8614 -
8615 -# Print decimal number in al
8616 -prtdec: pushw %ax
8617 - pushw %cx
8618 - xorb %ah, %ah
8619 - movb $0x0a, %cl
8620 - idivb %cl
8621 - cmpb $0x09, %al
8622 - jbe lt100
8623 -
8624 - call prtdec
8625 - jmp skip10
8626 -
8627 -lt100: addb $0x30, %al
8628 - call prtchr
8629 -skip10: movb %ah, %al
8630 - addb $0x30, %al
8631 - call prtchr
8632 - popw %cx
8633 - popw %ax
8634 - ret
8635 -
8636 -store_edid:
8637 -#ifdef CONFIG_FIRMWARE_EDID
8638 - pushw %es # just save all registers
8639 - pushw %ax
8640 - pushw %bx
8641 - pushw %cx
8642 - pushw %dx
8643 - pushw %di
8644 -
8645 - pushw %fs
8646 - popw %es
8647 -
8648 - movl $0x13131313, %eax # memset block with 0x13
8649 - movw $32, %cx
8650 - movw $0x140, %di
8651 - cld
8652 - rep
8653 - stosl
8654 -
8655 - cmpw $0x0200, vbe_version # only do EDID on >= VBE2.0
8656 - jl no_edid
8657 -
8658 - pushw %es # save ES
8659 - xorw %di, %di # Report Capability
8660 - pushw %di
8661 - popw %es # ES:DI must be 0:0
8662 - movw $0x4f15, %ax
8663 - xorw %bx, %bx
8664 - xorw %cx, %cx
8665 - int $0x10
8666 - popw %es # restore ES
8667 -
8668 - cmpb $0x00, %ah # call successful
8669 - jne no_edid
8670 -
8671 - cmpb $0x4f, %al # function supported
8672 - jne no_edid
8673 -
8674 - movw $0x4f15, %ax # do VBE/DDC
8675 - movw $0x01, %bx
8676 - movw $0x00, %cx
8677 - movw $0x00, %dx
8678 - movw $0x140, %di
8679 - int $0x10
8680 -
8681 -no_edid:
8682 - popw %di # restore all registers
8683 - popw %dx
8684 - popw %cx
8685 - popw %bx
8686 - popw %ax
8687 - popw %es
8688 -#endif
8689 - ret
8690 -
8691 -# VIDEO_SELECT-only variables
8692 -mt_end: .word 0 # End of video mode table if built
8693 -edit_buf: .space 6 # Line editor buffer
8694 -card_name: .word 0 # Pointer to adapter name
8695 -scanning: .byte 0 # Performing mode scan
8696 -do_restore: .byte 0 # Screen contents altered during mode change
8697 -svga_prefix: .byte VIDEO_FIRST_BIOS>>8 # Default prefix for BIOS modes
8698 -graphic_mode: .byte 0 # Graphic mode with a linear frame buffer
8699 -dac_size: .byte 6 # DAC bit depth
8700 -vbe_version: .word 0 # VBE bios version
8701 -
8702 -# Status messages
8703 -keymsg: .ascii "Press <RETURN> to see video modes available, "
8704 - .ascii "<SPACE> to continue or wait 30 secs"
8705 - .byte 0x0d, 0x0a, 0
8706 -
8707 -listhdr: .byte 0x0d, 0x0a
8708 - .ascii "Mode: COLSxROWS:"
8709 -
8710 -crlft: .byte 0x0d, 0x0a, 0
8711 -
8712 -prompt: .byte 0x0d, 0x0a
8713 - .asciz "Enter mode number or `scan': "
8714 -
8715 -unknt: .asciz "Unknown mode ID. Try again."
8716 -
8717 -badmdt: .ascii "You passed an undefined mode number."
8718 - .byte 0x0d, 0x0a, 0
8719 -
8720 -vesaer: .ascii "Error: Scanning of VESA modes failed. Please "
8721 - .ascii "report to <mj@ucw.cz>."
8722 - .byte 0x0d, 0x0a, 0
8723 -
8724 -old_name: .asciz "CGA/MDA/HGA"
8725 -
8726 -ega_name: .asciz "EGA"
8727 -
8728 -svga_name: .ascii " "
8729 -
8730 -vga_name: .asciz "VGA"
8731 -
8732 -vesa_name: .asciz "VESA"
8733 -
8734 -name_bann: .asciz "Video adapter: "
8735 -#endif /* CONFIG_VIDEO_SELECT */
8736 -
8737 -# Other variables:
8738 -adapter: .byte 0 # Video adapter: 0=CGA/MDA/HGA,1=EGA,2=VGA
8739 -video_segment: .word 0xb800 # Video memory segment
8740 -force_size: .word 0 # Use this size instead of the one in BIOS vars
8741 --- /dev/null
8742 +++ b/arch/i386/boot/video.c
8743 @@ -0,0 +1,456 @@
8744 +/* -*- linux-c -*- ------------------------------------------------------- *
8745 + *
8746 + * Copyright (C) 1991, 1992 Linus Torvalds
8747 + * Copyright 2007 rPath, Inc. - All Rights Reserved
8748 + *
8749 + * This file is part of the Linux kernel, and is made available under
8750 + * the terms of the GNU General Public License version 2.
8751 + *
8752 + * ----------------------------------------------------------------------- */
8753 +
8754 +/*
8755 + * arch/i386/boot/video.c
8756 + *
8757 + * Select video mode
8758 + */
8759 +
8760 +#include "boot.h"
8761 +#include "video.h"
8762 +#include "vesa.h"
8763 +
8764 +/*
8765 + * Mode list variables
8766 + */
8767 +static struct card_info cards[]; /* List of cards to probe for */
8768 +
8769 +/*
8770 + * Common variables
8771 + */
8772 +int adapter; /* 0=CGA/MDA/HGC, 1=EGA, 2=VGA+ */
8773 +u16 video_segment;
8774 +int force_x, force_y; /* Don't query the BIOS for cols/rows */
8775 +
8776 +int do_restore = 0; /* Screen contents changed during mode flip */
8777 +int graphic_mode; /* Graphic mode with linear frame buffer */
8778 +
8779 +static void store_cursor_position(void)
8780 +{
8781 + u16 curpos;
8782 + u16 ax, bx;
8783 +
8784 + ax = 0x0300;
8785 + bx = 0;
8786 + asm(INT10
8787 + : "=d" (curpos), "+a" (ax), "+b" (bx)
8788 + : : "ecx", "esi", "edi");
8789 +
8790 + boot_params.screen_info.orig_x = curpos;
8791 + boot_params.screen_info.orig_y = curpos >> 8;
8792 +}
8793 +
8794 +static void store_video_mode(void)
8795 +{
8796 + u16 ax, page;
8797 +
8798 + /* N.B.: the saving of the video page here is a bit silly,
8799 + since we pretty much assume page 0 everywhere. */
8800 + ax = 0x0f00;
8801 + asm(INT10
8802 + : "+a" (ax), "=b" (page)
8803 + : : "ecx", "edx", "esi", "edi");
8804 +
8805 + /* Not all BIOSes are clean with respect to the top bit */
8806 + boot_params.screen_info.orig_video_mode = ax & 0x7f;
8807 + boot_params.screen_info.orig_video_page = page;
8808 +}
8809 +
8810 +/*
8811 + * Store the video mode parameters for later usage by the kernel.
8812 + * This is done by asking the BIOS except for the rows/columns
8813 + * parameters in the default 80x25 mode -- these are set directly,
8814 + * because some very obscure BIOSes supply insane values.
8815 + */
8816 +static void store_mode_params(void)
8817 +{
8818 + u16 font_size;
8819 + int x, y;
8820 +
8821 + /* For graphics mode, it is up to the mode-setting driver
8822 + (currently only video-vesa.c) to store the parameters */
8823 + if (graphic_mode)
8824 + return;
8825 +
8826 + store_cursor_position();
8827 + store_video_mode();
8828 +
8829 + if (boot_params.screen_info.orig_video_mode == 0x07) {
8830 + /* MDA, HGC, or VGA in monochrome mode */
8831 + video_segment = 0xb000;
8832 + } else {
8833 + /* CGA, EGA, VGA and so forth */
8834 + video_segment = 0xb800;
8835 + }
8836 +
8837 + set_fs(0);
8838 + font_size = rdfs16(0x485); /* Font size, BIOS area */
8839 + boot_params.screen_info.orig_video_points = font_size;
8840 +
8841 + x = rdfs16(0x44a);
8842 + y = (adapter == ADAPTER_CGA) ? 25 : rdfs8(0x484)+1;
8843 +
8844 + if (force_x)
8845 + x = force_x;
8846 + if (force_y)
8847 + y = force_y;
8848 +
8849 + boot_params.screen_info.orig_video_cols = x;
8850 + boot_params.screen_info.orig_video_lines = y;
8851 +}
8852 +
8853 +/* Probe the video drivers and have them generate their mode lists. */
8854 +static void probe_cards(int unsafe)
8855 +{
8856 + struct card_info *card;
8857 + static u8 probed[2];
8858 +
8859 + if (probed[unsafe])
8860 + return;
8861 +
8862 + probed[unsafe] = 1;
8863 +
8864 + for (card = video_cards; card < video_cards_end; card++) {
8865 + if (card->unsafe == unsafe) {
8866 + if (card->probe)
8867 + card->nmodes = card->probe();
8868 + else
8869 + card->nmodes = 0;
8870 + }
8871 + }
8872 +}
8873 +
8874 +/* Test if a mode is defined */
8875 +int mode_defined(u16 mode)
8876 +{
8877 + struct card_info *card;
8878 + struct mode_info *mi;
8879 + int i;
8880 +
8881 + for (card = video_cards; card < video_cards_end; card++) {
8882 + mi = card->modes;
8883 + for (i = 0; i < card->nmodes; i++, mi++) {
8884 + if (mi->mode == mode)
8885 + return 1;
8886 + }
8887 + }
8888 +
8889 + return 0;
8890 +}
8891 +
8892 +/* Set mode (without recalc) */
8893 +static int raw_set_mode(u16 mode)
8894 +{
8895 + int nmode, i;
8896 + struct card_info *card;
8897 + struct mode_info *mi;
8898 +
8899 + /* Drop the recalc bit if set */
8900 + mode &= ~VIDEO_RECALC;
8901 +
8902 + /* Scan for mode based on fixed ID, position, or resolution */
8903 + nmode = 0;
8904 + for (card = video_cards; card < video_cards_end; card++) {
8905 + mi = card->modes;
8906 + for (i = 0; i < card->nmodes; i++, mi++) {
8907 + int visible = mi->x || mi->y;
8908 +
8909 + if ((mode == nmode && visible) ||
8910 + mode == mi->mode ||
8911 + mode == (mi->y << 8)+mi->x)
8912 + return card->set_mode(mi);
8913 +
8914 + if (visible)
8915 + nmode++;
8916 + }
8917 + }
8918 +
8919 + /* Nothing found? Is it an "exceptional" (unprobed) mode? */
8920 + for (card = video_cards; card < video_cards_end; card++) {
8921 + if (mode >= card->xmode_first &&
8922 + mode < card->xmode_first+card->xmode_n) {
8923 + struct mode_info mix;
8924 + mix.mode = mode;
8925 + mix.x = mix.y = 0;
8926 + return card->set_mode(&mix);
8927 + }
8928 + }
8929 +
8930 + /* Otherwise, failure... */
8931 + return -1;
8932 +}
8933 +
8934 +/*
8935 + * Recalculate the vertical video cutoff (hack!)
8936 + */
8937 +static void vga_recalc_vertical(void)
8938 +{
8939 + unsigned int font_size, rows;
8940 + u16 crtc;
8941 + u8 ov;
8942 +
8943 + set_fs(0);
8944 + font_size = rdfs8(0x485); /* BIOS: font size (pixels) */
8945 + rows = force_y ? force_y : rdfs8(0x484)+1; /* Text rows */
8946 +
8947 + rows *= font_size; /* Visible scan lines */
8948 + rows--; /* ... minus one */
8949 +
8950 + crtc = vga_crtc();
8951 +
8952 + out_idx((u8)rows, crtc, 0x12); /* Lower height register */
8953 + ov = in_idx(crtc, 0x07); /* Overflow register */
8954 + ov &= 0xbd;
8955 + ov |= (rows >> (8-1)) & 0x02;
8956 + ov |= (rows >> (9-6)) & 0x40;
8957 + out_idx(ov, crtc, 0x07);
8958 +}
8959 +
8960 +/* Set mode (with recalc if specified) */
8961 +static int set_mode(u16 mode)
8962 +{
8963 + int rv;
8964 +
8965 + /* Very special mode numbers... */
8966 + if (mode == VIDEO_CURRENT_MODE)
8967 + return 0; /* Nothing to do... */
8968 + else if (mode == NORMAL_VGA)
8969 + mode = VIDEO_80x25;
8970 + else if (mode == EXTENDED_VGA)
8971 + mode = VIDEO_8POINT;
8972 +
8973 + rv = raw_set_mode(mode);
8974 + if (rv)
8975 + return rv;
8976 +
8977 + if (mode & VIDEO_RECALC)
8978 + vga_recalc_vertical();
8979 +
8980 + return 0;
8981 +}
8982 +
8983 +static unsigned int get_entry(void)
8984 +{
8985 + char entry_buf[4];
8986 + int i, len = 0;
8987 + int key;
8988 + unsigned int v;
8989 +
8990 + do {
8991 + key = getchar();
8992 +
8993 + if (key == '\b') {
8994 + if (len > 0) {
8995 + puts("\b \b");
8996 + len--;
8997 + }
8998 + } else if ((key >= '0' && key <= '9') ||
8999 + (key >= 'A' && key <= 'Z') ||
9000 + (key >= 'a' && key <= 'z')) {
9001 + if (len < sizeof entry_buf) {
9002 + entry_buf[len++] = key;
9003 + putchar(key);
9004 + }
9005 + }
9006 + } while (key != '\r');
9007 + putchar('\n');
9008 +
9009 + if (len == 0)
9010 + return VIDEO_CURRENT_MODE; /* Default */
9011 +
9012 + v = 0;
9013 + for (i = 0; i < len; i++) {
9014 + v <<= 4;
9015 + key = entry_buf[i] | 0x20;
9016 + v += (key > '9') ? key-'a'+10 : key-'0';
9017 + }
9018 +
9019 + return v;
9020 +}
9021 +
9022 +static void display_menu(void)
9023 +{
9024 + struct card_info *card;
9025 + struct mode_info *mi;
9026 + char ch;
9027 + int i;
9028 +
9029 + puts("Mode: COLSxROWS:\n");
9030 +
9031 + ch = '0';
9032 + for (card = video_cards; card < video_cards_end; card++) {
9033 + mi = card->modes;
9034 + for (i = 0; i < card->nmodes; i++, mi++) {
9035 + int visible = mi->x && mi->y;
9036 + u16 mode_id = mi->mode ? mi->mode :
9037 + (mi->y << 8)+mi->x;
9038 +
9039 + if (!visible)
9040 + continue; /* Hidden mode */
9041 +
9042 + printf("%c %04X %3dx%-3d %s\n",
9043 + ch, mode_id, mi->x, mi->y, card->card_name);
9044 +
9045 + if (ch == '9')
9046 + ch = 'a';
9047 + else if (ch == 'z' || ch == ' ')
9048 + ch = ' '; /* Out of keys... */
9049 + else
9050 + ch++;
9051 + }
9052 + }
9053 +}
9054 +
9055 +#define H(x) ((x)-'a'+10)
9056 +#define SCAN ((H('s')<<12)+(H('c')<<8)+(H('a')<<4)+H('n'))
9057 +
9058 +static unsigned int mode_menu(void)
9059 +{
9060 + int key;
9061 + unsigned int sel;
9062 +
9063 + puts("Press <ENTER> to see video modes available, "
9064 + "<SPACE> to continue, or wait 30 sec\n");
9065 +
9066 + kbd_flush();
9067 + while (1) {
9068 + key = getchar_timeout();
9069 + if (key == ' ' || key == 0)
9070 + return VIDEO_CURRENT_MODE; /* Default */
9071 + if (key == '\r')
9072 + break;
9073 + putchar('\a'); /* Beep! */
9074 + }
9075 +
9076 +
9077 + for (;;) {
9078 + display_menu();
9079 +
9080 + puts("Enter a video mode or \"scan\" to scan for "
9081 + "additional modes: ");
9082 + sel = get_entry();
9083 + if (sel != SCAN)
9084 + return sel;
9085 +
9086 + probe_cards(1);
9087 + }
9088 +}
9089 +
9090 +#ifdef CONFIG_VIDEO_RETAIN
9091 +/* Save screen content to the heap */
9092 +struct saved_screen {
9093 + int x, y;
9094 + int curx, cury;
9095 + u16 *data;
9096 +} saved;
9097 +
9098 +static void save_screen(void)
9099 +{
9100 + /* Should be called after store_mode_params() */
9101 + saved.x = boot_params.screen_info.orig_video_cols;
9102 + saved.y = boot_params.screen_info.orig_video_lines;
9103 + saved.curx = boot_params.screen_info.orig_x;
9104 + saved.cury = boot_params.screen_info.orig_y;
9105 +
9106 + if (heap_free() < saved.x*saved.y*sizeof(u16)+512)
9107 + return; /* Not enough heap to save the screen */
9108 +
9109 + saved.data = GET_HEAP(u16, saved.x*saved.y);
9110 +
9111 + set_fs(video_segment);
9112 + copy_from_fs(saved.data, 0, saved.x*saved.y*sizeof(u16));
9113 +}
9114 +
9115 +static void restore_screen(void)
9116 +{
9117 + /* Should be called after store_mode_params() */
9118 + int xs = boot_params.screen_info.orig_video_cols;
9119 + int ys = boot_params.screen_info.orig_video_lines;
9120 + int y;
9121 + addr_t dst = 0;
9122 + u16 *src = saved.data;
9123 + u16 ax, bx, dx;
9124 +
9125 + if (graphic_mode)
9126 + return; /* Can't restore onto a graphic mode */
9127 +
9128 + if (!src)
9129 + return; /* No saved screen contents */
9130 +
9131 + /* Restore screen contents */
9132 +
9133 + set_fs(video_segment);
9134 + for (y = 0; y < ys; y++) {
9135 + int npad;
9136 +
9137 + if (y < saved.y) {
9138 + int copy = (xs < saved.x) ? xs : saved.x;
9139 + copy_to_fs(dst, src, copy*sizeof(u16));
9140 + dst += copy*sizeof(u16);
9141 + src += saved.x;
9142 + npad = (xs < saved.x) ? 0 : xs-saved.x;
9143 + } else {
9144 + npad = xs;
9145 + }
9146 +
9147 + /* Writes "npad" blank characters to
9148 + video_segment:dst and advances dst */
9149 + asm volatile("pushw %%es ; "
9150 + "movw %2,%%es ; "
9151 + "shrw %%cx ; "
9152 + "jnc 1f ; "
9153 + "stosw \n\t"
9154 + "1: rep;stosl ; "
9155 + "popw %%es"
9156 + : "+D" (dst), "+c" (npad)
9157 + : "bdSm" (video_segment),
9158 + "a" (0x07200720));
9159 + }
9160 +
9161 + /* Restore cursor position */
9162 + ax = 0x0200; /* Set cursor position */
9163 + bx = 0; /* Page number (<< 8) */
9164 + dx = (saved.cury << 8)+saved.curx;
9165 + asm volatile(INT10
9166 + : "+a" (ax), "+b" (bx), "+d" (dx)
9167 + : : "ecx", "esi", "edi");
9168 +}
9169 +#else
9170 +#define save_screen() ((void)0)
9171 +#define restore_screen() ((void)0)
9172 +#endif
9173 +
9174 +void set_video(void)
9175 +{
9176 + u16 mode = boot_params.hdr.vid_mode;
9177 +
9178 + RESET_HEAP();
9179 +
9180 + store_mode_params();
9181 + save_screen();
9182 + probe_cards(0);
9183 +
9184 + for (;;) {
9185 + if (mode == ASK_VGA)
9186 + mode = mode_menu();
9187 +
9188 + if (!set_mode(mode))
9189 + break;
9190 +
9191 + printf("Undefined video mode number: %x\n", mode);
9192 + mode = ASK_VGA;
9193 + }
9194 + vesa_store_edid();
9195 + store_mode_params();
9196 +
9197 + if (do_restore)
9198 + restore_screen();
9199 +}
9200 --- /dev/null
9201 +++ b/arch/i386/boot/video.h
9202 @@ -0,0 +1,145 @@
9203 +/* -*- linux-c -*- ------------------------------------------------------- *
9204 + *
9205 + * Copyright (C) 1991, 1992 Linus Torvalds
9206 + * Copyright 2007 rPath, Inc. - All Rights Reserved
9207 + *
9208 + * This file is part of the Linux kernel, and is made available under
9209 + * the terms of the GNU General Public License version 2.
9210 + *
9211 + * ----------------------------------------------------------------------- */
9212 +
9213 +/*
9214 + * arch/i386/boot/video.h
9215 + *
9216 + * Header file for the real-mode video probing code
9217 + */
9218 +
9219 +#ifndef BOOT_VIDEO_H
9220 +#define BOOT_VIDEO_H
9221 +
9222 +#include <linux/types.h>
9223 +
9224 +/* Enable autodetection of SVGA adapters and modes. */
9225 +#undef CONFIG_VIDEO_SVGA
9226 +
9227 +/* Enable autodetection of VESA modes */
9228 +#define CONFIG_VIDEO_VESA
9229 +
9230 +/* Retain screen contents when switching modes */
9231 +#define CONFIG_VIDEO_RETAIN
9232 +
9233 +/* Force 400 scan lines for standard modes (hack to fix bad BIOS behaviour */
9234 +#undef CONFIG_VIDEO_400_HACK
9235 +
9236 +/* This code uses an extended set of video mode numbers. These include:
9237 + * Aliases for standard modes
9238 + * NORMAL_VGA (-1)
9239 + * EXTENDED_VGA (-2)
9240 + * ASK_VGA (-3)
9241 + * Video modes numbered by menu position -- NOT RECOMMENDED because of lack
9242 + * of compatibility when extending the table. These are between 0x00 and 0xff.
9243 + */
9244 +#define VIDEO_FIRST_MENU 0x0000
9245 +
9246 +/* Standard BIOS video modes (BIOS number + 0x0100) */
9247 +#define VIDEO_FIRST_BIOS 0x0100
9248 +
9249 +/* VESA BIOS video modes (VESA number + 0x0200) */
9250 +#define VIDEO_FIRST_VESA 0x0200
9251 +
9252 +/* Video7 special modes (BIOS number + 0x0900) */
9253 +#define VIDEO_FIRST_V7 0x0900
9254 +
9255 +/* Special video modes */
9256 +#define VIDEO_FIRST_SPECIAL 0x0f00
9257 +#define VIDEO_80x25 0x0f00
9258 +#define VIDEO_8POINT 0x0f01
9259 +#define VIDEO_80x43 0x0f02
9260 +#define VIDEO_80x28 0x0f03
9261 +#define VIDEO_CURRENT_MODE 0x0f04
9262 +#define VIDEO_80x30 0x0f05
9263 +#define VIDEO_80x34 0x0f06
9264 +#define VIDEO_80x60 0x0f07
9265 +#define VIDEO_GFX_HACK 0x0f08
9266 +#define VIDEO_LAST_SPECIAL 0x0f09
9267 +
9268 +/* Video modes given by resolution */
9269 +#define VIDEO_FIRST_RESOLUTION 0x1000
9270 +
9271 +/* The "recalculate timings" flag */
9272 +#define VIDEO_RECALC 0x8000
9273 +
9274 +/* Define DO_STORE according to CONFIG_VIDEO_RETAIN */
9275 +#ifdef CONFIG_VIDEO_RETAIN
9276 +void store_screen(void);
9277 +#define DO_STORE() store_screen()
9278 +#else
9279 +#define DO_STORE() ((void)0)
9280 +#endif /* CONFIG_VIDEO_RETAIN */
9281 +
9282 +/*
9283 + * Mode table structures
9284 + */
9285 +
9286 +struct mode_info {
9287 + u16 mode; /* Mode number (vga= style) */
9288 + u8 x, y; /* Width, height */
9289 +};
9290 +
9291 +struct card_info {
9292 + const char *card_name;
9293 + int (*set_mode)(struct mode_info *mode);
9294 + int (*probe)(void);
9295 + struct mode_info *modes;
9296 + int nmodes; /* Number of probed modes so far */
9297 + int unsafe; /* Probing is unsafe, only do after "scan" */
9298 + u16 xmode_first; /* Unprobed modes to try to call anyway */
9299 + u16 xmode_n; /* Size of unprobed mode range */
9300 +};
9301 +
9302 +#define __videocard struct card_info __attribute__((section(".videocards")))
9303 +extern struct card_info video_cards[], video_cards_end[];
9304 +
9305 +int mode_defined(u16 mode); /* video.c */
9306 +
9307 +/* Basic video information */
9308 +#define ADAPTER_CGA 0 /* CGA/MDA/HGC */
9309 +#define ADAPTER_EGA 1
9310 +#define ADAPTER_VGA 2
9311 +
9312 +extern int adapter;
9313 +extern u16 video_segment;
9314 +extern int force_x, force_y; /* Don't query the BIOS for cols/rows */
9315 +extern int do_restore; /* Restore screen contents */
9316 +extern int graphic_mode; /* Graphics mode with linear frame buffer */
9317 +
9318 +/*
9319 + * int $0x10 is notorious for touching registers it shouldn't.
9320 + * gcc doesn't like %ebp being clobbered, so define it as a push/pop
9321 + * sequence here.
9322 + */
9323 +#define INT10 "pushl %%ebp; int $0x10; popl %%ebp"
9324 +
9325 +/* Accessing VGA indexed registers */
9326 +static inline u8 in_idx(u16 port, u8 index)
9327 +{
9328 + outb(index, port);
9329 + return inb(port+1);
9330 +}
9331 +
9332 +static inline void out_idx(u8 v, u16 port, u8 index)
9333 +{
9334 + outw(index+(v << 8), port);
9335 +}
9336 +
9337 +/* Writes a value to an indexed port and then reads the port again */
9338 +static inline u8 tst_idx(u8 v, u16 port, u8 index)
9339 +{
9340 + out_idx(port, index, v);
9341 + return in_idx(port, index);
9342 +}
9343 +
9344 +/* Get the I/O port of the VGA CRTC */
9345 +u16 vga_crtc(void); /* video-vga.c */
9346 +
9347 +#endif /* BOOT_VIDEO_H */
9348 --- /dev/null
9349 +++ b/arch/i386/boot/voyager.c
9350 @@ -0,0 +1,46 @@
9351 +/* -*- linux-c -*- ------------------------------------------------------- *
9352 + *
9353 + * Copyright (C) 1991, 1992 Linus Torvalds
9354 + * Copyright 2007 rPath, Inc. - All Rights Reserved
9355 + *
9356 + * This file is part of the Linux kernel, and is made available under
9357 + * the terms of the GNU General Public License version 2.
9358 + *
9359 + * ----------------------------------------------------------------------- */
9360 +
9361 +/*
9362 + * arch/i386/boot/voyager.c
9363 + *
9364 + * Get the Voyager config information
9365 + */
9366 +
9367 +#include "boot.h"
9368 +
9369 +#ifdef CONFIG_X86_VOYAGER
9370 +
9371 +int query_voyager(void)
9372 +{
9373 + u8 err;
9374 + u16 es, di;
9375 + /* Abuse the apm_bios_info area for this */
9376 + u8 *data_ptr = (u8 *)&boot_params.apm_bios_info;
9377 +
9378 + data_ptr[0] = 0xff; /* Flag on config not found(?) */
9379 +
9380 + asm("pushw %%es ; "
9381 + "int $0x15 ; "
9382 + "setc %0 ; "
9383 + "movw %%es, %1 ; "
9384 + "popw %%es"
9385 + : "=qm" (err), "=rm" (es), "=D" (di)
9386 + : "a" (0xffc0));
9387 +
9388 + if (err)
9389 + return -1; /* Not Voyager */
9390 +
9391 + set_fs(es);
9392 + copy_from_fs(data_ptr, di, 7); /* Table is 7 bytes apparently */
9393 + return 0;
9394 +}
9395 +
9396 +#endif /* CONFIG_X86_VOYAGER */
9397 --- /dev/null
9398 +++ b/arch/i386/kernel/cpu/addon_cpuid_features.c
9399 @@ -0,0 +1,50 @@
9400 +
9401 +/*
9402 + * Routines to indentify additional cpu features that are scattered in
9403 + * cpuid space.
9404 + */
9405 +
9406 +#include <linux/cpu.h>
9407 +
9408 +#include <asm/processor.h>
9409 +
9410 +struct cpuid_bit {
9411 + u16 feature;
9412 + u8 reg;
9413 + u8 bit;
9414 + u32 level;
9415 +};
9416 +
9417 +enum cpuid_regs {
9418 + CR_EAX = 0,
9419 + CR_ECX,
9420 + CR_EDX,
9421 + CR_EBX
9422 +};
9423 +
9424 +void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)
9425 +{
9426 + u32 max_level;
9427 + u32 regs[4];
9428 + const struct cpuid_bit *cb;
9429 +
9430 + static const struct cpuid_bit cpuid_bits[] = {
9431 + { X86_FEATURE_IDA, CR_EAX, 1, 0x00000006 },
9432 + { 0, 0, 0, 0 }
9433 + };
9434 +
9435 + for (cb = cpuid_bits; cb->feature; cb++) {
9436 +
9437 + /* Verify that the level is valid */
9438 + max_level = cpuid_eax(cb->level & 0xffff0000);
9439 + if (max_level < cb->level ||
9440 + max_level > (cb->level | 0xffff))
9441 + continue;
9442 +
9443 + cpuid(cb->level, &regs[CR_EAX], &regs[CR_EBX],
9444 + &regs[CR_ECX], &regs[CR_EDX]);
9445 +
9446 + if (regs[cb->reg] & (1 << cb->bit))
9447 + set_bit(cb->feature, c->x86_capability);
9448 + }
9449 +}
9450 --- a/arch/i386/kernel/cpu/common.c
9451 +++ b/arch/i386/kernel/cpu/common.c
9452 @@ -353,6 +353,8 @@
9453 if ( xlvl >= 0x80000004 )
9454 get_model_name(c); /* Default name */
9455 }
9456 +
9457 + init_scattered_cpuid_features(c);
9458 }
9459
9460 early_intel_workaround(c);
9461 --- a/arch/i386/kernel/cpu/proc.c
9462 +++ b/arch/i386/kernel/cpu/proc.c
9463 @@ -29,7 +29,8 @@
9464 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9465 NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
9466 NULL, NULL, NULL, "mp", "nx", NULL, "mmxext", NULL,
9467 - NULL, "fxsr_opt", "pdpe1gb", "rdtscp", NULL, "lm", "3dnowext", "3dnow",
9468 + NULL, "fxsr_opt", "pdpe1gb", "rdtscp", NULL, "lm",
9469 + "3dnowext", "3dnow",
9470
9471 /* Transmeta-defined */
9472 "recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
9473 @@ -40,8 +41,9 @@
9474 /* Other (Linux-defined) */
9475 "cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr",
9476 NULL, NULL, NULL, NULL,
9477 - "constant_tsc", "up", NULL, NULL, NULL, NULL, NULL, NULL,
9478 - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9479 + "constant_tsc", "up", NULL, "arch_perfmon",
9480 + "pebs", "bts", NULL, "sync_rdtsc",
9481 + "rep_good", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9482 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9483
9484 /* Intel-defined (#2) */
9485 @@ -57,9 +59,16 @@
9486 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9487
9488 /* AMD-defined (#2) */
9489 - "lahf_lm", "cmp_legacy", "svm", "extapic", "cr8legacy", "abm",
9490 - "sse4a", "misalignsse",
9491 - "3dnowprefetch", "osvw", "ibs", NULL, NULL, NULL, NULL, NULL,
9492 + "lahf_lm", "cmp_legacy", "svm", "extapic", "cr8_legacy",
9493 + "altmovcr8", "abm", "sse4a",
9494 + "misalignsse", "3dnowprefetch",
9495 + "osvw", "ibs", NULL, NULL, NULL, NULL,
9496 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9497 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9498 +
9499 + /* Auxiliary (Linux-defined) */
9500 + "ida", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9501 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9502 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9503 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9504 };
9505 --- a/arch/i386/kernel/e820.c
9506 +++ b/arch/i386/kernel/e820.c
9507 @@ -734,7 +734,7 @@
9508 case E820_NVS:
9509 printk("(ACPI NVS)\n");
9510 break;
9511 - default: printk("type %lu\n", e820.map[i].type);
9512 + default: printk("type %u\n", e820.map[i].type);
9513 break;
9514 }
9515 }
9516 --- a/arch/i386/kernel/setup.c
9517 +++ b/arch/i386/kernel/setup.c
9518 @@ -102,19 +102,10 @@
9519 /*
9520 * Setup options
9521 */
9522 -struct drive_info_struct { char dummy[32]; } drive_info;
9523 -#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_HD) || \
9524 - defined(CONFIG_BLK_DEV_IDE_MODULE) || defined(CONFIG_BLK_DEV_HD_MODULE)
9525 -EXPORT_SYMBOL(drive_info);
9526 -#endif
9527 struct screen_info screen_info;
9528 EXPORT_SYMBOL(screen_info);
9529 struct apm_info apm_info;
9530 EXPORT_SYMBOL(apm_info);
9531 -struct sys_desc_table_struct {
9532 - unsigned short length;
9533 - unsigned char table[0];
9534 -};
9535 struct edid_info edid_info;
9536 EXPORT_SYMBOL_GPL(edid_info);
9537 struct ist_info ist_info;
9538 @@ -134,7 +125,7 @@
9539
9540 static char __initdata command_line[COMMAND_LINE_SIZE];
9541
9542 -unsigned char __initdata boot_params[PARAM_SIZE];
9543 +struct boot_params __initdata boot_params;
9544
9545 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
9546 struct edd edd;
9547 @@ -528,7 +519,6 @@
9548 #endif
9549
9550 ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
9551 - drive_info = DRIVE_INFO;
9552 screen_info = SCREEN_INFO;
9553 edid_info = EDID_INFO;
9554 apm_info.bios = APM_BIOS_INFO;
9555 --- a/arch/i386/kernel/verify_cpu.S
9556 +++ /dev/null
9557 @@ -1,94 +0,0 @@
9558 -/* Check if CPU has some minimum CPUID bits
9559 - This runs in 16bit mode so that the caller can still use the BIOS
9560 - to output errors on the screen */
9561 -#include <asm/cpufeature.h>
9562 -#include <asm/msr.h>
9563 -
9564 -verify_cpu:
9565 - pushfl # Save caller passed flags
9566 - pushl $0 # Kill any dangerous flags
9567 - popfl
9568 -
9569 -#if CONFIG_X86_MINIMUM_CPU_MODEL >= 4
9570 - pushfl
9571 - pop %eax
9572 - orl $(1<<18),%eax # try setting AC
9573 - push %eax
9574 - popfl
9575 - pushfl
9576 - popl %eax
9577 - testl $(1<<18),%eax
9578 - jz bad
9579 -#endif
9580 -#if REQUIRED_MASK1 != 0
9581 - pushfl # standard way to check for cpuid
9582 - popl %eax
9583 - movl %eax,%ebx
9584 - xorl $0x200000,%eax
9585 - pushl %eax
9586 - popfl
9587 - pushfl
9588 - popl %eax
9589 - cmpl %eax,%ebx
9590 - pushfl # standard way to check for cpuid
9591 - popl %eax
9592 - movl %eax,%ebx
9593 - xorl $0x200000,%eax
9594 - pushl %eax
9595 - popfl
9596 - pushfl
9597 - popl %eax
9598 - cmpl %eax,%ebx
9599 - jz bad # REQUIRED_MASK1 != 0 requires CPUID
9600 -
9601 - movl $0x0,%eax # See if cpuid 1 is implemented
9602 - cpuid
9603 - cmpl $0x1,%eax
9604 - jb bad # no cpuid 1
9605 -
9606 -#if REQUIRED_MASK1 & NEED_CMPXCHG64
9607 - /* Some VIA C3s need magic MSRs to enable CX64. Do this here */
9608 - cmpl $0x746e6543,%ebx # Cent
9609 - jne 1f
9610 - cmpl $0x48727561,%edx # aurH
9611 - jne 1f
9612 - cmpl $0x736c7561,%ecx # auls
9613 - jne 1f
9614 - movl $1,%eax # check model
9615 - cpuid
9616 - movl %eax,%ebx
9617 - shr $8,%ebx
9618 - andl $0xf,%ebx
9619 - cmp $6,%ebx # check family == 6
9620 - jne 1f
9621 - shr $4,%eax
9622 - andl $0xf,%eax
9623 - cmpl $6,%eax # check model >= 6
9624 - jb 1f
9625 - # assume models >= 6 all support this MSR
9626 - movl $MSR_VIA_FCR,%ecx
9627 - rdmsr
9628 - orl $((1<<1)|(1<<7)),%eax # enable CMPXCHG64 and PGE
9629 - wrmsr
9630 -1:
9631 -#endif
9632 - movl $0x1,%eax # Does the cpu have what it takes
9633 - cpuid
9634 -
9635 -#if CONFIG_X86_MINIMUM_CPU_MODEL > 4
9636 -#error add proper model checking here
9637 -#endif
9638 -
9639 - andl $REQUIRED_MASK1,%edx
9640 - xorl $REQUIRED_MASK1,%edx
9641 - jnz bad
9642 -#endif /* REQUIRED_MASK1 */
9643 -
9644 - popfl
9645 - xor %eax,%eax
9646 - ret
9647 -
9648 -bad:
9649 - popfl
9650 - movl $1,%eax
9651 - ret
9652 --- a/arch/x86_64/Kconfig
9653 +++ b/arch/x86_64/Kconfig
9654 @@ -427,6 +427,10 @@
9655 This is purely to save memory - each supported CPU requires
9656 memory in the static kernel configuration.
9657
9658 +config PHYSICAL_ALIGN
9659 + hex
9660 + default "0x200000"
9661 +
9662 config HOTPLUG_CPU
9663 bool "Support for suspend on SMP and hot-pluggable CPUs (EXPERIMENTAL)"
9664 depends on SMP && HOTPLUG && EXPERIMENTAL
9665 --- a/arch/x86_64/boot/Makefile
9666 +++ b/arch/x86_64/boot/Makefile
9667 @@ -1,135 +1,9 @@
9668 #
9669 # arch/x86_64/boot/Makefile
9670 #
9671 -# This file is subject to the terms and conditions of the GNU General Public
9672 -# License. See the file "COPYING" in the main directory of this archive
9673 -# for more details.
9674 -#
9675 -# Copyright (C) 1994 by Linus Torvalds
9676 -#
9677 -
9678 -# ROOT_DEV specifies the default root-device when making the image.
9679 -# This can be either FLOPPY, CURRENT, /dev/xxxx or empty, in which case
9680 -# the default of FLOPPY is used by 'build'.
9681 -
9682 -ROOT_DEV := CURRENT
9683 -
9684 -# If you want to preset the SVGA mode, uncomment the next line and
9685 -# set SVGA_MODE to whatever number you want.
9686 -# Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
9687 -# The number is the same as you would ordinarily press at bootup.
9688 -
9689 -SVGA_MODE := -DSVGA_MODE=NORMAL_VGA
9690 -
9691 -# If you want the RAM disk device, define this to be the size in blocks.
9692 -
9693 -#RAMDISK := -DRAMDISK=512
9694 -
9695 -targets := vmlinux.bin bootsect bootsect.o \
9696 - setup setup.o bzImage mtools.conf
9697 -
9698 -EXTRA_CFLAGS := -m32
9699 -
9700 -hostprogs-y := tools/build
9701 -HOST_EXTRACFLAGS += $(LINUXINCLUDE)
9702 -subdir- := compressed/ #Let make clean descend in compressed/
9703 -# ---------------------------------------------------------------------------
9704 -
9705 -$(obj)/bzImage: IMAGE_OFFSET := 0x100000
9706 -$(obj)/bzImage: EXTRA_AFLAGS := $(SVGA_MODE) $(RAMDISK) -D__BIG_KERNEL__
9707 -$(obj)/bzImage: BUILDFLAGS := -b
9708 -
9709 -quiet_cmd_image = BUILD $@
9710 -cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/bootsect $(obj)/setup \
9711 - $(obj)/vmlinux.bin $(ROOT_DEV) > $@
9712 -
9713 -$(obj)/bzImage: $(obj)/bootsect $(obj)/setup \
9714 - $(obj)/vmlinux.bin $(obj)/tools/build FORCE
9715 - $(call if_changed,image)
9716 - @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
9717 -
9718 -$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
9719 - $(call if_changed,objcopy)
9720 -
9721 -LDFLAGS_bootsect := -Ttext 0x0 -s --oformat binary
9722 -LDFLAGS_setup := -Ttext 0x0 -s --oformat binary -e begtext
9723 -
9724 -$(obj)/setup $(obj)/bootsect: %: %.o FORCE
9725 - $(call if_changed,ld)
9726 -
9727 -$(obj)/compressed/vmlinux: FORCE
9728 - $(Q)$(MAKE) $(build)=$(obj)/compressed IMAGE_OFFSET=$(IMAGE_OFFSET) $@
9729 -
9730 -# Set this if you want to pass append arguments to the zdisk/fdimage/isoimage kernel
9731 -FDARGS =
9732 -# Set this if you want an initrd included with the zdisk/fdimage/isoimage kernel
9733 -FDINITRD =
9734 -
9735 -image_cmdline = default linux $(FDARGS) $(if $(FDINITRD),initrd=initrd.img,)
9736 -
9737 -$(obj)/mtools.conf: $(src)/mtools.conf.in
9738 - sed -e 's|@OBJ@|$(obj)|g' < $< > $@
9739 -
9740 -# This requires write access to /dev/fd0
9741 -zdisk: $(BOOTIMAGE) $(obj)/mtools.conf
9742 - MTOOLSRC=$(obj)/mtools.conf mformat a: ; sync
9743 - syslinux /dev/fd0 ; sync
9744 - echo '$(image_cmdline)' | \
9745 - MTOOLSRC=$(obj)/mtools.conf mcopy - a:syslinux.cfg
9746 - if [ -f '$(FDINITRD)' ] ; then \
9747 - MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' a:initrd.img ; \
9748 - fi
9749 - MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) a:linux ; sync
9750 -
9751 -# These require being root or having syslinux 2.02 or higher installed
9752 -fdimage fdimage144: $(BOOTIMAGE) $(obj)/mtools.conf
9753 - dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440
9754 - MTOOLSRC=$(obj)/mtools.conf mformat v: ; sync
9755 - syslinux $(obj)/fdimage ; sync
9756 - echo '$(image_cmdline)' | \
9757 - MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg
9758 - if [ -f '$(FDINITRD)' ] ; then \
9759 - MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' v:initrd.img ; \
9760 - fi
9761 - MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) v:linux ; sync
9762 -
9763 -fdimage288: $(BOOTIMAGE) $(obj)/mtools.conf
9764 - dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880
9765 - MTOOLSRC=$(obj)/mtools.conf mformat w: ; sync
9766 - syslinux $(obj)/fdimage ; sync
9767 - echo '$(image_cmdline)' | \
9768 - MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg
9769 - if [ -f '$(FDINITRD)' ] ; then \
9770 - MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' w:initrd.img ; \
9771 - fi
9772 - MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) w:linux ; sync
9773 -
9774 -isoimage: $(BOOTIMAGE)
9775 - -rm -rf $(obj)/isoimage
9776 - mkdir $(obj)/isoimage
9777 - for i in lib lib64 share end ; do \
9778 - if [ -f /usr/$$i/syslinux/isolinux.bin ] ; then \
9779 - cp /usr/$$i/syslinux/isolinux.bin $(obj)/isoimage ; \
9780 - break ; \
9781 - fi ; \
9782 - if [ $$i = end ] ; then exit 1 ; fi ; \
9783 - done
9784 - cp $(BOOTIMAGE) $(obj)/isoimage/linux
9785 - echo '$(image_cmdline)' > $(obj)/isoimage/isolinux.cfg
9786 - if [ -f '$(FDINITRD)' ] ; then \
9787 - cp '$(FDINITRD)' $(obj)/isoimage/initrd.img ; \
9788 - fi
9789 - mkisofs -J -r -o $(obj)/image.iso -b isolinux.bin -c boot.cat \
9790 - -no-emul-boot -boot-load-size 4 -boot-info-table \
9791 - $(obj)/isoimage
9792 - rm -rf $(obj)/isoimage
9793 -
9794 -zlilo: $(BOOTIMAGE)
9795 - if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
9796 - if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
9797 - cat $(BOOTIMAGE) > $(INSTALL_PATH)/vmlinuz
9798 - cp System.map $(INSTALL_PATH)/
9799 - if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
9800 +# The actual boot code is shared with i386 including the Makefile.
9801 +# So tell kbuild that we fetch the code from i386 and include the
9802 +# Makefile from i386 too.
9803
9804 -install:
9805 - sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"
9806 +src := arch/i386/boot
9807 +include $(src)/Makefile
9808 --- a/arch/x86_64/boot/bootsect.S
9809 +++ /dev/null
9810 @@ -1,98 +0,0 @@
9811 -/*
9812 - * bootsect.S Copyright (C) 1991, 1992 Linus Torvalds
9813 - *
9814 - * modified by Drew Eckhardt
9815 - * modified by Bruce Evans (bde)
9816 - * modified by Chris Noe (May 1999) (as86 -> gas)
9817 - * gutted by H. Peter Anvin (Jan 2003)
9818 - *
9819 - * BIG FAT NOTE: We're in real mode using 64k segments. Therefore segment
9820 - * addresses must be multiplied by 16 to obtain their respective linear
9821 - * addresses. To avoid confusion, linear addresses are written using leading
9822 - * hex while segment addresses are written as segment:offset.
9823 - *
9824 - */
9825 -
9826 -#include <asm/boot.h>
9827 -
9828 -SETUPSECTS = 4 /* default nr of setup-sectors */
9829 -BOOTSEG = 0x07C0 /* original address of boot-sector */
9830 -INITSEG = DEF_INITSEG /* we move boot here - out of the way */
9831 -SETUPSEG = DEF_SETUPSEG /* setup starts here */
9832 -SYSSEG = DEF_SYSSEG /* system loaded at 0x10000 (65536) */
9833 -SYSSIZE = DEF_SYSSIZE /* system size: # of 16-byte clicks */
9834 - /* to be loaded */
9835 -ROOT_DEV = 0 /* ROOT_DEV is now written by "build" */
9836 -SWAP_DEV = 0 /* SWAP_DEV is now written by "build" */
9837 -
9838 -#ifndef SVGA_MODE
9839 -#define SVGA_MODE ASK_VGA
9840 -#endif
9841 -
9842 -#ifndef RAMDISK
9843 -#define RAMDISK 0
9844 -#endif
9845 -
9846 -#ifndef ROOT_RDONLY
9847 -#define ROOT_RDONLY 1
9848 -#endif
9849 -
9850 -.code16
9851 -.text
9852 -
9853 -.global _start
9854 -_start:
9855 -
9856 - # Normalize the start address
9857 - jmpl $BOOTSEG, $start2
9858 -
9859 -start2:
9860 - movw %cs, %ax
9861 - movw %ax, %ds
9862 - movw %ax, %es
9863 - movw %ax, %ss
9864 - movw $0x7c00, %sp
9865 - sti
9866 - cld
9867 -
9868 - movw $bugger_off_msg, %si
9869 -
9870 -msg_loop:
9871 - lodsb
9872 - andb %al, %al
9873 - jz die
9874 - movb $0xe, %ah
9875 - movw $7, %bx
9876 - int $0x10
9877 - jmp msg_loop
9878 -
9879 -die:
9880 - # Allow the user to press a key, then reboot
9881 - xorw %ax, %ax
9882 - int $0x16
9883 - int $0x19
9884 -
9885 - # int 0x19 should never return. In case it does anyway,
9886 - # invoke the BIOS reset code...
9887 - ljmp $0xf000,$0xfff0
9888 -
9889 -
9890 -bugger_off_msg:
9891 - .ascii "Direct booting from floppy is no longer supported.\r\n"
9892 - .ascii "Please use a boot loader program instead.\r\n"
9893 - .ascii "\n"
9894 - .ascii "Remove disk and press any key to reboot . . .\r\n"
9895 - .byte 0
9896 -
9897 -
9898 - # Kernel attributes; used by setup
9899 -
9900 - .org 497
9901 -setup_sects: .byte SETUPSECTS
9902 -root_flags: .word ROOT_RDONLY
9903 -syssize: .word SYSSIZE
9904 -swap_dev: .word SWAP_DEV
9905 -ram_size: .word RAMDISK
9906 -vid_mode: .word SVGA_MODE
9907 -root_dev: .word ROOT_DEV
9908 -boot_flag: .word 0xAA55
9909 --- a/arch/x86_64/boot/compressed/Makefile
9910 +++ b/arch/x86_64/boot/compressed/Makefile
9911 @@ -7,11 +7,12 @@
9912 #
9913
9914 targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o
9915 -EXTRA_AFLAGS := -traditional
9916
9917 -# cannot use EXTRA_CFLAGS because base CFLAGS contains -mkernel which conflicts with
9918 -# -m32
9919 -CFLAGS := -m64 -D__KERNEL__ -Iinclude -O2 -fno-strict-aliasing -fPIC -mcmodel=small -fno-builtin
9920 +CFLAGS := -m64 -D__KERNEL__ $(LINUXINCLUDE) -O2 \
9921 + -fno-strict-aliasing -fPIC -mcmodel=small \
9922 + $(call cc-option, -ffreestanding) \
9923 + $(call cc-option, -fno-stack-protector)
9924 +AFLAGS := $(CFLAGS) -D__ASSEMBLY__
9925 LDFLAGS := -m elf_x86_64
9926
9927 LDFLAGS_vmlinux := -T
9928 --- a/arch/x86_64/boot/compressed/head.S
9929 +++ b/arch/x86_64/boot/compressed/head.S
9930 @@ -46,10 +46,10 @@
9931 * at and where we were actually loaded at. This can only be done
9932 * with a short local call on x86. Nothing else will tell us what
9933 * address we are running at. The reserved chunk of the real-mode
9934 - * data at 0x34-0x3f are used as the stack for this calculation.
9935 - * Only 4 bytes are needed.
9936 + * data at 0x1e4 (defined as a scratch field) are used as the stack
9937 + * for this calculation. Only 4 bytes are needed.
9938 */
9939 - leal 0x40(%esi), %esp
9940 + leal (0x1e4+4)(%esi), %esp
9941 call 1f
9942 1: popl %ebp
9943 subl $1b, %ebp
9944 --- a/arch/x86_64/boot/install.sh
9945 +++ /dev/null
9946 @@ -1,2 +0,0 @@
9947 -#!/bin/sh
9948 -. $srctree/arch/i386/boot/install.sh
9949 --- a/arch/x86_64/boot/mtools.conf.in
9950 +++ /dev/null
9951 @@ -1,17 +0,0 @@
9952 -#
9953 -# mtools configuration file for "make (b)zdisk"
9954 -#
9955 -
9956 -# Actual floppy drive
9957 -drive a:
9958 - file="/dev/fd0"
9959 -
9960 -# 1.44 MB floppy disk image
9961 -drive v:
9962 - file="@OBJ@/fdimage" cylinders=80 heads=2 sectors=18 filter
9963 -
9964 -# 2.88 MB floppy disk image (mostly for virtual uses)
9965 -drive w:
9966 - file="@OBJ@/fdimage" cylinders=80 heads=2 sectors=36 filter
9967 -
9968 -
9969 --- a/arch/x86_64/boot/setup.S
9970 +++ /dev/null
9971 @@ -1,826 +0,0 @@
9972 -/*
9973 - * setup.S Copyright (C) 1991, 1992 Linus Torvalds
9974 - *
9975 - * setup.s is responsible for getting the system data from the BIOS,
9976 - * and putting them into the appropriate places in system memory.
9977 - * both setup.s and system has been loaded by the bootblock.
9978 - *
9979 - * This code asks the bios for memory/disk/other parameters, and
9980 - * puts them in a "safe" place: 0x90000-0x901FF, ie where the
9981 - * boot-block used to be. It is then up to the protected mode
9982 - * system to read them from there before the area is overwritten
9983 - * for buffer-blocks.
9984 - *
9985 - * Move PS/2 aux init code to psaux.c
9986 - * (troyer@saifr00.cfsat.Honeywell.COM) 03Oct92
9987 - *
9988 - * some changes and additional features by Christoph Niemann,
9989 - * March 1993/June 1994 (Christoph.Niemann@linux.org)
9990 - *
9991 - * add APM BIOS checking by Stephen Rothwell, May 1994
9992 - * (sfr@canb.auug.org.au)
9993 - *
9994 - * High load stuff, initrd support and position independency
9995 - * by Hans Lermen & Werner Almesberger, February 1996
9996 - * <lermen@elserv.ffm.fgan.de>, <almesber@lrc.epfl.ch>
9997 - *
9998 - * Video handling moved to video.S by Martin Mares, March 1996
9999 - * <mj@k332.feld.cvut.cz>
10000 - *
10001 - * Extended memory detection scheme retwiddled by orc@pell.chi.il.us (david
10002 - * parsons) to avoid loadlin confusion, July 1997
10003 - *
10004 - * Transcribed from Intel (as86) -> AT&T (gas) by Chris Noe, May 1999.
10005 - * <stiker@northlink.com>
10006 - *
10007 - * Fix to work around buggy BIOSes which don't use carry bit correctly
10008 - * and/or report extended memory in CX/DX for e801h memory size detection
10009 - * call. As a result the kernel got wrong figures. The int15/e801h docs
10010 - * from Ralf Brown interrupt list seem to indicate AX/BX should be used
10011 - * anyway. So to avoid breaking many machines (presumably there was a reason
10012 - * to orginally use CX/DX instead of AX/BX), we do a kludge to see
10013 - * if CX/DX have been changed in the e801 call and if so use AX/BX .
10014 - * Michael Miller, April 2001 <michaelm@mjmm.org>
10015 - *
10016 - * Added long mode checking and SSE force. March 2003, Andi Kleen.
10017 - */
10018 -
10019 -#include <asm/segment.h>
10020 -#include <linux/utsrelease.h>
10021 -#include <linux/compile.h>
10022 -#include <asm/boot.h>
10023 -#include <asm/e820.h>
10024 -#include <asm/page.h>
10025 -#include <asm/setup.h>
10026 -
10027 -/* Signature words to ensure LILO loaded us right */
10028 -#define SIG1 0xAA55
10029 -#define SIG2 0x5A5A
10030 -
10031 -INITSEG = DEF_INITSEG # 0x9000, we move boot here, out of the way
10032 -SYSSEG = DEF_SYSSEG # 0x1000, system loaded at 0x10000 (65536).
10033 -SETUPSEG = DEF_SETUPSEG # 0x9020, this is the current segment
10034 - # ... and the former contents of CS
10035 -
10036 -DELTA_INITSEG = SETUPSEG - INITSEG # 0x0020
10037 -
10038 -.code16
10039 -.globl begtext, begdata, begbss, endtext, enddata, endbss
10040 -
10041 -.text
10042 -begtext:
10043 -.data
10044 -begdata:
10045 -.bss
10046 -begbss:
10047 -.text
10048 -
10049 -start:
10050 - jmp trampoline
10051 -
10052 -# This is the setup header, and it must start at %cs:2 (old 0x9020:2)
10053 -
10054 - .ascii "HdrS" # header signature
10055 - .word 0x0206 # header version number (>= 0x0105)
10056 - # or else old loadlin-1.5 will fail)
10057 -realmode_swtch: .word 0, 0 # default_switch, SETUPSEG
10058 -start_sys_seg: .word SYSSEG
10059 - .word kernel_version # pointing to kernel version string
10060 - # above section of header is compatible
10061 - # with loadlin-1.5 (header v1.5). Don't
10062 - # change it.
10063 -
10064 -type_of_loader: .byte 0 # = 0, old one (LILO, Loadlin,
10065 - # Bootlin, SYSLX, bootsect...)
10066 - # See Documentation/i386/boot.txt for
10067 - # assigned ids
10068 -
10069 -# flags, unused bits must be zero (RFU) bit within loadflags
10070 -loadflags:
10071 -LOADED_HIGH = 1 # If set, the kernel is loaded high
10072 -CAN_USE_HEAP = 0x80 # If set, the loader also has set
10073 - # heap_end_ptr to tell how much
10074 - # space behind setup.S can be used for
10075 - # heap purposes.
10076 - # Only the loader knows what is free
10077 -#ifndef __BIG_KERNEL__
10078 - .byte 0
10079 -#else
10080 - .byte LOADED_HIGH
10081 -#endif
10082 -
10083 -setup_move_size: .word 0x8000 # size to move, when setup is not
10084 - # loaded at 0x90000. We will move setup
10085 - # to 0x90000 then just before jumping
10086 - # into the kernel. However, only the
10087 - # loader knows how much data behind
10088 - # us also needs to be loaded.
10089 -
10090 -code32_start: # here loaders can put a different
10091 - # start address for 32-bit code.
10092 -#ifndef __BIG_KERNEL__
10093 - .long 0x1000 # 0x1000 = default for zImage
10094 -#else
10095 - .long 0x100000 # 0x100000 = default for big kernel
10096 -#endif
10097 -
10098 -ramdisk_image: .long 0 # address of loaded ramdisk image
10099 - # Here the loader puts the 32-bit
10100 - # address where it loaded the image.
10101 - # This only will be read by the kernel.
10102 -
10103 -ramdisk_size: .long 0 # its size in bytes
10104 -
10105 -bootsect_kludge:
10106 - .long 0 # obsolete
10107 -
10108 -heap_end_ptr: .word modelist+1024 # (Header version 0x0201 or later)
10109 - # space from here (exclusive) down to
10110 - # end of setup code can be used by setup
10111 - # for local heap purposes.
10112 -
10113 -pad1: .word 0
10114 -cmd_line_ptr: .long 0 # (Header version 0x0202 or later)
10115 - # If nonzero, a 32-bit pointer
10116 - # to the kernel command line.
10117 - # The command line should be
10118 - # located between the start of
10119 - # setup and the end of low
10120 - # memory (0xa0000), or it may
10121 - # get overwritten before it
10122 - # gets read. If this field is
10123 - # used, there is no longer
10124 - # anything magical about the
10125 - # 0x90000 segment; the setup
10126 - # can be located anywhere in
10127 - # low memory 0x10000 or higher.
10128 -
10129 -ramdisk_max: .long 0xffffffff
10130 -kernel_alignment: .long 0x200000 # physical addr alignment required for
10131 - # protected mode relocatable kernel
10132 -#ifdef CONFIG_RELOCATABLE
10133 -relocatable_kernel: .byte 1
10134 -#else
10135 -relocatable_kernel: .byte 0
10136 -#endif
10137 -pad2: .byte 0
10138 -pad3: .word 0
10139 -
10140 -cmdline_size: .long COMMAND_LINE_SIZE-1 #length of the command line,
10141 - #added with boot protocol
10142 - #version 2.06
10143 -
10144 -trampoline: call start_of_setup
10145 - .align 16
10146 - # The offset at this point is 0x240
10147 - .space (0xeff-0x240+1) # E820 & EDD space (ending at 0xeff)
10148 -# End of setup header #####################################################
10149 -
10150 -start_of_setup:
10151 -# Bootlin depends on this being done early
10152 - movw $0x01500, %ax
10153 - movb $0x81, %dl
10154 - int $0x13
10155 -
10156 -#ifdef SAFE_RESET_DISK_CONTROLLER
10157 -# Reset the disk controller.
10158 - movw $0x0000, %ax
10159 - movb $0x80, %dl
10160 - int $0x13
10161 -#endif
10162 -
10163 -# Set %ds = %cs, we know that SETUPSEG = %cs at this point
10164 - movw %cs, %ax # aka SETUPSEG
10165 - movw %ax, %ds
10166 -# Check signature at end of setup
10167 - cmpw $SIG1, setup_sig1
10168 - jne bad_sig
10169 -
10170 - cmpw $SIG2, setup_sig2
10171 - jne bad_sig
10172 -
10173 - jmp good_sig1
10174 -
10175 -# Routine to print asciiz string at ds:si
10176 -prtstr:
10177 - lodsb
10178 - andb %al, %al
10179 - jz fin
10180 -
10181 - call prtchr
10182 - jmp prtstr
10183 -
10184 -fin: ret
10185 -
10186 -# Space printing
10187 -prtsp2: call prtspc # Print double space
10188 -prtspc: movb $0x20, %al # Print single space (note: fall-thru)
10189 -
10190 -prtchr:
10191 - pushw %ax
10192 - pushw %cx
10193 - movw $0007,%bx
10194 - movw $0x01, %cx
10195 - movb $0x0e, %ah
10196 - int $0x10
10197 - popw %cx
10198 - popw %ax
10199 - ret
10200 -
10201 -beep: movb $0x07, %al
10202 - jmp prtchr
10203 -
10204 -no_sig_mess: .string "No setup signature found ..."
10205 -
10206 -good_sig1:
10207 - jmp good_sig
10208 -
10209 -# We now have to find the rest of the setup code/data
10210 -bad_sig:
10211 - movw %cs, %ax # SETUPSEG
10212 - subw $DELTA_INITSEG, %ax # INITSEG
10213 - movw %ax, %ds
10214 - xorb %bh, %bh
10215 - movb (497), %bl # get setup sect from bootsect
10216 - subw $4, %bx # LILO loads 4 sectors of setup
10217 - shlw $8, %bx # convert to words (1sect=2^8 words)
10218 - movw %bx, %cx
10219 - shrw $3, %bx # convert to segment
10220 - addw $SYSSEG, %bx
10221 - movw %bx, %cs:start_sys_seg
10222 -# Move rest of setup code/data to here
10223 - movw $2048, %di # four sectors loaded by LILO
10224 - subw %si, %si
10225 - movw %cs, %ax # aka SETUPSEG
10226 - movw %ax, %es
10227 - movw $SYSSEG, %ax
10228 - movw %ax, %ds
10229 - rep
10230 - movsw
10231 - movw %cs, %ax # aka SETUPSEG
10232 - movw %ax, %ds
10233 - cmpw $SIG1, setup_sig1
10234 - jne no_sig
10235 -
10236 - cmpw $SIG2, setup_sig2
10237 - jne no_sig
10238 -
10239 - jmp good_sig
10240 -
10241 -no_sig:
10242 - lea no_sig_mess, %si
10243 - call prtstr
10244 -
10245 -no_sig_loop:
10246 - jmp no_sig_loop
10247 -
10248 -good_sig:
10249 - movw %cs, %ax # aka SETUPSEG
10250 - subw $DELTA_INITSEG, %ax # aka INITSEG
10251 - movw %ax, %ds
10252 -# Check if an old loader tries to load a big-kernel
10253 - testb $LOADED_HIGH, %cs:loadflags # Do we have a big kernel?
10254 - jz loader_ok # No, no danger for old loaders.
10255 -
10256 - cmpb $0, %cs:type_of_loader # Do we have a loader that
10257 - # can deal with us?
10258 - jnz loader_ok # Yes, continue.
10259 -
10260 - pushw %cs # No, we have an old loader,
10261 - popw %ds # die.
10262 - lea loader_panic_mess, %si
10263 - call prtstr
10264 -
10265 - jmp no_sig_loop
10266 -
10267 -loader_panic_mess: .string "Wrong loader, giving up..."
10268 -
10269 -loader_ok:
10270 - /* check for long mode. */
10271 - /* we have to do this before the VESA setup, otherwise the user
10272 - can't see the error message. */
10273 -
10274 - pushw %ds
10275 - movw %cs,%ax
10276 - movw %ax,%ds
10277 -
10278 - call verify_cpu
10279 - testl %eax,%eax
10280 - jz sse_ok
10281 -
10282 -no_longmode:
10283 - call beep
10284 - lea long_mode_panic,%si
10285 - call prtstr
10286 -no_longmode_loop:
10287 - jmp no_longmode_loop
10288 -long_mode_panic:
10289 - .string "Your CPU does not support long mode. Use a 32bit distribution."
10290 - .byte 0
10291 -
10292 -#include "../kernel/verify_cpu.S"
10293 -sse_ok:
10294 - popw %ds
10295 -
10296 -# tell BIOS we want to go to long mode
10297 - movl $0xec00,%eax # declare target operating mode
10298 - movl $2,%ebx # long mode
10299 - int $0x15
10300 -
10301 -# Get memory size (extended mem, kB)
10302 -
10303 - xorl %eax, %eax
10304 - movl %eax, (0x1e0)
10305 -#ifndef STANDARD_MEMORY_BIOS_CALL
10306 - movb %al, (E820NR)
10307 -# Try three different memory detection schemes. First, try
10308 -# e820h, which lets us assemble a memory map, then try e801h,
10309 -# which returns a 32-bit memory size, and finally 88h, which
10310 -# returns 0-64m
10311 -
10312 -# method E820H:
10313 -# the memory map from hell. e820h returns memory classified into
10314 -# a whole bunch of different types, and allows memory holes and
10315 -# everything. We scan through this memory map and build a list
10316 -# of the first 32 memory areas, which we return at [E820MAP].
10317 -# This is documented at http://www.acpi.info/, in the ACPI 2.0 specification.
10318 -
10319 -#define SMAP 0x534d4150
10320 -
10321 -meme820:
10322 - xorl %ebx, %ebx # continuation counter
10323 - movw $E820MAP, %di # point into the whitelist
10324 - # so we can have the bios
10325 - # directly write into it.
10326 -
10327 -jmpe820:
10328 - movl $0x0000e820, %eax # e820, upper word zeroed
10329 - movl $SMAP, %edx # ascii 'SMAP'
10330 - movl $20, %ecx # size of the e820rec
10331 - pushw %ds # data record.
10332 - popw %es
10333 - int $0x15 # make the call
10334 - jc bail820 # fall to e801 if it fails
10335 -
10336 - cmpl $SMAP, %eax # check the return is `SMAP'
10337 - jne bail820 # fall to e801 if it fails
10338 -
10339 -# cmpl $1, 16(%di) # is this usable memory?
10340 -# jne again820
10341 -
10342 - # If this is usable memory, we save it by simply advancing %di by
10343 - # sizeof(e820rec).
10344 - #
10345 -good820:
10346 - movb (E820NR), %al # up to 128 entries
10347 - cmpb $E820MAX, %al
10348 - jae bail820
10349 -
10350 - incb (E820NR)
10351 - movw %di, %ax
10352 - addw $20, %ax
10353 - movw %ax, %di
10354 -again820:
10355 - cmpl $0, %ebx # check to see if
10356 - jne jmpe820 # %ebx is set to EOF
10357 -bail820:
10358 -
10359 -
10360 -# method E801H:
10361 -# memory size is in 1k chunksizes, to avoid confusing loadlin.
10362 -# we store the 0xe801 memory size in a completely different place,
10363 -# because it will most likely be longer than 16 bits.
10364 -# (use 1e0 because that's what Larry Augustine uses in his
10365 -# alternative new memory detection scheme, and it's sensible
10366 -# to write everything into the same place.)
10367 -
10368 -meme801:
10369 - stc # fix to work around buggy
10370 - xorw %cx,%cx # BIOSes which don't clear/set
10371 - xorw %dx,%dx # carry on pass/error of
10372 - # e801h memory size call
10373 - # or merely pass cx,dx though
10374 - # without changing them.
10375 - movw $0xe801, %ax
10376 - int $0x15
10377 - jc mem88
10378 -
10379 - cmpw $0x0, %cx # Kludge to handle BIOSes
10380 - jne e801usecxdx # which report their extended
10381 - cmpw $0x0, %dx # memory in AX/BX rather than
10382 - jne e801usecxdx # CX/DX. The spec I have read
10383 - movw %ax, %cx # seems to indicate AX/BX
10384 - movw %bx, %dx # are more reasonable anyway...
10385 -
10386 -e801usecxdx:
10387 - andl $0xffff, %edx # clear sign extend
10388 - shll $6, %edx # and go from 64k to 1k chunks
10389 - movl %edx, (0x1e0) # store extended memory size
10390 - andl $0xffff, %ecx # clear sign extend
10391 - addl %ecx, (0x1e0) # and add lower memory into
10392 - # total size.
10393 -
10394 -# Ye Olde Traditional Methode. Returns the memory size (up to 16mb or
10395 -# 64mb, depending on the bios) in ax.
10396 -mem88:
10397 -
10398 -#endif
10399 - movb $0x88, %ah
10400 - int $0x15
10401 - movw %ax, (2)
10402 -
10403 -# Set the keyboard repeat rate to the max
10404 - movw $0x0305, %ax
10405 - xorw %bx, %bx
10406 - int $0x16
10407 -
10408 -# Check for video adapter and its parameters and allow the
10409 -# user to browse video modes.
10410 - call video # NOTE: we need %ds pointing
10411 - # to bootsector
10412 -
10413 -# Get hd0 data...
10414 - xorw %ax, %ax
10415 - movw %ax, %ds
10416 - ldsw (4 * 0x41), %si
10417 - movw %cs, %ax # aka SETUPSEG
10418 - subw $DELTA_INITSEG, %ax # aka INITSEG
10419 - pushw %ax
10420 - movw %ax, %es
10421 - movw $0x0080, %di
10422 - movw $0x10, %cx
10423 - pushw %cx
10424 - cld
10425 - rep
10426 - movsb
10427 -# Get hd1 data...
10428 - xorw %ax, %ax
10429 - movw %ax, %ds
10430 - ldsw (4 * 0x46), %si
10431 - popw %cx
10432 - popw %es
10433 - movw $0x0090, %di
10434 - rep
10435 - movsb
10436 -# Check that there IS a hd1 :-)
10437 - movw $0x01500, %ax
10438 - movb $0x81, %dl
10439 - int $0x13
10440 - jc no_disk1
10441 -
10442 - cmpb $3, %ah
10443 - je is_disk1
10444 -
10445 -no_disk1:
10446 - movw %cs, %ax # aka SETUPSEG
10447 - subw $DELTA_INITSEG, %ax # aka INITSEG
10448 - movw %ax, %es
10449 - movw $0x0090, %di
10450 - movw $0x10, %cx
10451 - xorw %ax, %ax
10452 - cld
10453 - rep
10454 - stosb
10455 -is_disk1:
10456 -
10457 -# Check for PS/2 pointing device
10458 - movw %cs, %ax # aka SETUPSEG
10459 - subw $DELTA_INITSEG, %ax # aka INITSEG
10460 - movw %ax, %ds
10461 - movb $0, (0x1ff) # default is no pointing device
10462 - int $0x11 # int 0x11: equipment list
10463 - testb $0x04, %al # check if mouse installed
10464 - jz no_psmouse
10465 -
10466 - movb $0xAA, (0x1ff) # device present
10467 -no_psmouse:
10468 -
10469 -#include "../../i386/boot/edd.S"
10470 -
10471 -# Now we want to move to protected mode ...
10472 - cmpw $0, %cs:realmode_swtch
10473 - jz rmodeswtch_normal
10474 -
10475 - lcall *%cs:realmode_swtch
10476 -
10477 - jmp rmodeswtch_end
10478 -
10479 -rmodeswtch_normal:
10480 - pushw %cs
10481 - call default_switch
10482 -
10483 -rmodeswtch_end:
10484 -# we get the code32 start address and modify the below 'jmpi'
10485 -# (loader may have changed it)
10486 - movl %cs:code32_start, %eax
10487 - movl %eax, %cs:code32
10488 -
10489 -# Now we move the system to its rightful place ... but we check if we have a
10490 -# big-kernel. In that case we *must* not move it ...
10491 - testb $LOADED_HIGH, %cs:loadflags
10492 - jz do_move0 # .. then we have a normal low
10493 - # loaded zImage
10494 - # .. or else we have a high
10495 - # loaded bzImage
10496 - jmp end_move # ... and we skip moving
10497 -
10498 -do_move0:
10499 - movw $0x100, %ax # start of destination segment
10500 - movw %cs, %bp # aka SETUPSEG
10501 - subw $DELTA_INITSEG, %bp # aka INITSEG
10502 - movw %cs:start_sys_seg, %bx # start of source segment
10503 - cld
10504 -do_move:
10505 - movw %ax, %es # destination segment
10506 - incb %ah # instead of add ax,#0x100
10507 - movw %bx, %ds # source segment
10508 - addw $0x100, %bx
10509 - subw %di, %di
10510 - subw %si, %si
10511 - movw $0x800, %cx
10512 - rep
10513 - movsw
10514 - cmpw %bp, %bx # assume start_sys_seg > 0x200,
10515 - # so we will perhaps read one
10516 - # page more than needed, but
10517 - # never overwrite INITSEG
10518 - # because destination is a
10519 - # minimum one page below source
10520 - jb do_move
10521 -
10522 -end_move:
10523 -# then we load the segment descriptors
10524 - movw %cs, %ax # aka SETUPSEG
10525 - movw %ax, %ds
10526 -
10527 -# Check whether we need to be downward compatible with version <=201
10528 - cmpl $0, cmd_line_ptr
10529 - jne end_move_self # loader uses version >=202 features
10530 - cmpb $0x20, type_of_loader
10531 - je end_move_self # bootsect loader, we know of it
10532 -
10533 -# Boot loader doesnt support boot protocol version 2.02.
10534 -# If we have our code not at 0x90000, we need to move it there now.
10535 -# We also then need to move the params behind it (commandline)
10536 -# Because we would overwrite the code on the current IP, we move
10537 -# it in two steps, jumping high after the first one.
10538 - movw %cs, %ax
10539 - cmpw $SETUPSEG, %ax
10540 - je end_move_self
10541 -
10542 - cli # make sure we really have
10543 - # interrupts disabled !
10544 - # because after this the stack
10545 - # should not be used
10546 - subw $DELTA_INITSEG, %ax # aka INITSEG
10547 - movw %ss, %dx
10548 - cmpw %ax, %dx
10549 - jb move_self_1
10550 -
10551 - addw $INITSEG, %dx
10552 - subw %ax, %dx # this will go into %ss after
10553 - # the move
10554 -move_self_1:
10555 - movw %ax, %ds
10556 - movw $INITSEG, %ax # real INITSEG
10557 - movw %ax, %es
10558 - movw %cs:setup_move_size, %cx
10559 - std # we have to move up, so we use
10560 - # direction down because the
10561 - # areas may overlap
10562 - movw %cx, %di
10563 - decw %di
10564 - movw %di, %si
10565 - subw $move_self_here+0x200, %cx
10566 - rep
10567 - movsb
10568 - ljmp $SETUPSEG, $move_self_here
10569 -
10570 -move_self_here:
10571 - movw $move_self_here+0x200, %cx
10572 - rep
10573 - movsb
10574 - movw $SETUPSEG, %ax
10575 - movw %ax, %ds
10576 - movw %dx, %ss
10577 -end_move_self: # now we are at the right place
10578 - lidt idt_48 # load idt with 0,0
10579 - xorl %eax, %eax # Compute gdt_base
10580 - movw %ds, %ax # (Convert %ds:gdt to a linear ptr)
10581 - shll $4, %eax
10582 - addl $gdt, %eax
10583 - movl %eax, (gdt_48+2)
10584 - lgdt gdt_48 # load gdt with whatever is
10585 - # appropriate
10586 -
10587 -# that was painless, now we enable a20
10588 - call empty_8042
10589 -
10590 - movb $0xD1, %al # command write
10591 - outb %al, $0x64
10592 - call empty_8042
10593 -
10594 - movb $0xDF, %al # A20 on
10595 - outb %al, $0x60
10596 - call empty_8042
10597 -
10598 -#
10599 -# You must preserve the other bits here. Otherwise embarrasing things
10600 -# like laptops powering off on boot happen. Corrected version by Kira
10601 -# Brown from Linux 2.2
10602 -#
10603 - inb $0x92, %al #
10604 - orb $02, %al # "fast A20" version
10605 - outb %al, $0x92 # some chips have only this
10606 -
10607 -# wait until a20 really *is* enabled; it can take a fair amount of
10608 -# time on certain systems; Toshiba Tecras are known to have this
10609 -# problem. The memory location used here (0x200) is the int 0x80
10610 -# vector, which should be safe to use.
10611 -
10612 - xorw %ax, %ax # segment 0x0000
10613 - movw %ax, %fs
10614 - decw %ax # segment 0xffff (HMA)
10615 - movw %ax, %gs
10616 -a20_wait:
10617 - incw %ax # unused memory location <0xfff0
10618 - movw %ax, %fs:(0x200) # we use the "int 0x80" vector
10619 - cmpw %gs:(0x210), %ax # and its corresponding HMA addr
10620 - je a20_wait # loop until no longer aliased
10621 -
10622 -# make sure any possible coprocessor is properly reset..
10623 - xorw %ax, %ax
10624 - outb %al, $0xf0
10625 - call delay
10626 -
10627 - outb %al, $0xf1
10628 - call delay
10629 -
10630 -# well, that went ok, I hope. Now we mask all interrupts - the rest
10631 -# is done in init_IRQ().
10632 - movb $0xFF, %al # mask all interrupts for now
10633 - outb %al, $0xA1
10634 - call delay
10635 -
10636 - movb $0xFB, %al # mask all irq's but irq2 which
10637 - outb %al, $0x21 # is cascaded
10638 -
10639 -# Well, that certainly wasn't fun :-(. Hopefully it works, and we don't
10640 -# need no steenking BIOS anyway (except for the initial loading :-).
10641 -# The BIOS-routine wants lots of unnecessary data, and it's less
10642 -# "interesting" anyway. This is how REAL programmers do it.
10643 -#
10644 -# Well, now's the time to actually move into protected mode. To make
10645 -# things as simple as possible, we do no register set-up or anything,
10646 -# we let the gnu-compiled 32-bit programs do that. We just jump to
10647 -# absolute address 0x1000 (or the loader supplied one),
10648 -# in 32-bit protected mode.
10649 -#
10650 -# Note that the short jump isn't strictly needed, although there are
10651 -# reasons why it might be a good idea. It won't hurt in any case.
10652 - movw $1, %ax # protected mode (PE) bit
10653 - lmsw %ax # This is it!
10654 - jmp flush_instr
10655 -
10656 -flush_instr:
10657 - xorw %bx, %bx # Flag to indicate a boot
10658 - xorl %esi, %esi # Pointer to real-mode code
10659 - movw %cs, %si
10660 - subw $DELTA_INITSEG, %si
10661 - shll $4, %esi # Convert to 32-bit pointer
10662 -# NOTE: For high loaded big kernels we need a
10663 -# jmpi 0x100000,__KERNEL_CS
10664 -#
10665 -# but we yet haven't reloaded the CS register, so the default size
10666 -# of the target offset still is 16 bit.
10667 -# However, using an operand prefix (0x66), the CPU will properly
10668 -# take our 48 bit far pointer. (INTeL 80386 Programmer's Reference
10669 -# Manual, Mixing 16-bit and 32-bit code, page 16-6)
10670 -
10671 - .byte 0x66, 0xea # prefix + jmpi-opcode
10672 -code32: .long 0x1000 # will be set to 0x100000
10673 - # for big kernels
10674 - .word __KERNEL_CS
10675 -
10676 -# Here's a bunch of information about your current kernel..
10677 -kernel_version: .ascii UTS_RELEASE
10678 - .ascii " ("
10679 - .ascii LINUX_COMPILE_BY
10680 - .ascii "@"
10681 - .ascii LINUX_COMPILE_HOST
10682 - .ascii ") "
10683 - .ascii UTS_VERSION
10684 - .byte 0
10685 -
10686 -# This is the default real mode switch routine.
10687 -# to be called just before protected mode transition
10688 -default_switch:
10689 - cli # no interrupts allowed !
10690 - movb $0x80, %al # disable NMI for bootup
10691 - # sequence
10692 - outb %al, $0x70
10693 - lret
10694 -
10695 -
10696 -# This routine checks that the keyboard command queue is empty
10697 -# (after emptying the output buffers)
10698 -#
10699 -# Some machines have delusions that the keyboard buffer is always full
10700 -# with no keyboard attached...
10701 -#
10702 -# If there is no keyboard controller, we will usually get 0xff
10703 -# to all the reads. With each IO taking a microsecond and
10704 -# a timeout of 100,000 iterations, this can take about half a
10705 -# second ("delay" == outb to port 0x80). That should be ok,
10706 -# and should also be plenty of time for a real keyboard controller
10707 -# to empty.
10708 -#
10709 -
10710 -empty_8042:
10711 - pushl %ecx
10712 - movl $100000, %ecx
10713 -
10714 -empty_8042_loop:
10715 - decl %ecx
10716 - jz empty_8042_end_loop
10717 -
10718 - call delay
10719 -
10720 - inb $0x64, %al # 8042 status port
10721 - testb $1, %al # output buffer?
10722 - jz no_output
10723 -
10724 - call delay
10725 - inb $0x60, %al # read it
10726 - jmp empty_8042_loop
10727 -
10728 -no_output:
10729 - testb $2, %al # is input buffer full?
10730 - jnz empty_8042_loop # yes - loop
10731 -empty_8042_end_loop:
10732 - popl %ecx
10733 - ret
10734 -
10735 -# Read the cmos clock. Return the seconds in al
10736 -gettime:
10737 - pushw %cx
10738 - movb $0x02, %ah
10739 - int $0x1a
10740 - movb %dh, %al # %dh contains the seconds
10741 - andb $0x0f, %al
10742 - movb %dh, %ah
10743 - movb $0x04, %cl
10744 - shrb %cl, %ah
10745 - aad
10746 - popw %cx
10747 - ret
10748 -
10749 -# Delay is needed after doing I/O
10750 -delay:
10751 - outb %al,$0x80
10752 - ret
10753 -
10754 -# Descriptor tables
10755 -gdt:
10756 - .word 0, 0, 0, 0 # dummy
10757 -
10758 - .word 0, 0, 0, 0 # unused
10759 -
10760 - .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb)
10761 - .word 0 # base address = 0
10762 - .word 0x9A00 # code read/exec
10763 - .word 0x00CF # granularity = 4096, 386
10764 - # (+5th nibble of limit)
10765 -
10766 - .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb)
10767 - .word 0 # base address = 0
10768 - .word 0x9200 # data read/write
10769 - .word 0x00CF # granularity = 4096, 386
10770 - # (+5th nibble of limit)
10771 -gdt_end:
10772 -idt_48:
10773 - .word 0 # idt limit = 0
10774 - .word 0, 0 # idt base = 0L
10775 -gdt_48:
10776 - .word gdt_end-gdt-1 # gdt limit
10777 - .word 0, 0 # gdt base (filled in later)
10778 -
10779 -# Include video setup & detection code
10780 -
10781 -#include "../../i386/boot/video.S"
10782 -
10783 -# Setup signature -- must be last
10784 -setup_sig1: .word SIG1
10785 -setup_sig2: .word SIG2
10786 -
10787 -# After this point, there is some free space which is used by the video mode
10788 -# handling code to store the temporary mode table (not used by the kernel).
10789 -
10790 -modelist:
10791 -
10792 -.text
10793 -endtext:
10794 -.data
10795 -enddata:
10796 -.bss
10797 -endbss:
10798 --- a/arch/x86_64/boot/tools/build.c
10799 +++ /dev/null
10800 @@ -1,185 +0,0 @@
10801 -/*
10802 - * Copyright (C) 1991, 1992 Linus Torvalds
10803 - * Copyright (C) 1997 Martin Mares
10804 - */
10805 -
10806 -/*
10807 - * This file builds a disk-image from three different files:
10808 - *
10809 - * - bootsect: compatibility mbr which prints an error message if
10810 - * someone tries to boot the kernel directly.
10811 - * - setup: 8086 machine code, sets up system parm
10812 - * - system: 80386 code for actual system
10813 - *
10814 - * It does some checking that all files are of the correct type, and
10815 - * just writes the result to stdout, removing headers and padding to
10816 - * the right amount. It also writes some system data to stderr.
10817 - */
10818 -
10819 -/*
10820 - * Changes by tytso to allow root device specification
10821 - * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
10822 - * Cross compiling fixes by Gertjan van Wingerde, July 1996
10823 - * Rewritten by Martin Mares, April 1997
10824 - */
10825 -
10826 -#include <stdio.h>
10827 -#include <string.h>
10828 -#include <stdlib.h>
10829 -#include <stdarg.h>
10830 -#include <sys/types.h>
10831 -#include <sys/stat.h>
10832 -#include <sys/sysmacros.h>
10833 -#include <unistd.h>
10834 -#include <fcntl.h>
10835 -#include <asm/boot.h>
10836 -
10837 -typedef unsigned char byte;
10838 -typedef unsigned short word;
10839 -typedef unsigned long u32;
10840 -
10841 -#define DEFAULT_MAJOR_ROOT 0
10842 -#define DEFAULT_MINOR_ROOT 0
10843 -
10844 -/* Minimal number of setup sectors (see also bootsect.S) */
10845 -#define SETUP_SECTS 4
10846 -
10847 -byte buf[1024];
10848 -int fd;
10849 -int is_big_kernel;
10850 -
10851 -void die(const char * str, ...)
10852 -{
10853 - va_list args;
10854 - va_start(args, str);
10855 - vfprintf(stderr, str, args);
10856 - fputc('\n', stderr);
10857 - exit(1);
10858 -}
10859 -
10860 -void file_open(const char *name)
10861 -{
10862 - if ((fd = open(name, O_RDONLY, 0)) < 0)
10863 - die("Unable to open `%s': %m", name);
10864 -}
10865 -
10866 -void usage(void)
10867 -{
10868 - die("Usage: build [-b] bootsect setup system [rootdev] [> image]");
10869 -}
10870 -
10871 -int main(int argc, char ** argv)
10872 -{
10873 - unsigned int i, c, sz, setup_sectors;
10874 - u32 sys_size;
10875 - byte major_root, minor_root;
10876 - struct stat sb;
10877 -
10878 - if (argc > 2 && !strcmp(argv[1], "-b"))
10879 - {
10880 - is_big_kernel = 1;
10881 - argc--, argv++;
10882 - }
10883 - if ((argc < 4) || (argc > 5))
10884 - usage();
10885 - if (argc > 4) {
10886 - if (!strcmp(argv[4], "CURRENT")) {
10887 - if (stat("/", &sb)) {
10888 - perror("/");
10889 - die("Couldn't stat /");
10890 - }
10891 - major_root = major(sb.st_dev);
10892 - minor_root = minor(sb.st_dev);
10893 - } else if (strcmp(argv[4], "FLOPPY")) {
10894 - if (stat(argv[4], &sb)) {
10895 - perror(argv[4]);
10896 - die("Couldn't stat root device.");
10897 - }
10898 - major_root = major(sb.st_rdev);
10899 - minor_root = minor(sb.st_rdev);
10900 - } else {
10901 - major_root = 0;
10902 - minor_root = 0;
10903 - }
10904 - } else {
10905 - major_root = DEFAULT_MAJOR_ROOT;
10906 - minor_root = DEFAULT_MINOR_ROOT;
10907 - }
10908 - fprintf(stderr, "Root device is (%d, %d)\n", major_root, minor_root);
10909 -
10910 - file_open(argv[1]);
10911 - i = read(fd, buf, sizeof(buf));
10912 - fprintf(stderr,"Boot sector %d bytes.\n",i);
10913 - if (i != 512)
10914 - die("Boot block must be exactly 512 bytes");
10915 - if (buf[510] != 0x55 || buf[511] != 0xaa)
10916 - die("Boot block hasn't got boot flag (0xAA55)");
10917 - buf[508] = minor_root;
10918 - buf[509] = major_root;
10919 - if (write(1, buf, 512) != 512)
10920 - die("Write call failed");
10921 - close (fd);
10922 -
10923 - file_open(argv[2]); /* Copy the setup code */
10924 - for (i=0 ; (c=read(fd, buf, sizeof(buf)))>0 ; i+=c )
10925 - if (write(1, buf, c) != c)
10926 - die("Write call failed");
10927 - if (c != 0)
10928 - die("read-error on `setup'");
10929 - close (fd);
10930 -
10931 - setup_sectors = (i + 511) / 512; /* Pad unused space with zeros */
10932 - /* for compatibility with ancient versions of LILO. */
10933 - if (setup_sectors < SETUP_SECTS)
10934 - setup_sectors = SETUP_SECTS;
10935 - fprintf(stderr, "Setup is %d bytes.\n", i);
10936 - memset(buf, 0, sizeof(buf));
10937 - while (i < setup_sectors * 512) {
10938 - c = setup_sectors * 512 - i;
10939 - if (c > sizeof(buf))
10940 - c = sizeof(buf);
10941 - if (write(1, buf, c) != c)
10942 - die("Write call failed");
10943 - i += c;
10944 - }
10945 -
10946 - file_open(argv[3]);
10947 - if (fstat (fd, &sb))
10948 - die("Unable to stat `%s': %m", argv[3]);
10949 - sz = sb.st_size;
10950 - fprintf (stderr, "System is %d kB\n", sz/1024);
10951 - sys_size = (sz + 15) / 16;
10952 - if (!is_big_kernel && sys_size > DEF_SYSSIZE)
10953 - die("System is too big. Try using bzImage or modules.");
10954 - while (sz > 0) {
10955 - int l, n;
10956 -
10957 - l = (sz > sizeof(buf)) ? sizeof(buf) : sz;
10958 - if ((n=read(fd, buf, l)) != l) {
10959 - if (n < 0)
10960 - die("Error reading %s: %m", argv[3]);
10961 - else
10962 - die("%s: Unexpected EOF", argv[3]);
10963 - }
10964 - if (write(1, buf, l) != l)
10965 - die("Write failed");
10966 - sz -= l;
10967 - }
10968 - close(fd);
10969 -
10970 - if (lseek(1, 497, SEEK_SET) != 497) /* Write sizes to the bootsector */
10971 - die("Output: seek failed");
10972 - buf[0] = setup_sectors;
10973 - if (write(1, buf, 1) != 1)
10974 - die("Write of setup sector count failed");
10975 - if (lseek(1, 500, SEEK_SET) != 500)
10976 - die("Output: seek failed");
10977 - buf[0] = (sys_size & 0xff);
10978 - buf[1] = ((sys_size >> 8) & 0xff);
10979 - buf[2] = ((sys_size >> 16) & 0xff);
10980 - buf[3] = ((sys_size >> 24) & 0xff);
10981 - if (write(1, buf, 4) != 4)
10982 - die("Write of image length failed");
10983 -
10984 - return 0; /* Everything is OK */
10985 -}
10986 --- a/arch/x86_64/kernel/Makefile
10987 +++ b/arch/x86_64/kernel/Makefile
10988 @@ -43,6 +43,7 @@
10989
10990 obj-y += topology.o
10991 obj-y += intel_cacheinfo.o
10992 +obj-y += addon_cpuid_features.o
10993 obj-y += pcspeaker.o
10994
10995 CFLAGS_vsyscall.o := $(PROFILING) -g0
10996 @@ -53,6 +54,7 @@
10997 topology-y += ../../i386/kernel/topology.o
10998 microcode-$(subst m,y,$(CONFIG_MICROCODE)) += ../../i386/kernel/microcode.o
10999 intel_cacheinfo-y += ../../i386/kernel/cpu/intel_cacheinfo.o
11000 +addon_cpuid_features-y += ../../i386/kernel/cpu/addon_cpuid_features.o
11001 quirks-y += ../../i386/kernel/quirks.o
11002 i8237-y += ../../i386/kernel/i8237.o
11003 msr-$(subst m,y,$(CONFIG_X86_MSR)) += ../../i386/kernel/msr.o
11004 --- a/arch/x86_64/kernel/setup.c
11005 +++ b/arch/x86_64/kernel/setup.c
11006 @@ -846,6 +846,8 @@
11007 c->x86_capability[2] = cpuid_edx(0x80860001);
11008 }
11009
11010 + init_scattered_cpuid_features(c);
11011 +
11012 c->apicid = phys_pkg_id(0);
11013
11014 /*
11015 @@ -931,7 +933,7 @@
11016 "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
11017 "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
11018 "pat", "pse36", "pn", "clflush", NULL, "dts", "acpi", "mmx",
11019 - "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", NULL,
11020 + "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", "pbe",
11021
11022 /* AMD-defined */
11023 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11024 @@ -947,10 +949,11 @@
11025 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11026
11027 /* Other (Linux-defined) */
11028 - "cxmmx", NULL, "cyrix_arr", "centaur_mcr", NULL,
11029 - "constant_tsc", NULL, NULL,
11030 - "up", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11031 - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11032 + "cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr",
11033 + NULL, NULL, NULL, NULL,
11034 + "constant_tsc", "up", NULL, "arch_perfmon",
11035 + "pebs", "bts", NULL, "sync_rdtsc",
11036 + "rep_good", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11037 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11038
11039 /* Intel-defined (#2) */
11040 @@ -961,7 +964,7 @@
11041
11042 /* VIA/Cyrix/Centaur-defined */
11043 NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
11044 - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11045 + "ace2", "ace2_en", "phe", "phe_en", "pmm", "pmm_en", NULL, NULL,
11046 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11047 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11048
11049 @@ -972,6 +975,12 @@
11050 "osvw", "ibs", NULL, NULL, NULL, NULL,
11051 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11052 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11053 +
11054 + /* Auxiliary (Linux-defined) */
11055 + "ida", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11056 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11057 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11058 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11059 };
11060 static char *x86_power_flags[] = {
11061 "ts", /* temperature sensor */
11062 --- a/arch/x86_64/kernel/verify_cpu.S
11063 +++ b/arch/x86_64/kernel/verify_cpu.S
11064 @@ -37,20 +37,6 @@
11065 pushl $0 # Kill any dangerous flags
11066 popfl
11067
11068 - /* minimum CPUID flags for x86-64 as defined by AMD */
11069 -#define M(x) (1<<(x))
11070 -#define M2(a,b) M(a)|M(b)
11071 -#define M4(a,b,c,d) M(a)|M(b)|M(c)|M(d)
11072 -
11073 -#define SSE_MASK \
11074 - (M2(X86_FEATURE_XMM,X86_FEATURE_XMM2))
11075 -#define REQUIRED_MASK1 \
11076 - (M4(X86_FEATURE_FPU,X86_FEATURE_PSE,X86_FEATURE_TSC,X86_FEATURE_MSR)|\
11077 - M4(X86_FEATURE_PAE,X86_FEATURE_CX8,X86_FEATURE_PGE,X86_FEATURE_CMOV)|\
11078 - M(X86_FEATURE_FXSR))
11079 -#define REQUIRED_MASK2 \
11080 - (M(X86_FEATURE_LM - 32))
11081 -
11082 pushfl # standard way to check for cpuid
11083 popl %eax
11084 movl %eax,%ebx
11085 @@ -79,8 +65,8 @@
11086 verify_cpu_noamd:
11087 movl $0x1,%eax # Does the cpu have what it takes
11088 cpuid
11089 - andl $REQUIRED_MASK1,%edx
11090 - xorl $REQUIRED_MASK1,%edx
11091 + andl $REQUIRED_MASK0,%edx
11092 + xorl $REQUIRED_MASK0,%edx
11093 jnz verify_cpu_no_longmode
11094
11095 movl $0x80000000,%eax # See if extended cpuid is implemented
11096 @@ -90,8 +76,8 @@
11097
11098 movl $0x80000001,%eax # Does the cpu have what it takes
11099 cpuid
11100 - andl $REQUIRED_MASK2,%edx
11101 - xorl $REQUIRED_MASK2,%edx
11102 + andl $REQUIRED_MASK1,%edx
11103 + xorl $REQUIRED_MASK1,%edx
11104 jnz verify_cpu_no_longmode
11105
11106 verify_cpu_sse_test:
11107 --- a/drivers/ide/legacy/hd.c
11108 +++ b/drivers/ide/legacy/hd.c
11109 @@ -718,74 +718,25 @@
11110 device_timer.function = hd_times_out;
11111 blk_queue_hardsect_size(hd_queue, 512);
11112
11113 -#ifdef __i386__
11114 if (!NR_HD) {
11115 - extern struct drive_info drive_info;
11116 - unsigned char *BIOS = (unsigned char *) &drive_info;
11117 - unsigned long flags;
11118 - int cmos_disks;
11119 -
11120 - for (drive=0 ; drive<2 ; drive++) {
11121 - hd_info[drive].cyl = *(unsigned short *) BIOS;
11122 - hd_info[drive].head = *(2+BIOS);
11123 - hd_info[drive].wpcom = *(unsigned short *) (5+BIOS);
11124 - hd_info[drive].ctl = *(8+BIOS);
11125 - hd_info[drive].lzone = *(unsigned short *) (12+BIOS);
11126 - hd_info[drive].sect = *(14+BIOS);
11127 -#ifdef does_not_work_for_everybody_with_scsi_but_helps_ibm_vp
11128 - if (hd_info[drive].cyl && NR_HD == drive)
11129 - NR_HD++;
11130 -#endif
11131 - BIOS += 16;
11132 - }
11133 -
11134 - /*
11135 - We query CMOS about hard disks : it could be that
11136 - we have a SCSI/ESDI/etc controller that is BIOS
11137 - compatible with ST-506, and thus showing up in our
11138 - BIOS table, but not register compatible, and therefore
11139 - not present in CMOS.
11140 -
11141 - Furthermore, we will assume that our ST-506 drives
11142 - <if any> are the primary drives in the system, and
11143 - the ones reflected as drive 1 or 2.
11144 -
11145 - The first drive is stored in the high nibble of CMOS
11146 - byte 0x12, the second in the low nibble. This will be
11147 - either a 4 bit drive type or 0xf indicating use byte 0x19
11148 - for an 8 bit type, drive 1, 0x1a for drive 2 in CMOS.
11149 -
11150 - Needless to say, a non-zero value means we have
11151 - an AT controller hard disk for that drive.
11152 -
11153 - Currently the rtc_lock is a bit academic since this
11154 - driver is non-modular, but someday... ? Paul G.
11155 - */
11156 -
11157 - spin_lock_irqsave(&rtc_lock, flags);
11158 - cmos_disks = CMOS_READ(0x12);
11159 - spin_unlock_irqrestore(&rtc_lock, flags);
11160 -
11161 - if (cmos_disks & 0xf0) {
11162 - if (cmos_disks & 0x0f)
11163 - NR_HD = 2;
11164 - else
11165 - NR_HD = 1;
11166 - }
11167 - }
11168 -#endif /* __i386__ */
11169 -#ifdef __arm__
11170 - if (!NR_HD) {
11171 - /* We don't know anything about the drive. This means
11172 + /*
11173 + * We don't know anything about the drive. This means
11174 * that you *MUST* specify the drive parameters to the
11175 * kernel yourself.
11176 + *
11177 + * If we were on an i386, we used to read this info from
11178 + * the BIOS or CMOS. This doesn't work all that well,
11179 + * since this assumes that this is a primary or secondary
11180 + * drive, and if we're using this legacy driver, it's
11181 + * probably an auxilliary controller added to recover
11182 + * legacy data off an ST-506 drive. Either way, it's
11183 + * definitely safest to have the user explicitly specify
11184 + * the information.
11185 */
11186 printk("hd: no drives specified - use hd=cyl,head,sectors"
11187 " on kernel command line\n");
11188 - }
11189 -#endif
11190 - if (!NR_HD)
11191 goto out;
11192 + }
11193
11194 for (drive=0 ; drive < NR_HD ; drive++) {
11195 struct gendisk *disk = alloc_disk(64);
11196 --- a/include/asm-i386/boot.h
11197 +++ b/include/asm-i386/boot.h
11198 @@ -1,5 +1,5 @@
11199 -#ifndef _LINUX_BOOT_H
11200 -#define _LINUX_BOOT_H
11201 +#ifndef _ASM_BOOT_H
11202 +#define _ASM_BOOT_H
11203
11204 /* Don't touch these, unless you really know what you're doing. */
11205 #define DEF_INITSEG 0x9000
11206 @@ -17,4 +17,4 @@
11207 + (CONFIG_PHYSICAL_ALIGN - 1)) \
11208 & ~(CONFIG_PHYSICAL_ALIGN - 1))
11209
11210 -#endif /* _LINUX_BOOT_H */
11211 +#endif /* _ASM_BOOT_H */
11212 --- /dev/null
11213 +++ b/include/asm-i386/bootparam.h
11214 @@ -0,0 +1,85 @@
11215 +#ifndef _ASM_BOOTPARAM_H
11216 +#define _ASM_BOOTPARAM_H
11217 +
11218 +#include <linux/types.h>
11219 +#include <linux/screen_info.h>
11220 +#include <linux/apm_bios.h>
11221 +#include <asm/e820.h>
11222 +#include <linux/edd.h>
11223 +#include <video/edid.h>
11224 +
11225 +struct setup_header {
11226 + u8 setup_sects;
11227 + u16 root_flags;
11228 + u32 syssize;
11229 + u16 ram_size;
11230 + u16 vid_mode;
11231 + u16 root_dev;
11232 + u16 boot_flag;
11233 + u16 jump;
11234 + u32 header;
11235 + u16 version;
11236 + u32 realmode_swtch;
11237 + u16 start_sys;
11238 + u16 kernel_version;
11239 + u8 type_of_loader;
11240 + u8 loadflags;
11241 +#define LOADED_HIGH 0x01
11242 +#define CAN_USE_HEAP 0x80
11243 + u16 setup_move_size;
11244 + u32 code32_start;
11245 + u32 ramdisk_image;
11246 + u32 ramdisk_size;
11247 + u32 bootsect_kludge;
11248 + u16 heap_end_ptr;
11249 + u16 _pad1;
11250 + u32 cmd_line_ptr;
11251 + u32 initrd_addr_max;
11252 + u32 kernel_alignment;
11253 + u8 relocatable_kernel;
11254 +} __attribute__((packed));
11255 +
11256 +struct sys_desc_table {
11257 + u16 length;
11258 + u8 table[14];
11259 +};
11260 +
11261 +struct efi_info {
11262 + u32 _pad1;
11263 + u32 efi_systab;
11264 + u32 efi_memdesc_size;
11265 + u32 efi_memdec_version;
11266 + u32 efi_memmap;
11267 + u32 fi_memmap_size;
11268 + u32 _pad2[2];
11269 +};
11270 +
11271 +/* The so-called "zeropage" */
11272 +struct boot_params {
11273 + struct screen_info screen_info; /* 0x000 */
11274 + struct apm_bios_info apm_bios_info; /* 0x040 */
11275 + u8 _pad2[12]; /* 0x054 */
11276 + u32 speedstep_info[4]; /* 0x060 */
11277 + u8 _pad3[16]; /* 0x070 */
11278 + u8 hd0_info[16]; /* obsolete! */ /* 0x080 */
11279 + u8 hd1_info[16]; /* obsolete! */ /* 0x090 */
11280 + struct sys_desc_table sys_desc_table; /* 0x0a0 */
11281 + u8 _pad4[144]; /* 0x0b0 */
11282 + struct edid_info edid_info; /* 0x140 */
11283 + struct efi_info efi_info; /* 0x1c0 */
11284 + u32 alt_mem_k; /* 0x1e0 */
11285 + u32 scratch; /* Scratch field! */ /* 0x1e4 */
11286 + u8 e820_entries; /* 0x1e8 */
11287 + u8 eddbuf_entries; /* 0x1e9 */
11288 + u8 edd_mbr_sig_buf_entries; /* 0x1ea */
11289 + u8 _pad6[6]; /* 0x1eb */
11290 + struct setup_header hdr; /* setup header */ /* 0x1f1 */
11291 + u8 _pad7[0x290-0x1f1-sizeof(struct setup_header)];
11292 + u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX]; /* 0x290 */
11293 + struct e820entry e820_map[E820MAX]; /* 0x2d0 */
11294 + u8 _pad8[48]; /* 0xcd0 */
11295 + struct edd_info eddbuf[EDDMAXNR]; /* 0xd00 */
11296 + u8 _pad9[276]; /* 0xeec */
11297 +} __attribute__((packed));
11298 +
11299 +#endif /* _ASM_BOOTPARAM_H */
11300 --- a/include/asm-i386/cpufeature.h
11301 +++ b/include/asm-i386/cpufeature.h
11302 @@ -12,7 +12,7 @@
11303 #endif
11304 #include <asm/required-features.h>
11305
11306 -#define NCAPINTS 7 /* N 32-bit words worth of info */
11307 +#define NCAPINTS 8 /* N 32-bit words worth of info */
11308
11309 /* Intel-defined CPU features, CPUID level 0x00000001 (edx), word 0 */
11310 #define X86_FEATURE_FPU (0*32+ 0) /* Onboard FPU */
11311 @@ -81,6 +81,7 @@
11312 #define X86_FEATURE_BTS (3*32+13) /* Branch Trace Store */
11313 /* 14 free */
11314 #define X86_FEATURE_SYNC_RDTSC (3*32+15) /* RDTSC synchronizes the CPU */
11315 +#define X86_FEATURE_REP_GOOD (3*32+16) /* rep microcode works well on this CPU */
11316
11317 /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
11318 #define X86_FEATURE_XMM3 (4*32+ 0) /* Streaming SIMD Extensions-3 */
11319 @@ -108,11 +109,24 @@
11320 #define X86_FEATURE_LAHF_LM (6*32+ 0) /* LAHF/SAHF in long mode */
11321 #define X86_FEATURE_CMP_LEGACY (6*32+ 1) /* If yes HyperThreading not valid */
11322
11323 -#define cpu_has(c, bit) \
11324 - ((__builtin_constant_p(bit) && (bit) < 32 && \
11325 - (1UL << (bit)) & REQUIRED_MASK1) ? \
11326 - 1 : \
11327 - test_bit(bit, (c)->x86_capability))
11328 +/*
11329 + * Auxiliary flags: Linux defined - For features scattered in various
11330 + * CPUID levels like 0x6, 0xA etc
11331 + */
11332 +#define X86_FEATURE_IDA (7*32+ 0) /* Intel Dynamic Acceleration */
11333 +
11334 +#define cpu_has(c, bit) \
11335 + (__builtin_constant_p(bit) && \
11336 + ( (((bit)>>5)==0 && (1UL<<((bit)&31) & REQUIRED_MASK0)) || \
11337 + (((bit)>>5)==1 && (1UL<<((bit)&31) & REQUIRED_MASK1)) || \
11338 + (((bit)>>5)==2 && (1UL<<((bit)&31) & REQUIRED_MASK2)) || \
11339 + (((bit)>>5)==3 && (1UL<<((bit)&31) & REQUIRED_MASK3)) || \
11340 + (((bit)>>5)==4 && (1UL<<((bit)&31) & REQUIRED_MASK4)) || \
11341 + (((bit)>>5)==5 && (1UL<<((bit)&31) & REQUIRED_MASK5)) || \
11342 + (((bit)>>5)==6 && (1UL<<((bit)&31) & REQUIRED_MASK6)) || \
11343 + (((bit)>>5)==7 && (1UL<<((bit)&31) & REQUIRED_MASK7)) ) \
11344 + ? 1 : \
11345 + test_bit(bit, (c)->x86_capability))
11346 #define boot_cpu_has(bit) cpu_has(&boot_cpu_data, bit)
11347
11348 #define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)
11349 --- a/include/asm-i386/e820.h
11350 +++ b/include/asm-i386/e820.h
11351 @@ -25,13 +25,15 @@
11352
11353 #ifndef __ASSEMBLY__
11354
11355 +struct e820entry {
11356 + u64 addr; /* start of memory segment */
11357 + u64 size; /* size of memory segment */
11358 + u32 type; /* type of memory segment */
11359 +} __attribute__((packed));
11360 +
11361 struct e820map {
11362 - int nr_map;
11363 - struct e820entry {
11364 - unsigned long long addr; /* start of memory segment */
11365 - unsigned long long size; /* size of memory segment */
11366 - unsigned long type; /* type of memory segment */
11367 - } map[E820MAX];
11368 + u32 nr_map;
11369 + struct e820entry map[E820MAX];
11370 };
11371
11372 extern struct e820map e820;
11373 --- a/include/asm-i386/processor.h
11374 +++ b/include/asm-i386/processor.h
11375 @@ -119,6 +119,7 @@
11376 extern void identify_boot_cpu(void);
11377 extern void identify_secondary_cpu(struct cpuinfo_x86 *);
11378 extern void print_cpu_info(struct cpuinfo_x86 *);
11379 +extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c);
11380 extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
11381 extern unsigned short num_cache_leaves;
11382
11383 --- a/include/asm-i386/required-features.h
11384 +++ b/include/asm-i386/required-features.h
11385 @@ -3,7 +3,7 @@
11386
11387 /* Define minimum CPUID feature set for kernel These bits are checked
11388 really early to actually display a visible error message before the
11389 - kernel dies. Only add word 0 bits here
11390 + kernel dies. Make sure to assign features to the proper mask!
11391
11392 Some requirements that are not in CPUID yet are also in the
11393 CONFIG_X86_MINIMUM_CPU mode which is checked too.
11394 @@ -11,24 +11,45 @@
11395 The real information is in arch/i386/Kconfig.cpu, this just converts
11396 the CONFIGs into a bitmask */
11397
11398 +#ifndef CONFIG_MATH_EMULATION
11399 +# define NEED_FPU (1<<(X86_FEATURE_FPU & 31))
11400 +#else
11401 +# define NEED_FPU 0
11402 +#endif
11403 +
11404 #ifdef CONFIG_X86_PAE
11405 -#define NEED_PAE (1<<X86_FEATURE_PAE)
11406 +# define NEED_PAE (1<<(X86_FEATURE_PAE & 31))
11407 #else
11408 -#define NEED_PAE 0
11409 +# define NEED_PAE 0
11410 #endif
11411
11412 #ifdef CONFIG_X86_CMOV
11413 -#define NEED_CMOV (1<<X86_FEATURE_CMOV)
11414 +# define NEED_CMOV (1<<(X86_FEATURE_CMOV & 31))
11415 #else
11416 -#define NEED_CMOV 0
11417 +# define NEED_CMOV 0
11418 #endif
11419
11420 #ifdef CONFIG_X86_CMPXCHG64
11421 -#define NEED_CMPXCHG64 (1<<X86_FEATURE_CX8)
11422 +# define NEED_CX8 (1<<(X86_FEATURE_CX8 & 31))
11423 +#else
11424 +# define NEED_CX8 0
11425 +#endif
11426 +
11427 +#define REQUIRED_MASK0 (NEED_FPU|NEED_PAE|NEED_CMOV|NEED_CX8)
11428 +
11429 +#ifdef CONFIG_X86_USE_3DNOW
11430 +# define NEED_3DNOW (1<<(X86_FEATURE_3DNOW & 31))
11431 #else
11432 -#define NEED_CMPXCHG64 0
11433 +# define NEED_3DNOW 0
11434 #endif
11435
11436 -#define REQUIRED_MASK1 (NEED_PAE|NEED_CMOV|NEED_CMPXCHG64)
11437 +#define REQUIRED_MASK1 (NEED_3DNOW)
11438 +
11439 +#define REQUIRED_MASK2 0
11440 +#define REQUIRED_MASK3 0
11441 +#define REQUIRED_MASK4 0
11442 +#define REQUIRED_MASK5 0
11443 +#define REQUIRED_MASK6 0
11444 +#define REQUIRED_MASK7 0
11445
11446 #endif
11447 --- a/include/asm-i386/setup.h
11448 +++ b/include/asm-i386/setup.h
11449 @@ -26,12 +26,15 @@
11450 #define NEW_CL_POINTER 0x228 /* Relative to real mode data */
11451
11452 #ifndef __ASSEMBLY__
11453 +
11454 +#include <asm/bootparam.h>
11455 +
11456 /*
11457 * This is set up by the setup-routine at boot-time
11458 */
11459 -extern unsigned char boot_params[PARAM_SIZE];
11460 +extern struct boot_params boot_params;
11461
11462 -#define PARAM (boot_params)
11463 +#define PARAM ((char *)&boot_params)
11464 #define SCREEN_INFO (*(struct screen_info *) (PARAM+0))
11465 #define EXT_MEM_K (*(unsigned short *) (PARAM+2))
11466 #define ALT_MEM_K (*(unsigned long *) (PARAM+0x1e0))
11467 @@ -39,8 +42,7 @@
11468 #define E820_MAP ((struct e820entry *) (PARAM+E820MAP))
11469 #define APM_BIOS_INFO (*(struct apm_bios_info *) (PARAM+0x40))
11470 #define IST_INFO (*(struct ist_info *) (PARAM+0x60))
11471 -#define DRIVE_INFO (*(struct drive_info_struct *) (PARAM+0x80))
11472 -#define SYS_DESC_TABLE (*(struct sys_desc_table_struct*)(PARAM+0xa0))
11473 +#define SYS_DESC_TABLE (*(struct sys_desc_table *)(PARAM+0xa0))
11474 #define EFI_SYSTAB ((efi_system_table_t *) *((unsigned long *)(PARAM+0x1c4)))
11475 #define EFI_MEMDESC_SIZE (*((unsigned long *) (PARAM+0x1c8)))
11476 #define EFI_MEMDESC_VERSION (*((unsigned long *) (PARAM+0x1cc)))
11477 --- a/include/asm-x86_64/alternative.h
11478 +++ b/include/asm-x86_64/alternative.h
11479 @@ -5,6 +5,41 @@
11480
11481 #include <linux/types.h>
11482 #include <linux/stddef.h>
11483 +
11484 +/*
11485 + * Alternative inline assembly for SMP.
11486 + *
11487 + * The LOCK_PREFIX macro defined here replaces the LOCK and
11488 + * LOCK_PREFIX macros used everywhere in the source tree.
11489 + *
11490 + * SMP alternatives use the same data structures as the other
11491 + * alternatives and the X86_FEATURE_UP flag to indicate the case of a
11492 + * UP system running a SMP kernel. The existing apply_alternatives()
11493 + * works fine for patching a SMP kernel for UP.
11494 + *
11495 + * The SMP alternative tables can be kept after boot and contain both
11496 + * UP and SMP versions of the instructions to allow switching back to
11497 + * SMP at runtime, when hotplugging in a new CPU, which is especially
11498 + * useful in virtualized environments.
11499 + *
11500 + * The very common lock prefix is handled as special case in a
11501 + * separate table which is a pure address list without replacement ptr
11502 + * and size information. That keeps the table sizes small.
11503 + */
11504 +
11505 +#ifdef CONFIG_SMP
11506 +#define LOCK_PREFIX \
11507 + ".section .smp_locks,\"a\"\n" \
11508 + " .align 8\n" \
11509 + " .quad 661f\n" /* address */ \
11510 + ".previous\n" \
11511 + "661:\n\tlock; "
11512 +
11513 +#else /* ! CONFIG_SMP */
11514 +#define LOCK_PREFIX ""
11515 +#endif
11516 +
11517 +/* This must be included *after* the definition of LOCK_PREFIX */
11518 #include <asm/cpufeature.h>
11519
11520 struct alt_instr {
11521 @@ -108,39 +143,6 @@
11522 */
11523 #define ASM_OUTPUT2(a, b) a, b
11524
11525 -/*
11526 - * Alternative inline assembly for SMP.
11527 - *
11528 - * The LOCK_PREFIX macro defined here replaces the LOCK and
11529 - * LOCK_PREFIX macros used everywhere in the source tree.
11530 - *
11531 - * SMP alternatives use the same data structures as the other
11532 - * alternatives and the X86_FEATURE_UP flag to indicate the case of a
11533 - * UP system running a SMP kernel. The existing apply_alternatives()
11534 - * works fine for patching a SMP kernel for UP.
11535 - *
11536 - * The SMP alternative tables can be kept after boot and contain both
11537 - * UP and SMP versions of the instructions to allow switching back to
11538 - * SMP at runtime, when hotplugging in a new CPU, which is especially
11539 - * useful in virtualized environments.
11540 - *
11541 - * The very common lock prefix is handled as special case in a
11542 - * separate table which is a pure address list without replacement ptr
11543 - * and size information. That keeps the table sizes small.
11544 - */
11545 -
11546 -#ifdef CONFIG_SMP
11547 -#define LOCK_PREFIX \
11548 - ".section .smp_locks,\"a\"\n" \
11549 - " .align 8\n" \
11550 - " .quad 661f\n" /* address */ \
11551 - ".previous\n" \
11552 - "661:\n\tlock; "
11553 -
11554 -#else /* ! CONFIG_SMP */
11555 -#define LOCK_PREFIX ""
11556 -#endif
11557 -
11558 struct paravirt_patch;
11559 #ifdef CONFIG_PARAVIRT
11560 void apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end);
11561 --- a/include/asm-x86_64/boot.h
11562 +++ b/include/asm-x86_64/boot.h
11563 @@ -1,15 +1 @@
11564 -#ifndef _LINUX_BOOT_H
11565 -#define _LINUX_BOOT_H
11566 -
11567 -/* Don't touch these, unless you really know what you're doing. */
11568 -#define DEF_INITSEG 0x9000
11569 -#define DEF_SYSSEG 0x1000
11570 -#define DEF_SETUPSEG 0x9020
11571 -#define DEF_SYSSIZE 0x7F00
11572 -
11573 -/* Internal svga startup constants */
11574 -#define NORMAL_VGA 0xffff /* 80x25 mode */
11575 -#define EXTENDED_VGA 0xfffe /* 80x50 mode */
11576 -#define ASK_VGA 0xfffd /* ask for it at bootup */
11577 -
11578 -#endif
11579 +#include <asm-i386/boot.h>
11580 --- /dev/null
11581 +++ b/include/asm-x86_64/bootparam.h
11582 @@ -0,0 +1 @@
11583 +#include <asm-i386/bootparam.h>
11584 --- a/include/asm-x86_64/cpufeature.h
11585 +++ b/include/asm-x86_64/cpufeature.h
11586 @@ -7,115 +7,24 @@
11587 #ifndef __ASM_X8664_CPUFEATURE_H
11588 #define __ASM_X8664_CPUFEATURE_H
11589
11590 -#define NCAPINTS 7 /* N 32-bit words worth of info */
11591 +#include <asm-i386/cpufeature.h>
11592
11593 -/* Intel-defined CPU features, CPUID level 0x00000001, word 0 */
11594 -#define X86_FEATURE_FPU (0*32+ 0) /* Onboard FPU */
11595 -#define X86_FEATURE_VME (0*32+ 1) /* Virtual Mode Extensions */
11596 -#define X86_FEATURE_DE (0*32+ 2) /* Debugging Extensions */
11597 -#define X86_FEATURE_PSE (0*32+ 3) /* Page Size Extensions */
11598 -#define X86_FEATURE_TSC (0*32+ 4) /* Time Stamp Counter */
11599 -#define X86_FEATURE_MSR (0*32+ 5) /* Model-Specific Registers, RDMSR, WRMSR */
11600 -#define X86_FEATURE_PAE (0*32+ 6) /* Physical Address Extensions */
11601 -#define X86_FEATURE_MCE (0*32+ 7) /* Machine Check Architecture */
11602 -#define X86_FEATURE_CX8 (0*32+ 8) /* CMPXCHG8 instruction */
11603 -#define X86_FEATURE_APIC (0*32+ 9) /* Onboard APIC */
11604 -#define X86_FEATURE_SEP (0*32+11) /* SYSENTER/SYSEXIT */
11605 -#define X86_FEATURE_MTRR (0*32+12) /* Memory Type Range Registers */
11606 -#define X86_FEATURE_PGE (0*32+13) /* Page Global Enable */
11607 -#define X86_FEATURE_MCA (0*32+14) /* Machine Check Architecture */
11608 -#define X86_FEATURE_CMOV (0*32+15) /* CMOV instruction (FCMOVCC and FCOMI too if FPU present) */
11609 -#define X86_FEATURE_PAT (0*32+16) /* Page Attribute Table */
11610 -#define X86_FEATURE_PSE36 (0*32+17) /* 36-bit PSEs */
11611 -#define X86_FEATURE_PN (0*32+18) /* Processor serial number */
11612 -#define X86_FEATURE_CLFLSH (0*32+19) /* Supports the CLFLUSH instruction */
11613 -#define X86_FEATURE_DS (0*32+21) /* Debug Store */
11614 -#define X86_FEATURE_ACPI (0*32+22) /* ACPI via MSR */
11615 -#define X86_FEATURE_MMX (0*32+23) /* Multimedia Extensions */
11616 -#define X86_FEATURE_FXSR (0*32+24) /* FXSAVE and FXRSTOR instructions (fast save and restore */
11617 - /* of FPU context), and CR4.OSFXSR available */
11618 -#define X86_FEATURE_XMM (0*32+25) /* Streaming SIMD Extensions */
11619 -#define X86_FEATURE_XMM2 (0*32+26) /* Streaming SIMD Extensions-2 */
11620 -#define X86_FEATURE_SELFSNOOP (0*32+27) /* CPU self snoop */
11621 -#define X86_FEATURE_HT (0*32+28) /* Hyper-Threading */
11622 -#define X86_FEATURE_ACC (0*32+29) /* Automatic clock control */
11623 -#define X86_FEATURE_IA64 (0*32+30) /* IA-64 processor */
11624 -
11625 -/* AMD-defined CPU features, CPUID level 0x80000001, word 1 */
11626 -/* Don't duplicate feature flags which are redundant with Intel! */
11627 -#define X86_FEATURE_SYSCALL (1*32+11) /* SYSCALL/SYSRET */
11628 -#define X86_FEATURE_MMXEXT (1*32+22) /* AMD MMX extensions */
11629 -#define X86_FEATURE_FXSR_OPT (1*32+25) /* FXSR optimizations */
11630 -#define X86_FEATURE_RDTSCP (1*32+27) /* RDTSCP */
11631 -#define X86_FEATURE_LM (1*32+29) /* Long Mode (x86-64) */
11632 -#define X86_FEATURE_3DNOWEXT (1*32+30) /* AMD 3DNow! extensions */
11633 -#define X86_FEATURE_3DNOW (1*32+31) /* 3DNow! */
11634 -
11635 -/* Transmeta-defined CPU features, CPUID level 0x80860001, word 2 */
11636 -#define X86_FEATURE_RECOVERY (2*32+ 0) /* CPU in recovery mode */
11637 -#define X86_FEATURE_LONGRUN (2*32+ 1) /* Longrun power control */
11638 -#define X86_FEATURE_LRTI (2*32+ 3) /* LongRun table interface */
11639 -
11640 -/* Other features, Linux-defined mapping, word 3 */
11641 -/* This range is used for feature bits which conflict or are synthesized */
11642 -#define X86_FEATURE_CXMMX (3*32+ 0) /* Cyrix MMX extensions */
11643 -#define X86_FEATURE_K6_MTRR (3*32+ 1) /* AMD K6 nonstandard MTRRs */
11644 -#define X86_FEATURE_CYRIX_ARR (3*32+ 2) /* Cyrix ARRs (= MTRRs) */
11645 -#define X86_FEATURE_CENTAUR_MCR (3*32+ 3) /* Centaur MCRs (= MTRRs) */
11646 -#define X86_FEATURE_REP_GOOD (3*32+ 4) /* rep microcode works well on this CPU */
11647 -#define X86_FEATURE_CONSTANT_TSC (3*32+5) /* TSC runs at constant rate */
11648 -#define X86_FEATURE_SYNC_RDTSC (3*32+6) /* RDTSC syncs CPU core */
11649 -#define X86_FEATURE_FXSAVE_LEAK (3*32+7) /* FIP/FOP/FDP leaks through FXSAVE */
11650 -#define X86_FEATURE_UP (3*32+8) /* SMP kernel running on UP */
11651 -#define X86_FEATURE_ARCH_PERFMON (3*32+9) /* Intel Architectural PerfMon */
11652 -#define X86_FEATURE_PEBS (3*32+10) /* Precise-Event Based Sampling */
11653 -#define X86_FEATURE_BTS (3*32+11) /* Branch Trace Store */
11654 -
11655 -/* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
11656 -#define X86_FEATURE_XMM3 (4*32+ 0) /* Streaming SIMD Extensions-3 */
11657 -#define X86_FEATURE_MWAIT (4*32+ 3) /* Monitor/Mwait support */
11658 -#define X86_FEATURE_DSCPL (4*32+ 4) /* CPL Qualified Debug Store */
11659 -#define X86_FEATURE_EST (4*32+ 7) /* Enhanced SpeedStep */
11660 -#define X86_FEATURE_TM2 (4*32+ 8) /* Thermal Monitor 2 */
11661 -#define X86_FEATURE_CID (4*32+10) /* Context ID */
11662 -#define X86_FEATURE_CX16 (4*32+13) /* CMPXCHG16B */
11663 -#define X86_FEATURE_XTPR (4*32+14) /* Send Task Priority Messages */
11664 -
11665 -/* VIA/Cyrix/Centaur-defined CPU features, CPUID level 0xC0000001, word 5 */
11666 -#define X86_FEATURE_XSTORE (5*32+ 2) /* on-CPU RNG present (xstore insn) */
11667 -#define X86_FEATURE_XSTORE_EN (5*32+ 3) /* on-CPU RNG enabled */
11668 -#define X86_FEATURE_XCRYPT (5*32+ 6) /* on-CPU crypto (xcrypt insn) */
11669 -#define X86_FEATURE_XCRYPT_EN (5*32+ 7) /* on-CPU crypto enabled */
11670 -
11671 -/* More extended AMD flags: CPUID level 0x80000001, ecx, word 6 */
11672 -#define X86_FEATURE_LAHF_LM (6*32+ 0) /* LAHF/SAHF in long mode */
11673 -#define X86_FEATURE_CMP_LEGACY (6*32+ 1) /* If yes HyperThreading not valid */
11674 -
11675 -#define cpu_has(c, bit) test_bit(bit, (c)->x86_capability)
11676 -#define boot_cpu_has(bit) test_bit(bit, boot_cpu_data.x86_capability)
11677 -
11678 -#define cpu_has_fpu 1
11679 +#undef cpu_has_vme
11680 #define cpu_has_vme 0
11681 -#define cpu_has_de 1
11682 -#define cpu_has_pse 1
11683 -#define cpu_has_tsc 1
11684 +
11685 +#undef cpu_has_pae
11686 #define cpu_has_pae ___BUG___
11687 -#define cpu_has_pge 1
11688 -#define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC)
11689 -#define cpu_has_mtrr 1
11690 -#define cpu_has_mmx 1
11691 -#define cpu_has_fxsr 1
11692 -#define cpu_has_xmm 1
11693 -#define cpu_has_xmm2 1
11694 -#define cpu_has_xmm3 boot_cpu_has(X86_FEATURE_XMM3)
11695 -#define cpu_has_ht boot_cpu_has(X86_FEATURE_HT)
11696 +
11697 +#undef cpu_has_mp
11698 #define cpu_has_mp 1 /* XXX */
11699 +
11700 +#undef cpu_has_k6_mtrr
11701 #define cpu_has_k6_mtrr 0
11702 +
11703 +#undef cpu_has_cyrix_arr
11704 #define cpu_has_cyrix_arr 0
11705 +
11706 +#undef cpu_has_centaur_mcr
11707 #define cpu_has_centaur_mcr 0
11708 -#define cpu_has_clflush boot_cpu_has(X86_FEATURE_CLFLSH)
11709 -#define cpu_has_ds boot_cpu_has(X86_FEATURE_DS)
11710 -#define cpu_has_pebs boot_cpu_has(X86_FEATURE_PEBS)
11711 -#define cpu_has_bts boot_cpu_has(X86_FEATURE_BTS)
11712
11713 #endif /* __ASM_X8664_CPUFEATURE_H */
11714 --- a/include/asm-x86_64/e820.h
11715 +++ b/include/asm-x86_64/e820.h
11716 @@ -11,7 +11,9 @@
11717 #ifndef __E820_HEADER
11718 #define __E820_HEADER
11719
11720 -#include <linux/mmzone.h>
11721 +#ifndef _SETUP
11722 +# include <linux/mmzone.h>
11723 +#endif
11724
11725 #define E820MAP 0x2d0 /* our map */
11726 #define E820MAX 128 /* number of entries in E820MAP */
11727 @@ -30,7 +32,7 @@
11728 } __attribute__((packed));
11729
11730 struct e820map {
11731 - int nr_map;
11732 + u32 nr_map;
11733 struct e820entry map[E820MAX];
11734 };
11735
11736 --- a/include/asm-x86_64/processor.h
11737 +++ b/include/asm-x86_64/processor.h
11738 @@ -100,6 +100,7 @@
11739
11740 extern void identify_cpu(struct cpuinfo_x86 *);
11741 extern void print_cpu_info(struct cpuinfo_x86 *);
11742 +extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c);
11743 extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
11744 extern unsigned short num_cache_leaves;
11745
11746 @@ -368,8 +369,6 @@
11747 asm volatile("cpuid" : "=a" (tmp) : "0" (1) : "ebx","ecx","edx","memory");
11748 }
11749
11750 -#define cpu_has_fpu 1
11751 -
11752 #define ARCH_HAS_PREFETCH
11753 static inline void prefetch(void *x)
11754 {
11755 --- /dev/null
11756 +++ b/include/asm-x86_64/required-features.h
11757 @@ -0,0 +1,46 @@
11758 +#ifndef _ASM_REQUIRED_FEATURES_H
11759 +#define _ASM_REQUIRED_FEATURES_H 1
11760 +
11761 +/* Define minimum CPUID feature set for kernel These bits are checked
11762 + really early to actually display a visible error message before the
11763 + kernel dies. Make sure to assign features to the proper mask!
11764 +
11765 + The real information is in arch/x86_64/Kconfig.cpu, this just converts
11766 + the CONFIGs into a bitmask */
11767 +
11768 +/* x86-64 baseline features */
11769 +#define NEED_FPU (1<<(X86_FEATURE_FPU & 31))
11770 +#define NEED_PSE (1<<(X86_FEATURE_PSE & 31))
11771 +#define NEED_MSR (1<<(X86_FEATURE_MSR & 31))
11772 +#define NEED_PAE (1<<(X86_FEATURE_PAE & 31))
11773 +#define NEED_CX8 (1<<(X86_FEATURE_CX8 & 31))
11774 +#define NEED_PGE (1<<(X86_FEATURE_PGE & 31))
11775 +#define NEED_FXSR (1<<(X86_FEATURE_FXSR & 31))
11776 +#define NEED_CMOV (1<<(X86_FEATURE_CMOV & 31))
11777 +#define NEED_XMM (1<<(X86_FEATURE_XMM & 31))
11778 +#define NEED_XMM2 (1<<(X86_FEATURE_XMM2 & 31))
11779 +
11780 +#define REQUIRED_MASK0 (NEED_FPU|NEED_PSE|NEED_MSR|NEED_PAE|\
11781 + NEED_CX8|NEED_PGE|NEED_FXSR|NEED_CMOV|\
11782 + NEED_XMM|NEED_XMM2)
11783 +#define SSE_MASK (NEED_XMM|NEED_XMM2)
11784 +
11785 +/* x86-64 baseline features */
11786 +#define NEED_LM (1<<(X86_FEATURE_LM & 31))
11787 +
11788 +#ifdef CONFIG_X86_USE_3DNOW
11789 +# define NEED_3DNOW (1<<(X86_FEATURE_3DNOW & 31))
11790 +#else
11791 +# define NEED_3DNOW 0
11792 +#endif
11793 +
11794 +#define REQUIRED_MASK1 (NEED_LM|NEED_3DNOW)
11795 +
11796 +#define REQUIRED_MASK2 0
11797 +#define REQUIRED_MASK3 0
11798 +#define REQUIRED_MASK4 0
11799 +#define REQUIRED_MASK5 0
11800 +#define REQUIRED_MASK6 0
11801 +#define REQUIRED_MASK7 0
11802 +
11803 +#endif
11804 --- a/include/asm-x86_64/segment.h
11805 +++ b/include/asm-x86_64/segment.h
11806 @@ -3,6 +3,14 @@
11807
11808 #include <asm/cache.h>
11809
11810 +/* Simple and small GDT entries for booting only */
11811 +
11812 +#define GDT_ENTRY_BOOT_CS 2
11813 +#define __BOOT_CS (GDT_ENTRY_BOOT_CS * 8)
11814 +
11815 +#define GDT_ENTRY_BOOT_DS (GDT_ENTRY_BOOT_CS + 1)
11816 +#define __BOOT_DS (GDT_ENTRY_BOOT_DS * 8)
11817 +
11818 #define __KERNEL_CS 0x10
11819 #define __KERNEL_DS 0x18
11820
11821 --- a/include/linux/edd.h
11822 +++ b/include/linux/edd.h
11823 @@ -49,10 +49,6 @@
11824 #define EDD_MBR_SIG_MAX 16 /* max number of signatures to store */
11825 #define EDD_MBR_SIG_NR_BUF 0x1ea /* addr of number of MBR signtaures at EDD_MBR_SIG_BUF
11826 in boot_params - treat this as 1 byte */
11827 -#define EDD_CL_EQUALS 0x3d646465 /* "edd=" */
11828 -#define EDD_CL_OFF 0x666f /* "of" for off */
11829 -#define EDD_CL_SKIP 0x6b73 /* "sk" for skipmbr */
11830 -#define EDD_CL_ON 0x6e6f /* "on" for on */
11831
11832 #ifndef __ASSEMBLY__
11833
11834 --- a/include/linux/screen_info.h
11835 +++ b/include/linux/screen_info.h
11836 @@ -10,7 +10,7 @@
11837 struct screen_info {
11838 u8 orig_x; /* 0x00 */
11839 u8 orig_y; /* 0x01 */
11840 - u16 dontuse1; /* 0x02 -- EXT_MEM_K sits here */
11841 + u16 ext_mem_k; /* 0x02 */
11842 u16 orig_video_page; /* 0x04 */
11843 u8 orig_video_mode; /* 0x06 */
11844 u8 orig_video_cols; /* 0x07 */
11845 @@ -27,7 +27,7 @@
11846 u16 lfb_depth; /* 0x16 */
11847 u32 lfb_base; /* 0x18 */
11848 u32 lfb_size; /* 0x1c */
11849 - u16 dontuse2, dontuse3; /* 0x20 -- CL_MAGIC and CL_OFFSET here */
11850 + u16 cl_magic, cl_offset; /* 0x20 */
11851 u16 lfb_linelength; /* 0x24 */
11852 u8 red_size; /* 0x26 */
11853 u8 red_pos; /* 0x27 */
11854 @@ -42,9 +42,8 @@
11855 u16 pages; /* 0x32 */
11856 u16 vesa_attributes; /* 0x34 */
11857 u32 capabilities; /* 0x36 */
11858 - /* 0x3a -- 0x3b reserved for future expansion */
11859 - /* 0x3c -- 0x3f micro stack for relocatable kernels */
11860 -};
11861 + u8 _reserved[6]; /* 0x3a */
11862 +} __attribute__((packed));
11863
11864 extern struct screen_info screen_info;
11865
This page took 0.500095 seconds and 5 git commands to generate.