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