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