1 /* $OpenBSD: fpu.h,v 1.1 2002/04/28 20:55:14 pvalchev Exp $ */ 2 /* $NetBSD: fpu.h,v 1.4 2001/04/26 03:10:46 ross Exp $ */ 3 4 /*- 5 * Copyright (c) 2001 Ross Harvey 6 * All rights reserved. 7 * 8 * This software was written for NetBSD. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 #ifndef _ALPHA_FPU_H_ 40 #define _ALPHA_FPU_H_ 41 42 #define _FP_C_DEF(n) (1UL << (n)) 43 44 /* 45 * Most of these next definitions were moved from <ieeefp.h>. Apparently the 46 * names happen to match those exported by Compaq and Linux from their fpu.h 47 * files. 48 */ 49 50 #define FPCR_SUM _FP_C_DEF(63) 51 #define FPCR_INED _FP_C_DEF(62) 52 #define FPCR_UNFD _FP_C_DEF(61) 53 #define FPCR_UNDZ _FP_C_DEF(60) 54 #define FPCR_DYN(rm) ((unsigned long)(rm) << 58) 55 #define FPCR_IOV _FP_C_DEF(57) 56 #define FPCR_INE _FP_C_DEF(56) 57 #define FPCR_UNF _FP_C_DEF(55) 58 #define FPCR_OVF _FP_C_DEF(54) 59 #define FPCR_DZE _FP_C_DEF(53) 60 #define FPCR_INV _FP_C_DEF(52) 61 #define FPCR_OVFD _FP_C_DEF(51) 62 #define FPCR_DZED _FP_C_DEF(50) 63 #define FPCR_INVD _FP_C_DEF(49) 64 #define FPCR_DNZ _FP_C_DEF(48) 65 #define FPCR_DNOD _FP_C_DEF(47) 66 67 #define FPCR_MIRRORED (FPCR_INE | FPCR_UNF | FPCR_OVF | FPCR_DZE | FPCR_INV) 68 #define FPCR_MIR_START 52 69 70 /* 71 * The AARM specifies the bit positions of the software word used for 72 * user mode interface to the control and status of the kernel completion 73 * routines. Although it largely just redefines the FPCR, it shuffles 74 * the bit order. The names of the bits are defined in the AARM, and 75 * the definition prefix can easily be determined from public domain 76 * programs written to either the Compaq or Linux interfaces, which 77 * appear to be identical. 78 */ 79 80 #define IEEE_STATUS_DNO _FP_C_DEF(22) 81 #define IEEE_STATUS_INE _FP_C_DEF(21) 82 #define IEEE_STATUS_UNF _FP_C_DEF(20) 83 #define IEEE_STATUS_OVF _FP_C_DEF(19) 84 #define IEEE_STATUS_DZE _FP_C_DEF(18) 85 #define IEEE_STATUS_INV _FP_C_DEF(17) 86 87 #define IEEE_TRAP_ENABLE_DNO _FP_C_DEF(6) 88 #define IEEE_TRAP_ENABLE_INE _FP_C_DEF(5) 89 #define IEEE_TRAP_ENABLE_UNF _FP_C_DEF(4) 90 #define IEEE_TRAP_ENABLE_OVF _FP_C_DEF(3) 91 #define IEEE_TRAP_ENABLE_DZE _FP_C_DEF(2) 92 #define IEEE_TRAP_ENABLE_INV _FP_C_DEF(1) 93 94 #define IEEE_INHERIT _FP_C_DEF(14) 95 #define IEEE_MAP_UMZ _FP_C_DEF(13) 96 #define IEEE_MAP_DMZ _FP_C_DEF(12) 97 98 #define FP_C_MIRRORED (IEEE_STATUS_INE | IEEE_STATUS_UNF | IEEE_STATUS_OVF\ 99 | IEEE_STATUS_DZE | IEEE_STATUS_INV) 100 #define FP_C_MIR_START 17 101 102 #ifdef _KERNEL 103 104 #define FLD_MASK(len) ((1UL << (len)) - 1) 105 #define FLD_CLEAR(obj, origin, len) \ 106 ((obj) & ~(FLD_MASK(len) << (origin))) 107 #define FLD_INSERT(obj, origin, len, value) \ 108 (FLD_CLEAR(obj, origin, len) | (value) << origin) 109 110 #define FP_C_TO_OPENBSD_MASK(fp_c) ((fp_c) >> 1 & 0x3f) 111 #define FP_C_TO_OPENBSD_FLAG(fp_c) ((fp_c) >> 17 & 0x3f) 112 #define OPENBSD_MASK_TO_FP_C(m) (((m) & 0x3f) << 1) 113 #define OPENBSD_FLAG_TO_FP_C(s) (((s) & 0x3f) << 17) 114 #define CLEAR_FP_C_MASK(fp_c) ((fp_c) & ~(0x3f << 1)) 115 #define CLEAR_FP_C_FLAG(fp_c) ((fp_c) & ~(0x3f << 17)) 116 #define SET_FP_C_MASK(fp_c, m) (CLEAR_FP_C_MASK(fp_c) | OPENBSD_MASK_TO_FP_C(m)) 117 #define SET_FP_C_FLAG(fp_c, m) (CLEAR_FP_C_FLAG(fp_c) | OPENBSD_FLAG_TO_FP_C(m)) 118 119 #endif 120 121 #endif 122