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 if (cpu_subtype
== CPU_SUBTYPE_POWERPC_601
)
61 switch (cpu_subtype
) {
62 case CPU_SUBTYPE_POWERPC_7450
:
63 case CPU_SUBTYPE_POWERPC_7400
:
64 case CPU_SUBTYPE_POWERPC_750
:
65 case CPU_SUBTYPE_POWERPC_604e
:
66 case CPU_SUBTYPE_POWERPC_604
:
67 case CPU_SUBTYPE_POWERPC_603ev
:
68 case CPU_SUBTYPE_POWERPC_603e
:
69 case CPU_SUBTYPE_POWERPC_603
:
70 case CPU_SUBTYPE_POWERPC_ALL
:
78 * Routine: grade_cpu_subtype()
81 * Return a relative preference for cpu_subtypes in fat executable files.
82 * The higher the grade, the higher the preference.
83 * A grade of 0 means not acceptable.
87 grade_cpu_subtype(cpu_subtype_t cpu_subtype
)
89 struct machine_slot
*ms
= &machine_slot
[cpu_number()];
92 * This code should match cpusubtype_findbestarch() in best_arch.c in the
93 * cctools project. As of 2/16/98 this is what has been agreed upon for
94 * the PowerPC subtypes. If an exact match is not found the subtype will
95 * be picked from the following order:
96 * 7400, 750, 604e, 604, 603ev, 603e, 603, ALL
97 * Note the 601 is NOT in the list above. It is only picked via an exact
98 * match. For details see Radar 2213821.
100 * To implement this function to follow what was agreed upon above, we use
101 * the fact there are currently 10 different subtypes. Exact matches return
102 * the value 10, the value 0 is returned for 601 that is not an exact match,
103 * and the values 9 thru 1 are returned for the subtypes listed in the order
106 if (ms
->cpu_subtype
== cpu_subtype
)
108 if (cpu_subtype
== CPU_SUBTYPE_POWERPC_601
)
110 switch (cpu_subtype
) {
111 case CPU_SUBTYPE_POWERPC_7450
:
113 case CPU_SUBTYPE_POWERPC_7400
:
115 case CPU_SUBTYPE_POWERPC_750
:
117 case CPU_SUBTYPE_POWERPC_604e
:
119 case CPU_SUBTYPE_POWERPC_604
:
121 case CPU_SUBTYPE_POWERPC_603ev
:
123 case CPU_SUBTYPE_POWERPC_603e
:
125 case CPU_SUBTYPE_POWERPC_603
:
127 case CPU_SUBTYPE_POWERPC_ALL
:
131 * If we get here it is because it is a cpusubtype we don't support (602 and
132 * 620) or new cpusubtype that was added since this code was written. Both
133 * will be considered unacceptable.
147 base
= trunc_page(start
);
151 if(kvtophys((vm_offset_t
)base
) == NULL
)