xref: /titanic_51/usr/src/uts/common/sys/isa_defs.h (revision bdfc6d18da790deeec2e0eb09c625902defe2498)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 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  * _CONSOLE_OUTPUT_VIA_FIRMWARE / _CONSOLE_OUTPUT_VIA_SOFTWARE
172  *	This indicates whether framebuffer console output is done by
173  *	firmware or software.
174  *
175  *	_CONSOLE_OUTPUT_VIA_FIRMWARE
176  *		Framebuffer console output is done via prom_* calls.
177  *
178  *	_CONSOLE_OUTPUT_VIA_SOFTWARE
179  *		Framebuffer console output is done via the software
180  *		terminal emulator.
181  *	_DONT_USE_1275_GENERIC_NAMES
182  *		Controls whether or not device tree node names should
183  *		comply with the IEEE 1275 "Generic Names" Recommended
184  *		Practice. With _DONT_USE_GENERIC_NAMES, device-specific
185  *		names identifying the particular device will be used.
186  *
187  * __i386_COMPAT
188  *	This indicates whether the i386 ABI is supported as a *non-native*
189  *	mode for the platform.  When this symbol is defined:
190  *	-	32-bit xstat-style system calls are enabled
191  *	-	32-bit xmknod-style system calls are enabled
192  *	-	32-bit system calls use i386 sizes -and- alignments
193  *
194  *	Note that this is NOT defined for the i386 native environment!
195  *
196  * __x86
197  *	This is ONLY a synonym for defined(__i386) || defined(__amd64)
198  *	which is useful only insofar as these two architectures share
199  *	common attributes.  Analogous to __sparc.
200  *
201  * _PSM_MODULES
202  *	This indicates whether or not the implementation uses PSM
203  *	modules for processor support, reading /etc/mach from inside
204  *	the kernel to extract a list.
205  *
206  * _RTC_CONFIG
207  *	This indicates whether or not the implementation uses /etc/rtc_config
208  *	to configure the real-time clock in the kernel.
209  */
210 
211 #ifdef	__cplusplus
212 extern "C" {
213 #endif
214 
215 /*
216  * The feature test macro __ia64 is generic for all processors implementing
217  * the Intel ia64 instruction set.
218  */
219 #if defined(__ia64) || defined(__ia64__)
220 #if !defined(__ia64)
221 #define	__ia64
222 #endif
223 
224 /*
225  * Define the appropriate "processor characteristics"
226  */
227 #define	_LITTLE_ENDIAN
228 #define	_STACK_GROWS_DOWNWARD		/* sort of */
229 #define	_LONG_LONG_LTOH
230 #define	_BIT_FIELDS_LTOH
231 #define	_IEEE_754
232 #define	_CHAR_IS_SIGNED
233 #define	_CHAR_ALIGNMENT		1
234 #define	_SHORT_ALIGNMENT	2
235 #define	_INT_ALIGNMENT		4
236 #define	_FLOAT_ALIGNMENT	4
237 #define	_LONG_ALIGNMENT		8
238 #define	_LONG_LONG_ALIGNMENT	8
239 #define	_DOUBLE_ALIGNMENT	8
240 #define	_LONG_DOUBLE_ALIGNMENT	16
241 #define	_POINTER_ALIGNMENT	8
242 #define	_MAX_ALIGNMENT		16
243 #define	_ALIGNMENT_REQUIRED	1
244 
245 /*
246  * Different alignment constraints for the i386 ABI in compatibility mode
247  */
248 #define	_LONG_LONG_ALIGNMENT_32	4
249 
250 /*
251  * Define the appropriate "implementation choices".
252  */
253 #if !defined(_LP64)
254 #define	_LP64
255 #endif
256 #if !defined(_I32LPx) && defined(_KERNEL)
257 #define	_I32LPx
258 #endif
259 #define	_MULTI_DATAMODEL
260 #define	_SUNOS_VTOC_16
261 #define	_DMA_USES_PHYSADDR
262 #define	_FIRMWARE_NEEDS_FDISK
263 #define	_CONSOLE_OUTPUT_VIA_SOFTWARE
264 #define	__i386_COMPAT
265 #define	_PSM_MODULES
266 #define	_RTC_CONFIG
267 #define	_HAVE_CPUID_INSN
268 
269 /*
270  * The following set of definitions characterize Solaris on AMD's
271  * 64-bit systems.
272  */
273 #elif defined(__x86_64) || defined(__amd64)
274 
275 #if !defined(__amd64)
276 #define	__amd64		/* preferred guard */
277 #endif
278 
279 #if !defined(__x86)
280 #define	__x86
281 #endif
282 
283 /*
284  * Define the appropriate "processor characteristics"
285  */
286 #define	_LITTLE_ENDIAN
287 #define	_STACK_GROWS_DOWNWARD
288 #define	_LONG_LONG_LTOH
289 #define	_BIT_FIELDS_LTOH
290 #define	_IEEE_754
291 #define	_CHAR_IS_SIGNED
292 #define	_BOOL_ALIGNMENT			1
293 #define	_CHAR_ALIGNMENT			1
294 #define	_SHORT_ALIGNMENT		2
295 #define	_INT_ALIGNMENT			4
296 #define	_FLOAT_ALIGNMENT		4
297 #define	_FLOAT_COMPLEX_ALIGNMENT	4
298 #define	_LONG_ALIGNMENT			8
299 #define	_LONG_LONG_ALIGNMENT		8
300 #define	_DOUBLE_ALIGNMENT		8
301 #define	_DOUBLE_COMPLEX_ALIGNMENT	8
302 #define	_LONG_DOUBLE_ALIGNMENT		16
303 #define	_LONG_DOUBLE_COMPLEX_ALIGNMENT	16
304 #define	_POINTER_ALIGNMENT		8
305 #define	_MAX_ALIGNMENT			16
306 #define	_ALIGNMENT_REQUIRED		1
307 
308 /*
309  * Different alignment constraints for the i386 ABI in compatibility mode
310  */
311 #define	_LONG_LONG_ALIGNMENT_32		4
312 
313 /*
314  * Define the appropriate "implementation choices".
315  */
316 #if !defined(_LP64)
317 #define	_LP64
318 #endif
319 #if !defined(_I32LPx) && defined(_KERNEL)
320 #define	_I32LPx
321 #endif
322 #define	_MULTI_DATAMODEL
323 #define	_SUNOS_VTOC_16
324 #define	_DMA_USES_PHYSADDR
325 #define	_FIRMWARE_NEEDS_FDISK
326 #define	_CONSOLE_OUTPUT_VIA_SOFTWARE
327 #define	__i386_COMPAT
328 #define	_PSM_MODULES
329 #define	_RTC_CONFIG
330 #define	_DONT_USE_1275_GENERIC_NAMES
331 #define	_HAVE_CPUID_INSN
332 
333 /*
334  * The feature test macro __i386 is generic for all processors implementing
335  * the Intel 386 instruction set or a superset of it.  Specifically, this
336  * includes all members of the 386, 486, and Pentium family of processors.
337  */
338 #elif defined(__i386) || defined(__i386__)
339 
340 #if !defined(__i386)
341 #define	__i386
342 #endif
343 
344 #if !defined(__x86)
345 #define	__x86
346 #endif
347 
348 /*
349  * Define the appropriate "processor characteristics"
350  */
351 #define	_LITTLE_ENDIAN
352 #define	_STACK_GROWS_DOWNWARD
353 #define	_LONG_LONG_LTOH
354 #define	_BIT_FIELDS_LTOH
355 #define	_IEEE_754
356 #define	_CHAR_IS_SIGNED
357 #define	_BOOL_ALIGNMENT			1
358 #define	_CHAR_ALIGNMENT			1
359 #define	_SHORT_ALIGNMENT		2
360 #define	_INT_ALIGNMENT			4
361 #define	_FLOAT_ALIGNMENT		4
362 #define	_FLOAT_COMPLEX_ALIGNMENT	4
363 #define	_LONG_ALIGNMENT			4
364 #define	_LONG_LONG_ALIGNMENT		4
365 #define	_DOUBLE_ALIGNMENT		4
366 #define	_DOUBLE_COMPLEX_ALIGNMENT	4
367 #define	_LONG_DOUBLE_ALIGNMENT		4
368 #define	_LONG_DOUBLE_COMPLEX_ALIGNMENT	4
369 #define	_POINTER_ALIGNMENT		4
370 #define	_MAX_ALIGNMENT			4
371 #define	_ALIGNMENT_REQUIRED		0
372 
373 #define	_LONG_LONG_ALIGNMENT_32		_LONG_LONG_ALIGNMENT
374 
375 /*
376  * Define the appropriate "implementation choices".
377  */
378 #define	_ILP32
379 #if !defined(_I32LPx) && defined(_KERNEL)
380 #define	_I32LPx
381 #endif
382 #define	_SUNOS_VTOC_16
383 #define	_DMA_USES_PHYSADDR
384 #define	_FIRMWARE_NEEDS_FDISK
385 #define	_CONSOLE_OUTPUT_VIA_SOFTWARE
386 #define	_PSM_MODULES
387 #define	_RTC_CONFIG
388 #define	_DONT_USE_1275_GENERIC_NAMES
389 #define	_HAVE_CPUID_INSN
390 
391 /*
392  * The following set of definitions characterize the Solaris on SPARC systems.
393  *
394  * The symbol __sparc indicates any of the SPARC family of processor
395  * architectures.  This includes SPARC V7, SPARC V8 and SPARC V9.
396  *
397  * The symbol __sparcv8 indicates the 32-bit SPARC V8 architecture as defined
398  * by Version 8 of the SPARC Architecture Manual.  (SPARC V7 is close enough
399  * to SPARC V8 for the former to be subsumed into the latter definition.)
400  *
401  * The symbol __sparcv9 indicates the 64-bit SPARC V9 architecture as defined
402  * by Version 9 of the SPARC Architecture Manual.
403  *
404  * The symbols __sparcv8 and __sparcv9 are mutually exclusive, and are only
405  * relevant when the symbol __sparc is defined.
406  */
407 /*
408  * XXX Due to the existence of 5110166, "defined(__sparcv9)" needs to be added
409  * to support backwards builds.  This workaround should be removed in s10_71.
410  */
411 #elif defined(__sparc) || defined(__sparcv9) || defined(__sparc__)
412 #if !defined(__sparc)
413 #define	__sparc
414 #endif
415 
416 /*
417  * You can be 32-bit or 64-bit, but not both at the same time.
418  */
419 #if defined(__sparcv8) && defined(__sparcv9)
420 #error	"SPARC Versions 8 and 9 are mutually exclusive choices"
421 #endif
422 
423 /*
424  * Existing compilers do not set __sparcv8.  Years will transpire before
425  * the compilers can be depended on to set the feature test macro. In
426  * the interim, we'll set it here on the basis of historical behaviour;
427  * if you haven't asked for SPARC V9, then you must've meant SPARC V8.
428  */
429 #if !defined(__sparcv9) && !defined(__sparcv8)
430 #define	__sparcv8
431 #endif
432 
433 /*
434  * Define the appropriate "processor characteristics" shared between
435  * all Solaris on SPARC systems.
436  */
437 #define	_BIG_ENDIAN
438 #define	_STACK_GROWS_DOWNWARD
439 #define	_LONG_LONG_HTOL
440 #define	_BIT_FIELDS_HTOL
441 #define	_IEEE_754
442 #define	_CHAR_IS_SIGNED
443 #define	_BOOL_ALIGNMENT			1
444 #define	_CHAR_ALIGNMENT			1
445 #define	_SHORT_ALIGNMENT		2
446 #define	_INT_ALIGNMENT			4
447 #define	_FLOAT_ALIGNMENT		4
448 #define	_FLOAT_COMPLEX_ALIGNMENT	4
449 #define	_LONG_LONG_ALIGNMENT		8
450 #define	_DOUBLE_ALIGNMENT		8
451 #define	_DOUBLE_COMPLEX_ALIGNMENT	8
452 #define	_ALIGNMENT_REQUIRED		1
453 
454 /*
455  * Define the appropriate "implementation choices" shared between versions.
456  */
457 #define	_SUNOS_VTOC_8
458 #define	_DMA_USES_VIRTADDR
459 #define	_NO_FDISK_PRESENT
460 #define	_CONSOLE_OUTPUT_VIA_FIRMWARE
461 
462 /*
463  * The following set of definitions characterize the implementation of
464  * 32-bit Solaris on SPARC V8 systems.
465  */
466 #if defined(__sparcv8)
467 
468 /*
469  * Define the appropriate "processor characteristics"
470  */
471 #define	_LONG_ALIGNMENT			4
472 #define	_LONG_DOUBLE_ALIGNMENT		8
473 #define	_LONG_DOUBLE_COMPLEX_ALIGNMENT	8
474 #define	_POINTER_ALIGNMENT		4
475 #define	_MAX_ALIGNMENT			8
476 
477 #define	_LONG_LONG_ALIGNMENT_32		_LONG_LONG_ALIGNMENT
478 
479 /*
480  * Define the appropriate "implementation choices"
481  */
482 #define	_ILP32
483 #if !defined(_I32LPx) && defined(_KERNEL)
484 #define	_I32LPx
485 #endif
486 
487 /*
488  * The following set of definitions characterize the implementation of
489  * 64-bit Solaris on SPARC V9 systems.
490  */
491 #elif defined(__sparcv9)
492 
493 /*
494  * Define the appropriate "processor characteristics"
495  */
496 #define	_LONG_ALIGNMENT			8
497 #define	_LONG_DOUBLE_ALIGNMENT		16
498 #define	_LONG_DOUBLE_COMPLEX_ALIGNMENT	16
499 #define	_POINTER_ALIGNMENT		8
500 #define	_MAX_ALIGNMENT			16
501 
502 #define	_LONG_LONG_ALIGNMENT_32		_LONG_LONG_ALIGMENT
503 
504 /*
505  * Define the appropriate "implementation choices"
506  */
507 #if !defined(_LP64)
508 #define	_LP64
509 #endif
510 #if !defined(_I32LPx)
511 #define	_I32LPx
512 #endif
513 #define	_MULTI_DATAMODEL
514 
515 #else
516 #error	"unknown SPARC version"
517 #endif
518 
519 /*
520  * #error is strictly ansi-C, but works as well as anything for K&R systems.
521  */
522 #else
523 #error "ISA not supported"
524 #endif
525 
526 #if defined(_ILP32) && defined(_LP64)
527 #error "Both _ILP32 and _LP64 are defined"
528 #endif
529 
530 #ifdef	__cplusplus
531 }
532 #endif
533 
534 #endif	/* _SYS_ISA_DEFS_H */
535