diff --git a/include/os/freebsd/spl/sys/isa_defs.h b/include/os/freebsd/spl/sys/isa_defs.h index 817521cc2cb9..9eba593fa797 100644 --- a/include/os/freebsd/spl/sys/isa_defs.h +++ b/include/os/freebsd/spl/sys/isa_defs.h @@ -1,712 +1,297 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #ifndef _SYS_ISA_DEFS_H #define _SYS_ISA_DEFS_H #include /* * This header file serves to group a set of well known defines and to * set these for each instruction set architecture. These defines may * be divided into two groups; characteristics of the processor and * implementation choices for Solaris on a processor. * * Processor Characteristics: * * _LITTLE_ENDIAN / _BIG_ENDIAN: * The natural byte order of the processor. A pointer to an int points * to the least/most significant byte of that int. * - * _STACK_GROWS_UPWARD / _STACK_GROWS_DOWNWARD: - * The processor specific direction of stack growth. A push onto the - * stack increases/decreases the stack pointer, so it stores data at - * successively higher/lower addresses. (Stackless machines ignored - * without regrets). - * - * _LONG_LONG_HTOL / _LONG_LONG_LTOH: - * A pointer to a long long points to the most/least significant long - * within that long long. - * - * _BIT_FIELDS_HTOL / _BIT_FIELDS_LTOH: - * The C compiler assigns bit fields from the high/low to the low/high end - * of an int (most to least significant vs. least to most significant). - * - * _IEEE_754: - * The processor (or supported implementations of the processor) - * supports the ieee-754 floating point standard. No other floating - * point standards are supported (or significant). Any other supported - * floating point formats are expected to be cased on the ISA processor - * symbol. - * - * _CHAR_IS_UNSIGNED / _CHAR_IS_SIGNED: - * The C Compiler implements objects of type `char' as `unsigned' or - * `signed' respectively. This is really an implementation choice of - * the compiler writer, but it is specified in the ABI and tends to - * be uniform across compilers for an instruction set architecture. - * Hence, it has the properties of a processor characteristic. - * - * _CHAR_ALIGNMENT / _SHORT_ALIGNMENT / _INT_ALIGNMENT / _LONG_ALIGNMENT / - * _LONG_LONG_ALIGNMENT / _DOUBLE_ALIGNMENT / _LONG_DOUBLE_ALIGNMENT / - * _POINTER_ALIGNMENT / _FLOAT_ALIGNMENT: - * The ABI defines alignment requirements of each of the primitive - * object types. Some, if not all, may be hardware requirements as - * well. The values are expressed in "byte-alignment" units. - * - * _MAX_ALIGNMENT: - * The most stringent alignment requirement as specified by the ABI. - * Equal to the maximum of all the above _XXX_ALIGNMENT values. - * - * _ALIGNMENT_REQUIRED: - * True or false (1 or 0) whether or not the hardware requires the ABI - * alignment. - * - * _LONG_LONG_ALIGNMENT_32 - * The 32-bit ABI supported by a 64-bit kernel may have different - * alignment requirements for primitive object types. The value of this - * identifier is expressed in "byte-alignment" units. - * - * _HAVE_CPUID_INSN - * This indicates that the architecture supports the 'cpuid' - * instruction as defined by Intel. (Intel allows other vendors - * to extend the instruction for their own purposes.) - * * * Implementation Choices: * * _ILP32 / _LP64: * This specifies the compiler data type implementation as specified in * the relevant ABI. The choice between these is strongly influenced * by the underlying hardware, but is not absolutely tied to it. * Currently only two data type models are supported: * * _ILP32: * Int/Long/Pointer are 32 bits. This is the historical UNIX * and Solaris implementation. Due to its historical standing, * this is the default case. * * _LP64: * Long/Pointer are 64 bits, Int is 32 bits. This is the chosen * implementation for 64-bit ABIs such as SPARC V9. * - * _I32LPx: - * A compilation environment where 'int' is 32-bit, and - * longs and pointers are simply the same size. - * * In all cases, Char is 8 bits and Short is 16 bits. * * _SUNOS_VTOC_8 / _SUNOS_VTOC_16 / _SVR4_VTOC_16: * This specifies the form of the disk VTOC (or label): * * _SUNOS_VTOC_8: * This is a VTOC form which is upwardly compatible with the * SunOS 4.x disk label and allows 8 partitions per disk. * * _SUNOS_VTOC_16: * In this format the incore vtoc image matches the ondisk * version. It allows 16 slices per disk, and is not * compatible with the SunOS 4.x disk label. * * Note that these are not the only two VTOC forms possible and * additional forms may be added. One possible form would be the * SVr4 VTOC form. The symbol for that is reserved now, although * it is not implemented. * * _SVR4_VTOC_16: * This VTOC form is compatible with the System V Release 4 * VTOC (as implemented on the SVr4 Intel and 3b ports) with * 16 partitions per disk. * * - * _DMA_USES_PHYSADDR / _DMA_USES_VIRTADDR - * This describes the type of addresses used by system DMA: - * - * _DMA_USES_PHYSADDR: - * This type of DMA, used in the x86 implementation, - * requires physical addresses for DMA buffers. The 24-bit - * addresses used by some legacy boards is the source of the - * "low-memory" (<16MB) requirement for some devices using DMA. - * - * _DMA_USES_VIRTADDR: - * This method of DMA allows the use of virtual addresses for - * DMA transfers. - * - * _FIRMWARE_NEEDS_FDISK / _NO_FDISK_PRESENT - * This indicates the presence/absence of an fdisk table. - * - * _FIRMWARE_NEEDS_FDISK - * The fdisk table is required by system firmware. If present, - * it allows a disk to be subdivided into multiple fdisk - * partitions, each of which is equivalent to a separate, - * virtual disk. This enables the co-existence of multiple - * operating systems on a shared hard disk. - * - * _NO_FDISK_PRESENT - * If the fdisk table is absent, it is assumed that the entire - * media is allocated for a single operating system. - * - * _HAVE_TEM_FIRMWARE - * Defined if this architecture has the (fallback) option of - * using prom_* calls for doing I/O if a suitable kernel driver - * is not available to do it. - * - * _DONT_USE_1275_GENERIC_NAMES - * Controls whether or not device tree node names should - * comply with the IEEE 1275 "Generic Names" Recommended - * Practice. With _DONT_USE_GENERIC_NAMES, device-specific - * names identifying the particular device will be used. - * - * __i386_COMPAT - * This indicates whether the i386 ABI is supported as a *non-native* - * mode for the platform. When this symbol is defined: - * - 32-bit xstat-style system calls are enabled - * - 32-bit xmknod-style system calls are enabled - * - 32-bit system calls use i386 sizes -and- alignments - * - * Note that this is NOT defined for the i386 native environment! - * * __x86 * This is ONLY a synonym for defined(__i386) || defined(__amd64) * which is useful only insofar as these two architectures share * common attributes. Analogous to __sparc. - * - * _PSM_MODULES - * This indicates whether or not the implementation uses PSM - * modules for processor support, reading /etc/mach from inside - * the kernel to extract a list. - * - * _RTC_CONFIG - * This indicates whether or not the implementation uses /etc/rtc_config - * to configure the real-time clock in the kernel. - * - * _UNIX_KRTLD - * This indicates that the implementation uses a dynamically - * linked unix + krtld to form the core kernel image at boot - * time, or (in the absence of this symbol) a prelinked kernel image. - * - * _OBP - * This indicates the firmware interface is OBP. - * - * _SOFT_HOSTID - * This indicates that the implementation obtains the hostid - * from the file /etc/hostid, rather than from hardware. */ #ifdef __cplusplus extern "C" { #endif /* * The following set of definitions characterize Solaris on AMD's * 64-bit systems. */ #if defined(__x86_64) || defined(__amd64) #if !defined(__amd64) #define __amd64 /* preferred guard */ #endif #if !defined(__x86) #define __x86 #endif -/* - * Define the appropriate "processor characteristics" - */ -#define _STACK_GROWS_DOWNWARD -#define _LONG_LONG_LTOH -#define _BIT_FIELDS_LTOH -#define _IEEE_754 -#define _CHAR_IS_SIGNED -#define _BOOL_ALIGNMENT 1 -#define _CHAR_ALIGNMENT 1 -#define _SHORT_ALIGNMENT 2 -#define _INT_ALIGNMENT 4 -#define _FLOAT_ALIGNMENT 4 -#define _FLOAT_COMPLEX_ALIGNMENT 4 -#define _LONG_ALIGNMENT 8 -#define _LONG_LONG_ALIGNMENT 8 -#define _DOUBLE_ALIGNMENT 8 -#define _DOUBLE_COMPLEX_ALIGNMENT 8 -#define _LONG_DOUBLE_ALIGNMENT 16 -#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 16 -#define _POINTER_ALIGNMENT 8 -#define _MAX_ALIGNMENT 16 -#define _ALIGNMENT_REQUIRED 1 - -/* - * Different alignment constraints for the i386 ABI in compatibility mode - */ -#define _LONG_LONG_ALIGNMENT_32 4 - /* * Define the appropriate "implementation choices". */ #if !defined(_LP64) #error "_LP64 not defined" #endif -#if !defined(_I32LPx) -#define _I32LPx -#endif -#define _MULTI_DATAMODEL #define _SUNOS_VTOC_16 -#define _DMA_USES_PHYSADDR -#define _FIRMWARE_NEEDS_FDISK -#define __i386_COMPAT -#define _PSM_MODULES -#define _RTC_CONFIG -#define _SOFT_HOSTID -#define _DONT_USE_1275_GENERIC_NAMES -#define _HAVE_CPUID_INSN /* * The feature test macro __i386 is generic for all processors implementing * the Intel 386 instruction set or a superset of it. Specifically, this * includes all members of the 386, 486, and Pentium family of processors. */ #elif defined(__i386) || defined(__i386__) #if !defined(__i386) #define __i386 #endif #if !defined(__x86) #define __x86 #endif -/* - * Define the appropriate "processor characteristics" - */ -#define _STACK_GROWS_DOWNWARD -#define _LONG_LONG_LTOH -#define _BIT_FIELDS_LTOH -#define _IEEE_754 -#define _CHAR_IS_SIGNED -#define _BOOL_ALIGNMENT 1 -#define _CHAR_ALIGNMENT 1 -#define _SHORT_ALIGNMENT 2 -#define _INT_ALIGNMENT 4 -#define _FLOAT_ALIGNMENT 4 -#define _FLOAT_COMPLEX_ALIGNMENT 4 -#define _LONG_ALIGNMENT 4 -#define _LONG_LONG_ALIGNMENT 4 -#define _DOUBLE_ALIGNMENT 4 -#define _DOUBLE_COMPLEX_ALIGNMENT 4 -#define _LONG_DOUBLE_ALIGNMENT 4 -#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 4 -#define _POINTER_ALIGNMENT 4 -#define _MAX_ALIGNMENT 4 -#define _ALIGNMENT_REQUIRED 0 - -#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT - /* * Define the appropriate "implementation choices". */ #if !defined(_ILP32) #define _ILP32 #endif -#if !defined(_I32LPx) -#define _I32LPx -#endif #define _SUNOS_VTOC_16 -#define _DMA_USES_PHYSADDR -#define _FIRMWARE_NEEDS_FDISK -#define _PSM_MODULES -#define _RTC_CONFIG -#define _SOFT_HOSTID -#define _DONT_USE_1275_GENERIC_NAMES -#define _HAVE_CPUID_INSN #elif defined(__aarch64__) -/* - * Define the appropriate "processor characteristics" - */ -#define _STACK_GROWS_DOWNWARD -#define _LONG_LONG_LTOH -#define _BIT_FIELDS_LTOH -#define _IEEE_754 -#define _CHAR_IS_UNSIGNED -#define _BOOL_ALIGNMENT 1 -#define _CHAR_ALIGNMENT 1 -#define _SHORT_ALIGNMENT 2 -#define _INT_ALIGNMENT 4 -#define _FLOAT_ALIGNMENT 4 -#define _FLOAT_COMPLEX_ALIGNMENT 4 -#define _LONG_ALIGNMENT 8 -#define _LONG_LONG_ALIGNMENT 8 -#define _DOUBLE_ALIGNMENT 8 -#define _DOUBLE_COMPLEX_ALIGNMENT 8 -#define _LONG_DOUBLE_ALIGNMENT 16 -#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 16 -#define _POINTER_ALIGNMENT 8 -#define _MAX_ALIGNMENT 16 -#define _ALIGNMENT_REQUIRED 1 - -#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT - /* * Define the appropriate "implementation choices" */ #if !defined(_LP64) #error "_LP64 not defined" #endif #define _SUNOS_VTOC_16 -#define _DMA_USES_PHYSADDR -#define _FIRMWARE_NEEDS_FDISK -#define _PSM_MODULES -#define _RTC_CONFIG -#define _DONT_USE_1275_GENERIC_NAMES -#define _HAVE_CPUID_INSN #elif defined(__riscv) -/* - * Define the appropriate "processor characteristics" - */ -#define _STACK_GROWS_DOWNWARD -#define _LONG_LONG_LTOH -#define _BIT_FIELDS_LTOH -#define _IEEE_754 -#define _CHAR_IS_UNSIGNED -#define _BOOL_ALIGNMENT 1 -#define _CHAR_ALIGNMENT 1 -#define _SHORT_ALIGNMENT 2 -#define _INT_ALIGNMENT 4 -#define _FLOAT_ALIGNMENT 4 -#define _FLOAT_COMPLEX_ALIGNMENT 4 -#define _LONG_ALIGNMENT 8 -#define _LONG_LONG_ALIGNMENT 8 -#define _DOUBLE_ALIGNMENT 8 -#define _DOUBLE_COMPLEX_ALIGNMENT 8 -#define _LONG_DOUBLE_ALIGNMENT 16 -#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 16 -#define _POINTER_ALIGNMENT 8 -#define _MAX_ALIGNMENT 16 -#define _ALIGNMENT_REQUIRED 1 - -#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT - /* * Define the appropriate "implementation choices" */ #if !defined(_LP64) #define _LP64 #endif #define _SUNOS_VTOC_16 -#define _DMA_USES_PHYSADDR -#define _FIRMWARE_NEEDS_FDISK -#define _PSM_MODULES -#define _RTC_CONFIG -#define _DONT_USE_1275_GENERIC_NAMES -#define _HAVE_CPUID_INSN #elif defined(__arm__) -/* - * Define the appropriate "processor characteristics" - */ -#define _STACK_GROWS_DOWNWARD -#define _LONG_LONG_LTOH -#define _BIT_FIELDS_LTOH -#define _IEEE_754 -#define _CHAR_IS_SIGNED -#define _BOOL_ALIGNMENT 1 -#define _CHAR_ALIGNMENT 1 -#define _SHORT_ALIGNMENT 2 -#define _INT_ALIGNMENT 4 -#define _FLOAT_ALIGNMENT 4 -#define _FLOAT_COMPLEX_ALIGNMENT 4 -#define _LONG_ALIGNMENT 4 -#define _LONG_LONG_ALIGNMENT 4 -#define _DOUBLE_ALIGNMENT 4 -#define _DOUBLE_COMPLEX_ALIGNMENT 4 -#define _LONG_DOUBLE_ALIGNMENT 4 -#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 4 -#define _POINTER_ALIGNMENT 4 -#define _MAX_ALIGNMENT 4 -#define _ALIGNMENT_REQUIRED 0 - -#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT - /* * Define the appropriate "implementation choices". */ #if !defined(_ILP32) #define _ILP32 #endif -#if !defined(_I32LPx) -#define _I32LPx -#endif #define _SUNOS_VTOC_16 -#define _DMA_USES_PHYSADDR -#define _FIRMWARE_NEEDS_FDISK -#define _PSM_MODULES -#define _RTC_CONFIG -#define _DONT_USE_1275_GENERIC_NAMES -#define _HAVE_CPUID_INSN #elif defined(__mips__) -/* - * Define the appropriate "processor characteristics" - */ -#define _STACK_GROWS_DOWNWARD -#define _LONG_LONG_LTOH -#define _BIT_FIELDS_LTOH -#define _IEEE_754 -#define _CHAR_IS_SIGNED -#define _BOOL_ALIGNMENT 1 -#define _CHAR_ALIGNMENT 1 -#define _SHORT_ALIGNMENT 2 -#define _INT_ALIGNMENT 4 -#define _FLOAT_ALIGNMENT 4 -#define _FLOAT_COMPLEX_ALIGNMENT 4 #if defined(__mips_n64) -#define _LONG_ALIGNMENT 8 -#define _LONG_LONG_ALIGNMENT 8 -#define _DOUBLE_ALIGNMENT 8 -#define _DOUBLE_COMPLEX_ALIGNMENT 8 -#define _LONG_DOUBLE_ALIGNMENT 8 -#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 8 -#define _POINTER_ALIGNMENT 8 -#define _MAX_ALIGNMENT 8 -#define _ALIGNMENT_REQUIRED 0 - -#define _LONG_LONG_ALIGNMENT_32 _INT_ALIGNMENT /* * Define the appropriate "implementation choices". */ #if !defined(_LP64) #error "_LP64 not defined" #endif #else -#define _LONG_ALIGNMENT 4 -#define _LONG_LONG_ALIGNMENT 4 -#define _DOUBLE_ALIGNMENT 4 -#define _DOUBLE_COMPLEX_ALIGNMENT 4 -#define _LONG_DOUBLE_ALIGNMENT 4 -#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 4 -#define _POINTER_ALIGNMENT 4 -#define _MAX_ALIGNMENT 4 -#define _ALIGNMENT_REQUIRED 0 - -#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT - /* * Define the appropriate "implementation choices". */ #if !defined(_ILP32) #define _ILP32 #endif -#if !defined(_I32LPx) -#define _I32LPx -#endif #endif #define _SUNOS_VTOC_16 -#define _DMA_USES_PHYSADDR -#define _FIRMWARE_NEEDS_FDISK -#define _PSM_MODULES -#define _RTC_CONFIG -#define _DONT_USE_1275_GENERIC_NAMES -#define _HAVE_CPUID_INSN #elif defined(__powerpc__) -#if defined(__BIG_ENDIAN__) -#define _BIT_FIELDS_HTOL -#else -#define _BIT_FIELDS_LTOH -#endif - #if !defined(__powerpc) #define __powerpc #endif -#if defined(__powerpc64__) -#define _LONG_LONG_ALIGNMENT 8 -#define _MULTI_DATAMODEL -#else -#define _LONG_LONG_ALIGNMENT 4 -#endif -#define _LONG_LONG_ALIGNMENT_32 4 -#define _ALIGNMENT_REQUIRED 1 - #define _SUNOS_VTOC_16 1 /* * The following set of definitions characterize the Solaris on SPARC systems. * * The symbol __sparc indicates any of the SPARC family of processor * architectures. This includes SPARC V7, SPARC V8 and SPARC V9. * * The symbol __sparcv8 indicates the 32-bit SPARC V8 architecture as defined * by Version 8 of the SPARC Architecture Manual. (SPARC V7 is close enough * to SPARC V8 for the former to be subsumed into the latter definition.) * * The symbol __sparcv9 indicates the 64-bit SPARC V9 architecture as defined * by Version 9 of the SPARC Architecture Manual. * * The symbols __sparcv8 and __sparcv9 are mutually exclusive, and are only * relevant when the symbol __sparc is defined. */ /* * XXX Due to the existence of 5110166, "defined(__sparcv9)" needs to be added * to support backwards builds. This workaround should be removed in s10_71. */ #elif defined(__sparc) || defined(__sparcv9) || defined(__sparc__) #if !defined(__sparc) #define __sparc #endif /* * You can be 32-bit or 64-bit, but not both at the same time. */ #if defined(__sparcv8) && defined(__sparcv9) #error "SPARC Versions 8 and 9 are mutually exclusive choices" #endif /* * Existing compilers do not set __sparcv8. Years will transpire before * the compilers can be depended on to set the feature test macro. In * the interim, we'll set it here on the basis of historical behaviour; * if you haven't asked for SPARC V9, then you must've meant SPARC V8. */ #if !defined(__sparcv9) && !defined(__sparcv8) #define __sparcv8 #endif -/* - * Define the appropriate "processor characteristics" shared between - * all Solaris on SPARC systems. - */ -#define _STACK_GROWS_DOWNWARD -#define _LONG_LONG_HTOL -#define _BIT_FIELDS_HTOL -#define _IEEE_754 -#define _CHAR_IS_SIGNED -#define _BOOL_ALIGNMENT 1 -#define _CHAR_ALIGNMENT 1 -#define _SHORT_ALIGNMENT 2 -#define _INT_ALIGNMENT 4 -#define _FLOAT_ALIGNMENT 4 -#define _FLOAT_COMPLEX_ALIGNMENT 4 -#define _LONG_LONG_ALIGNMENT 8 -#define _DOUBLE_ALIGNMENT 8 -#define _DOUBLE_COMPLEX_ALIGNMENT 8 -#define _ALIGNMENT_REQUIRED 1 - /* * Define the appropriate "implementation choices" shared between versions. */ #define _SUNOS_VTOC_8 -#define _DMA_USES_VIRTADDR -#define _NO_FDISK_PRESENT -#define _HAVE_TEM_FIRMWARE -#define _OBP /* * The following set of definitions characterize the implementation of * 32-bit Solaris on SPARC V8 systems. */ #if defined(__sparcv8) -/* - * Define the appropriate "processor characteristics" - */ -#define _LONG_ALIGNMENT 4 -#define _LONG_DOUBLE_ALIGNMENT 8 -#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 8 -#define _POINTER_ALIGNMENT 4 -#define _MAX_ALIGNMENT 8 - -#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT - /* * Define the appropriate "implementation choices" */ #define _ILP32 -#if !defined(_I32LPx) -#define _I32LPx -#endif /* * The following set of definitions characterize the implementation of * 64-bit Solaris on SPARC V9 systems. */ #elif defined(__sparcv9) -/* - * Define the appropriate "processor characteristics" - */ -#define _LONG_ALIGNMENT 8 -#define _LONG_DOUBLE_ALIGNMENT 16 -#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 16 -#define _POINTER_ALIGNMENT 8 -#define _MAX_ALIGNMENT 16 - -#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT - /* * Define the appropriate "implementation choices" */ #if !defined(_LP64) #error "_LP64 not defined" #endif -#if !defined(_I32LPx) -#define _I32LPx -#endif -#define _MULTI_DATAMODEL #else #error "unknown SPARC version" #endif /* * #error is strictly ansi-C, but works as well as anything for K&R systems. */ #else #error "ISA not supported" #endif #if defined(_ILP32) && defined(_LP64) #error "Both _ILP32 and _LP64 are defined" #endif #if BYTE_ORDER == _BIG_ENDIAN #define _ZFS_BIG_ENDIAN #elif BYTE_ORDER == _LITTLE_ENDIAN #define _ZFS_LITTLE_ENDIAN #else #error "unknown byte order" #endif #ifdef __cplusplus } #endif #endif /* _SYS_ISA_DEFS_H */ diff --git a/include/os/freebsd/spl/sys/sysmacros.h b/include/os/freebsd/spl/sys/sysmacros.h index 1c8475a7092c..3e8841ae66bd 100644 --- a/include/os/freebsd/spl/sys/sysmacros.h +++ b/include/os/freebsd/spl/sys/sysmacros.h @@ -1,410 +1,370 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #ifndef _SYS_SYSMACROS_H #define _SYS_SYSMACROS_H #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif /* * Some macros for units conversion */ /* * Disk blocks (sectors) and bytes. */ #define dtob(DD) ((DD) << DEV_BSHIFT) #define btod(BB) (((BB) + DEV_BSIZE - 1) >> DEV_BSHIFT) #define btodt(BB) ((BB) >> DEV_BSHIFT) #define lbtod(BB) (((offset_t)(BB) + DEV_BSIZE - 1) >> DEV_BSHIFT) /* common macros */ #ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif #ifndef MAX #define MAX(a, b) ((a) < (b) ? (b) : (a)) #endif #ifndef ABS #define ABS(a) ((a) < 0 ? -(a) : (a)) #endif #ifndef SIGNOF #define SIGNOF(a) ((a) < 0 ? -1 : (a) > 0) #endif #ifndef ARRAY_SIZE #define ARRAY_SIZE(a) (sizeof (a) / sizeof (a[0])) #endif #ifndef DIV_ROUND_UP #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) #endif #ifdef _STANDALONE #define boot_ncpus 1 #else /* _STANDALONE */ #define boot_ncpus mp_ncpus #endif /* _STANDALONE */ #define kpreempt_disable() critical_enter() #define kpreempt_enable() critical_exit() #define CPU_SEQID curcpu #define CPU_SEQID_UNSTABLE curcpu #define is_system_labeled() 0 /* * Convert a single byte to/from binary-coded decimal (BCD). */ extern unsigned char byte_to_bcd[256]; extern unsigned char bcd_to_byte[256]; #define BYTE_TO_BCD(x) byte_to_bcd[(x) & 0xff] #define BCD_TO_BYTE(x) bcd_to_byte[(x) & 0xff] /* * WARNING: The device number macros defined here should not be used by device * drivers or user software. Device drivers should use the device functions * defined in the DDI/DKI interface (see also ddi.h). Application software * should make use of the library routines available in makedev(3). A set of * new device macros are provided to operate on the expanded device number * format supported in SVR4. Macro versions of the DDI device functions are * provided for use by kernel proper routines only. Macro routines bmajor(), * major(), minor(), emajor(), eminor(), and makedev() will be removed or * their definitions changed at the next major release following SVR4. */ #define O_BITSMAJOR 7 /* # of SVR3 major device bits */ #define O_BITSMINOR 8 /* # of SVR3 minor device bits */ #define O_MAXMAJ 0x7f /* SVR3 max major value */ #define O_MAXMIN 0xff /* SVR3 max minor value */ #define L_BITSMAJOR32 14 /* # of SVR4 major device bits */ #define L_BITSMINOR32 18 /* # of SVR4 minor device bits */ #define L_MAXMAJ32 0x3fff /* SVR4 max major value */ #define L_MAXMIN32 0x3ffff /* MAX minor for 3b2 software drivers. */ /* For 3b2 hardware devices the minor is */ /* restricted to 256 (0-255) */ #ifdef _LP64 #define L_BITSMAJOR 32 /* # of major device bits in 64-bit Solaris */ #define L_BITSMINOR 32 /* # of minor device bits in 64-bit Solaris */ #define L_MAXMAJ 0xfffffffful /* max major value */ #define L_MAXMIN 0xfffffffful /* max minor value */ #else #define L_BITSMAJOR L_BITSMAJOR32 #define L_BITSMINOR L_BITSMINOR32 #define L_MAXMAJ L_MAXMAJ32 #define L_MAXMIN L_MAXMIN32 #endif /* * These are versions of the kernel routines for compressing and * expanding long device numbers that don't return errors. */ #if (L_BITSMAJOR32 == L_BITSMAJOR) && (L_BITSMINOR32 == L_BITSMINOR) #define DEVCMPL(x) (x) #define DEVEXPL(x) (x) #else #define DEVCMPL(x) \ (dev32_t)((((x) >> L_BITSMINOR) > L_MAXMAJ32 || \ ((x) & L_MAXMIN) > L_MAXMIN32) ? NODEV32 : \ ((((x) >> L_BITSMINOR) << L_BITSMINOR32) | ((x) & L_MAXMIN32))) #define DEVEXPL(x) \ (((x) == NODEV32) ? NODEV : \ makedevice(((x) >> L_BITSMINOR32) & L_MAXMAJ32, (x) & L_MAXMIN32)) #endif /* L_BITSMAJOR32 ... */ /* convert to old (SVR3.2) dev format */ #define cmpdev(x) \ (o_dev_t)((((x) >> L_BITSMINOR) > O_MAXMAJ || \ ((x) & L_MAXMIN) > O_MAXMIN) ? NODEV : \ ((((x) >> L_BITSMINOR) << O_BITSMINOR) | ((x) & O_MAXMIN))) /* convert to new (SVR4) dev format */ #define expdev(x) \ (dev_t)(((dev_t)(((x) >> O_BITSMINOR) & O_MAXMAJ) << L_BITSMINOR) | \ ((x) & O_MAXMIN)) /* * Macro for checking power of 2 address alignment. */ #define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0) /* * Macros for counting and rounding. */ #define howmany(x, y) (((x)+((y)-1))/(y)) #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* * Macro to determine if value is a power of 2 */ #define ISP2(x) (((x) & ((x) - 1)) == 0) /* * Macros for various sorts of alignment and rounding. The "align" must * be a power of 2. Often times it is a block, sector, or page. */ /* * return x rounded down to an align boundary * eg, P2ALIGN(1200, 1024) == 1024 (1*align) * eg, P2ALIGN(1024, 1024) == 1024 (1*align) * eg, P2ALIGN(0x1234, 0x100) == 0x1200 (0x12*align) * eg, P2ALIGN(0x5600, 0x100) == 0x5600 (0x56*align) */ #define P2ALIGN(x, align) ((x) & -(align)) /* * return x % (mod) align * eg, P2PHASE(0x1234, 0x100) == 0x34 (x-0x12*align) * eg, P2PHASE(0x5600, 0x100) == 0x00 (x-0x56*align) */ #define P2PHASE(x, align) ((x) & ((align) - 1)) /* * return how much space is left in this block (but if it's perfectly * aligned, return 0). * eg, P2NPHASE(0x1234, 0x100) == 0xcc (0x13*align-x) * eg, P2NPHASE(0x5600, 0x100) == 0x00 (0x56*align-x) */ #define P2NPHASE(x, align) (-(x) & ((align) - 1)) /* * return x rounded up to an align boundary * eg, P2ROUNDUP(0x1234, 0x100) == 0x1300 (0x13*align) * eg, P2ROUNDUP(0x5600, 0x100) == 0x5600 (0x56*align) */ #define P2ROUNDUP(x, align) (-(-(x) & -(align))) /* * return the ending address of the block that x is in * eg, P2END(0x1234, 0x100) == 0x12ff (0x13*align - 1) * eg, P2END(0x5600, 0x100) == 0x56ff (0x57*align - 1) */ #define P2END(x, align) (-(~(x) & -(align))) /* * return x rounded up to the next phase (offset) within align. * phase should be < align. * eg, P2PHASEUP(0x1234, 0x100, 0x10) == 0x1310 (0x13*align + phase) * eg, P2PHASEUP(0x5600, 0x100, 0x10) == 0x5610 (0x56*align + phase) */ #define P2PHASEUP(x, align, phase) ((phase) - (((phase) - (x)) & -(align))) /* * return TRUE if adding len to off would cause it to cross an align * boundary. * eg, P2BOUNDARY(0x1234, 0xe0, 0x100) == TRUE (0x1234 + 0xe0 == 0x1314) * eg, P2BOUNDARY(0x1234, 0x50, 0x100) == FALSE (0x1234 + 0x50 == 0x1284) */ #define P2BOUNDARY(off, len, align) \ (((off) ^ ((off) + (len) - 1)) > (align) - 1) /* * Return TRUE if they have the same highest bit set. * eg, P2SAMEHIGHBIT(0x1234, 0x1001) == TRUE (the high bit is 0x1000) * eg, P2SAMEHIGHBIT(0x1234, 0x3010) == FALSE (high bit of 0x3010 is 0x2000) */ #define P2SAMEHIGHBIT(x, y) (((x) ^ (y)) < ((x) & (y))) /* * Typed version of the P2* macros. These macros should be used to ensure * that the result is correctly calculated based on the data type of (x), * which is passed in as the last argument, regardless of the data * type of the alignment. For example, if (x) is of type uint64_t, * and we want to round it up to a page boundary using "PAGESIZE" as * the alignment, we can do either * P2ROUNDUP(x, (uint64_t)PAGESIZE) * or * P2ROUNDUP_TYPED(x, PAGESIZE, uint64_t) */ #define P2ALIGN_TYPED(x, align, type) \ ((type)(x) & -(type)(align)) #define P2PHASE_TYPED(x, align, type) \ ((type)(x) & ((type)(align) - 1)) #define P2NPHASE_TYPED(x, align, type) \ (-(type)(x) & ((type)(align) - 1)) #define P2ROUNDUP_TYPED(x, align, type) \ (-(-(type)(x) & -(type)(align))) #define P2END_TYPED(x, align, type) \ (-(~(type)(x) & -(type)(align))) #define P2PHASEUP_TYPED(x, align, phase, type) \ ((type)(phase) - (((type)(phase) - (type)(x)) & -(type)(align))) #define P2CROSS_TYPED(x, y, align, type) \ (((type)(x) ^ (type)(y)) > (type)(align) - 1) #define P2SAMEHIGHBIT_TYPED(x, y, type) \ (((type)(x) ^ (type)(y)) < ((type)(x) & (type)(y))) /* * Macros to atomically increment/decrement a variable. mutex and var * must be pointers. */ #define INCR_COUNT(var, mutex) mutex_enter(mutex), (*(var))++, mutex_exit(mutex) #define DECR_COUNT(var, mutex) mutex_enter(mutex), (*(var))--, mutex_exit(mutex) -/* - * Macros to declare bitfields - the order in the parameter list is - * Low to High - that is, declare bit 0 first. We only support 8-bit bitfields - * because if a field crosses a byte boundary it's not likely to be meaningful - * without reassembly in its nonnative endianness. - */ -#if defined(_BIT_FIELDS_LTOH) -#define DECL_BITFIELD2(_a, _b) \ - uint8_t _a, _b -#define DECL_BITFIELD3(_a, _b, _c) \ - uint8_t _a, _b, _c -#define DECL_BITFIELD4(_a, _b, _c, _d) \ - uint8_t _a, _b, _c, _d -#define DECL_BITFIELD5(_a, _b, _c, _d, _e) \ - uint8_t _a, _b, _c, _d, _e -#define DECL_BITFIELD6(_a, _b, _c, _d, _e, _f) \ - uint8_t _a, _b, _c, _d, _e, _f -#define DECL_BITFIELD7(_a, _b, _c, _d, _e, _f, _g) \ - uint8_t _a, _b, _c, _d, _e, _f, _g -#define DECL_BITFIELD8(_a, _b, _c, _d, _e, _f, _g, _h) \ - uint8_t _a, _b, _c, _d, _e, _f, _g, _h -#elif defined(_BIT_FIELDS_HTOL) -#define DECL_BITFIELD2(_a, _b) \ - uint8_t _b, _a -#define DECL_BITFIELD3(_a, _b, _c) \ - uint8_t _c, _b, _a -#define DECL_BITFIELD4(_a, _b, _c, _d) \ - uint8_t _d, _c, _b, _a -#define DECL_BITFIELD5(_a, _b, _c, _d, _e) \ - uint8_t _e, _d, _c, _b, _a -#define DECL_BITFIELD6(_a, _b, _c, _d, _e, _f) \ - uint8_t _f, _e, _d, _c, _b, _a -#define DECL_BITFIELD7(_a, _b, _c, _d, _e, _f, _g) \ - uint8_t _g, _f, _e, _d, _c, _b, _a -#define DECL_BITFIELD8(_a, _b, _c, _d, _e, _f, _g, _h) \ - uint8_t _h, _g, _f, _e, _d, _c, _b, _a -#else -#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined -#endif /* _BIT_FIELDS_LTOH */ - #if !defined(_KMEMUSER) && !defined(offsetof) /* avoid any possibility of clashing with version */ #define offsetof(type, field) __offsetof(type, field) #endif /* * Find highest one bit set. * Returns bit number + 1 of highest bit that is set, otherwise returns 0. * High order bit is 31 (or 63 in _LP64 kernel). */ static __inline int highbit(ulong_t i) { #if defined(HAVE_INLINE_FLSL) return (flsl(i)); #else int h = 1; if (i == 0) return (0); #ifdef _LP64 if (i & 0xffffffff00000000ul) { h += 32; i >>= 32; } #endif if (i & 0xffff0000) { h += 16; i >>= 16; } if (i & 0xff00) { h += 8; i >>= 8; } if (i & 0xf0) { h += 4; i >>= 4; } if (i & 0xc) { h += 2; i >>= 2; } if (i & 0x2) { h += 1; } return (h); #endif } /* * Find highest one bit set. * Returns bit number + 1 of highest bit that is set, otherwise returns 0. */ static __inline int highbit64(uint64_t i) { #if defined(HAVE_INLINE_FLSLL) return (flsll(i)); #else int h = 1; if (i == 0) return (0); if (i & 0xffffffff00000000ULL) { h += 32; i >>= 32; } if (i & 0xffff0000) { h += 16; i >>= 16; } if (i & 0xff00) { h += 8; i >>= 8; } if (i & 0xf0) { h += 4; i >>= 4; } if (i & 0xc) { h += 2; i >>= 2; } if (i & 0x2) { h += 1; } return (h); #endif } #ifdef __cplusplus } #endif #endif /* _SYS_SYSMACROS_H */ diff --git a/lib/libspl/include/sys/types.h b/lib/libspl/include/sys/types.h index 5a84123d201f..90e3cf9bdaf8 100644 --- a/lib/libspl/include/sys/types.h +++ b/lib/libspl/include/sys/types.h @@ -1,77 +1,52 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #ifndef _LIBSPL_SYS_TYPES_H #define _LIBSPL_SYS_TYPES_H #if defined(HAVE_MAKEDEV_IN_SYSMACROS) #include #elif defined(HAVE_MAKEDEV_IN_MKDEV) #include #endif #include #include #include_next #include #include #include #ifndef HAVE_INTTYPES #include #endif /* HAVE_INTTYPES */ typedef uint_t zoneid_t; typedef int projid_t; -/* - * Definitions remaining from previous partial support for 64-bit file - * offsets. This partial support for devices greater than 2gb requires - * compiler support for long long. - */ -#ifdef _LONG_LONG_LTOH -typedef union { - offset_t _f; /* Full 64 bit offset value */ - struct { - int32_t _l; /* lower 32 bits of offset value */ - int32_t _u; /* upper 32 bits of offset value */ - } _p; -} lloff_t; -#endif - -#ifdef _LONG_LONG_HTOL -typedef union { - offset_t _f; /* Full 64 bit offset value */ - struct { - int32_t _u; /* upper 32 bits of offset value */ - int32_t _l; /* lower 32 bits of offset value */ - } _p; -} lloff_t; -#endif - #include /* for NBBY */ #endif