]>
Commit | Line | Data |
---|---|---|
55e303ae | 1 | /* |
0c530ab8 | 2 | * Copyright (c) 2003-2005 Apple Computer, Inc. All rights reserved. |
55e303ae | 3 | * |
6601e61a | 4 | * @APPLE_LICENSE_HEADER_START@ |
55e303ae | 5 | * |
6601e61a A |
6 | * The contents of this file constitute Original Code as defined in and |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
8f6c56a5 | 11 | * |
6601e61a A |
12 | * This Original Code and all software distributed under the License are |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
6601e61a A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
8f6c56a5 | 19 | * |
6601e61a | 20 | * @APPLE_LICENSE_HEADER_END@ |
55e303ae A |
21 | */ |
22 | /* | |
23 | * @OSF_COPYRIGHT@ | |
24 | */ | |
25 | /* | |
26 | * Mach Operating System | |
27 | * Copyright (c) 1991,1990,1989, 1988 Carnegie Mellon University | |
28 | * All Rights Reserved. | |
29 | * | |
30 | * Permission to use, copy, modify and distribute this software and its | |
31 | * documentation is hereby granted, provided that both the copyright | |
32 | * notice and this permission notice appear in all copies of the | |
33 | * software, derivative works or modified versions, and any portions | |
34 | * thereof, and that both notices appear in supporting documentation. | |
35 | * | |
36 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
37 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |
38 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
39 | * | |
40 | * Carnegie Mellon requests users of this software to return to | |
41 | * | |
42 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
43 | * School of Computer Science | |
44 | * Carnegie Mellon University | |
45 | * Pittsburgh PA 15213-3890 | |
46 | * | |
47 | * any improvements or extensions that they make and grant Carnegie Mellon | |
48 | * the rights to redistribute these changes. | |
49 | */ | |
50 | ||
55e303ae A |
51 | #include <platforms.h> |
52 | #include <mach_kdb.h> | |
55e303ae A |
53 | |
54 | #include <mach/i386/vm_param.h> | |
55 | ||
56 | #include <string.h> | |
57 | #include <mach/vm_param.h> | |
58 | #include <mach/vm_prot.h> | |
59 | #include <mach/machine.h> | |
60 | #include <mach/time_value.h> | |
55e303ae A |
61 | #include <kern/spl.h> |
62 | #include <kern/assert.h> | |
63 | #include <kern/debug.h> | |
64 | #include <kern/misc_protos.h> | |
65 | #include <kern/startup.h> | |
66 | #include <kern/clock.h> | |
0c530ab8 | 67 | #include <kern/pms.h> |
55e303ae A |
68 | #include <kern/xpr.h> |
69 | #include <kern/cpu_data.h> | |
70 | #include <kern/processor.h> | |
0c530ab8 | 71 | #include <console/serial_protos.h> |
55e303ae A |
72 | #include <vm/vm_page.h> |
73 | #include <vm/pmap.h> | |
74 | #include <vm/vm_kern.h> | |
75 | #include <i386/fpu.h> | |
76 | #include <i386/pmap.h> | |
77 | #include <i386/ipl.h> | |
55e303ae A |
78 | #include <i386/misc_protos.h> |
79 | #include <i386/cpuid.h> | |
55e303ae | 80 | #include <i386/mp.h> |
0c530ab8 | 81 | #include <i386/mp_desc.h> |
91447636 | 82 | #include <i386/machine_routines.h> |
0c530ab8 | 83 | #include <i386/machine_check.h> |
91447636 | 84 | #include <i386/postcode.h> |
0c530ab8 A |
85 | #include <i386/Diagnostics.h> |
86 | #include <i386/pmCPU.h> | |
87 | #include <i386/tsc.h> | |
88 | #include <i386/hpet.h> | |
55e303ae A |
89 | #if MACH_KDB |
90 | #include <ddb/db_aout.h> | |
91 | #endif /* MACH_KDB */ | |
92 | #include <ddb/tr.h> | |
55e303ae | 93 | |
0c530ab8 | 94 | static boot_args *kernelBootArgs; |
55e303ae | 95 | |
0c530ab8 A |
96 | extern int disableConsoleOutput; |
97 | extern const char version[]; | |
98 | extern const char version_variant[]; | |
99 | extern int nx_enabled; | |
8ad349bb | 100 | |
0c530ab8 | 101 | extern int noVMX; /* if set, rosetta should not emulate altivec */ |
21362eb3 | 102 | |
0c530ab8 | 103 | void cpu_stack_set(void); |
21362eb3 | 104 | |
55e303ae A |
105 | |
106 | /* | |
107 | * Cpu initialization. Running virtual, but without MACH VM | |
0c530ab8 | 108 | * set up. First C routine called. |
55e303ae A |
109 | */ |
110 | void | |
0c530ab8 | 111 | i386_init(vm_offset_t boot_args_start) |
55e303ae A |
112 | { |
113 | unsigned int maxmem; | |
0c530ab8 | 114 | uint64_t maxmemtouse; |
91447636 | 115 | unsigned int cpus; |
0c530ab8 | 116 | boolean_t legacy_mode; |
91447636 A |
117 | |
118 | postcode(I386_INIT_ENTRY); | |
55e303ae | 119 | |
0c530ab8 A |
120 | i386_macho_zerofill(); |
121 | ||
122 | /* Initialize machine-check handling */ | |
123 | mca_cpu_init(); | |
4452a7af | 124 | |
6601e61a | 125 | /* |
0c530ab8 | 126 | * Setup boot args given the physical start address. |
6601e61a | 127 | */ |
0c530ab8 A |
128 | kernelBootArgs = (boot_args *) |
129 | ml_static_ptovirt(boot_args_start); | |
130 | kernelBootArgs->MemoryMap = (uint32_t) | |
131 | ml_static_ptovirt((vm_offset_t)kernelBootArgs->MemoryMap); | |
132 | kernelBootArgs->deviceTreeP = (uint32_t) | |
133 | ml_static_ptovirt((vm_offset_t)kernelBootArgs->deviceTreeP); | |
6601e61a | 134 | |
0c530ab8 A |
135 | master_cpu = 0; |
136 | (void) cpu_data_alloc(TRUE); | |
137 | cpu_init(); | |
138 | postcode(CPU_INIT_D); | |
139 | ||
140 | /* init processor performance control */ | |
141 | pmsInit(); | |
142 | ||
55e303ae | 143 | PE_init_platform(FALSE, kernelBootArgs); |
91447636 | 144 | postcode(PE_INIT_PLATFORM_D); |
55e303ae | 145 | |
55e303ae A |
146 | printf_init(); /* Init this in case we need debugger */ |
147 | panic_init(); /* Init this in case we need debugger */ | |
148 | ||
149 | /* setup debugging output if one has been chosen */ | |
150 | PE_init_kprintf(FALSE); | |
55e303ae | 151 | |
0c530ab8 A |
152 | if (!PE_parse_boot_arg("diag", &dgWork.dgFlags)) |
153 | dgWork.dgFlags = 0; | |
154 | ||
155 | serialmode = 0; | |
156 | if(PE_parse_boot_arg("serial", &serialmode)) { | |
157 | /* We want a serial keyboard and/or console */ | |
158 | kprintf("Serial mode specified: %08X\n", serialmode); | |
159 | } | |
160 | if(serialmode & 1) { | |
161 | (void)switch_to_serial_console(); | |
162 | disableConsoleOutput = FALSE; /* Allow printfs to happen */ | |
163 | } | |
164 | ||
55e303ae A |
165 | /* setup console output */ |
166 | PE_init_printf(FALSE); | |
167 | ||
168 | kprintf("version_variant = %s\n", version_variant); | |
169 | kprintf("version = %s\n", version); | |
170 | ||
55e303ae A |
171 | /* |
172 | * VM initialization, after this we're using page tables... | |
173 | * The maximum number of cpus must be set beforehand. | |
174 | */ | |
175 | if (!PE_parse_boot_arg("maxmem", &maxmem)) | |
0c530ab8 | 176 | maxmemtouse=0; |
55e303ae | 177 | else |
0c530ab8 | 178 | maxmemtouse = ((uint64_t)maxmem) * (uint64_t)(1024 * 1024); |
55e303ae | 179 | |
91447636 A |
180 | if (PE_parse_boot_arg("cpus", &cpus)) { |
181 | if ((0 < cpus) && (cpus < max_ncpus)) | |
182 | max_ncpus = cpus; | |
183 | } | |
55e303ae | 184 | |
0c530ab8 A |
185 | /* |
186 | * debug support for > 4G systems | |
187 | */ | |
188 | if (!PE_parse_boot_arg("himemory_mode", &vm_himemory_mode)) | |
189 | vm_himemory_mode = 0; | |
190 | ||
191 | /* | |
192 | * At this point we check whether we are a 64-bit processor | |
193 | * and that we're not restricted to legacy mode, 32-bit operation. | |
194 | */ | |
195 | boolean_t IA32e = FALSE; | |
196 | if (cpuid_extfeatures() & CPUID_EXTFEATURE_EM64T) { | |
197 | kprintf("EM64T supported"); | |
198 | if (PE_parse_boot_arg("-legacy", &legacy_mode)) { | |
199 | kprintf(" but legacy mode forced\n"); | |
200 | } else { | |
201 | IA32e = TRUE; | |
202 | kprintf(" and will be enabled\n"); | |
203 | } | |
204 | } | |
205 | if (!(cpuid_extfeatures() & CPUID_EXTFEATURE_XD)) | |
206 | nx_enabled = 0; | |
207 | ||
208 | i386_vm_init(maxmemtouse, IA32e, kernelBootArgs); | |
209 | ||
210 | if ( ! PE_parse_boot_arg("novmx", &noVMX)) | |
211 | noVMX = 0; /* OK to support Altivec in rosetta? */ | |
212 | ||
213 | tsc_init(); | |
214 | hpet_init(); | |
215 | power_management_init(); | |
55e303ae A |
216 | |
217 | PE_init_platform(TRUE, kernelBootArgs); | |
218 | ||
219 | /* create the console for verbose or pretty mode */ | |
220 | PE_create_console(); | |
91447636 | 221 | |
0c530ab8 A |
222 | processor_bootstrap(); |
223 | thread_bootstrap(); | |
224 | ||
55e303ae A |
225 | machine_startup(); |
226 | ||
227 | } |