2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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 License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (C) 1990, 1993 NeXT, Inc.
30 * Copyright (C) 1997 Apple Computer, Inc.
32 * File: next/kern_machdep.c
33 * Author: John Seamons
35 * Machine-specific kernel routines.
38 #include <sys/types.h>
39 #include <sys/param.h>
40 #include <mach/machine.h>
41 #include <mach/boolean.h>
42 #include <mach/vm_param.h>
43 #include <kern/cpu_number.h>
44 #include <machine/exec.h>
46 boolean_t
kernacc(off_t
, size_t );
50 * Routine: grade_binary()
53 * Return a relative preference for exectypes and execsubtypes in fat
54 * executable files. The higher the grade, the higher the preference.
55 * A grade of 0 means not acceptable.
57 * Note: We really don't care about the real cpu_type() here,
58 * because machines can only have one type.
61 grade_binary(cpu_type_t exectype
, cpu_subtype_t execsubtype
)
63 int cpusubtype
= cpu_subtype();
66 * This code should match cpusubtype_findbestarch() in best_arch.c
67 * in the cctools project. As of 2/16/98 this is what has been
68 * agreed upon for the PowerPC subtypes. If an exact match is not
69 * found the subtype will be picked from the following order:
70 * 970(but only on 970), 7450, 7400, 750, ALL
71 * Note the 601 is NOT in the list above. It is only picked via
72 * an exact match. For details see Radar 2213821.
76 case CPU_SUBTYPE_POWERPC_970
:
78 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
81 * Prefer 64 bit architecture specific binaries; note
82 * that this value does not mean the same thing here
85 case CPU_SUBTYPE_POWERPC_970
:
87 /* Prefer generic binaries */
88 case CPU_SUBTYPE_POWERPC_ALL
:
95 case CPU_TYPE_POWERPC
:
98 * Prefer 32 bit binaries with 64 bit leaf functions;
99 * this is actually bogus use of the subtype to encode
102 case CPU_SUBTYPE_POWERPC_970
:
104 case CPU_SUBTYPE_POWERPC_7450
:
106 case CPU_SUBTYPE_POWERPC_7400
:
108 case CPU_SUBTYPE_POWERPC_750
:
110 case CPU_SUBTYPE_POWERPC_ALL
:
122 case CPU_SUBTYPE_POWERPC_7450
:
124 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
127 case CPU_TYPE_POWERPC
:
128 switch(execsubtype
) {
129 case CPU_SUBTYPE_POWERPC_7450
:
131 case CPU_SUBTYPE_POWERPC_7400
:
133 case CPU_SUBTYPE_POWERPC_750
:
135 case CPU_SUBTYPE_POWERPC_ALL
:
147 case CPU_SUBTYPE_POWERPC_7400
:
149 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
152 case CPU_TYPE_POWERPC
:
153 switch(execsubtype
) {
154 case CPU_SUBTYPE_POWERPC_7400
:
156 case CPU_SUBTYPE_POWERPC_7450
:
158 case CPU_SUBTYPE_POWERPC_750
:
160 case CPU_SUBTYPE_POWERPC_ALL
:
172 case CPU_SUBTYPE_POWERPC_750
:
174 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
177 case CPU_TYPE_POWERPC
:
178 switch(execsubtype
) {
179 case CPU_SUBTYPE_POWERPC_750
:
181 #ifndef ADDRESS_RADAR_2678019
183 * Currently implemented because dropping this would
184 * turn the executable subtype into a "has Altivec"
185 * flag, which we do not want to permit. It could
186 * also break working third party applications
187 * already in use in the field.
189 case CPU_SUBTYPE_POWERPC_7400
:
191 case CPU_SUBTYPE_POWERPC_7450
:
193 #endif /* ADDRESS_RADAR_2678019 */
194 case CPU_SUBTYPE_POWERPC_ALL
:
208 case CPU_TYPE_POWERPC64
: /* CPU_IS64BIT | CPU_POWERPC */
211 case CPU_TYPE_POWERPC
:
212 /* Special case for PPC601 */
213 if (cpusubtype
== execsubtype
)
216 * If we get here it is because it is a cpusubtype we
217 * don't support or a new cpusubtype that was added
218 * since this code was written. Both will be
219 * considered unacceptable.
232 extern vm_map_offset_t
kvtophys64(vm_map_offset_t
);
243 base
= trunc_page_64(start
);
247 if(kvtophys64((vm_map_offset_t
)base
) == (vm_map_offset_t
)0)
256 md_prepare_for_shutdown(int paniced
, int howto
, char * command
);
259 md_prepare_for_shutdown(__unused
int paniced
, __unused
int howto
,
260 __unused
char * command
)