FEATURES: add notes about compilation env changes
[unleashed.git] / include / sys / isa_defs.h
blob572783c4a20a05565952cb8fff80a545363fc9b5
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
24 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
26 * Copyright 2016 Joyent, Inc.
29 #ifndef _SYS_ISA_DEFS_H
30 #define _SYS_ISA_DEFS_H
33 * This header file serves to group a set of well known defines and to
34 * set these for each instruction set architecture. These defines may
35 * be divided into two groups; characteristics of the processor and
36 * implementation choices for Solaris on a processor.
38 * Processor Characteristics:
40 * _LITTLE_ENDIAN / _BIG_ENDIAN:
41 * The natural byte order of the processor. A pointer to an int points
42 * to the least/most significant byte of that int.
44 * _STACK_GROWS_UPWARD / _STACK_GROWS_DOWNWARD:
45 * The processor specific direction of stack growth. A push onto the
46 * stack increases/decreases the stack pointer, so it stores data at
47 * successively higher/lower addresses. (Stackless machines ignored
48 * without regrets).
50 * _LONG_LONG_HTOL / _LONG_LONG_LTOH:
51 * A pointer to a long long points to the most/least significant long
52 * within that long long.
54 * _BIT_FIELDS_HTOL / _BIT_FIELDS_LTOH:
55 * The C compiler assigns bit fields from the high/low to the low/high end
56 * of an int (most to least significant vs. least to most significant).
58 * _IEEE_754:
59 * The processor (or supported implementations of the processor)
60 * supports the ieee-754 floating point standard. No other floating
61 * point standards are supported (or significant). Any other supported
62 * floating point formats are expected to be cased on the ISA processor
63 * symbol.
65 * _CHAR_IS_UNSIGNED / _CHAR_IS_SIGNED:
66 * The C Compiler implements objects of type `char' as `unsigned' or
67 * `signed' respectively. This is really an implementation choice of
68 * the compiler writer, but it is specified in the ABI and tends to
69 * be uniform across compilers for an instruction set architecture.
70 * Hence, it has the properties of a processor characteristic.
72 * _CHAR_ALIGNMENT / _SHORT_ALIGNMENT / _INT_ALIGNMENT / _LONG_ALIGNMENT /
73 * _LONG_LONG_ALIGNMENT / _DOUBLE_ALIGNMENT / _LONG_DOUBLE_ALIGNMENT /
74 * _POINTER_ALIGNMENT / _FLOAT_ALIGNMENT:
75 * The ABI defines alignment requirements of each of the primitive
76 * object types. Some, if not all, may be hardware requirements as
77 * well. The values are expressed in "byte-alignment" units.
79 * _MAX_ALIGNMENT:
80 * The most stringent alignment requirement as specified by the ABI.
81 * Equal to the maximum of all the above _XXX_ALIGNMENT values.
83 * _MAX_ALIGNMENT_TYPE:
84 * The name of the C type that has the value descried in _MAX_ALIGNMENT.
86 * _ALIGNMENT_REQUIRED:
87 * True or false (1 or 0) whether or not the hardware requires the ABI
88 * alignment.
90 * _LONG_LONG_ALIGNMENT_32
91 * The 32-bit ABI supported by a 64-bit kernel may have different
92 * alignment requirements for primitive object types. The value of this
93 * identifier is expressed in "byte-alignment" units.
95 * _HAVE_CPUID_INSN
96 * This indicates that the architecture supports the 'cpuid'
97 * instruction as defined by Intel. (Intel allows other vendors
98 * to extend the instruction for their own purposes.)
101 * Implementation Choices:
103 * _ILP32 / _LP64:
104 * This specifies the compiler data type implementation as specified in
105 * the relevant ABI. The choice between these is strongly influenced
106 * by the underlying hardware, but is not absolutely tied to it.
107 * Currently only two data type models are supported:
109 * _ILP32:
110 * Int/Long/Pointer are 32 bits. This is the historical UNIX
111 * and Solaris implementation. Due to its historical standing,
112 * this is the default case.
114 * _LP64:
115 * Long/Pointer are 64 bits, Int is 32 bits. This is the chosen
116 * implementation for 64-bit ABIs such as SPARC V9.
118 * _I32LPx:
119 * A compilation environment where 'int' is 32-bit, and
120 * longs and pointers are simply the same size.
122 * In all cases, Char is 8 bits and Short is 16 bits.
124 * _SUNOS_VTOC_8 / _SUNOS_VTOC_16 / _SVR4_VTOC_16:
125 * This specifies the form of the disk VTOC (or label):
127 * _SUNOS_VTOC_8:
128 * This is a VTOC form which is upwardly compatible with the
129 * SunOS 4.x disk label and allows 8 partitions per disk.
131 * _SUNOS_VTOC_16:
132 * In this format the incore vtoc image matches the ondisk
133 * version. It allows 16 slices per disk, and is not
134 * compatible with the SunOS 4.x disk label.
136 * Note that these are not the only two VTOC forms possible and
137 * additional forms may be added. One possible form would be the
138 * SVr4 VTOC form. The symbol for that is reserved now, although
139 * it is not implemented.
141 * _SVR4_VTOC_16:
142 * This VTOC form is compatible with the System V Release 4
143 * VTOC (as implemented on the SVr4 Intel and 3b ports) with
144 * 16 partitions per disk.
147 * _DMA_USES_PHYSADDR / _DMA_USES_VIRTADDR
148 * This describes the type of addresses used by system DMA:
150 * _DMA_USES_PHYSADDR:
151 * This type of DMA, used in the x86 implementation,
152 * requires physical addresses for DMA buffers. The 24-bit
153 * addresses used by some legacy boards is the source of the
154 * "low-memory" (<16MB) requirement for some devices using DMA.
156 * _DMA_USES_VIRTADDR:
157 * This method of DMA allows the use of virtual addresses for
158 * DMA transfers.
160 * _FIRMWARE_NEEDS_FDISK / _NO_FDISK_PRESENT
161 * This indicates the presence/absence of an fdisk table.
163 * _FIRMWARE_NEEDS_FDISK
164 * The fdisk table is required by system firmware. If present,
165 * it allows a disk to be subdivided into multiple fdisk
166 * partitions, each of which is equivalent to a separate,
167 * virtual disk. This enables the co-existence of multiple
168 * operating systems on a shared hard disk.
170 * _NO_FDISK_PRESENT
171 * If the fdisk table is absent, it is assumed that the entire
172 * media is allocated for a single operating system.
174 * _HAVE_TEM_FIRMWARE
175 * Defined if this architecture has the (fallback) option of
176 * using prom_* calls for doing I/O if a suitable kernel driver
177 * is not available to do it.
179 * _DONT_USE_1275_GENERIC_NAMES
180 * Controls whether or not device tree node names should
181 * comply with the IEEE 1275 "Generic Names" Recommended
182 * Practice. With _DONT_USE_GENERIC_NAMES, device-specific
183 * names identifying the particular device will be used.
185 * __i386_COMPAT
186 * This indicates whether the i386 ABI is supported as a *non-native*
187 * mode for the platform. When this symbol is defined:
188 * - 32-bit xstat-style system calls are enabled
189 * - 32-bit xmknod-style system calls are enabled
190 * - 32-bit system calls use i386 sizes -and- alignments
192 * Note that this is NOT defined for the i386 native environment!
194 * __x86
195 * This is ONLY a synonym for defined(__i386) || defined(__amd64)
196 * which is useful only insofar as these two architectures share
197 * common attributes. Analogous to __sparc.
199 * _PSM_MODULES
200 * This indicates whether or not the implementation uses PSM
201 * modules for processor support, reading /etc/mach from inside
202 * the kernel to extract a list.
204 * _RTC_CONFIG
205 * This indicates whether or not the implementation uses /etc/rtc_config
206 * to configure the real-time clock in the kernel.
208 * _OBP
209 * This indicates the firmware interface is OBP.
211 * _SOFT_HOSTID
212 * This indicates that the implementation obtains the hostid
213 * from the file /etc/hostid, rather than from hardware.
216 #ifdef __cplusplus
217 extern "C" {
218 #endif
221 * The following set of definitions characterize Solaris on AMD's
222 * 64-bit systems.
224 #if defined(__x86_64) || defined(__amd64)
226 #if !defined(__amd64)
227 #define __amd64 /* preferred guard */
228 #endif
230 #if !defined(__x86)
231 #define __x86
232 #endif
235 * Define the appropriate "processor characteristics"
237 #define _LITTLE_ENDIAN
238 #define _STACK_GROWS_DOWNWARD
239 #define _LONG_LONG_LTOH
240 #define _BIT_FIELDS_LTOH
241 #define _IEEE_754
242 #define _CHAR_IS_SIGNED
243 #define _BOOL_ALIGNMENT 1
244 #define _CHAR_ALIGNMENT 1
245 #define _SHORT_ALIGNMENT 2
246 #define _INT_ALIGNMENT 4
247 #define _FLOAT_ALIGNMENT 4
248 #define _FLOAT_COMPLEX_ALIGNMENT 4
249 #define _LONG_ALIGNMENT 8
250 #define _LONG_LONG_ALIGNMENT 8
251 #define _DOUBLE_ALIGNMENT 8
252 #define _DOUBLE_COMPLEX_ALIGNMENT 8
253 #define _LONG_DOUBLE_ALIGNMENT 16
254 #define _LONG_DOUBLE_COMPLEX_ALIGNMENT 16
255 #define _POINTER_ALIGNMENT 8
256 #define _MAX_ALIGNMENT 16
257 #define _ALIGNMENT_REQUIRED 1
258 #define _MAX_ALIGNMENT_TYPE long double
261 * Different alignment constraints for the i386 ABI in compatibility mode
263 #define _LONG_LONG_ALIGNMENT_32 4
266 * Define the appropriate "implementation choices".
268 #if !defined(_LP64)
269 #define _LP64
270 #endif
271 #if !defined(_I32LPx) && defined(_KERNEL)
272 #define _I32LPx
273 #endif
274 #define _MULTI_DATAMODEL
275 #define _SUNOS_VTOC_16
276 #define _DMA_USES_PHYSADDR
277 #define _FIRMWARE_NEEDS_FDISK
278 #define __i386_COMPAT
279 #define _PSM_MODULES
280 #define _RTC_CONFIG
281 #define _SOFT_HOSTID
282 #define _DONT_USE_1275_GENERIC_NAMES
283 #define _HAVE_CPUID_INSN
286 * The feature test macro __i386 is generic for all processors implementing
287 * the Intel 386 instruction set or a superset of it. Specifically, this
288 * includes all members of the 386, 486, and Pentium family of processors.
290 #elif defined(__i386) || defined(__i386__)
292 #if !defined(__i386)
293 #define __i386
294 #endif
296 #if !defined(__x86)
297 #define __x86
298 #endif
301 * Define the appropriate "processor characteristics"
303 #define _LITTLE_ENDIAN
304 #define _STACK_GROWS_DOWNWARD
305 #define _LONG_LONG_LTOH
306 #define _BIT_FIELDS_LTOH
307 #define _IEEE_754
308 #define _CHAR_IS_SIGNED
309 #define _BOOL_ALIGNMENT 1
310 #define _CHAR_ALIGNMENT 1
311 #define _SHORT_ALIGNMENT 2
312 #define _INT_ALIGNMENT 4
313 #define _FLOAT_ALIGNMENT 4
314 #define _FLOAT_COMPLEX_ALIGNMENT 4
315 #define _LONG_ALIGNMENT 4
316 #define _LONG_LONG_ALIGNMENT 4
317 #define _DOUBLE_ALIGNMENT 4
318 #define _DOUBLE_COMPLEX_ALIGNMENT 4
319 #define _LONG_DOUBLE_ALIGNMENT 4
320 #define _LONG_DOUBLE_COMPLEX_ALIGNMENT 4
321 #define _POINTER_ALIGNMENT 4
322 #define _MAX_ALIGNMENT 4
323 #define _ALIGNMENT_REQUIRED 0
324 #define _MAX_ALIGNMENT_TYPE long
326 #define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT
329 * Define the appropriate "implementation choices".
331 #if !defined(_ILP32)
332 #define _ILP32
333 #endif
334 #if !defined(_I32LPx) && defined(_KERNEL)
335 #define _I32LPx
336 #endif
337 #define _SUNOS_VTOC_16
338 #define _DMA_USES_PHYSADDR
339 #define _FIRMWARE_NEEDS_FDISK
340 #define _PSM_MODULES
341 #define _RTC_CONFIG
342 #define _SOFT_HOSTID
343 #define _DONT_USE_1275_GENERIC_NAMES
344 #define _HAVE_CPUID_INSN
347 * The following set of definitions characterize the Solaris on SPARC systems.
349 * The symbol __sparc indicates any of the SPARC family of processor
350 * architectures. This includes SPARC V7, SPARC V8 and SPARC V9.
352 * The symbol __sparcv8 indicates the 32-bit SPARC V8 architecture as defined
353 * by Version 8 of the SPARC Architecture Manual. (SPARC V7 is close enough
354 * to SPARC V8 for the former to be subsumed into the latter definition.)
356 * The symbol __sparcv9 indicates the 64-bit SPARC V9 architecture as defined
357 * by Version 9 of the SPARC Architecture Manual.
359 * The symbols __sparcv8 and __sparcv9 are mutually exclusive, and are only
360 * relevant when the symbol __sparc is defined.
363 * XXX Due to the existence of 5110166, "defined(__sparcv9)" needs to be added
364 * to support backwards builds. This workaround should be removed in s10_71.
366 #elif defined(__sparc) || defined(__sparcv9) || defined(__sparc__)
367 #if !defined(__sparc)
368 #define __sparc
369 #endif
372 * You can be 32-bit or 64-bit, but not both at the same time.
374 #if defined(__sparcv8) && defined(__sparcv9)
375 #error "SPARC Versions 8 and 9 are mutually exclusive choices"
376 #endif
379 * Existing compilers do not set __sparcv8. Years will transpire before
380 * the compilers can be depended on to set the feature test macro. In
381 * the interim, we'll set it here on the basis of historical behaviour;
382 * if you haven't asked for SPARC V9, then you must've meant SPARC V8.
384 #if !defined(__sparcv9) && !defined(__sparcv8)
385 #define __sparcv8
386 #endif
389 * Define the appropriate "processor characteristics" shared between
390 * all Solaris on SPARC systems.
392 #define _BIG_ENDIAN
393 #define _STACK_GROWS_DOWNWARD
394 #define _LONG_LONG_HTOL
395 #define _BIT_FIELDS_HTOL
396 #define _IEEE_754
397 #define _CHAR_IS_SIGNED
398 #define _BOOL_ALIGNMENT 1
399 #define _CHAR_ALIGNMENT 1
400 #define _SHORT_ALIGNMENT 2
401 #define _INT_ALIGNMENT 4
402 #define _FLOAT_ALIGNMENT 4
403 #define _FLOAT_COMPLEX_ALIGNMENT 4
404 #define _LONG_LONG_ALIGNMENT 8
405 #define _DOUBLE_ALIGNMENT 8
406 #define _DOUBLE_COMPLEX_ALIGNMENT 8
407 #define _ALIGNMENT_REQUIRED 1
410 * Define the appropriate "implementation choices" shared between versions.
412 #define _SUNOS_VTOC_8
413 #define _DMA_USES_VIRTADDR
414 #define _NO_FDISK_PRESENT
415 #define _HAVE_TEM_FIRMWARE
416 #define _OBP
419 * The following set of definitions characterize the implementation of
420 * 32-bit Solaris on SPARC V8 systems.
422 #if defined(__sparcv8)
425 * Define the appropriate "processor characteristics"
427 #define _LONG_ALIGNMENT 4
428 #define _LONG_DOUBLE_ALIGNMENT 8
429 #define _LONG_DOUBLE_COMPLEX_ALIGNMENT 8
430 #define _POINTER_ALIGNMENT 4
431 #define _MAX_ALIGNMENT 8
432 #define _MAX_ALIGNMENT_TYPE long double
434 #define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT
437 * Define the appropriate "implementation choices"
439 #if !defined(_ILP32)
440 #define _ILP32
441 #endif
442 #if !defined(_I32LPx) && defined(_KERNEL)
443 #define _I32LPx
444 #endif
447 * The following set of definitions characterize the implementation of
448 * 64-bit Solaris on SPARC V9 systems.
450 #elif defined(__sparcv9)
453 * Define the appropriate "processor characteristics"
455 #define _LONG_ALIGNMENT 8
456 #define _LONG_DOUBLE_ALIGNMENT 16
457 #define _LONG_DOUBLE_COMPLEX_ALIGNMENT 16
458 #define _POINTER_ALIGNMENT 8
459 #define _MAX_ALIGNMENT 16
460 #define _MAX_ALIGNMENT_TYPE long double
462 #define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT
465 * Define the appropriate "implementation choices"
467 #if !defined(_LP64)
468 #define _LP64
469 #endif
470 #if !defined(_I32LPx)
471 #define _I32LPx
472 #endif
473 #define _MULTI_DATAMODEL
475 #else
476 #error "unknown SPARC version"
477 #endif
480 * #error is strictly ansi-C, but works as well as anything for K&R systems.
482 #else
483 #error "ISA not supported"
484 #endif
486 #if defined(_ILP32) && defined(_LP64)
487 #error "Both _ILP32 and _LP64 are defined"
488 #endif
490 #ifdef __cplusplus
492 #endif
494 #endif /* _SYS_ISA_DEFS_H */