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