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