]> git.saurik.com Git - apple/xnu.git/blame - osfmk/i386/AT386/model_dep.c
xnu-517.3.15.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 *
43866e37 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
43866e37
A
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
43866e37
A
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
1c79356b
A
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25/*
26 * @OSF_COPYRIGHT@
27 */
28/*
29 * Mach Operating System
30 * Copyright (c) 1991,1990,1989, 1988 Carnegie Mellon University
31 * All Rights Reserved.
32 *
33 * Permission to use, copy, modify and distribute this software and its
34 * documentation is hereby granted, provided that both the copyright
35 * notice and this permission notice appear in all copies of the
36 * software, derivative works or modified versions, and any portions
37 * thereof, and that both notices appear in supporting documentation.
38 *
39 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
40 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
41 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
42 *
43 * Carnegie Mellon requests users of this software to return to
44 *
45 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
46 * School of Computer Science
47 * Carnegie Mellon University
48 * Pittsburgh PA 15213-3890
49 *
50 * any improvements or extensions that they make and grant Carnegie Mellon
51 * the rights to redistribute these changes.
52 */
53
54/*
55 */
56
57/*
58 * File: model_dep.c
59 * Author: Avadis Tevanian, Jr., Michael Wayne Young
60 *
61 * Copyright (C) 1986, Avadis Tevanian, Jr., Michael Wayne Young
62 *
63 * Basic initialization for I386 - ISA bus machines.
64 */
65
66#include <cpus.h>
67#include <platforms.h>
1c79356b
A
68#include <mach_kdb.h>
69#include <himem.h>
70#include <fast_idle.h>
71
72#include <mach/i386/vm_param.h>
73
74#include <string.h>
75#include <mach/vm_param.h>
76#include <mach/vm_prot.h>
77#include <mach/machine.h>
78#include <mach/time_value.h>
1c79356b
A
79#include <kern/spl.h>
80#include <kern/assert.h>
81#include <kern/debug.h>
82#include <kern/misc_protos.h>
83#include <kern/startup.h>
84#include <kern/clock.h>
85#include <kern/time_out.h>
1c79356b 86#include <kern/cpu_data.h>
1c79356b 87#include <i386/fpu.h>
1c79356b
A
88#include <i386/ipl.h>
89#include <i386/pio.h>
90#include <i386/misc_protos.h>
1c79356b 91#include <i386/rtclock_entries.h>
55e303ae
A
92#include <i386/mp.h>
93#include <pexpert/i386/boot.h>
1c79356b
A
94#if MACH_KDB
95#include <ddb/db_aout.h>
96#endif /* MACH_KDB */
1c79356b
A
97
98#if NCPUS > 1
99#include <i386/mp_desc.h>
100#endif /* NCPUS */
101
55e303ae
A
102#if NCPUS > 1
103#include <i386/mp.h>
104#endif /* NCPUS > 1 */
1c79356b 105
9bccf70c
A
106#include <IOKit/IOPlatformExpert.h>
107
55e303ae
A
108static void machine_conf(void);
109#include <i386/cpuid.h>
1c79356b 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)) {
159 extern int default_preemption_rate;
1c79356b 160
55e303ae 161 default_preemption_rate = boot_arg;
1c79356b 162 }
55e303ae
A
163 if (PE_parse_boot_arg("unsafe", &boot_arg)) {
164 extern int max_unsafe_quanta;
9bccf70c 165
55e303ae
A
166 max_unsafe_quanta = boot_arg;
167 }
168 if (PE_parse_boot_arg("poll", &boot_arg)) {
169 extern int max_poll_quanta;
1c79356b 170
55e303ae
A
171 max_poll_quanta = boot_arg;
172 }
173 if (PE_parse_boot_arg("yield", &boot_arg)) {
174 extern int sched_poll_yield_shift;
1c79356b 175
55e303ae
A
176 sched_poll_yield_shift = boot_arg;
177 }
178
179 machine_conf();
180
181#if NOTYET
182 ml_thrm_init(); /* Start thermal monitoring on this processor */
1c79356b
A
183#endif
184
185 /*
186 * Start the system.
187 */
1c79356b 188 setup_main();
1c79356b 189
55e303ae 190 /* Should never return */
1c79356b
A
191}
192
55e303ae
A
193
194static void
195machine_conf(void)
1c79356b 196{
55e303ae
A
197 machine_info.max_cpus = NCPUS;
198 machine_info.avail_cpus = 1;
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{
208 int unit;
209 const char *p;
210 int n;
211
1c79356b
A
212 /*
213 * Display CPU identification
214 */
215 cpuid_cpu_display("CPU identification", 0);
55e303ae 216 cpuid_feature_display("CPU features", 0);
1c79356b 217
55e303ae
A
218
219#if NCPUS > 1
220 smp_init();
221#endif
1c79356b
A
222
223 /*
224 * Set up to use floating point.
225 */
226 init_fpu();
227
1c79356b
A
228 /*
229 * Configure clock devices.
230 */
231 clock_config();
232}
233
234/*
235 * Halt a cpu.
236 */
237void
238halt_cpu(void)
239{
240 halt_all_cpus(FALSE);
241}
242
243int reset_mem_on_reboot = 1;
244
245/*
246 * Halt the system or reboot.
247 */
248void
9bccf70c 249halt_all_cpus(boolean_t reboot)
1c79356b 250{
55e303ae 251 if (reboot) {
1c79356b 252 /*
55e303ae 253 * Tell the BIOS not to clear and test memory.
1c79356b 254 */
55e303ae
A
255 if (!reset_mem_on_reboot)
256 *(unsigned short *)phystokv(0x472) = 0x1234;
257
258 printf("MACH Reboot\n");
259 PEHaltRestart( kPERestartCPU );
260 } else {
261 printf("CPU halted\n");
262 PEHaltRestart( kPEHaltCPU );
1c79356b 263 }
55e303ae 264 while(1);
1c79356b
A
265}
266
267/*XXX*/
268void fc_get(mach_timespec_t *ts);
269#include <kern/clock.h>
270#include <i386/rtclock_entries.h>
271extern kern_return_t sysclk_gettime(
272 mach_timespec_t *cur_time);
273void fc_get(mach_timespec_t *ts) {
274 (void )sysclk_gettime(ts);
275}
276
277void
278Debugger(
279 const char *message)
280{
281 printf("Debugger called: <%s>\n", message);
282
55e303ae
A
283 draw_panic_dialog();
284
1c79356b
A
285 __asm__("int3");
286}
287
288void
289display_syscall(int syscall)
290{
291 printf("System call happened %d\n", syscall);
292}
293
55e303ae 294#if XPR_DEBUG && (NCPUS == 1)
1c79356b
A
295
296extern kern_return_t sysclk_gettime_interrupts_disabled(
297 mach_timespec_t *cur_time);
298
299int xpr_time(void)
300{
301 mach_timespec_t time;
302
303 sysclk_gettime_interrupts_disabled(&time);
304 return(time.tv_sec*1000000 + time.tv_nsec/1000);
305}
55e303ae 306#endif /* XPR_DEBUG && (NCPUS == 1) */
1c79356b
A
307
308enable_bluebox()
309{
310}
311disable_bluebox()
312{
313}
314
315char *
316machine_boot_info(char *buf, vm_size_t size)
317{
318 *buf ='\0';
319 return buf;
320}
321