]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
d7e50217 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
d7e50217 A |
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 | |
13 | * file. | |
14 | * | |
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 | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
d7e50217 A |
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. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * Copyright (C) 1990, NeXT, Inc. | |
27 | * | |
28 | * File: next/kern_machdep.c | |
29 | * Author: John Seamons | |
30 | * | |
31 | * Machine-specific kernel routines. | |
32 | * | |
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()? | |
36 | * | |
37 | * 5-Mar-90 John Seamons (jks) at NeXT | |
38 | * Created. | |
39 | */ | |
40 | ||
41 | #include <sys/types.h> | |
42 | #include <mach/machine.h> | |
43 | #include <kern/cpu_number.h> | |
44 | ||
45 | check_cpu_subtype (cpu_subtype) | |
46 | cpu_subtype_t cpu_subtype; | |
47 | { | |
48 | struct machine_slot *ms = &machine_slot[cpu_number()]; | |
49 | ||
50 | switch (ms->cpu_subtype) { | |
51 | case CPU_SUBTYPE_386: | |
52 | if (cpu_subtype == CPU_SUBTYPE_386) | |
53 | return (TRUE); | |
54 | break; | |
55 | ||
56 | case CPU_SUBTYPE_486: | |
57 | case CPU_SUBTYPE_486SX: | |
58 | if ( cpu_subtype == CPU_SUBTYPE_486 || | |
59 | cpu_subtype == CPU_SUBTYPE_486SX || | |
60 | cpu_subtype == CPU_SUBTYPE_386 ) | |
61 | return (TRUE); | |
62 | break; | |
63 | ||
64 | case CPU_SUBTYPE_586: | |
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 ) | |
69 | return (TRUE); | |
70 | break; | |
71 | ||
72 | default: | |
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)) | |
77 | return (TRUE); | |
78 | } | |
79 | else { | |
80 | if ( ms->cpu_subtype == cpu_subtype) | |
81 | return (TRUE); | |
82 | } | |
83 | break; | |
84 | } | |
85 | ||
86 | return (FALSE); | |
87 | } | |
88 | ||
89 | /********************************************************************** | |
90 | * Routine: grade_cpu_subtype() | |
91 | * | |
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; | |
98 | { | |
99 | struct machine_slot *ms = &machine_slot[cpu_number()]; | |
100 | ||
101 | switch (ms->cpu_subtype) { | |
102 | case CPU_SUBTYPE_386: | |
103 | switch (cpu_subtype) { | |
104 | case CPU_SUBTYPE_386: | |
105 | return 1; | |
106 | default: | |
107 | return 0; | |
108 | } | |
109 | ||
110 | case CPU_SUBTYPE_486: | |
111 | switch (cpu_subtype) { | |
112 | case CPU_SUBTYPE_386: | |
113 | return 1; | |
114 | ||
115 | case CPU_SUBTYPE_486SX: | |
116 | return 2; | |
117 | ||
118 | case CPU_SUBTYPE_486: | |
119 | return 3; | |
120 | ||
121 | default: | |
122 | return 0; | |
123 | } | |
124 | ||
125 | case CPU_SUBTYPE_486SX: | |
126 | switch (cpu_subtype) { | |
127 | case CPU_SUBTYPE_386: | |
128 | return 1; | |
129 | ||
130 | case CPU_SUBTYPE_486: | |
131 | return 2; | |
132 | ||
133 | case CPU_SUBTYPE_486SX: | |
134 | return 3; | |
135 | ||
136 | default: | |
137 | return 0; | |
138 | } | |
139 | ||
140 | case CPU_SUBTYPE_586: | |
141 | switch (cpu_subtype) { | |
142 | case CPU_SUBTYPE_386: | |
143 | return 1; | |
144 | ||
145 | case CPU_SUBTYPE_486SX: | |
146 | return 2; | |
147 | ||
148 | case CPU_SUBTYPE_486: | |
149 | return 3; | |
150 | ||
151 | case CPU_SUBTYPE_586: | |
152 | return 4; | |
153 | ||
154 | default: | |
155 | return 0; | |
156 | } | |
157 | ||
158 | default: | |
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); | |
166 | } | |
167 | else { | |
168 | if ( ms->cpu_subtype == cpu_subtype) | |
169 | return CPU_SUBTYPE_INTEL_FAMILY_MAX + 1; | |
170 | } | |
171 | return 0; | |
172 | } | |
173 | } |