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