xref: /titanic_50/usr/src/uts/common/sys/isa_defs.h (revision 42516a0c6ebf6e259c2abcd1ca315fec43268f39)
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 2008 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 /*
31  * This header file serves to group a set of well known defines and to
32  * set these for each instruction set architecture.  These defines may
33  * be divided into two groups;  characteristics of the processor and
34  * implementation choices for Solaris on a processor.
35  *
36  * Processor Characteristics:
37  *
38  * _LITTLE_ENDIAN / _BIG_ENDIAN:
39  *	The natural byte order of the processor.  A pointer to an int points
40  *	to the least/most significant byte of that int.
41  *
42  * _STACK_GROWS_UPWARD / _STACK_GROWS_DOWNWARD:
43  *	The processor specific direction of stack growth.  A push onto the
44  *	stack increases/decreases the stack pointer, so it stores data at
45  *	successively higher/lower addresses.  (Stackless machines ignored
46  *	without regrets).
47  *
48  * _LONG_LONG_HTOL / _LONG_LONG_LTOH:
49  *	A pointer to a long long points to the most/least significant long
50  *	within that long long.
51  *
52  * _BIT_FIELDS_HTOL / _BIT_FIELDS_LTOH:
53  *	The C compiler assigns bit fields from the high/low to the low/high end
54  *	of an int (most to least significant vs. least to most significant).
55  *
56  * _IEEE_754:
57  *	The processor (or supported implementations of the processor)
58  *	supports the ieee-754 floating point standard.  No other floating
59  *	point standards are supported (or significant).  Any other supported
60  *	floating point formats are expected to be cased on the ISA processor
61  *	symbol.
62  *
63  * _CHAR_IS_UNSIGNED / _CHAR_IS_SIGNED:
64  *	The C Compiler implements objects of type `char' as `unsigned' or
65  *	`signed' respectively.  This is really an implementation choice of
66  *	the compiler writer, but it is specified in the ABI and tends to
67  *	be uniform across compilers for an instruction set architecture.
68  *	Hence, it has the properties of a processor characteristic.
69  *
70  * _CHAR_ALIGNMENT / _SHORT_ALIGNMENT / _INT_ALIGNMENT / _LONG_ALIGNMENT /
71  * _LONG_LONG_ALIGNMENT / _DOUBLE_ALIGNMENT / _LONG_DOUBLE_ALIGNMENT /
72  * _POINTER_ALIGNMENT / _FLOAT_ALIGNMENT:
73  *	The ABI defines alignment requirements of each of the primitive
74  *	object types.  Some, if not all, may be hardware requirements as
75  * 	well.  The values are expressed in "byte-alignment" units.
76  *
77  * _MAX_ALIGNMENT:
78  *	The most stringent alignment requirement as specified by the ABI.
79  *	Equal to the maximum of all the above _XXX_ALIGNMENT values.
80  *
81  * _ALIGNMENT_REQUIRED:
82  *	True or false (1 or 0) whether or not the hardware requires the ABI
83  *	alignment.
84  *
85  * _LONG_LONG_ALIGNMENT_32
86  *	The 32-bit ABI supported by a 64-bit kernel may have different
87  *	alignment requirements for primitive object types.  The value of this
88  *	identifier is expressed in "byte-alignment" units.
89  *
90  * _HAVE_CPUID_INSN
91  *	This indicates that the architecture supports the 'cpuid'
92  *	instruction as defined by Intel.  (Intel allows other vendors
93  *	to extend the instruction for their own purposes.)
94  *
95  *
96  * Implementation Choices:
97  *
98  * _ILP32 / _LP64:
99  *	This specifies the compiler data type implementation as specified in
100  *	the relevant ABI.  The choice between these is strongly influenced
101  *	by the underlying hardware, but is not absolutely tied to it.
102  *	Currently only two data type models are supported:
103  *
104  *	_ILP32:
105  *		Int/Long/Pointer are 32 bits.  This is the historical UNIX
106  *		and Solaris implementation.  Due to its historical standing,
107  *		this is the default case.
108  *
109  *	_LP64:
110  *		Long/Pointer are 64 bits, Int is 32 bits.  This is the chosen
111  *		implementation for 64-bit ABIs such as SPARC V9.
112  *
113  *	_I32LPx:
114  *		A compilation environment where 'int' is 32-bit, and
115  *		longs and pointers are simply the same size.
116  *
117  *	In all cases, Char is 8 bits and Short is 16 bits.
118  *
119  * _SUNOS_VTOC_8 / _SUNOS_VTOC_16 / _SVR4_VTOC_16:
120  *	This specifies the form of the disk VTOC (or label):
121  *
122  *	_SUNOS_VTOC_8:
123  *		This is a VTOC form which is upwardly compatible with the
124  *		SunOS 4.x disk label and allows 8 partitions per disk.
125  *
126  *	_SUNOS_VTOC_16:
127  *		In this format the incore vtoc image matches the ondisk
128  *		version.  It allows 16 slices per disk, and is not
129  *		compatible with the SunOS 4.x disk label.
130  *
131  *	Note that these are not the only two VTOC forms possible and
132  *	additional forms may be added.  One possible form would be the
133  *	SVr4 VTOC form.  The symbol for that is reserved now, although
134  *	it is not implemented.
135  *
136  *	_SVR4_VTOC_16:
137  *		This VTOC form is compatible with the System V Release 4
138  *		VTOC (as implemented on the SVr4 Intel and 3b ports) with
139  *		16 partitions per disk.
140  *
141  *
142  * _DMA_USES_PHYSADDR / _DMA_USES_VIRTADDR
143  *	This describes the type of addresses used by system DMA:
144  *
145  *	_DMA_USES_PHYSADDR:
146  *		This type of DMA, used in the x86 implementation,
147  *		requires physical addresses for DMA buffers.  The 24-bit
148  *		addresses used by some legacy boards is the source of the
149  *		"low-memory" (<16MB) requirement for some devices using DMA.
150  *
151  *	_DMA_USES_VIRTADDR:
152  *		This method of DMA allows the use of virtual addresses for
153  *		DMA transfers.
154  *
155  * _FIRMWARE_NEEDS_FDISK / _NO_FDISK_PRESENT
156  *      This indicates the presence/absence of an fdisk table.
157  *
158  *      _FIRMWARE_NEEDS_FDISK
159  *              The fdisk table is required by system firmware.  If present,
160  *              it allows a disk to be subdivided into multiple fdisk
161  *              partitions, each of which is equivalent to a separate,
162  *              virtual disk.  This enables the co-existence of multiple
163  *              operating systems on a shared hard disk.
164  *
165  *      _NO_FDISK_PRESENT
166  *              If the fdisk table is absent, it is assumed that the entire
167  *              media is allocated for a single operating system.
168  *
169  * _HAVE_TEM_FIRMWARE
170  *	Defined if this architecture has the (fallback) option of
171  *	using prom_* calls for doing I/O if a suitable kernel driver
172  *	is not available to do it.
173  *
174  * _DONT_USE_1275_GENERIC_NAMES
175  *		Controls whether or not device tree node names should
176  *		comply with the IEEE 1275 "Generic Names" Recommended
177  *		Practice. With _DONT_USE_GENERIC_NAMES, device-specific
178  *		names identifying the particular device will be used.
179  *
180  * __i386_COMPAT
181  *	This indicates whether the i386 ABI is supported as a *non-native*
182  *	mode for the platform.  When this symbol is defined:
183  *	-	32-bit xstat-style system calls are enabled
184  *	-	32-bit xmknod-style system calls are enabled
185  *	-	32-bit system calls use i386 sizes -and- alignments
186  *
187  *	Note that this is NOT defined for the i386 native environment!
188  *
189  * __x86
190  *	This is ONLY a synonym for defined(__i386) || defined(__amd64)
191  *	which is useful only insofar as these two architectures share
192  *	common attributes.  Analogous to __sparc.
193  *
194  * _PSM_MODULES
195  *	This indicates whether or not the implementation uses PSM
196  *	modules for processor support, reading /etc/mach from inside
197  *	the kernel to extract a list.
198  *
199  * _RTC_CONFIG
200  *	This indicates whether or not the implementation uses /etc/rtc_config
201  *	to configure the real-time clock in the kernel.
202  *
203  * _UNIX_KRTLD
204  *	This indicates that the implementation uses a dynamically
205  *	linked unix + krtld to form the core kernel image at boot
206  *	time, or (in the absence of this symbol) a prelinked kernel image.
207  *
208  * _OBP
209  *	This indicates the firmware interface is OBP.
210  */
211 
212 #ifdef	__cplusplus
213 extern "C" {
214 #endif
215 
216 /*
217  * The following set of definitions characterize Solaris on AMD's
218  * 64-bit systems.
219  */
220 #if defined(__x86_64) || defined(__amd64)
221 
222 #if !defined(__amd64)
223 #define	__amd64		/* preferred guard */
224 #endif
225 
226 #if !defined(__x86)
227 #define	__x86
228 #endif
229 
230 /*
231  * Define the appropriate "processor characteristics"
232  */
233 #define	_LITTLE_ENDIAN
234 #define	_STACK_GROWS_DOWNWARD
235 #define	_LONG_LONG_LTOH
236 #define	_BIT_FIELDS_LTOH
237 #define	_IEEE_754
238 #define	_CHAR_IS_SIGNED
239 #define	_BOOL_ALIGNMENT			1
240 #define	_CHAR_ALIGNMENT			1
241 #define	_SHORT_ALIGNMENT		2
242 #define	_INT_ALIGNMENT			4
243 #define	_FLOAT_ALIGNMENT		4
244 #define	_FLOAT_COMPLEX_ALIGNMENT	4
245 #define	_LONG_ALIGNMENT			8
246 #define	_LONG_LONG_ALIGNMENT		8
247 #define	_DOUBLE_ALIGNMENT		8
248 #define	_DOUBLE_COMPLEX_ALIGNMENT	8
249 #define	_LONG_DOUBLE_ALIGNMENT		16
250 #define	_LONG_DOUBLE_COMPLEX_ALIGNMENT	16
251 #define	_POINTER_ALIGNMENT		8
252 #define	_MAX_ALIGNMENT			16
253 #define	_ALIGNMENT_REQUIRED		1
254 
255 /*
256  * Different alignment constraints for the i386 ABI in compatibility mode
257  */
258 #define	_LONG_LONG_ALIGNMENT_32		4
259 
260 /*
261  * Define the appropriate "implementation choices".
262  */
263 #if !defined(_LP64)
264 #define	_LP64
265 #endif
266 #if !defined(_I32LPx) && defined(_KERNEL)
267 #define	_I32LPx
268 #endif
269 #define	_MULTI_DATAMODEL
270 #define	_SUNOS_VTOC_16
271 #define	_DMA_USES_PHYSADDR
272 #define	_FIRMWARE_NEEDS_FDISK
273 #define	__i386_COMPAT
274 #define	_PSM_MODULES
275 #define	_RTC_CONFIG
276 #define	_DONT_USE_1275_GENERIC_NAMES
277 #define	_HAVE_CPUID_INSN
278 
279 /*
280  * The feature test macro __i386 is generic for all processors implementing
281  * the Intel 386 instruction set or a superset of it.  Specifically, this
282  * includes all members of the 386, 486, and Pentium family of processors.
283  */
284 #elif defined(__i386) || defined(__i386__)
285 
286 #if !defined(__i386)
287 #define	__i386
288 #endif
289 
290 #if !defined(__x86)
291 #define	__x86
292 #endif
293 
294 /*
295  * Define the appropriate "processor characteristics"
296  */
297 #define	_LITTLE_ENDIAN
298 #define	_STACK_GROWS_DOWNWARD
299 #define	_LONG_LONG_LTOH
300 #define	_BIT_FIELDS_LTOH
301 #define	_IEEE_754
302 #define	_CHAR_IS_SIGNED
303 #define	_BOOL_ALIGNMENT			1
304 #define	_CHAR_ALIGNMENT			1
305 #define	_SHORT_ALIGNMENT		2
306 #define	_INT_ALIGNMENT			4
307 #define	_FLOAT_ALIGNMENT		4
308 #define	_FLOAT_COMPLEX_ALIGNMENT	4
309 #define	_LONG_ALIGNMENT			4
310 #define	_LONG_LONG_ALIGNMENT		4
311 #define	_DOUBLE_ALIGNMENT		4
312 #define	_DOUBLE_COMPLEX_ALIGNMENT	4
313 #define	_LONG_DOUBLE_ALIGNMENT		4
314 #define	_LONG_DOUBLE_COMPLEX_ALIGNMENT	4
315 #define	_POINTER_ALIGNMENT		4
316 #define	_MAX_ALIGNMENT			4
317 #define	_ALIGNMENT_REQUIRED		0
318 
319 #define	_LONG_LONG_ALIGNMENT_32		_LONG_LONG_ALIGNMENT
320 
321 /*
322  * Define the appropriate "implementation choices".
323  */
324 #define	_ILP32
325 #if !defined(_I32LPx) && defined(_KERNEL)
326 #define	_I32LPx
327 #endif
328 #define	_SUNOS_VTOC_16
329 #define	_DMA_USES_PHYSADDR
330 #define	_FIRMWARE_NEEDS_FDISK
331 #define	_PSM_MODULES
332 #define	_RTC_CONFIG
333 #define	_DONT_USE_1275_GENERIC_NAMES
334 #define	_HAVE_CPUID_INSN
335 
336 /*
337  * The following set of definitions characterize the Solaris on SPARC systems.
338  *
339  * The symbol __sparc indicates any of the SPARC family of processor
340  * architectures.  This includes SPARC V7, SPARC V8 and SPARC V9.
341  *
342  * The symbol __sparcv8 indicates the 32-bit SPARC V8 architecture as defined
343  * by Version 8 of the SPARC Architecture Manual.  (SPARC V7 is close enough
344  * to SPARC V8 for the former to be subsumed into the latter definition.)
345  *
346  * The symbol __sparcv9 indicates the 64-bit SPARC V9 architecture as defined
347  * by Version 9 of the SPARC Architecture Manual.
348  *
349  * The symbols __sparcv8 and __sparcv9 are mutually exclusive, and are only
350  * relevant when the symbol __sparc is defined.
351  */
352 /*
353  * XXX Due to the existence of 5110166, "defined(__sparcv9)" needs to be added
354  * to support backwards builds.  This workaround should be removed in s10_71.
355  */
356 #elif defined(__sparc) || defined(__sparcv9) || defined(__sparc__)
357 #if !defined(__sparc)
358 #define	__sparc
359 #endif
360 
361 /*
362  * You can be 32-bit or 64-bit, but not both at the same time.
363  */
364 #if defined(__sparcv8) && defined(__sparcv9)
365 #error	"SPARC Versions 8 and 9 are mutually exclusive choices"
366 #endif
367 
368 /*
369  * Existing compilers do not set __sparcv8.  Years will transpire before
370  * the compilers can be depended on to set the feature test macro. In
371  * the interim, we'll set it here on the basis of historical behaviour;
372  * if you haven't asked for SPARC V9, then you must've meant SPARC V8.
373  */
374 #if !defined(__sparcv9) && !defined(__sparcv8)
375 #define	__sparcv8
376 #endif
377 
378 /*
379  * Define the appropriate "processor characteristics" shared between
380  * all Solaris on SPARC systems.
381  */
382 #define	_BIG_ENDIAN
383 #define	_STACK_GROWS_DOWNWARD
384 #define	_LONG_LONG_HTOL
385 #define	_BIT_FIELDS_HTOL
386 #define	_IEEE_754
387 #define	_CHAR_IS_SIGNED
388 #define	_BOOL_ALIGNMENT			1
389 #define	_CHAR_ALIGNMENT			1
390 #define	_SHORT_ALIGNMENT		2
391 #define	_INT_ALIGNMENT			4
392 #define	_FLOAT_ALIGNMENT		4
393 #define	_FLOAT_COMPLEX_ALIGNMENT	4
394 #define	_LONG_LONG_ALIGNMENT		8
395 #define	_DOUBLE_ALIGNMENT		8
396 #define	_DOUBLE_COMPLEX_ALIGNMENT	8
397 #define	_ALIGNMENT_REQUIRED		1
398 
399 /*
400  * Define the appropriate "implementation choices" shared between versions.
401  */
402 #define	_SUNOS_VTOC_8
403 #define	_DMA_USES_VIRTADDR
404 #define	_NO_FDISK_PRESENT
405 #define	_HAVE_TEM_FIRMWARE
406 #define	_OBP
407 
408 /*
409  * The following set of definitions characterize the implementation of
410  * 32-bit Solaris on SPARC V8 systems.
411  */
412 #if defined(__sparcv8)
413 
414 /*
415  * Define the appropriate "processor characteristics"
416  */
417 #define	_LONG_ALIGNMENT			4
418 #define	_LONG_DOUBLE_ALIGNMENT		8
419 #define	_LONG_DOUBLE_COMPLEX_ALIGNMENT	8
420 #define	_POINTER_ALIGNMENT		4
421 #define	_MAX_ALIGNMENT			8
422 
423 #define	_LONG_LONG_ALIGNMENT_32		_LONG_LONG_ALIGNMENT
424 
425 /*
426  * Define the appropriate "implementation choices"
427  */
428 #define	_ILP32
429 #if !defined(_I32LPx) && defined(_KERNEL)
430 #define	_I32LPx
431 #endif
432 
433 /*
434  * The following set of definitions characterize the implementation of
435  * 64-bit Solaris on SPARC V9 systems.
436  */
437 #elif defined(__sparcv9)
438 
439 /*
440  * Define the appropriate "processor characteristics"
441  */
442 #define	_LONG_ALIGNMENT			8
443 #define	_LONG_DOUBLE_ALIGNMENT		16
444 #define	_LONG_DOUBLE_COMPLEX_ALIGNMENT	16
445 #define	_POINTER_ALIGNMENT		8
446 #define	_MAX_ALIGNMENT			16
447 
448 #define	_LONG_LONG_ALIGNMENT_32		_LONG_LONG_ALIGNMENT
449 
450 /*
451  * Define the appropriate "implementation choices"
452  */
453 #if !defined(_LP64)
454 #define	_LP64
455 #endif
456 #if !defined(_I32LPx)
457 #define	_I32LPx
458 #endif
459 #define	_MULTI_DATAMODEL
460 
461 #else
462 #error	"unknown SPARC version"
463 #endif
464 
465 /*
466  * #error is strictly ansi-C, but works as well as anything for K&R systems.
467  */
468 #else
469 #error "ISA not supported"
470 #endif
471 
472 #if defined(_ILP32) && defined(_LP64)
473 #error "Both _ILP32 and _LP64 are defined"
474 #endif
475 
476 #ifdef	__cplusplus
477 }
478 #endif
479 
480 #endif	/* _SYS_ISA_DEFS_H */
481