]> git.saurik.com Git - apple/xnu.git/blame - osfmk/i386/AT386/model_dep.c
xnu-792.6.22.tar.gz
[apple/xnu.git] / osfmk / i386 / AT386 / model_dep.c
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
e5568f75
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.
11 *
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
1c79356b
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
e5568f75
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.
1c79356b
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
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
51/*
52 */
53
54/*
55 * File: model_dep.c
56 * Author: Avadis Tevanian, Jr., Michael Wayne Young
57 *
58 * Copyright (C) 1986, Avadis Tevanian, Jr., Michael Wayne Young
59 *
60 * Basic initialization for I386 - ISA bus machines.
61 */
62
1c79356b 63#include <platforms.h>
1c79356b
A
64#include <mach_kdb.h>
65#include <himem.h>
1c79356b
A
66
67#include <mach/i386/vm_param.h>
68
69#include <string.h>
70#include <mach/vm_param.h>
71#include <mach/vm_prot.h>
72#include <mach/machine.h>
73#include <mach/time_value.h>
1c79356b
A
74#include <kern/spl.h>
75#include <kern/assert.h>
76#include <kern/debug.h>
77#include <kern/misc_protos.h>
78#include <kern/startup.h>
79#include <kern/clock.h>
1c79356b 80#include <kern/cpu_data.h>
91447636 81#include <kern/machine.h>
1c79356b 82#include <i386/fpu.h>
1c79356b
A
83#include <i386/ipl.h>
84#include <i386/pio.h>
85#include <i386/misc_protos.h>
55e303ae 86#include <i386/mp.h>
91447636
A
87#include <i386/mtrr.h>
88#include <i386/postcode.h>
55e303ae 89#include <pexpert/i386/boot.h>
1c79356b
A
90#if MACH_KDB
91#include <ddb/db_aout.h>
92#endif /* MACH_KDB */
1c79356b 93
1c79356b 94#include <i386/mp_desc.h>
55e303ae 95#include <i386/mp.h>
1c79356b 96
9bccf70c
A
97#include <IOKit/IOPlatformExpert.h>
98
91447636
A
99void enable_bluebox(void);
100void disable_bluebox(void);
101
55e303ae
A
102static void machine_conf(void);
103#include <i386/cpuid.h>
1c79356b 104
91447636
A
105extern int default_preemption_rate;
106extern int max_unsafe_quanta;
107extern int max_poll_quanta;
108extern int idlehalt;
109extern unsigned int panic_is_inited;
110
1c79356b 111void
55e303ae 112machine_startup()
1c79356b 113{
55e303ae 114 int boot_arg;
1c79356b 115
55e303ae
A
116#if 0
117 if( PE_get_hotkey( kPEControlKey ))
118 halt_in_debugger = halt_in_debugger ? 0 : 1;
1c79356b
A
119#endif
120
55e303ae
A
121 if (PE_parse_boot_arg("debug", &boot_arg)) {
122 if (boot_arg & DB_HALT) halt_in_debugger=1;
123 if (boot_arg & DB_PRT) disableDebugOuput=FALSE;
124 if (boot_arg & DB_SLOG) systemLogDiags=TRUE;
125 if (boot_arg & DB_NMI) panicDebugging=TRUE;
126 if (boot_arg & DB_LOG_PI_SCRN) logPanicDataToScreen=TRUE;
127 }
1c79356b 128
55e303ae
A
129#if NOTYET
130 hw_lock_init(&debugger_lock); /* initialize debugger lock */
131 hw_lock_init(&pbtlock); /* initialize print backtrace lock */
132#endif
1c79356b
A
133
134#if MACH_KDB
1c79356b 135 /*
55e303ae 136 * Initialize KDB
1c79356b 137 */
55e303ae
A
138#if DB_MACHINE_COMMANDS
139 db_machine_commands_install(ppc_db_commands);
140#endif /* DB_MACHINE_COMMANDS */
1c79356b
A
141 ddb_init();
142
55e303ae
A
143 if (boot_arg & DB_KDB)
144 current_debugger = KDB_CUR_DB;
145
1c79356b
A
146 /*
147 * Cause a breakpoint trap to the debugger before proceeding
148 * any further if the proper option bit was specified in
149 * the boot flags.
1c79356b 150 */
55e303ae
A
151 if (halt_in_debugger && (current_debugger == KDB_CUR_DB)) {
152 Debugger("inline call to debugger(machine_startup)");
153 halt_in_debugger = 0;
154 active_debugger =1;
155 }
156#endif /* MACH_KDB */
157
158 if (PE_parse_boot_arg("preempt", &boot_arg)) {
55e303ae 159 default_preemption_rate = boot_arg;
1c79356b 160 }
55e303ae 161 if (PE_parse_boot_arg("unsafe", &boot_arg)) {
55e303ae
A
162 max_unsafe_quanta = boot_arg;
163 }
164 if (PE_parse_boot_arg("poll", &boot_arg)) {
55e303ae
A
165 max_poll_quanta = boot_arg;
166 }
167 if (PE_parse_boot_arg("yield", &boot_arg)) {
55e303ae
A
168 sched_poll_yield_shift = boot_arg;
169 }
91447636
A
170 if (PE_parse_boot_arg("idlehalt", &boot_arg)) {
171 idlehalt = boot_arg;
172 }
55e303ae
A
173
174 machine_conf();
175
176#if NOTYET
177 ml_thrm_init(); /* Start thermal monitoring on this processor */
1c79356b
A
178#endif
179
180 /*
181 * Start the system.
182 */
91447636
A
183 kernel_bootstrap();
184 /*NOTREACHED*/
1c79356b
A
185}
186
55e303ae
A
187
188static void
189machine_conf(void)
1c79356b 190{
55e303ae 191 machine_info.memory_size = mem_size;
1c79356b
A
192}
193
1c79356b
A
194/*
195 * Find devices. The system is alive.
196 */
197void
198machine_init(void)
199{
1c79356b
A
200 /*
201 * Display CPU identification
202 */
203 cpuid_cpu_display("CPU identification", 0);
55e303ae 204 cpuid_feature_display("CPU features", 0);
1c79356b 205
55e303ae 206
55e303ae 207 smp_init();
1c79356b
A
208
209 /*
210 * Set up to use floating point.
211 */
212 init_fpu();
213
1c79356b
A
214 /*
215 * Configure clock devices.
216 */
217 clock_config();
91447636
A
218
219 /*
220 * Initialize MTRR from boot processor.
221 */
222 mtrr_init();
223
224 /*
225 * Set up PAT for boot processor.
226 */
227 pat_init();
228
229 /*
230 * Free lowmem pages
231 */
232 x86_lowmem_free();
1c79356b
A
233}
234
235/*
236 * Halt a cpu.
237 */
238void
239halt_cpu(void)
240{
241 halt_all_cpus(FALSE);
242}
243
244int reset_mem_on_reboot = 1;
245
246/*
247 * Halt the system or reboot.
248 */
249void
9bccf70c 250halt_all_cpus(boolean_t reboot)
1c79356b 251{
55e303ae 252 if (reboot) {
1c79356b 253 /*
55e303ae 254 * Tell the BIOS not to clear and test memory.
1c79356b 255 */
91447636 256#if 0 /* XXX fixme */
55e303ae
A
257 if (!reset_mem_on_reboot)
258 *(unsigned short *)phystokv(0x472) = 0x1234;
91447636 259#endif
55e303ae
A
260
261 printf("MACH Reboot\n");
262 PEHaltRestart( kPERestartCPU );
263 } else {
264 printf("CPU halted\n");
265 PEHaltRestart( kPEHaltCPU );
1c79356b 266 }
55e303ae 267 while(1);
1c79356b
A
268}
269
270/*XXX*/
271void fc_get(mach_timespec_t *ts);
272#include <kern/clock.h>
1c79356b
A
273extern kern_return_t sysclk_gettime(
274 mach_timespec_t *cur_time);
275void fc_get(mach_timespec_t *ts) {
276 (void )sysclk_gettime(ts);
277}
278
279void
280Debugger(
281 const char *message)
282{
91447636
A
283
284 if (!panic_is_inited) {
285 postcode(PANIC_HLT);
286 asm("hlt");
287 }
288
1c79356b 289 printf("Debugger called: <%s>\n", message);
91447636 290 kprintf("Debugger called: <%s>\n", message);
1c79356b 291
55e303ae
A
292 draw_panic_dialog();
293
1c79356b
A
294 __asm__("int3");
295}
296
297void
91447636 298enable_bluebox(void)
1c79356b 299{
1c79356b 300}
91447636
A
301void
302disable_bluebox(void)
1c79356b
A
303{
304}
305
306char *
91447636 307machine_boot_info(char *buf, __unused vm_size_t size)
1c79356b
A
308{
309 *buf ='\0';
310 return buf;
311}
312