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