]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/cddl/contrib/opensolaris/uts/common/sys/isa_defs.h
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / cddl / contrib / opensolaris / uts / common / sys / isa_defs.h
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21
22 /*
23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26
27 #ifndef _SYS_ISA_DEFS_H
28 #define _SYS_ISA_DEFS_H
29
30 #pragma ident   "%Z%%M% %I%     %E% SMI"
31
32 /*
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.
37  *
38  * Processor Characteristics:
39  *
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.
43  *
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).
49  *
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.
53  *
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).
57  *
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.
64  *
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.
71  *
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.
78  *
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.
82  *
83  * _ALIGNMENT_REQUIRED:
84  *      True or false (1 or 0) whether or not the hardware requires the ABI
85  *      alignment.
86  *
87  * _LONG_LONG_ALIGNMENT_32
88  *      The 32-bit ABI supported by a 64-bit kernel may have different
89  *      alignment requirements for primitive object types.  The value of this
90  *      identifier is expressed in "byte-alignment" units.
91  *
92  * _HAVE_CPUID_INSN
93  *      This indicates that the architecture supports the 'cpuid'
94  *      instruction as defined by Intel.  (Intel allows other vendors
95  *      to extend the instruction for their own purposes.)
96  *
97  *
98  * Implementation Choices:
99  *
100  * _ILP32 / _LP64:
101  *      This specifies the compiler data type implementation as specified in
102  *      the relevant ABI.  The choice between these is strongly influenced
103  *      by the underlying hardware, but is not absolutely tied to it.
104  *      Currently only two data type models are supported:
105  *
106  *      _ILP32:
107  *              Int/Long/Pointer are 32 bits.  This is the historical UNIX
108  *              and Solaris implementation.  Due to its historical standing,
109  *              this is the default case.
110  *
111  *      _LP64:
112  *              Long/Pointer are 64 bits, Int is 32 bits.  This is the chosen
113  *              implementation for 64-bit ABIs such as SPARC V9.
114  *
115  *      _I32LPx:
116  *              A compilation environment where 'int' is 32-bit, and
117  *              longs and pointers are simply the same size.
118  *
119  *      In all cases, Char is 8 bits and Short is 16 bits.
120  *
121  * _SUNOS_VTOC_8 / _SUNOS_VTOC_16 / _SVR4_VTOC_16:
122  *      This specifies the form of the disk VTOC (or label):
123  *
124  *      _SUNOS_VTOC_8:
125  *              This is a VTOC form which is upwardly compatible with the
126  *              SunOS 4.x disk label and allows 8 partitions per disk.
127  *
128  *      _SUNOS_VTOC_16:
129  *              In this format the incore vtoc image matches the ondisk
130  *              version.  It allows 16 slices per disk, and is not
131  *              compatible with the SunOS 4.x disk label.
132  *
133  *      Note that these are not the only two VTOC forms possible and
134  *      additional forms may be added.  One possible form would be the
135  *      SVr4 VTOC form.  The symbol for that is reserved now, although
136  *      it is not implemented.
137  *
138  *      _SVR4_VTOC_16:
139  *              This VTOC form is compatible with the System V Release 4
140  *              VTOC (as implemented on the SVr4 Intel and 3b ports) with
141  *              16 partitions per disk.
142  *
143  *
144  * _DMA_USES_PHYSADDR / _DMA_USES_VIRTADDR
145  *      This describes the type of addresses used by system DMA:
146  *
147  *      _DMA_USES_PHYSADDR:
148  *              This type of DMA, used in the x86 implementation,
149  *              requires physical addresses for DMA buffers.  The 24-bit
150  *              addresses used by some legacy boards is the source of the
151  *              "low-memory" (<16MB) requirement for some devices using DMA.
152  *
153  *      _DMA_USES_VIRTADDR:
154  *              This method of DMA allows the use of virtual addresses for
155  *              DMA transfers.
156  *
157  * _FIRMWARE_NEEDS_FDISK / _NO_FDISK_PRESENT
158  *      This indicates the presence/absence of an fdisk table.
159  *
160  *      _FIRMWARE_NEEDS_FDISK
161  *              The fdisk table is required by system firmware.  If present,
162  *              it allows a disk to be subdivided into multiple fdisk
163  *              partitions, each of which is equivalent to a separate,
164  *              virtual disk.  This enables the co-existence of multiple
165  *              operating systems on a shared hard disk.
166  *
167  *      _NO_FDISK_PRESENT
168  *              If the fdisk table is absent, it is assumed that the entire
169  *              media is allocated for a single operating system.
170  *
171  * _HAVE_TEM_FIRMWARE
172  *      Defined if this architecture has the (fallback) option of
173  *      using prom_* calls for doing I/O if a suitable kernel driver
174  *      is not available to do it.
175  *
176  * _DONT_USE_1275_GENERIC_NAMES
177  *              Controls whether or not device tree node names should
178  *              comply with the IEEE 1275 "Generic Names" Recommended
179  *              Practice. With _DONT_USE_GENERIC_NAMES, device-specific
180  *              names identifying the particular device will be used.
181  *
182  * __i386_COMPAT
183  *      This indicates whether the i386 ABI is supported as a *non-native*
184  *      mode for the platform.  When this symbol is defined:
185  *      -       32-bit xstat-style system calls are enabled
186  *      -       32-bit xmknod-style system calls are enabled
187  *      -       32-bit system calls use i386 sizes -and- alignments
188  *
189  *      Note that this is NOT defined for the i386 native environment!
190  *
191  * __x86
192  *      This is ONLY a synonym for defined(__i386) || defined(__amd64)
193  *      which is useful only insofar as these two architectures share
194  *      common attributes.  Analogous to __sparc.
195  *
196  * _PSM_MODULES
197  *      This indicates whether or not the implementation uses PSM
198  *      modules for processor support, reading /etc/mach from inside
199  *      the kernel to extract a list.
200  *
201  * _RTC_CONFIG
202  *      This indicates whether or not the implementation uses /etc/rtc_config
203  *      to configure the real-time clock in the kernel.
204  *
205  * _UNIX_KRTLD
206  *      This indicates that the implementation uses a dynamically
207  *      linked unix + krtld to form the core kernel image at boot
208  *      time, or (in the absence of this symbol) a prelinked kernel image.
209  *
210  * _OBP
211  *      This indicates the firmware interface is OBP.
212  */
213
214 #ifdef  __cplusplus
215 extern "C" {
216 #endif
217
218 /*
219  * The following set of definitions characterize Solaris on AMD's
220  * 64-bit systems.
221  */
222 #if defined(__x86_64) || defined(__amd64) || defined(__ia64__)
223
224 #if !defined(__amd64)
225 #define __amd64         /* preferred guard */
226 #endif
227
228 #if !defined(__x86)
229 #define __x86
230 #endif
231
232 /*
233  * Define the appropriate "processor characteristics"
234  */
235 #if defined(sun)
236 #define _LITTLE_ENDIAN
237 #endif
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
259 /*
260  * Different alignment constraints for the i386 ABI in compatibility mode
261  */
262 #define _LONG_LONG_ALIGNMENT_32         4
263
264 /*
265  * Define the appropriate "implementation choices".
266  */
267 #if !defined(_LP64)
268 #define _LP64
269 #endif
270 #if !defined(_I32LPx) && defined(_KERNEL)
271 #define _I32LPx
272 #endif
273 #define _MULTI_DATAMODEL
274 #define _SUNOS_VTOC_16
275 #define _DMA_USES_PHYSADDR
276 #define _FIRMWARE_NEEDS_FDISK
277 #define __i386_COMPAT
278 #define _PSM_MODULES
279 #define _RTC_CONFIG
280 #define _DONT_USE_1275_GENERIC_NAMES
281 #define _HAVE_CPUID_INSN
282
283 /*
284  * The feature test macro __i386 is generic for all processors implementing
285  * the Intel 386 instruction set or a superset of it.  Specifically, this
286  * includes all members of the 386, 486, and Pentium family of processors.
287  */
288 #elif defined(__i386) || defined(__i386__)
289
290 #if !defined(__i386)
291 #define __i386
292 #endif
293
294 #if !defined(__x86)
295 #define __x86
296 #endif
297
298 /*
299  * Define the appropriate "processor characteristics"
300  */
301 #if defined(sun)
302 #define _LITTLE_ENDIAN
303 #endif
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
325 #define _LONG_LONG_ALIGNMENT_32         _LONG_LONG_ALIGNMENT
326
327 /*
328  * Define the appropriate "implementation choices".
329  */
330 #define _ILP32
331 #if !defined(_I32LPx) && defined(_KERNEL)
332 #define _I32LPx
333 #endif
334 #define _SUNOS_VTOC_16
335 #define _DMA_USES_PHYSADDR
336 #define _FIRMWARE_NEEDS_FDISK
337 #define _PSM_MODULES
338 #define _RTC_CONFIG
339 #define _DONT_USE_1275_GENERIC_NAMES
340 #define _HAVE_CPUID_INSN
341
342 #elif defined(__arm__)
343
344 /*
345  * Define the appropriate "processor characteristics"
346  */
347 #define _STACK_GROWS_DOWNWARD
348 #define _LONG_LONG_LTOH
349 #define _BIT_FIELDS_LTOH
350 #define _IEEE_754
351 #define _CHAR_IS_SIGNED
352 #define _BOOL_ALIGNMENT                 1
353 #define _CHAR_ALIGNMENT                 1
354 #define _SHORT_ALIGNMENT                2
355 #define _INT_ALIGNMENT                  4
356 #define _FLOAT_ALIGNMENT                4
357 #define _FLOAT_COMPLEX_ALIGNMENT        4
358 #define _LONG_ALIGNMENT                 4
359 #define _LONG_LONG_ALIGNMENT            4
360 #define _DOUBLE_ALIGNMENT               4
361 #define _DOUBLE_COMPLEX_ALIGNMENT       4
362 #define _LONG_DOUBLE_ALIGNMENT          4
363 #define _LONG_DOUBLE_COMPLEX_ALIGNMENT  4
364 #define _POINTER_ALIGNMENT              4
365 #define _MAX_ALIGNMENT                  4
366 #define _ALIGNMENT_REQUIRED             0
367
368 #define _LONG_LONG_ALIGNMENT_32         _LONG_LONG_ALIGNMENT
369
370 /*
371  * Define the appropriate "implementation choices".
372  */
373 #define _ILP32
374 #if !defined(_I32LPx) && defined(_KERNEL)
375 #define _I32LPx
376 #endif
377 #define _SUNOS_VTOC_16
378 #define _DMA_USES_PHYSADDR
379 #define _FIRMWARE_NEEDS_FDISK
380 #define _PSM_MODULES
381 #define _RTC_CONFIG
382 #define _DONT_USE_1275_GENERIC_NAMES
383 #define _HAVE_CPUID_INSN
384
385 #elif defined(__powerpc__)
386
387 /*
388  * The following set of definitions characterize the Solaris on SPARC systems.
389  *
390  * The symbol __sparc indicates any of the SPARC family of processor
391  * architectures.  This includes SPARC V7, SPARC V8 and SPARC V9.
392  *
393  * The symbol __sparcv8 indicates the 32-bit SPARC V8 architecture as defined
394  * by Version 8 of the SPARC Architecture Manual.  (SPARC V7 is close enough
395  * to SPARC V8 for the former to be subsumed into the latter definition.)
396  *
397  * The symbol __sparcv9 indicates the 64-bit SPARC V9 architecture as defined
398  * by Version 9 of the SPARC Architecture Manual.
399  *
400  * The symbols __sparcv8 and __sparcv9 are mutually exclusive, and are only
401  * relevant when the symbol __sparc is defined.
402  */
403 /*
404  * XXX Due to the existence of 5110166, "defined(__sparcv9)" needs to be added
405  * to support backwards builds.  This workaround should be removed in s10_71.
406  */
407 #elif defined(__sparc) || defined(__sparcv9) || defined(__sparc__)
408 #if !defined(__sparc)
409 #define __sparc
410 #endif
411
412 /*
413  * You can be 32-bit or 64-bit, but not both at the same time.
414  */
415 #if defined(__sparcv8) && defined(__sparcv9)
416 #error  "SPARC Versions 8 and 9 are mutually exclusive choices"
417 #endif
418
419 /*
420  * Existing compilers do not set __sparcv8.  Years will transpire before
421  * the compilers can be depended on to set the feature test macro. In
422  * the interim, we'll set it here on the basis of historical behaviour;
423  * if you haven't asked for SPARC V9, then you must've meant SPARC V8.
424  */
425 #if !defined(__sparcv9) && !defined(__sparcv8)
426 #define __sparcv8
427 #endif
428
429 /*
430  * Define the appropriate "processor characteristics" shared between
431  * all Solaris on SPARC systems.
432  */
433 #if defined(sun)
434 #define _BIG_ENDIAN
435 #endif
436 #define _STACK_GROWS_DOWNWARD
437 #define _LONG_LONG_HTOL
438 #define _BIT_FIELDS_HTOL
439 #define _IEEE_754
440 #define _CHAR_IS_SIGNED
441 #define _BOOL_ALIGNMENT                 1
442 #define _CHAR_ALIGNMENT                 1
443 #define _SHORT_ALIGNMENT                2
444 #define _INT_ALIGNMENT                  4
445 #define _FLOAT_ALIGNMENT                4
446 #define _FLOAT_COMPLEX_ALIGNMENT        4
447 #define _LONG_LONG_ALIGNMENT            8
448 #define _DOUBLE_ALIGNMENT               8
449 #define _DOUBLE_COMPLEX_ALIGNMENT       8
450 #define _ALIGNMENT_REQUIRED             1
451
452 /*
453  * Define the appropriate "implementation choices" shared between versions.
454  */
455 #define _SUNOS_VTOC_8
456 #define _DMA_USES_VIRTADDR
457 #define _NO_FDISK_PRESENT
458 #define _HAVE_TEM_FIRMWARE
459 #define _OBP
460
461 /*
462  * The following set of definitions characterize the implementation of
463  * 32-bit Solaris on SPARC V8 systems.
464  */
465 #if defined(__sparcv8)
466
467 /*
468  * Define the appropriate "processor characteristics"
469  */
470 #define _LONG_ALIGNMENT                 4
471 #define _LONG_DOUBLE_ALIGNMENT          8
472 #define _LONG_DOUBLE_COMPLEX_ALIGNMENT  8
473 #define _POINTER_ALIGNMENT              4
474 #define _MAX_ALIGNMENT                  8
475
476 #define _LONG_LONG_ALIGNMENT_32         _LONG_LONG_ALIGNMENT
477
478 /*
479  * Define the appropriate "implementation choices"
480  */
481 #define _ILP32
482 #if !defined(_I32LPx) && defined(_KERNEL)
483 #define _I32LPx
484 #endif
485
486 /*
487  * The following set of definitions characterize the implementation of
488  * 64-bit Solaris on SPARC V9 systems.
489  */
490 #elif defined(__sparcv9)
491
492 /*
493  * Define the appropriate "processor characteristics"
494  */
495 #define _LONG_ALIGNMENT                 8
496 #define _LONG_DOUBLE_ALIGNMENT          16
497 #define _LONG_DOUBLE_COMPLEX_ALIGNMENT  16
498 #define _POINTER_ALIGNMENT              8
499 #define _MAX_ALIGNMENT                  16
500
501 #define _LONG_LONG_ALIGNMENT_32         _LONG_LONG_ALIGMENT
502
503 /*
504  * Define the appropriate "implementation choices"
505  */
506 #if !defined(_LP64)
507 #define _LP64
508 #endif
509 #if !defined(_I32LPx)
510 #define _I32LPx
511 #endif
512 #define _MULTI_DATAMODEL
513
514 #else
515 #error  "unknown SPARC version"
516 #endif
517
518 /*
519  * #error is strictly ansi-C, but works as well as anything for K&R systems.
520  */
521 #else
522 #error "ISA not supported"
523 #endif
524
525 #if defined(_ILP32) && defined(_LP64)
526 #error "Both _ILP32 and _LP64 are defined"
527 #endif
528
529 #ifdef  __cplusplus
530 }
531 #endif
532
533 #endif  /* _SYS_ISA_DEFS_H */