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 if (cpu_subtype
== CPU_SUBTYPE_POWERPC_601
)
58 switch (cpu_subtype
) {
59 case CPU_SUBTYPE_POWERPC_7450
:
60 case CPU_SUBTYPE_POWERPC_7400
:
61 case CPU_SUBTYPE_POWERPC_750
:
62 case CPU_SUBTYPE_POWERPC_604e
:
63 case CPU_SUBTYPE_POWERPC_604
:
64 case CPU_SUBTYPE_POWERPC_603ev
:
65 case CPU_SUBTYPE_POWERPC_603e
:
66 case CPU_SUBTYPE_POWERPC_603
:
67 case CPU_SUBTYPE_POWERPC_ALL
:
75 * Routine: grade_cpu_subtype()
78 * Return a relative preference for cpu_subtypes in fat executable files.
79 * The higher the grade, the higher the preference.
80 * A grade of 0 means not acceptable.
84 grade_cpu_subtype(cpu_subtype_t cpu_subtype
)
86 struct machine_slot
*ms
= &machine_slot
[cpu_number()];
89 * This code should match cpusubtype_findbestarch() in best_arch.c in the
90 * cctools project. As of 2/16/98 this is what has been agreed upon for
91 * the PowerPC subtypes. If an exact match is not found the subtype will
92 * be picked from the following order:
93 * 7400, 750, 604e, 604, 603ev, 603e, 603, ALL
94 * Note the 601 is NOT in the list above. It is only picked via an exact
95 * match. For details see Radar 2213821.
97 * To implement this function to follow what was agreed upon above, we use
98 * the fact there are currently 10 different subtypes. Exact matches return
99 * the value 10, the value 0 is returned for 601 that is not an exact match,
100 * and the values 9 thru 1 are returned for the subtypes listed in the order
103 if (ms
->cpu_subtype
== cpu_subtype
)
105 if (cpu_subtype
== CPU_SUBTYPE_POWERPC_601
)
107 switch (cpu_subtype
) {
108 case CPU_SUBTYPE_POWERPC_7450
:
110 case CPU_SUBTYPE_POWERPC_7400
:
112 case CPU_SUBTYPE_POWERPC_750
:
114 case CPU_SUBTYPE_POWERPC_604e
:
116 case CPU_SUBTYPE_POWERPC_604
:
118 case CPU_SUBTYPE_POWERPC_603ev
:
120 case CPU_SUBTYPE_POWERPC_603e
:
122 case CPU_SUBTYPE_POWERPC_603
:
124 case CPU_SUBTYPE_POWERPC_ALL
:
128 * If we get here it is because it is a cpusubtype we don't support (602 and
129 * 620) or new cpusubtype that was added since this code was written. Both
130 * will be considered unacceptable.
144 base
= trunc_page(start
);
148 if(kvtophys((vm_offset_t
)base
) == NULL
)