2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
23 * @APPLE_LICENSE_HEADER_END@
29 * Mach Operating System
30 * Copyright (c) 1991,1990,1989, 1988 Carnegie Mellon University
31 * All Rights Reserved.
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.
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.
43 * Carnegie Mellon requests users of this software to return to
45 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
46 * School of Computer Science
47 * Carnegie Mellon University
48 * Pittsburgh PA 15213-3890
50 * any improvements or extensions that they make and grant Carnegie Mellon
51 * the rights to redistribute these changes.
55 #include <platforms.h>
58 #include <fast_idle.h>
60 #include <mach/i386/vm_param.h>
63 #include <mach/vm_param.h>
64 #include <mach/vm_prot.h>
65 #include <mach/machine.h>
66 #include <mach/time_value.h>
67 #include <kern/etap_macros.h>
69 #include <kern/assert.h>
70 #include <kern/debug.h>
71 #include <kern/misc_protos.h>
72 #include <kern/startup.h>
73 #include <kern/clock.h>
74 #include <kern/time_out.h>
76 #include <kern/cpu_data.h>
77 #include <kern/processor.h>
78 #include <vm/vm_page.h>
80 #include <vm/vm_kern.h>
82 #include <i386/pmap.h>
85 #include <i386/misc_protos.h>
86 #include <i386/cpuid.h>
87 #include <i386/rtclock_entries.h>
90 #include <ddb/db_aout.h>
94 #include <mach/boot_info.h>
95 #include <mach/thread_status.h>
97 static KernelBootArgs_t
*kernelBootArgs
;
100 vm_offset_t boot_args_start
= 0; /* pointer to kernel arguments, set in start.s */
103 #include <mach-o/loader.h>
104 vm_offset_t edata
, etext
, end
;
107 * Called first for a mach-o kernel before paging is set up.
108 * Returns the first available physical address in memory.
114 struct segment_command
*sgp
;
117 sgp
= (struct segment_command
*) getsegbyname("__DATA");
119 sp
= (struct section
*) firstsect(sgp
);
122 if (sp
->flags
& S_ZEROFILL
)
123 bzero((char *) sp
->addr
, sp
->size
);
124 } while (sp
= (struct section
*)nextsect(sgp
, sp
));
128 kernelBootArgs
= (KernelBootArgs_t
*) boot_args_start
;
129 end
= round_page( kernelBootArgs
->kaddr
+ kernelBootArgs
->ksize
);
135 extern const char version
[];
136 extern const char version_variant
[];
139 * Cpu initialization. Running virtual, but without MACH VM
140 * set up. First C routine called, unless i386_preinit() was called first.
150 * Setup some processor related structures to satisfy funnels.
151 * Must be done before using unparallelized device drivers.
153 processor_ptr
[0] = &processor_array
[0];
155 master_processor
= cpu_to_processor(master_cpu
);
157 PE_init_platform(FALSE
, kernelBootArgs
);
160 * Set up initial thread so current_thread() works early on
164 printf_init(); /* Init this in case we need debugger */
165 panic_init(); /* Init this in case we need debugger */
167 /* setup debugging output if one has been chosen */
168 PE_init_kprintf(FALSE
);
169 kprintf("kprintf initialized\n");
171 /* setup console output */
172 PE_init_printf(FALSE
);
174 kprintf("version_variant = %s\n", version_variant
);
175 kprintf("version = %s\n", version
);
179 * VM initialization, after this we're using page tables...
180 * The maximum number of cpus must be set beforehand.
182 if (!PE_parse_boot_arg("maxmem", &maxmem
))
185 maxmem
= maxmem
* (1024 * 1024);
187 if (PE_parse_boot_arg("cpus", &wncpu
)) {
188 if (!((wncpu
> 0) && (wncpu
< NCPUS
)))
193 i386_vm_init(maxmem
, kernelBootArgs
);
195 PE_init_platform(TRUE
, kernelBootArgs
);
197 /* create the console for verbose or pretty mode */