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, NeXT, Inc.
28 * File: next/kern_machdep.c
29 * Author: John Seamons
31 * Machine-specific kernel routines.
33 * 8-Dec-91 Peter King (king) at NeXT
34 * Added grade_cpu_subtype().
35 * FIXME: Do we want to merge this with check_cpu_subtype()?
37 * 5-Mar-90 John Seamons (jks) at NeXT
41 #include <sys/types.h>
42 #include <mach/machine.h>
43 #include <kern/cpu_number.h>
45 check_cpu_subtype (cpu_subtype
)
46 cpu_subtype_t cpu_subtype
;
48 struct machine_slot
*ms
= &machine_slot
[cpu_number()];
50 switch (ms
->cpu_subtype
) {
52 if (cpu_subtype
== CPU_SUBTYPE_386
)
57 case CPU_SUBTYPE_486SX
:
58 if ( cpu_subtype
== CPU_SUBTYPE_486
||
59 cpu_subtype
== CPU_SUBTYPE_486SX
||
60 cpu_subtype
== CPU_SUBTYPE_386
)
65 if ( cpu_subtype
== CPU_SUBTYPE_586
||
66 cpu_subtype
== CPU_SUBTYPE_486
||
67 cpu_subtype
== CPU_SUBTYPE_486SX
||
68 cpu_subtype
== CPU_SUBTYPE_386
)
73 if ( CPU_SUBTYPE_INTEL_MODEL(cpu_subtype
) ==
74 CPU_SUBTYPE_INTEL_MODEL_ALL
) {
75 if ( CPU_SUBTYPE_INTEL_FAMILY(ms
->cpu_subtype
) >=
76 CPU_SUBTYPE_INTEL_FAMILY(cpu_subtype
))
80 if ( ms
->cpu_subtype
== cpu_subtype
)
89 /**********************************************************************
90 * Routine: grade_cpu_subtype()
92 * Function: Return a relative preference for cpu_subtypes in fat
93 * executable files. The higher the grade, the higher the
94 * preference. A grade of 0 means not acceptable.
95 **********************************************************************/
96 grade_cpu_subtype (cpu_subtype
)
97 cpu_subtype_t cpu_subtype
;
99 struct machine_slot
*ms
= &machine_slot
[cpu_number()];
101 switch (ms
->cpu_subtype
) {
102 case CPU_SUBTYPE_386
:
103 switch (cpu_subtype
) {
104 case CPU_SUBTYPE_386
:
110 case CPU_SUBTYPE_486
:
111 switch (cpu_subtype
) {
112 case CPU_SUBTYPE_386
:
115 case CPU_SUBTYPE_486SX
:
118 case CPU_SUBTYPE_486
:
125 case CPU_SUBTYPE_486SX
:
126 switch (cpu_subtype
) {
127 case CPU_SUBTYPE_386
:
130 case CPU_SUBTYPE_486
:
133 case CPU_SUBTYPE_486SX
:
140 case CPU_SUBTYPE_586
:
141 switch (cpu_subtype
) {
142 case CPU_SUBTYPE_386
:
145 case CPU_SUBTYPE_486SX
:
148 case CPU_SUBTYPE_486
:
151 case CPU_SUBTYPE_586
:
159 if ( CPU_SUBTYPE_INTEL_MODEL(cpu_subtype
) ==
160 CPU_SUBTYPE_INTEL_MODEL_ALL
) {
161 if ( CPU_SUBTYPE_INTEL_FAMILY(ms
->cpu_subtype
) >=
162 CPU_SUBTYPE_INTEL_FAMILY(cpu_subtype
))
163 return CPU_SUBTYPE_INTEL_FAMILY_MAX
-
164 CPU_SUBTYPE_INTEL_FAMILY(ms
->cpu_subtype
) -
165 CPU_SUBTYPE_INTEL_FAMILY(cpu_subtype
);
168 if ( ms
->cpu_subtype
== cpu_subtype
)
169 return CPU_SUBTYPE_INTEL_FAMILY_MAX
+ 1;