1 // SPDX-License-Identifier: GPL-2.0-only 1 2 /* -*- linux-c -*- --------------------------- 3 * 4 * Copyright (C) 1991, 1992 Linus Torvalds 5 * Copyright 2007 rPath, Inc. - All Rights R 6 * Copyright 2009 Intel Corporation; author 7 * 8 * ------------------------------------------- 9 10 /* 11 * Main module for the real-mode kernel code 12 */ 13 #include <linux/build_bug.h> 14 15 #include "boot.h" 16 #include "string.h" 17 18 struct boot_params boot_params __attribute__(( 19 20 struct port_io_ops pio_ops; 21 22 char *HEAP = _end; 23 char *heap_end = _end; /* Default end 24 25 /* 26 * Copy the header into the boot parameter blo 27 * screws up the old-style command line protoc 28 * filling in the new-style command line point 29 */ 30 static void copy_boot_params(void) 31 { 32 struct old_cmdline { 33 u16 cl_magic; 34 u16 cl_offset; 35 }; 36 const struct old_cmdline * const oldcm 37 38 BUILD_BUG_ON(sizeof(boot_params) != 40 39 memcpy(&boot_params.hdr, &hdr, sizeof( 40 41 if (!boot_params.hdr.cmd_line_ptr && o 42 /* Old-style command line prot 43 u16 cmdline_seg; 44 45 /* 46 * Figure out if the command l 47 * of memory that an old kerne 48 * to 0x90000... 49 */ 50 if (oldcmd->cl_offset < boot_p 51 cmdline_seg = ds(); 52 else 53 cmdline_seg = 0x9000; 54 55 boot_params.hdr.cmd_line_ptr = 56 } 57 } 58 59 /* 60 * Query the keyboard lock status as given by 61 * set the keyboard repeat rate to maximum. U 62 * is done here; this might be possible to kil 63 */ 64 static void keyboard_init(void) 65 { 66 struct biosregs ireg, oreg; 67 68 initregs(&ireg); 69 70 ireg.ah = 0x02; /* Get keyboar 71 intcall(0x16, &ireg, &oreg); 72 boot_params.kbd_status = oreg.al; 73 74 ireg.ax = 0x0305; /* Set keyboar 75 intcall(0x16, &ireg, NULL); 76 } 77 78 /* 79 * Get Intel SpeedStep (IST) information. 80 */ 81 static void query_ist(void) 82 { 83 struct biosregs ireg, oreg; 84 85 /* 86 * Some older BIOSes apparently crash 87 * it from machines too old to have Sp 88 */ 89 if (cpu.level < 6) 90 return; 91 92 initregs(&ireg); 93 ireg.ax = 0xe980; /* IST Suppor 94 ireg.edx = 0x47534943; /* Request va 95 intcall(0x15, &ireg, &oreg); 96 97 boot_params.ist_info.signature = oreg 98 boot_params.ist_info.command = oreg 99 boot_params.ist_info.event = oreg 100 boot_params.ist_info.perf_level = oreg 101 } 102 103 /* 104 * Tell the BIOS what CPU mode we intend to ru 105 */ 106 static void set_bios_mode(void) 107 { 108 #ifdef CONFIG_X86_64 109 struct biosregs ireg; 110 111 initregs(&ireg); 112 ireg.ax = 0xec00; 113 ireg.bx = 2; 114 intcall(0x15, &ireg, NULL); 115 #endif 116 } 117 118 static void init_heap(void) 119 { 120 char *stack_end; 121 122 if (boot_params.hdr.loadflags & CAN_US 123 stack_end = (char *) (current_ 124 heap_end = (char *) ((size_t)b 125 if (heap_end > stack_end) 126 heap_end = stack_end; 127 } else { 128 /* Boot protocol 2.00 only, no 129 puts("WARNING: Ancient bootloa 130 } 131 } 132 133 void main(void) 134 { 135 init_default_io_ops(); 136 137 /* First, copy the boot header into th 138 copy_boot_params(); 139 140 /* Initialize the early-boot console * 141 console_init(); 142 if (cmdline_find_option_bool("debug")) 143 puts("early console in setup c 144 145 /* End of heap check */ 146 init_heap(); 147 148 /* Make sure we have all the proper CP 149 if (validate_cpu()) { 150 puts("Unable to boot - please 151 die(); 152 } 153 154 /* Tell the BIOS what CPU mode we inte 155 set_bios_mode(); 156 157 /* Detect memory layout */ 158 detect_memory(); 159 160 /* Set keyboard repeat rate (why?) and 161 keyboard_init(); 162 163 /* Query Intel SpeedStep (IST) informa 164 query_ist(); 165 166 /* Query APM information */ 167 #if defined(CONFIG_APM) || defined(CONFIG_APM_ 168 query_apm_bios(); 169 #endif 170 171 /* Query EDD information */ 172 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_ 173 query_edd(); 174 #endif 175 176 /* Set the video mode */ 177 set_video(); 178 179 /* Do the last things and invoke prote 180 go_to_protected_mode(); 181 } 182
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.