2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 * Mach Operating System
32 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
33 * All Rights Reserved.
35 * Permission to use, copy, modify and distribute this software and its
36 * documentation is hereby granted, provided that both the copyright
37 * notice and this permission notice appear in all copies of the
38 * software, derivative works or modified versions, and any portions
39 * thereof, and that both notices appear in supporting documentation.
41 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
42 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
43 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
45 * Carnegie Mellon requests users of this software to return to
47 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
48 * School of Computer Science
49 * Carnegie Mellon University
50 * Pittsburgh PA 15213-3890
52 * any improvements or extensions that they make and grant Carnegie Mellon
53 * the rights to redistribute these changes.
56 * Author: Avadis Tevanian, Jr.
59 * Machine independent machine abstraction.
62 #ifndef _MACH_MACHINE_H_
63 #define _MACH_MACHINE_H_
66 #include <mach/machine/vm_types.h>
67 #include <mach/boolean.h>
69 typedef integer_t cpu_type_t
;
70 typedef integer_t cpu_subtype_t
;
71 typedef integer_t cpu_threadtype_t
;
73 #define CPU_STATE_MAX 4
75 #define CPU_STATE_USER 0
76 #define CPU_STATE_SYSTEM 1
77 #define CPU_STATE_IDLE 2
78 #define CPU_STATE_NICE 3
82 #include <sys/cdefs.h>
85 cpu_type_t
cpu_type(void);
87 cpu_subtype_t
cpu_subtype(void);
89 cpu_threadtype_t
cpu_threadtype(void);
92 #ifdef MACH_KERNEL_PRIVATE
95 integer_t major_version
; /* kernel major version id */
96 integer_t minor_version
; /* kernel minor version id */
97 integer_t max_cpus
; /* max number of CPUs possible */
98 integer_t avail_cpus
; /* number of CPUs now available */
99 uint32_t memory_size
; /* size of memory in bytes, capped at 2 GB */
100 uint64_t max_mem
; /* actual size of physical memory */
101 integer_t physical_cpu
; /* number of physical CPUs now available */
102 integer_t physical_cpu_max
; /* max number of physical CPUs possible */
103 integer_t logical_cpu
; /* number of logical cpu now available */
104 integer_t logical_cpu_max
; /* max number of physical CPUs possible */
107 typedef struct machine_info
*machine_info_t
;
108 typedef struct machine_info machine_info_data_t
;
110 extern struct machine_info machine_info
;
113 cpu_type_t
slot_type(
116 cpu_subtype_t
slot_subtype(
119 cpu_threadtype_t
slot_threadtype(
123 #endif /* MACH_KERNEL_PRIVATE */
124 #endif /* KERNEL_PRIVATE */
128 * Capability bits used in the definition of cpu_type.
130 #define CPU_ARCH_MASK 0xff000000 /* mask for architecture bits */
131 #define CPU_ARCH_ABI64 0x01000000 /* 64 bit ABI */
134 * Machine types known by all.
137 #define CPU_TYPE_ANY ((cpu_type_t) -1)
139 #define CPU_TYPE_VAX ((cpu_type_t) 1)
140 /* skip ((cpu_type_t) 2) */
141 /* skip ((cpu_type_t) 3) */
142 /* skip ((cpu_type_t) 4) */
143 /* skip ((cpu_type_t) 5) */
144 #define CPU_TYPE_MC680x0 ((cpu_type_t) 6)
145 #define CPU_TYPE_X86 ((cpu_type_t) 7)
146 #define CPU_TYPE_I386 CPU_TYPE_X86 /* compatibility */
147 #define CPU_TYPE_X86_64 (CPU_TYPE_X86 | CPU_ARCH_ABI64)
149 /* skip CPU_TYPE_MIPS ((cpu_type_t) 8) */
150 /* skip ((cpu_type_t) 9) */
151 #define CPU_TYPE_MC98000 ((cpu_type_t) 10)
152 #define CPU_TYPE_HPPA ((cpu_type_t) 11)
153 /* skip CPU_TYPE_ARM ((cpu_type_t) 12) */
154 #define CPU_TYPE_MC88000 ((cpu_type_t) 13)
155 #define CPU_TYPE_SPARC ((cpu_type_t) 14)
156 #define CPU_TYPE_I860 ((cpu_type_t) 15)
157 /* skip CPU_TYPE_ALPHA ((cpu_type_t) 16) */
158 /* skip ((cpu_type_t) 17) */
159 #define CPU_TYPE_POWERPC ((cpu_type_t) 18)
160 #define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64)
163 * Machine subtypes (these are defined here, instead of in a machine
164 * dependent directory, so that any program can get all definitions
165 * regardless of where is it compiled).
169 * Object files that are hand-crafted to run on any
170 * implementation of an architecture are tagged with
171 * CPU_SUBTYPE_MULTIPLE. This functions essentially the same as
172 * the "ALL" subtype of an architecture except that it allows us
173 * to easily find object files that may need to be modified
174 * whenever a new implementation of an architecture comes out.
176 * It is the responsibility of the implementor to make sure the
177 * software handles unsupported implementations elegantly.
179 #define CPU_SUBTYPE_MULTIPLE ((cpu_subtype_t) -1)
180 #define CPU_SUBTYPE_LITTLE_ENDIAN ((cpu_subtype_t) 0)
181 #define CPU_SUBTYPE_BIG_ENDIAN ((cpu_subtype_t) 1)
184 * Machine threadtypes.
185 * This is none - not defined - for most machine types/subtypes.
187 #define CPU_THREADTYPE_NONE ((cpu_threadtype_t) 0)
190 * VAX subtypes (these do *not* necessary conform to the actual cpu
191 * ID assigned by DEC available via the SID register).
194 #define CPU_SUBTYPE_VAX_ALL ((cpu_subtype_t) 0)
195 #define CPU_SUBTYPE_VAX780 ((cpu_subtype_t) 1)
196 #define CPU_SUBTYPE_VAX785 ((cpu_subtype_t) 2)
197 #define CPU_SUBTYPE_VAX750 ((cpu_subtype_t) 3)
198 #define CPU_SUBTYPE_VAX730 ((cpu_subtype_t) 4)
199 #define CPU_SUBTYPE_UVAXI ((cpu_subtype_t) 5)
200 #define CPU_SUBTYPE_UVAXII ((cpu_subtype_t) 6)
201 #define CPU_SUBTYPE_VAX8200 ((cpu_subtype_t) 7)
202 #define CPU_SUBTYPE_VAX8500 ((cpu_subtype_t) 8)
203 #define CPU_SUBTYPE_VAX8600 ((cpu_subtype_t) 9)
204 #define CPU_SUBTYPE_VAX8650 ((cpu_subtype_t) 10)
205 #define CPU_SUBTYPE_VAX8800 ((cpu_subtype_t) 11)
206 #define CPU_SUBTYPE_UVAXIII ((cpu_subtype_t) 12)
211 * The subtype definitions here are unusual for historical reasons.
212 * NeXT used to consider 68030 code as generic 68000 code. For
213 * backwards compatability:
215 * CPU_SUBTYPE_MC68030 symbol has been preserved for source code
218 * CPU_SUBTYPE_MC680x0_ALL has been defined to be the same
219 * subtype as CPU_SUBTYPE_MC68030 for binary comatability.
221 * CPU_SUBTYPE_MC68030_ONLY has been added to allow new object
222 * files to be tagged as containing 68030-specific instructions.
225 #define CPU_SUBTYPE_MC680x0_ALL ((cpu_subtype_t) 1)
226 #define CPU_SUBTYPE_MC68030 ((cpu_subtype_t) 1) /* compat */
227 #define CPU_SUBTYPE_MC68040 ((cpu_subtype_t) 2)
228 #define CPU_SUBTYPE_MC68030_ONLY ((cpu_subtype_t) 3)
234 #define CPU_SUBTYPE_INTEL(f, m) ((cpu_subtype_t) (f) + ((m) << 4))
236 #define CPU_SUBTYPE_I386_ALL CPU_SUBTYPE_INTEL(3, 0)
237 #define CPU_SUBTYPE_386 CPU_SUBTYPE_INTEL(3, 0)
238 #define CPU_SUBTYPE_486 CPU_SUBTYPE_INTEL(4, 0)
239 #define CPU_SUBTYPE_486SX CPU_SUBTYPE_INTEL(4, 8) // 8 << 4 = 128
240 #define CPU_SUBTYPE_586 CPU_SUBTYPE_INTEL(5, 0)
241 #define CPU_SUBTYPE_PENT CPU_SUBTYPE_INTEL(5, 0)
242 #define CPU_SUBTYPE_PENTPRO CPU_SUBTYPE_INTEL(6, 1)
243 #define CPU_SUBTYPE_PENTII_M3 CPU_SUBTYPE_INTEL(6, 3)
244 #define CPU_SUBTYPE_PENTII_M5 CPU_SUBTYPE_INTEL(6, 5)
245 #define CPU_SUBTYPE_CELERON CPU_SUBTYPE_INTEL(7, 6)
246 #define CPU_SUBTYPE_CELERON_MOBILE CPU_SUBTYPE_INTEL(7, 7)
247 #define CPU_SUBTYPE_PENTIUM_3 CPU_SUBTYPE_INTEL(8, 0)
248 #define CPU_SUBTYPE_PENTIUM_3_M CPU_SUBTYPE_INTEL(8, 1)
249 #define CPU_SUBTYPE_PENTIUM_3_XEON CPU_SUBTYPE_INTEL(8, 2)
250 #define CPU_SUBTYPE_PENTIUM_M CPU_SUBTYPE_INTEL(9, 0)
251 #define CPU_SUBTYPE_PENTIUM_4 CPU_SUBTYPE_INTEL(10, 0)
252 #define CPU_SUBTYPE_PENTIUM_4_M CPU_SUBTYPE_INTEL(10, 1)
253 #define CPU_SUBTYPE_ITANIUM CPU_SUBTYPE_INTEL(11, 0)
254 #define CPU_SUBTYPE_ITANIUM_2 CPU_SUBTYPE_INTEL(11, 1)
255 #define CPU_SUBTYPE_XEON CPU_SUBTYPE_INTEL(12, 0)
256 #define CPU_SUBTYPE_XEON_MP CPU_SUBTYPE_INTEL(12, 1)
258 #define CPU_SUBTYPE_INTEL_FAMILY(x) ((x) & 15)
259 #define CPU_SUBTYPE_INTEL_FAMILY_MAX 15
261 #define CPU_SUBTYPE_INTEL_MODEL(x) ((x) >> 4)
262 #define CPU_SUBTYPE_INTEL_MODEL_ALL 0
268 #define CPU_SUBTYPE_X86_ALL ((cpu_subtype_t)3)
269 #define CPU_SUBTYPE_X86_64_ALL ((cpu_subtype_t)3)
270 #define CPU_SUBTYPE_X86_ARCH1 ((cpu_subtype_t)4)
273 #define CPU_THREADTYPE_INTEL_HTT ((cpu_threadtype_t) 1)
279 #define CPU_SUBTYPE_MIPS_ALL ((cpu_subtype_t) 0)
280 #define CPU_SUBTYPE_MIPS_R2300 ((cpu_subtype_t) 1)
281 #define CPU_SUBTYPE_MIPS_R2600 ((cpu_subtype_t) 2)
282 #define CPU_SUBTYPE_MIPS_R2800 ((cpu_subtype_t) 3)
283 #define CPU_SUBTYPE_MIPS_R2000a ((cpu_subtype_t) 4) /* pmax */
284 #define CPU_SUBTYPE_MIPS_R2000 ((cpu_subtype_t) 5)
285 #define CPU_SUBTYPE_MIPS_R3000a ((cpu_subtype_t) 6) /* 3max */
286 #define CPU_SUBTYPE_MIPS_R3000 ((cpu_subtype_t) 7)
289 * MC98000 (PowerPC) subtypes
291 #define CPU_SUBTYPE_MC98000_ALL ((cpu_subtype_t) 0)
292 #define CPU_SUBTYPE_MC98601 ((cpu_subtype_t) 1)
295 * HPPA subtypes for Hewlett-Packard HP-PA family of
296 * risc processors. Port by NeXT to 700 series.
299 #define CPU_SUBTYPE_HPPA_ALL ((cpu_subtype_t) 0)
300 #define CPU_SUBTYPE_HPPA_7100 ((cpu_subtype_t) 0) /* compat */
301 #define CPU_SUBTYPE_HPPA_7100LC ((cpu_subtype_t) 1)
306 #define CPU_SUBTYPE_MC88000_ALL ((cpu_subtype_t) 0)
307 #define CPU_SUBTYPE_MC88100 ((cpu_subtype_t) 1)
308 #define CPU_SUBTYPE_MC88110 ((cpu_subtype_t) 2)
313 #define CPU_SUBTYPE_SPARC_ALL ((cpu_subtype_t) 0)
318 #define CPU_SUBTYPE_I860_ALL ((cpu_subtype_t) 0)
319 #define CPU_SUBTYPE_I860_860 ((cpu_subtype_t) 1)
324 #define CPU_SUBTYPE_POWERPC_ALL ((cpu_subtype_t) 0)
325 #define CPU_SUBTYPE_POWERPC_601 ((cpu_subtype_t) 1)
326 #define CPU_SUBTYPE_POWERPC_602 ((cpu_subtype_t) 2)
327 #define CPU_SUBTYPE_POWERPC_603 ((cpu_subtype_t) 3)
328 #define CPU_SUBTYPE_POWERPC_603e ((cpu_subtype_t) 4)
329 #define CPU_SUBTYPE_POWERPC_603ev ((cpu_subtype_t) 5)
330 #define CPU_SUBTYPE_POWERPC_604 ((cpu_subtype_t) 6)
331 #define CPU_SUBTYPE_POWERPC_604e ((cpu_subtype_t) 7)
332 #define CPU_SUBTYPE_POWERPC_620 ((cpu_subtype_t) 8)
333 #define CPU_SUBTYPE_POWERPC_750 ((cpu_subtype_t) 9)
334 #define CPU_SUBTYPE_POWERPC_7400 ((cpu_subtype_t) 10)
335 #define CPU_SUBTYPE_POWERPC_7450 ((cpu_subtype_t) 11)
336 #define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100)
339 * CPU families (sysctl hw.cpufamily)
341 * NB: the encodings of the CPU families are intentionally arbitrary.
342 * There is no ordering, and you should never try to deduce whether
343 * or not some feature is available based on the family.
344 * Use feature flags (eg, hw.optional.altivec) to test for optional
347 #define CPUFAMILY_UNKNOWN 0
348 #define CPUFAMILY_POWERPC_G3 0xcee41549
349 #define CPUFAMILY_POWERPC_G4 0x77c184ae
350 #define CPUFAMILY_POWERPC_G5 0xed76d8aa
351 #define CPUFAMILY_INTEL_6_14 0x73d67300 /* Intel Core Solo and Intel Core Duo (32-bit Pentium-M with SSE3) */
352 #define CPUFAMILY_INTEL_6_15 0x426f69ef /* Intel Core 2 */
354 #endif /* _MACH_MACHINE_H_ */