|
|
1.1 root 1: /*
2: * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
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.
11: *
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
18: * under the License.
19: *
20: * @APPLE_LICENSE_HEADER_END@
21: */
22: /*
23: * Copyright (C) 1990, NeXT, Inc.
24: *
25: * File: next/kern_machdep.c
26: * Author: John Seamons
27: *
28: * Machine-specific kernel routines.
29: *
30: * 8-Dec-91 Peter King (king) at NeXT
31: * Added grade_cpu_subtype().
32: * FIXME: Do we want to merge this with check_cpu_subtype()?
33: *
34: * 5-Mar-90 John Seamons (jks) at NeXT
35: * Created.
36: */
37:
38: #include <sys/types.h>
39: #include <mach/machine.h>
40: #include <kern/cpu_number.h>
41:
42: check_cpu_subtype (cpu_subtype)
43: cpu_subtype_t cpu_subtype;
44: {
45: struct machine_slot *ms = &machine_slot[cpu_number()];
46:
47: switch (ms->cpu_subtype) {
48: case CPU_SUBTYPE_386:
49: if (cpu_subtype == CPU_SUBTYPE_386)
50: return (TRUE);
51: break;
52:
53: case CPU_SUBTYPE_486:
54: case CPU_SUBTYPE_486SX:
55: if ( cpu_subtype == CPU_SUBTYPE_486 ||
56: cpu_subtype == CPU_SUBTYPE_486SX ||
57: cpu_subtype == CPU_SUBTYPE_386 )
58: return (TRUE);
59: break;
60:
61: case CPU_SUBTYPE_586:
62: if ( cpu_subtype == CPU_SUBTYPE_586 ||
63: cpu_subtype == CPU_SUBTYPE_486 ||
64: cpu_subtype == CPU_SUBTYPE_486SX ||
65: cpu_subtype == CPU_SUBTYPE_386 )
66: return (TRUE);
67: break;
68:
69: default:
70: if ( CPU_SUBTYPE_INTEL_MODEL(cpu_subtype) ==
71: CPU_SUBTYPE_INTEL_MODEL_ALL) {
72: if ( CPU_SUBTYPE_INTEL_FAMILY(ms->cpu_subtype) >=
73: CPU_SUBTYPE_INTEL_FAMILY(cpu_subtype))
74: return (TRUE);
75: }
76: else {
77: if ( ms->cpu_subtype == cpu_subtype)
78: return (TRUE);
79: }
80: break;
81: }
82:
83: return (FALSE);
84: }
85:
86: /**********************************************************************
87: * Routine: grade_cpu_subtype()
88: *
89: * Function: Return a relative preference for cpu_subtypes in fat
90: * executable files. The higher the grade, the higher the
91: * preference. A grade of 0 means not acceptable.
92: **********************************************************************/
93: grade_cpu_subtype (cpu_subtype)
94: cpu_subtype_t cpu_subtype;
95: {
96: struct machine_slot *ms = &machine_slot[cpu_number()];
97:
98: switch (ms->cpu_subtype) {
99: case CPU_SUBTYPE_386:
100: switch (cpu_subtype) {
101: case CPU_SUBTYPE_386:
102: return 1;
103: default:
104: return 0;
105: }
106:
107: case CPU_SUBTYPE_486:
108: switch (cpu_subtype) {
109: case CPU_SUBTYPE_386:
110: return 1;
111:
112: case CPU_SUBTYPE_486SX:
113: return 2;
114:
115: case CPU_SUBTYPE_486:
116: return 3;
117:
118: default:
119: return 0;
120: }
121:
122: case CPU_SUBTYPE_486SX:
123: switch (cpu_subtype) {
124: case CPU_SUBTYPE_386:
125: return 1;
126:
127: case CPU_SUBTYPE_486:
128: return 2;
129:
130: case CPU_SUBTYPE_486SX:
131: return 3;
132:
133: default:
134: return 0;
135: }
136:
137: case CPU_SUBTYPE_586:
138: switch (cpu_subtype) {
139: case CPU_SUBTYPE_386:
140: return 1;
141:
142: case CPU_SUBTYPE_486SX:
143: return 2;
144:
145: case CPU_SUBTYPE_486:
146: return 3;
147:
148: case CPU_SUBTYPE_586:
149: return 4;
150:
151: default:
152: return 0;
153: }
154:
155: default:
156: if ( CPU_SUBTYPE_INTEL_MODEL(cpu_subtype) ==
157: CPU_SUBTYPE_INTEL_MODEL_ALL) {
158: if ( CPU_SUBTYPE_INTEL_FAMILY(ms->cpu_subtype) >=
159: CPU_SUBTYPE_INTEL_FAMILY(cpu_subtype))
160: return CPU_SUBTYPE_INTEL_FAMILY_MAX -
161: CPU_SUBTYPE_INTEL_FAMILY(ms->cpu_subtype) -
162: CPU_SUBTYPE_INTEL_FAMILY(cpu_subtype);
163: }
164: else {
165: if ( ms->cpu_subtype == cpu_subtype)
166: return CPU_SUBTYPE_INTEL_FAMILY_MAX + 1;
167: }
168: return 0;
169: }
170: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.