1 /* -*- linux-c -*- ------------------------------------------------------- *
3 * Copyright (C) 1991, 1992 Linus Torvalds
4 * Copyright 2007 rPath, Inc. - All Rights Reserved
6 * This file is part of the Linux kernel, and is made available under
7 * the terms of the GNU General Public License version 2.
9 * ----------------------------------------------------------------------- */
12 * arch/i386/boot/main.c
14 * Main module for the real-mode kernel code
19 struct boot_params boot_params
__attribute__((aligned(16)));
22 char *heap_end
= _end
; /* Default end of heap = no heap */
25 * Copy the header into the boot parameter block. Since this
26 * screws up the old-style command line protocol, adjust by
27 * filling in the new-style command line pointer instead.
30 static void copy_boot_params(void)
36 const struct old_cmdline
* const oldcmd
=
37 (const struct old_cmdline
*)OLD_CL_ADDRESS
;
39 BUILD_BUG_ON(sizeof boot_params
!= 4096);
40 memcpy(&boot_params
.hdr
, &hdr
, sizeof hdr
);
42 if (!boot_params
.hdr
.cmd_line_ptr
&&
43 oldcmd
->cl_magic
== OLD_CL_MAGIC
) {
44 /* Old-style command line protocol. */
47 /* Figure out if the command line falls in the region
48 of memory that an old kernel would have copied up
50 if (oldcmd
->cl_offset
< boot_params
.hdr
.setup_move_size
)
55 boot_params
.hdr
.cmd_line_ptr
=
56 (cmdline_seg
<< 4) + oldcmd
->cl_offset
;
61 * Set the keyboard repeat rate to maximum. Unclear why this
62 * is done here; this might be possible to kill off as stale code.
64 static void keyboard_set_repeat(void)
68 asm volatile("int $0x16"
69 : "+a" (ax
), "+b" (bx
)
70 : : "ecx", "edx", "esi", "edi");
74 * Get Intel SpeedStep (IST) information.
76 static void query_ist(void)
79 : "=a" (boot_params
.ist_info
.signature
),
80 "=b" (boot_params
.ist_info
.command
),
81 "=c" (boot_params
.ist_info
.event
),
82 "=d" (boot_params
.ist_info
.perf_level
)
83 : "a" (0x0000e980), /* IST Support */
84 "d" (0x47534943)); /* Request value */
88 * Tell the BIOS what CPU mode we intend to run in.
90 static void set_bios_mode(void)
97 asm volatile("int $0x15"
98 : "+a" (eax
), "+b" (ebx
)
99 : : "ecx", "edx", "esi", "edi");
103 static void init_heap(void)
107 if (boot_params
.hdr
.loadflags
& CAN_USE_HEAP
) {
108 asm("leal %P1(%%esp),%0"
109 : "=r" (stack_end
) : "i" (-STACK_SIZE
));
112 ((size_t)boot_params
.hdr
.heap_end_ptr
+ 0x200);
113 if (heap_end
> stack_end
)
114 heap_end
= stack_end
;
116 /* Boot protocol 2.00 only, no heap available */
117 puts("WARNING: Ancient bootloader, some functionality "
118 "may be limited!\n");
124 /* First, copy the boot header into the "zeropage" */
127 /* End of heap check */
130 /* Make sure we have all the proper CPU support */
131 if (validate_cpu()) {
132 puts("Unable to boot - please use a kernel appropriate "
137 /* Tell the BIOS what CPU mode we intend to run in. */
140 /* Detect memory layout */
143 /* Set keyboard repeat rate (why?) */
144 keyboard_set_repeat();
146 /* Query MCA information */
150 #ifdef CONFIG_X86_VOYAGER
154 /* Query Intel SpeedStep (IST) information */
157 /* Query APM information */
158 #if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
162 /* Query EDD information */
163 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
167 /* Set the video mode */
170 /* Do the last things and invoke protected mode */
171 go_to_protected_mode();