| 1 |
|
| 2 | #ifndef _UAPI__ASM_ALPHA_FPU_H
|
| 3 | #define _UAPI__ASM_ALPHA_FPU_H
|
| 4 |
|
| 5 |
|
| 6 | |
| 7 | * Alpha floating-point control register defines:
|
| 8 |
|
| 9 | #define FPCR_DNOD (1UL<<47)
|
| 10 | #define FPCR_DNZ (1UL<<48)
|
| 11 | #define FPCR_INVD (1UL<<49)
|
| 12 | #define FPCR_DZED (1UL<<50)
|
| 13 | #define FPCR_OVFD (1UL<<51)
|
| 14 | #define FPCR_INV (1UL<<52)
|
| 15 | #define FPCR_DZE (1UL<<53)
|
| 16 | #define FPCR_OVF (1UL<<54)
|
| 17 | #define FPCR_UNF (1UL<<55)
|
| 18 | #define FPCR_INE (1UL<<56)
|
| 19 | #define FPCR_IOV (1UL<<57)
|
| 20 | #define FPCR_UNDZ (1UL<<60)
|
| 21 | #define FPCR_UNFD (1UL<<61)
|
| 22 | #define FPCR_INED (1UL<<62)
|
| 23 | #define FPCR_SUM (1UL<<63)
|
| 24 |
|
| 25 | #define FPCR_DYN_SHIFT 58
|
| 26 | #define FPCR_DYN_CHOPPED (0x0UL << FPCR_DYN_SHIFT)
|
| 27 | #define FPCR_DYN_MINUS (0x1UL << FPCR_DYN_SHIFT)
|
| 28 | #define FPCR_DYN_NORMAL (0x2UL << FPCR_DYN_SHIFT)
|
| 29 | #define FPCR_DYN_PLUS (0x3UL << FPCR_DYN_SHIFT)
|
| 30 | #define FPCR_DYN_MASK (0x3UL << FPCR_DYN_SHIFT)
|
| 31 |
|
| 32 | #define FPCR_MASK 0xffff800000000000L
|
| 33 |
|
| 34 | |
| 35 | * IEEE trap enables are implemented in software. These per-thread
|
| 36 | * bits are stored in the "ieee_state" field of "struct thread_info".
|
| 37 | * Thus, the bits are defined so as not to conflict with the
|
| 38 | * floating-point enable bit (which is architected). On top of that,
|
| 39 | * we want to make these bits compatible with OSF/1 so
|
| 40 | * ieee_set_fp_control() etc. can be implemented easily and
|
| 41 | * compatibly. The corresponding definitions are in
|
| 42 | * /usr/include/machine/fpu.h under OSF/1.
|
| 43 |
|
| 44 | #define IEEE_TRAP_ENABLE_INV (1UL<<1)
|
| 45 | #define IEEE_TRAP_ENABLE_DZE (1UL<<2)
|
| 46 | #define IEEE_TRAP_ENABLE_OVF (1UL<<3)
|
| 47 | #define IEEE_TRAP_ENABLE_UNF (1UL<<4)
|
| 48 | #define IEEE_TRAP_ENABLE_INE (1UL<<5)
|
| 49 | #define IEEE_TRAP_ENABLE_DNO (1UL<<6)
|
| 50 | #define IEEE_TRAP_ENABLE_MASK (IEEE_TRAP_ENABLE_INV | IEEE_TRAP_ENABLE_DZE |\
|
| 51 | IEEE_TRAP_ENABLE_OVF | IEEE_TRAP_ENABLE_UNF |\
|
| 52 | IEEE_TRAP_ENABLE_INE | IEEE_TRAP_ENABLE_DNO)
|
| 53 |
|
| 54 |
|
| 55 | #define IEEE_MAP_DMZ (1UL<<12)
|
| 56 | #define IEEE_MAP_UMZ (1UL<<13)
|
| 57 |
|
| 58 | #define IEEE_MAP_MASK (IEEE_MAP_DMZ | IEEE_MAP_UMZ)
|
| 59 |
|
| 60 |
|
| 61 | #define IEEE_STATUS_INV (1UL<<17)
|
| 62 | #define IEEE_STATUS_DZE (1UL<<18)
|
| 63 | #define IEEE_STATUS_OVF (1UL<<19)
|
| 64 | #define IEEE_STATUS_UNF (1UL<<20)
|
| 65 | #define IEEE_STATUS_INE (1UL<<21)
|
| 66 | #define IEEE_STATUS_DNO (1UL<<22)
|
| 67 |
|
| 68 | #define IEEE_STATUS_MASK (IEEE_STATUS_INV | IEEE_STATUS_DZE | \
|
| 69 | IEEE_STATUS_OVF | IEEE_STATUS_UNF | \
|
| 70 | IEEE_STATUS_INE | IEEE_STATUS_DNO)
|
| 71 |
|
| 72 | #define IEEE_SW_MASK (IEEE_TRAP_ENABLE_MASK | \
|
| 73 | IEEE_STATUS_MASK | IEEE_MAP_MASK)
|
| 74 |
|
| 75 | #define IEEE_CURRENT_RM_SHIFT 32
|
| 76 | #define IEEE_CURRENT_RM_MASK (3UL<<IEEE_CURRENT_RM_SHIFT)
|
| 77 |
|
| 78 | #define IEEE_STATUS_TO_EXCSUM_SHIFT 16
|
| 79 |
|
| 80 | #define IEEE_INHERIT (1UL<<63)
|
| 81 |
|
| 82 | |
| 83 | * Convert the software IEEE trap enable and status bits into the
|
| 84 | * hardware fpcr format.
|
| 85 | *
|
| 86 | * Digital Unix engineers receive my thanks for not defining the
|
| 87 | * software bits identical to the hardware bits. The chip designers
|
| 88 | * receive my thanks for making all the not-implemented fpcr bits
|
| 89 | * RAZ forcing us to use system calls to read/write this value.
|
| 90 |
|
| 91 |
|
| 92 | static inline unsigned long
|
| 93 | ieee_swcr_to_fpcr(unsigned long sw)
|
| 94 | {
|
| 95 | unsigned long fp;
|
| 96 | fp = (sw & IEEE_STATUS_MASK) << 35;
|
| 97 | fp |= (sw & IEEE_MAP_DMZ) << 36;
|
| 98 | fp |= (sw & IEEE_STATUS_MASK ? FPCR_SUM : 0);
|
| 99 | fp |= (~sw & (IEEE_TRAP_ENABLE_INV
|
| 100 | | IEEE_TRAP_ENABLE_DZE
|
| 101 | | IEEE_TRAP_ENABLE_OVF)) << 48;
|
| 102 | fp |= (~sw & (IEEE_TRAP_ENABLE_UNF | IEEE_TRAP_ENABLE_INE)) << 57;
|
| 103 | fp |= (sw & IEEE_MAP_UMZ ? FPCR_UNDZ | FPCR_UNFD : 0);
|
| 104 | |
| 105 | * Disable denormal operand traps only when denormal inputs are to be
|
| 106 | * flushed to zero. Otherwise they must keep trapping, so that /S
|
| 107 | * instructions reach the kernel emulation handler.
|
| 108 |
|
| 109 | fp |= (sw & IEEE_MAP_DMZ ? FPCR_DNOD : 0);
|
| 110 | return fp;
|
| 111 | }
|
| 112 |
|
| 113 | static inline unsigned long
|
| 114 | ieee_fpcr_to_swcr(unsigned long fp)
|
| 115 | {
|
| 116 | unsigned long sw;
|
| 117 | sw = (fp >> 35) & IEEE_STATUS_MASK;
|
| 118 | sw |= (fp >> 36) & IEEE_MAP_DMZ;
|
| 119 | sw |= (~fp >> 48) & (IEEE_TRAP_ENABLE_INV
|
| 120 | | IEEE_TRAP_ENABLE_DZE
|
| 121 | | IEEE_TRAP_ENABLE_OVF);
|
| 122 | sw |= (~fp >> 57) & (IEEE_TRAP_ENABLE_UNF | IEEE_TRAP_ENABLE_INE);
|
| 123 | sw |= (fp >> 47) & IEEE_MAP_UMZ;
|
| 124 | return sw;
|
| 125 | }
|
| 126 |
|
| 127 |
|
| 128 | #endif
|