1 /* -*- linux-c -*- ------------------------------------------------------- *
3 * Copyright (C) 1991, 1992 Linus Torvalds
4 * Copyright 2007 rPath, Inc. - All Rights Reserved
5 * Copyright 2009 Intel Corporation; author H. Peter Anvin
7 * This file is part of the Linux kernel, and is made available under
8 * the terms of the GNU General Public License version 2.
10 * ----------------------------------------------------------------------- */
13 * Main module for the real-mode kernel code
18 struct boot_params boot_params
__attribute__((aligned(16)));
21 char *heap_end
= _end
; /* Default end of heap = no heap */
24 * Copy the header into the boot parameter block. Since this
25 * screws up the old-style command line protocol, adjust by
26 * filling in the new-style command line pointer instead.
29 static void copy_boot_params(void)
35 const struct old_cmdline
* const oldcmd
=
36 (const struct old_cmdline
*)OLD_CL_ADDRESS
;
38 BUILD_BUG_ON(sizeof boot_params
!= 4096);
39 memcpy(&boot_params
.hdr
, &hdr
, sizeof hdr
);
41 if (!boot_params
.hdr
.cmd_line_ptr
&&
42 oldcmd
->cl_magic
== OLD_CL_MAGIC
) {
43 /* Old-style command line protocol. */
46 /* Figure out if the command line falls in the region
47 of memory that an old kernel would have copied up
49 if (oldcmd
->cl_offset
< boot_params
.hdr
.setup_move_size
)
54 boot_params
.hdr
.cmd_line_ptr
=
55 (cmdline_seg
<< 4) + oldcmd
->cl_offset
;
60 * Set the keyboard repeat rate to maximum. Unclear why this
61 * is done here; this might be possible to kill off as stale code.
63 static void keyboard_set_repeat(void)
68 intcall(0x16, &ireg
, NULL
);
72 * Get Intel SpeedStep (IST) information.
74 static void query_ist(void)
76 struct biosregs ireg
, oreg
;
78 /* Some older BIOSes apparently crash on this call, so filter
79 it from machines too old to have SpeedStep at all. */
84 ireg
.ax
= 0xe980; /* IST Support */
85 ireg
.edx
= 0x47534943; /* Request value */
86 intcall(0x15, &ireg
, &oreg
);
88 boot_params
.ist_info
.signature
= oreg
.eax
;
89 boot_params
.ist_info
.command
= oreg
.ebx
;
90 boot_params
.ist_info
.event
= oreg
.ecx
;
91 boot_params
.ist_info
.perf_level
= oreg
.edx
;
95 * Tell the BIOS what CPU mode we intend to run in.
97 static void set_bios_mode(void)
100 struct biosregs ireg
;
105 intcall(0x15, &ireg
, NULL
);
109 static void init_heap(void)
113 if (boot_params
.hdr
.loadflags
& CAN_USE_HEAP
) {
114 asm("leal %P1(%%esp),%0"
115 : "=r" (stack_end
) : "i" (-STACK_SIZE
));
118 ((size_t)boot_params
.hdr
.heap_end_ptr
+ 0x200);
119 if (heap_end
> stack_end
)
120 heap_end
= stack_end
;
122 /* Boot protocol 2.00 only, no heap available */
123 puts("WARNING: Ancient bootloader, some functionality "
124 "may be limited!\n");
130 /* First, copy the boot header into the "zeropage" */
133 /* End of heap check */
136 /* Make sure we have all the proper CPU support */
137 if (validate_cpu()) {
138 puts("Unable to boot - please use a kernel appropriate "
143 /* Tell the BIOS what CPU mode we intend to run in. */
146 /* Detect memory layout */
149 /* Set keyboard repeat rate (why?) */
150 keyboard_set_repeat();
152 /* Query MCA information */
155 /* Query Intel SpeedStep (IST) information */
158 /* Query APM information */
159 #if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
163 /* Query EDD information */
164 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
168 /* Set the video mode */
171 /* Parse command line for 'quiet' and pass it to decompressor. */
172 if (cmdline_find_option_bool("quiet"))
173 boot_params
.hdr
.loadflags
|= QUIET_FLAG
;
175 /* Do the last things and invoke protected mode */
176 go_to_protected_mode();