2 * Copyright (c) 2000 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@
26 * Copyright (C) 1990, 1993 NeXT, Inc.
27 * Copyright (C) 1997 Apple Computer, Inc.
29 * File: next/kern_machdep.c
30 * Author: John Seamons
32 * Machine-specific kernel routines.
35 * 8-Dec-91 Peter King (king) at NeXT
36 * Added grade_cpu_subtype().
37 * FIXME: Do we want to merge this with check_cpu_subtype()?
39 * 5-Mar-90 John Seamons (jks) at NeXT
43 #include <sys/types.h>
44 #include <sys/param.h>
45 #include <mach/machine.h>
46 #include <mach/boolean.h>
47 #include <mach/vm_param.h>
48 #include <kern/cpu_number.h>
51 check_cpu_subtype(cpu_subtype_t cpu_subtype
)
53 struct machine_slot
*ms
= &machine_slot
[cpu_number()];
55 if (cpu_subtype
== ms
->cpu_subtype
)
58 switch (cpu_subtype
) {
59 case CPU_SUBTYPE_POWERPC_970
:
60 /* Do not allow a 970 binary to run on non-970 systems */
61 if (ms
->cpu_subtype
!= CPU_SUBTYPE_POWERPC_970
)
63 case CPU_SUBTYPE_POWERPC_7450
:
64 case CPU_SUBTYPE_POWERPC_7400
:
65 case CPU_SUBTYPE_POWERPC_750
:
66 case CPU_SUBTYPE_POWERPC_ALL
:
74 * Routine: grade_cpu_subtype()
77 * Return a relative preference for cpu_subtypes in fat executable files.
78 * The higher the grade, the higher the preference.
79 * A grade of 0 means not acceptable.
83 grade_cpu_subtype(cpu_subtype_t cpu_subtype
)
85 struct machine_slot
*ms
= &machine_slot
[cpu_number()];
88 * This code should match cpusubtype_findbestarch() in best_arch.c in the
89 * cctools project. As of 2/16/98 this is what has been agreed upon for
90 * the PowerPC subtypes. If an exact match is not found the subtype will
91 * be picked from the following order:
92 * 970(but only on 970), 7450, 7400, 750, ALL
93 * Note the 601 is NOT in the list above. It is only picked via an exact
94 * match. For details see Radar 2213821.
96 * To implement this function to follow what was agreed upon above, we use
97 * the fact there are currently 4 different subtypes. Exact matches return
98 * the value 6, and the values 5 thru 1 are returned for the
99 * subtypes listed in the order above.
101 if (ms
->cpu_subtype
== cpu_subtype
)
103 switch (cpu_subtype
) {
104 case CPU_SUBTYPE_POWERPC_970
:
105 /* Do not allow a 970 binary to run on non-970 systems */
106 if (ms
->cpu_subtype
!= CPU_SUBTYPE_POWERPC_970
)
109 case CPU_SUBTYPE_POWERPC_7450
:
111 case CPU_SUBTYPE_POWERPC_7400
:
113 case CPU_SUBTYPE_POWERPC_750
:
115 case CPU_SUBTYPE_POWERPC_ALL
:
119 * If we get here it is because it is a cpusubtype we don't support
120 * or a new cpusubtype that was added since this code was written. Both
121 * will be considered unacceptable.
135 base
= trunc_page_64(start
);
139 if(kvtophys((vm_offset_t
)base
) == NULL
)