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 * Main module for the real-mode kernel code
17 struct boot_params boot_params __attribute__((aligned(16)));
20 char *heap_end = _end; /* Default end of heap = no heap */
23 * Copy the header into the boot parameter block. Since this
24 * screws up the old-style command line protocol, adjust by
25 * filling in the new-style command line pointer instead.
28 static void copy_boot_params(void)
34 const struct old_cmdline * const oldcmd =
35 (const struct old_cmdline *)OLD_CL_ADDRESS;
37 BUILD_BUG_ON(sizeof boot_params != 4096);
38 memcpy(&boot_params.hdr, &hdr, sizeof hdr);
40 if (!boot_params.hdr.cmd_line_ptr &&
41 oldcmd->cl_magic == OLD_CL_MAGIC) {
42 /* Old-style command line protocol. */
45 /* Figure out if the command line falls in the region
46 of memory that an old kernel would have copied up
48 if (oldcmd->cl_offset < boot_params.hdr.setup_move_size)
53 boot_params.hdr.cmd_line_ptr =
54 (cmdline_seg << 4) + oldcmd->cl_offset;
59 * Set the keyboard repeat rate to maximum. Unclear why this
60 * is done here; this might be possible to kill off as stale code.
62 static void keyboard_set_repeat(void)
66 asm volatile("int $0x16"
67 : "+a" (ax), "+b" (bx)
68 : : "ecx", "edx", "esi", "edi");
72 * Get Intel SpeedStep (IST) information.
74 static void query_ist(void)
76 /* Some older BIOSes apparently crash on this call, so filter
77 it from machines too old to have SpeedStep at all. */
82 : "=a" (boot_params.ist_info.signature),
83 "=b" (boot_params.ist_info.command),
84 "=c" (boot_params.ist_info.event),
85 "=d" (boot_params.ist_info.perf_level)
86 : "a" (0x0000e980), /* IST Support */
87 "d" (0x47534943)); /* Request value */
91 * Tell the BIOS what CPU mode we intend to run in.
93 static void set_bios_mode(void)
100 asm volatile("int $0x15"
101 : "+a" (eax), "+b" (ebx)
102 : : "ecx", "edx", "esi", "edi");
106 static void init_heap(void)
110 if (boot_params.hdr.loadflags & CAN_USE_HEAP) {
111 asm("leal %P1(%%esp),%0"
112 : "=r" (stack_end) : "i" (-STACK_SIZE));
115 ((size_t)boot_params.hdr.heap_end_ptr + 0x200);
116 if (heap_end > stack_end)
117 heap_end = stack_end;
119 /* Boot protocol 2.00 only, no heap available */
120 puts("WARNING: Ancient bootloader, some functionality "
121 "may be limited!\n");
127 /* First, copy the boot header into the "zeropage" */
130 /* End of heap check */
133 /* Make sure we have all the proper CPU support */
134 if (validate_cpu()) {
135 puts("Unable to boot - please use a kernel appropriate "
140 /* Tell the BIOS what CPU mode we intend to run in. */
143 /* Detect memory layout */
146 /* Set keyboard repeat rate (why?) */
147 keyboard_set_repeat();
149 /* Query MCA information */
152 /* Query Intel SpeedStep (IST) information */
155 /* Query APM information */
156 #if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
160 /* Query EDD information */
161 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
165 /* Set the video mode */
168 /* Parse command line for 'quiet' and pass it to decompressor. */
169 if (cmdline_find_option_bool("quiet"))
170 boot_params.hdr.loadflags |= QUIET_FLAG;
172 /* Do the last things and invoke protected mode */
173 go_to_protected_mode();