2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (C) 1990, 1993 NeXT, Inc.
24 * Copyright (C) 1997 Apple Computer, Inc.
26 * File: next/kern_machdep.c
27 * Author: John Seamons
29 * Machine-specific kernel routines.
32 * 8-Dec-91 Peter King (king) at NeXT
33 * Added grade_cpu_subtype().
34 * FIXME: Do we want to merge this with check_cpu_subtype()?
36 * 5-Mar-90 John Seamons (jks) at NeXT
40 #include <sys/types.h>
41 #include <sys/param.h>
42 #include <mach/machine.h>
43 #include <mach/boolean.h>
44 #include <mach/vm_param.h>
45 #include <kern/cpu_number.h>
48 check_cpu_subtype(cpu_subtype_t cpu_subtype
)
50 struct machine_slot
*ms
= &machine_slot
[cpu_number()];
52 if (cpu_subtype
== ms
->cpu_subtype
)
55 switch (cpu_subtype
) {
56 case CPU_SUBTYPE_POWERPC_970
:
57 /* Do not allow a 970 binary to run on non-970 systems */
58 if (ms
->cpu_subtype
!= CPU_SUBTYPE_POWERPC_970
)
60 case CPU_SUBTYPE_POWERPC_7450
:
61 case CPU_SUBTYPE_POWERPC_7400
:
62 case CPU_SUBTYPE_POWERPC_750
:
63 case CPU_SUBTYPE_POWERPC_ALL
:
71 * Routine: grade_cpu_subtype()
74 * Return a relative preference for cpu_subtypes in fat executable files.
75 * The higher the grade, the higher the preference.
76 * A grade of 0 means not acceptable.
80 grade_cpu_subtype(cpu_subtype_t cpu_subtype
)
82 struct machine_slot
*ms
= &machine_slot
[cpu_number()];
85 * This code should match cpusubtype_findbestarch() in best_arch.c in the
86 * cctools project. As of 2/16/98 this is what has been agreed upon for
87 * the PowerPC subtypes. If an exact match is not found the subtype will
88 * be picked from the following order:
89 * 970(but only on 970), 7450, 7400, 750, ALL
90 * Note the 601 is NOT in the list above. It is only picked via an exact
91 * match. For details see Radar 2213821.
93 * To implement this function to follow what was agreed upon above, we use
94 * the fact there are currently 4 different subtypes. Exact matches return
95 * the value 6, and the values 5 thru 1 are returned for the
96 * subtypes listed in the order above.
98 if (ms
->cpu_subtype
== cpu_subtype
)
100 switch (cpu_subtype
) {
101 case CPU_SUBTYPE_POWERPC_970
:
102 /* Do not allow a 970 binary to run on non-970 systems */
103 if (ms
->cpu_subtype
!= CPU_SUBTYPE_POWERPC_970
)
106 case CPU_SUBTYPE_POWERPC_7450
:
108 case CPU_SUBTYPE_POWERPC_7400
:
110 case CPU_SUBTYPE_POWERPC_750
:
112 case CPU_SUBTYPE_POWERPC_ALL
:
116 * If we get here it is because it is a cpusubtype we don't support
117 * or a new cpusubtype that was added since this code was written. Both
118 * will be considered unacceptable.
132 base
= trunc_page_64(start
);
136 if(kvtophys((vm_offset_t
)base
) == NULL
)