]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/machine.h
xnu-792.6.76.tar.gz
[apple/xnu.git] / osfmk / mach / machine.h
1 /*
2 * Copyright (c) 2000-2005 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 * Mach Operating System
24 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
25 * All Rights Reserved.
26 *
27 * Permission to use, copy, modify and distribute this software and its
28 * documentation is hereby granted, provided that both the copyright
29 * notice and this permission notice appear in all copies of the
30 * software, derivative works or modified versions, and any portions
31 * thereof, and that both notices appear in supporting documentation.
32 *
33 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
34 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
35 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
36 *
37 * Carnegie Mellon requests users of this software to return to
38 *
39 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
40 * School of Computer Science
41 * Carnegie Mellon University
42 * Pittsburgh PA 15213-3890
43 *
44 * any improvements or extensions that they make and grant Carnegie Mellon
45 * the rights to redistribute these changes.
46 */
47 /* File: machine.h
48 * Author: Avadis Tevanian, Jr.
49 * Date: 1986
50 *
51 * Machine independent machine abstraction.
52 */
53
54 #ifndef _MACH_MACHINE_H_
55 #define _MACH_MACHINE_H_
56
57 #include <stdint.h>
58 #include <mach/machine/vm_types.h>
59 #include <mach/boolean.h>
60
61 typedef integer_t cpu_type_t;
62 typedef integer_t cpu_subtype_t;
63 typedef integer_t cpu_threadtype_t;
64
65 #define CPU_STATE_MAX 4
66
67 #define CPU_STATE_USER 0
68 #define CPU_STATE_SYSTEM 1
69 #define CPU_STATE_IDLE 2
70 #define CPU_STATE_NICE 3
71
72 #ifdef KERNEL_PRIVATE
73
74 #include <sys/cdefs.h>
75
76 __BEGIN_DECLS
77 cpu_type_t cpu_type(void);
78
79 cpu_subtype_t cpu_subtype(void);
80
81 cpu_threadtype_t cpu_threadtype(void);
82 __END_DECLS
83
84 #ifdef MACH_KERNEL_PRIVATE
85
86 struct machine_info {
87 integer_t major_version; /* kernel major version id */
88 integer_t minor_version; /* kernel minor version id */
89 integer_t max_cpus; /* max number of CPUs possible */
90 integer_t avail_cpus; /* number of CPUs now available */
91 uint32_t memory_size; /* size of memory in bytes, capped at 2 GB */
92 uint64_t max_mem; /* actual size of physical memory */
93 integer_t physical_cpu; /* number of physical CPUs now available */
94 integer_t physical_cpu_max; /* max number of physical CPUs possible */
95 integer_t logical_cpu; /* number of logical cpu now available */
96 integer_t logical_cpu_max; /* max number of physical CPUs possible */
97 };
98
99 typedef struct machine_info *machine_info_t;
100 typedef struct machine_info machine_info_data_t;
101
102 extern struct machine_info machine_info;
103
104 __BEGIN_DECLS
105 cpu_type_t slot_type(
106 int slot_num);
107
108 cpu_subtype_t slot_subtype(
109 int slot_num);
110
111 cpu_threadtype_t slot_threadtype(
112 int slot_num);
113 __END_DECLS
114
115 #endif /* MACH_KERNEL_PRIVATE */
116 #endif /* KERNEL_PRIVATE */
117
118
119 /*
120 * Capability bits used in the definition of cpu_type.
121 */
122 #define CPU_ARCH_MASK 0xff000000 /* mask for architecture bits */
123 #define CPU_ARCH_ABI64 0x01000000 /* 64 bit ABI */
124
125 /*
126 * Machine types known by all.
127 */
128
129 #define CPU_TYPE_ANY ((cpu_type_t) -1)
130
131 #define CPU_TYPE_VAX ((cpu_type_t) 1)
132 /* skip ((cpu_type_t) 2) */
133 /* skip ((cpu_type_t) 3) */
134 /* skip ((cpu_type_t) 4) */
135 /* skip ((cpu_type_t) 5) */
136 #define CPU_TYPE_MC680x0 ((cpu_type_t) 6)
137 #define CPU_TYPE_I386 ((cpu_type_t) 7)
138 /* skip CPU_TYPE_MIPS ((cpu_type_t) 8) */
139 /* skip ((cpu_type_t) 9) */
140 #define CPU_TYPE_MC98000 ((cpu_type_t) 10)
141 #define CPU_TYPE_HPPA ((cpu_type_t) 11)
142 /* skip CPU_TYPE_ARM ((cpu_type_t) 12) */
143 #define CPU_TYPE_MC88000 ((cpu_type_t) 13)
144 #define CPU_TYPE_SPARC ((cpu_type_t) 14)
145 #define CPU_TYPE_I860 ((cpu_type_t) 15)
146 /* skip CPU_TYPE_ALPHA ((cpu_type_t) 16) */
147 /* skip ((cpu_type_t) 17) */
148 #define CPU_TYPE_POWERPC ((cpu_type_t) 18)
149 #define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64)
150
151 /*
152 * Machine subtypes (these are defined here, instead of in a machine
153 * dependent directory, so that any program can get all definitions
154 * regardless of where is it compiled).
155 */
156
157 /*
158 * Object files that are hand-crafted to run on any
159 * implementation of an architecture are tagged with
160 * CPU_SUBTYPE_MULTIPLE. This functions essentially the same as
161 * the "ALL" subtype of an architecture except that it allows us
162 * to easily find object files that may need to be modified
163 * whenever a new implementation of an architecture comes out.
164 *
165 * It is the responsibility of the implementor to make sure the
166 * software handles unsupported implementations elegantly.
167 */
168 #define CPU_SUBTYPE_MULTIPLE ((cpu_subtype_t) -1)
169 #define CPU_SUBTYPE_LITTLE_ENDIAN ((cpu_subtype_t) 0)
170 #define CPU_SUBTYPE_BIG_ENDIAN ((cpu_subtype_t) 1)
171
172 /*
173 * Machine threadtypes.
174 * This is none - not defined - for most machine types/subtypes.
175 */
176 #define CPU_THREADTYPE_NONE ((cpu_threadtype_t) 0)
177
178 /*
179 * VAX subtypes (these do *not* necessary conform to the actual cpu
180 * ID assigned by DEC available via the SID register).
181 */
182
183 #define CPU_SUBTYPE_VAX_ALL ((cpu_subtype_t) 0)
184 #define CPU_SUBTYPE_VAX780 ((cpu_subtype_t) 1)
185 #define CPU_SUBTYPE_VAX785 ((cpu_subtype_t) 2)
186 #define CPU_SUBTYPE_VAX750 ((cpu_subtype_t) 3)
187 #define CPU_SUBTYPE_VAX730 ((cpu_subtype_t) 4)
188 #define CPU_SUBTYPE_UVAXI ((cpu_subtype_t) 5)
189 #define CPU_SUBTYPE_UVAXII ((cpu_subtype_t) 6)
190 #define CPU_SUBTYPE_VAX8200 ((cpu_subtype_t) 7)
191 #define CPU_SUBTYPE_VAX8500 ((cpu_subtype_t) 8)
192 #define CPU_SUBTYPE_VAX8600 ((cpu_subtype_t) 9)
193 #define CPU_SUBTYPE_VAX8650 ((cpu_subtype_t) 10)
194 #define CPU_SUBTYPE_VAX8800 ((cpu_subtype_t) 11)
195 #define CPU_SUBTYPE_UVAXIII ((cpu_subtype_t) 12)
196
197 /*
198 * 680x0 subtypes
199 *
200 * The subtype definitions here are unusual for historical reasons.
201 * NeXT used to consider 68030 code as generic 68000 code. For
202 * backwards compatability:
203 *
204 * CPU_SUBTYPE_MC68030 symbol has been preserved for source code
205 * compatability.
206 *
207 * CPU_SUBTYPE_MC680x0_ALL has been defined to be the same
208 * subtype as CPU_SUBTYPE_MC68030 for binary comatability.
209 *
210 * CPU_SUBTYPE_MC68030_ONLY has been added to allow new object
211 * files to be tagged as containing 68030-specific instructions.
212 */
213
214 #define CPU_SUBTYPE_MC680x0_ALL ((cpu_subtype_t) 1)
215 #define CPU_SUBTYPE_MC68030 ((cpu_subtype_t) 1) /* compat */
216 #define CPU_SUBTYPE_MC68040 ((cpu_subtype_t) 2)
217 #define CPU_SUBTYPE_MC68030_ONLY ((cpu_subtype_t) 3)
218
219 /*
220 * I386 subtypes.
221 */
222
223 #define CPU_SUBTYPE_I386_ALL ((cpu_subtype_t) 3)
224 #define CPU_SUBTYPE_386 ((cpu_subtype_t) 3)
225 #define CPU_SUBTYPE_486 ((cpu_subtype_t) 4)
226 #define CPU_SUBTYPE_486SX ((cpu_subtype_t) 4 + 128)
227 #define CPU_SUBTYPE_586 ((cpu_subtype_t) 5)
228 #define CPU_SUBTYPE_INTEL(f, m) ((cpu_subtype_t) (f) + ((m) << 4))
229 #define CPU_SUBTYPE_PENT CPU_SUBTYPE_INTEL(5, 0)
230 #define CPU_SUBTYPE_PENTPRO CPU_SUBTYPE_INTEL(6, 1)
231 #define CPU_SUBTYPE_PENTII_M3 CPU_SUBTYPE_INTEL(6, 3)
232 #define CPU_SUBTYPE_PENTII_M5 CPU_SUBTYPE_INTEL(6, 5)
233
234 #define CPU_SUBTYPE_INTEL_FAMILY(x) ((x) & 15)
235 #define CPU_SUBTYPE_INTEL_FAMILY_MAX 15
236
237 #define CPU_SUBTYPE_INTEL_MODEL(x) ((x) >> 4)
238 #define CPU_SUBTYPE_INTEL_MODEL_ALL 0
239
240
241 #define CPU_THREADTYPE_INTEL_HTT ((cpu_threadtype_t) 1)
242
243 /*
244 * Mips subtypes.
245 */
246
247 #define CPU_SUBTYPE_MIPS_ALL ((cpu_subtype_t) 0)
248 #define CPU_SUBTYPE_MIPS_R2300 ((cpu_subtype_t) 1)
249 #define CPU_SUBTYPE_MIPS_R2600 ((cpu_subtype_t) 2)
250 #define CPU_SUBTYPE_MIPS_R2800 ((cpu_subtype_t) 3)
251 #define CPU_SUBTYPE_MIPS_R2000a ((cpu_subtype_t) 4) /* pmax */
252 #define CPU_SUBTYPE_MIPS_R2000 ((cpu_subtype_t) 5)
253 #define CPU_SUBTYPE_MIPS_R3000a ((cpu_subtype_t) 6) /* 3max */
254 #define CPU_SUBTYPE_MIPS_R3000 ((cpu_subtype_t) 7)
255
256 /*
257 * MC98000 (PowerPC) subtypes
258 */
259 #define CPU_SUBTYPE_MC98000_ALL ((cpu_subtype_t) 0)
260 #define CPU_SUBTYPE_MC98601 ((cpu_subtype_t) 1)
261
262 /*
263 * HPPA subtypes for Hewlett-Packard HP-PA family of
264 * risc processors. Port by NeXT to 700 series.
265 */
266
267 #define CPU_SUBTYPE_HPPA_ALL ((cpu_subtype_t) 0)
268 #define CPU_SUBTYPE_HPPA_7100 ((cpu_subtype_t) 0) /* compat */
269 #define CPU_SUBTYPE_HPPA_7100LC ((cpu_subtype_t) 1)
270
271 /*
272 * MC88000 subtypes.
273 */
274 #define CPU_SUBTYPE_MC88000_ALL ((cpu_subtype_t) 0)
275 #define CPU_SUBTYPE_MC88100 ((cpu_subtype_t) 1)
276 #define CPU_SUBTYPE_MC88110 ((cpu_subtype_t) 2)
277
278 /*
279 * SPARC subtypes
280 */
281 #define CPU_SUBTYPE_SPARC_ALL ((cpu_subtype_t) 0)
282
283 /*
284 * I860 subtypes
285 */
286 #define CPU_SUBTYPE_I860_ALL ((cpu_subtype_t) 0)
287 #define CPU_SUBTYPE_I860_860 ((cpu_subtype_t) 1)
288
289 /*
290 * PowerPC subtypes
291 */
292 #define CPU_SUBTYPE_POWERPC_ALL ((cpu_subtype_t) 0)
293 #define CPU_SUBTYPE_POWERPC_601 ((cpu_subtype_t) 1)
294 #define CPU_SUBTYPE_POWERPC_602 ((cpu_subtype_t) 2)
295 #define CPU_SUBTYPE_POWERPC_603 ((cpu_subtype_t) 3)
296 #define CPU_SUBTYPE_POWERPC_603e ((cpu_subtype_t) 4)
297 #define CPU_SUBTYPE_POWERPC_603ev ((cpu_subtype_t) 5)
298 #define CPU_SUBTYPE_POWERPC_604 ((cpu_subtype_t) 6)
299 #define CPU_SUBTYPE_POWERPC_604e ((cpu_subtype_t) 7)
300 #define CPU_SUBTYPE_POWERPC_620 ((cpu_subtype_t) 8)
301 #define CPU_SUBTYPE_POWERPC_750 ((cpu_subtype_t) 9)
302 #define CPU_SUBTYPE_POWERPC_7400 ((cpu_subtype_t) 10)
303 #define CPU_SUBTYPE_POWERPC_7450 ((cpu_subtype_t) 11)
304 #define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100)
305
306 #endif /* _MACH_MACHINE_H_ */