]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
12 | * | |
13 | * The Original Code and all software distributed under the License are | |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
20 | * | |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | /* | |
24 | * @OSF_COPYRIGHT@ | |
25 | */ | |
26 | /* | |
27 | * Mach Operating System | |
28 | * Copyright (c) 1991,1990,1989, 1988 Carnegie Mellon University | |
29 | * All Rights Reserved. | |
30 | * | |
31 | * Permission to use, copy, modify and distribute this software and its | |
32 | * documentation is hereby granted, provided that both the copyright | |
33 | * notice and this permission notice appear in all copies of the | |
34 | * software, derivative works or modified versions, and any portions | |
35 | * thereof, and that both notices appear in supporting documentation. | |
36 | * | |
37 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
38 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |
39 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
40 | * | |
41 | * Carnegie Mellon requests users of this software to return to | |
42 | * | |
43 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
44 | * School of Computer Science | |
45 | * Carnegie Mellon University | |
46 | * Pittsburgh PA 15213-3890 | |
47 | * | |
48 | * any improvements or extensions that they make and grant Carnegie Mellon | |
49 | * the rights to redistribute these changes. | |
50 | */ | |
51 | ||
52 | /* | |
53 | */ | |
54 | ||
55 | /* | |
56 | * File: model_dep.c | |
57 | * Author: Avadis Tevanian, Jr., Michael Wayne Young | |
58 | * | |
59 | * Copyright (C) 1986, Avadis Tevanian, Jr., Michael Wayne Young | |
60 | * | |
61 | * Basic initialization for I386 - ISA bus machines. | |
62 | */ | |
63 | ||
64 | #include <platforms.h> | |
65 | #include <mach_kdb.h> | |
66 | #include <himem.h> | |
67 | ||
68 | #include <mach/i386/vm_param.h> | |
69 | ||
70 | #include <string.h> | |
71 | #include <mach/vm_param.h> | |
72 | #include <mach/vm_prot.h> | |
73 | #include <mach/machine.h> | |
74 | #include <mach/time_value.h> | |
75 | #include <kern/spl.h> | |
76 | #include <kern/assert.h> | |
77 | #include <kern/debug.h> | |
78 | #include <kern/misc_protos.h> | |
79 | #include <kern/startup.h> | |
80 | #include <kern/clock.h> | |
81 | #include <kern/cpu_data.h> | |
82 | #include <kern/machine.h> | |
83 | #include <i386/fpu.h> | |
84 | #include <i386/ipl.h> | |
85 | #include <i386/pio.h> | |
86 | #include <i386/misc_protos.h> | |
87 | #include <i386/mp.h> | |
88 | #include <i386/mtrr.h> | |
89 | #include <i386/postcode.h> | |
90 | #include <pexpert/i386/boot.h> | |
91 | #if MACH_KDB | |
92 | #include <ddb/db_aout.h> | |
93 | #endif /* MACH_KDB */ | |
94 | ||
95 | #include <i386/mp_desc.h> | |
96 | #include <i386/mp.h> | |
97 | ||
98 | #include <IOKit/IOPlatformExpert.h> | |
99 | ||
100 | void enable_bluebox(void); | |
101 | void disable_bluebox(void); | |
102 | ||
103 | static void machine_conf(void); | |
104 | #include <i386/cpuid.h> | |
105 | ||
106 | extern int default_preemption_rate; | |
107 | extern int max_unsafe_quanta; | |
108 | extern int max_poll_quanta; | |
109 | extern int idlehalt; | |
110 | extern unsigned int panic_is_inited; | |
111 | ||
112 | void | |
113 | machine_startup() | |
114 | { | |
115 | int boot_arg; | |
116 | ||
117 | #if 0 | |
118 | if( PE_get_hotkey( kPEControlKey )) | |
119 | halt_in_debugger = halt_in_debugger ? 0 : 1; | |
120 | #endif | |
121 | ||
122 | if (PE_parse_boot_arg("debug", &boot_arg)) { | |
123 | if (boot_arg & DB_HALT) halt_in_debugger=1; | |
124 | if (boot_arg & DB_PRT) disableDebugOuput=FALSE; | |
125 | if (boot_arg & DB_SLOG) systemLogDiags=TRUE; | |
126 | if (boot_arg & DB_NMI) panicDebugging=TRUE; | |
127 | if (boot_arg & DB_LOG_PI_SCRN) logPanicDataToScreen=TRUE; | |
128 | } | |
129 | ||
130 | #if NOTYET | |
131 | hw_lock_init(&debugger_lock); /* initialize debugger lock */ | |
132 | hw_lock_init(&pbtlock); /* initialize print backtrace lock */ | |
133 | #endif | |
134 | ||
135 | #if MACH_KDB | |
136 | /* | |
137 | * Initialize KDB | |
138 | */ | |
139 | #if DB_MACHINE_COMMANDS | |
140 | db_machine_commands_install(ppc_db_commands); | |
141 | #endif /* DB_MACHINE_COMMANDS */ | |
142 | ddb_init(); | |
143 | ||
144 | if (boot_arg & DB_KDB) | |
145 | current_debugger = KDB_CUR_DB; | |
146 | ||
147 | /* | |
148 | * Cause a breakpoint trap to the debugger before proceeding | |
149 | * any further if the proper option bit was specified in | |
150 | * the boot flags. | |
151 | */ | |
152 | if (halt_in_debugger && (current_debugger == KDB_CUR_DB)) { | |
153 | Debugger("inline call to debugger(machine_startup)"); | |
154 | halt_in_debugger = 0; | |
155 | active_debugger =1; | |
156 | } | |
157 | #endif /* MACH_KDB */ | |
158 | ||
159 | if (PE_parse_boot_arg("preempt", &boot_arg)) { | |
160 | default_preemption_rate = boot_arg; | |
161 | } | |
162 | if (PE_parse_boot_arg("unsafe", &boot_arg)) { | |
163 | max_unsafe_quanta = boot_arg; | |
164 | } | |
165 | if (PE_parse_boot_arg("poll", &boot_arg)) { | |
166 | max_poll_quanta = boot_arg; | |
167 | } | |
168 | if (PE_parse_boot_arg("yield", &boot_arg)) { | |
169 | sched_poll_yield_shift = boot_arg; | |
170 | } | |
171 | if (PE_parse_boot_arg("idlehalt", &boot_arg)) { | |
172 | idlehalt = boot_arg; | |
173 | } | |
174 | ||
175 | machine_conf(); | |
176 | ||
177 | #if NOTYET | |
178 | ml_thrm_init(); /* Start thermal monitoring on this processor */ | |
179 | #endif | |
180 | ||
181 | /* | |
182 | * Start the system. | |
183 | */ | |
184 | kernel_bootstrap(); | |
185 | /*NOTREACHED*/ | |
186 | } | |
187 | ||
188 | ||
189 | static void | |
190 | machine_conf(void) | |
191 | { | |
192 | machine_info.memory_size = mem_size; | |
193 | } | |
194 | ||
195 | /* | |
196 | * Find devices. The system is alive. | |
197 | */ | |
198 | void | |
199 | machine_init(void) | |
200 | { | |
201 | /* | |
202 | * Display CPU identification | |
203 | */ | |
204 | cpuid_cpu_display("CPU identification", 0); | |
205 | cpuid_feature_display("CPU features", 0); | |
206 | ||
207 | ||
208 | smp_init(); | |
209 | ||
210 | /* | |
211 | * Set up to use floating point. | |
212 | */ | |
213 | init_fpu(); | |
214 | ||
215 | /* | |
216 | * Configure clock devices. | |
217 | */ | |
218 | clock_config(); | |
219 | ||
220 | /* | |
221 | * Initialize MTRR from boot processor. | |
222 | */ | |
223 | mtrr_init(); | |
224 | ||
225 | /* | |
226 | * Set up PAT for boot processor. | |
227 | */ | |
228 | pat_init(); | |
229 | ||
230 | /* | |
231 | * Free lowmem pages | |
232 | */ | |
233 | x86_lowmem_free(); | |
234 | } | |
235 | ||
236 | /* | |
237 | * Halt a cpu. | |
238 | */ | |
239 | void | |
240 | halt_cpu(void) | |
241 | { | |
242 | halt_all_cpus(FALSE); | |
243 | } | |
244 | ||
245 | int reset_mem_on_reboot = 1; | |
246 | ||
247 | /* | |
248 | * Halt the system or reboot. | |
249 | */ | |
250 | void | |
251 | halt_all_cpus(boolean_t reboot) | |
252 | { | |
253 | if (reboot) { | |
254 | /* | |
255 | * Tell the BIOS not to clear and test memory. | |
256 | */ | |
257 | #if 0 /* XXX fixme */ | |
258 | if (!reset_mem_on_reboot) | |
259 | *(unsigned short *)phystokv(0x472) = 0x1234; | |
260 | #endif | |
261 | ||
262 | printf("MACH Reboot\n"); | |
263 | PEHaltRestart( kPERestartCPU ); | |
264 | } else { | |
265 | printf("CPU halted\n"); | |
266 | PEHaltRestart( kPEHaltCPU ); | |
267 | } | |
268 | while(1); | |
269 | } | |
270 | ||
271 | /*XXX*/ | |
272 | void fc_get(mach_timespec_t *ts); | |
273 | #include <kern/clock.h> | |
274 | extern kern_return_t sysclk_gettime( | |
275 | mach_timespec_t *cur_time); | |
276 | void fc_get(mach_timespec_t *ts) { | |
277 | (void )sysclk_gettime(ts); | |
278 | } | |
279 | ||
280 | void | |
281 | Debugger( | |
282 | const char *message) | |
283 | { | |
284 | ||
285 | if (!panic_is_inited) { | |
286 | postcode(PANIC_HLT); | |
287 | asm("hlt"); | |
288 | } | |
289 | ||
290 | printf("Debugger called: <%s>\n", message); | |
291 | kprintf("Debugger called: <%s>\n", message); | |
292 | ||
293 | draw_panic_dialog(); | |
294 | ||
295 | __asm__("int3"); | |
296 | } | |
297 | ||
298 | void | |
299 | enable_bluebox(void) | |
300 | { | |
301 | } | |
302 | void | |
303 | disable_bluebox(void) | |
304 | { | |
305 | } | |
306 | ||
307 | char * | |
308 | machine_boot_info(char *buf, __unused vm_size_t size) | |
309 | { | |
310 | *buf ='\0'; | |
311 | return buf; | |
312 | } | |
313 |