Home | History | Annotate | Line # | Download | only in include
fpu.h revision 1.1
      1  1.1  ross /*-
      2  1.1  ross  * Copyright (c) 1998 Doug Rabson
      3  1.1  ross  * All rights reserved.
      4  1.1  ross  *
      5  1.1  ross  * Redistribution and use in source and binary forms, with or without
      6  1.1  ross  * modification, are permitted provided that the following conditions
      7  1.1  ross  * are met:
      8  1.1  ross  * 1. Redistributions of source code must retain the above copyright
      9  1.1  ross  *    notice, this list of conditions and the following disclaimer.
     10  1.1  ross  * 2. Redistributions in binary form must reproduce the above copyright
     11  1.1  ross  *    notice, this list of conditions and the following disclaimer in the
     12  1.1  ross  *    documentation and/or other materials provided with the distribution.
     13  1.1  ross  *
     14  1.1  ross  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     15  1.1  ross  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     16  1.1  ross  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     17  1.1  ross  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     18  1.1  ross  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     19  1.1  ross  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     20  1.1  ross  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     21  1.1  ross  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     22  1.1  ross  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     23  1.1  ross  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     24  1.1  ross  * SUCH DAMAGE.
     25  1.1  ross  *
     26  1.1  ross  *	Id: fpu.h,v 1.2 1998/12/23 11:50:51 dfr Exp
     27  1.1  ross  */
     28  1.1  ross 
     29  1.1  ross #ifndef _MACHINE_FPU_H_
     30  1.1  ross #define _MACHINE_FPU_H_
     31  1.1  ross 
     32  1.1  ross /*
     33  1.1  ross  * Floating point control register bits.
     34  1.1  ross  *
     35  1.1  ross  * From Alpha AXP Architecture Reference Manual, Instruction
     36  1.1  ross  * Descriptions (I) PP 4-69.
     37  1.1  ross  */
     38  1.1  ross 
     39  1.1  ross #define FPCR_INVD	(1LL << 49)	/* Invalid Operation DIsable */
     40  1.1  ross #define FPCR_DZED	(1LL << 50)	/* Division by Zero Disable */
     41  1.1  ross #define FPCR_OVFD	(1LL << 51)	/* Overflow Disable */
     42  1.1  ross #define FPCR_INV	(1LL << 52)	/* Invalid Operation */
     43  1.1  ross #define FPCR_DZE	(1LL << 53)	/* Division by Zero */
     44  1.1  ross #define FPCR_OVF	(1LL << 54)	/* Overflow */
     45  1.1  ross #define FPCR_UNF	(1LL << 55)	/* Underflow */
     46  1.1  ross #define FPCR_INE	(1LL << 56)	/* Inexact Result */
     47  1.1  ross #define FPCR_IOV	(1LL << 57)	/* Integer Overflow */
     48  1.1  ross #define FPCR_DYN_CHOPPED (0LL << 58)	/* Chopped rounding mode */
     49  1.1  ross #define FPCR_DYN_MINUS	(1LL << 58)	/* Minus infinity */
     50  1.1  ross #define FPCR_DYN_NORMAL (2LL << 58)	/* Normal rounding */
     51  1.1  ross #define FPCR_DYN_PLUS	(3LL << 58)	/* Plus infinity */
     52  1.1  ross #define FPCR_DYN_MASK	(3LL << 58)	/* Rounding mode mask */
     53  1.1  ross #define FPCR_DYN_SHIFT	58
     54  1.1  ross #define FPCR_UNDZ	(1LL << 60)	/* Underflow to Zero */
     55  1.1  ross #define FPCR_UNFD	(1LL << 61)	/* Underflow Disable */
     56  1.1  ross #define FPCR_INED	(1LL << 62)	/* Inexact Disable */
     57  1.1  ross #define FPCR_SUM	(1LL << 63)	/* Summary Bit */
     58  1.1  ross #define FPCR_MASK	(~0LL << 49)
     59  1.1  ross 
     60  1.1  ross /*
     61  1.1  ross  * Exception summary bits.
     62  1.1  ross  *
     63  1.1  ross  * From Alpha AXP Architecture Reference Manual, DEC OSF/1 Exceptions
     64  1.1  ross  * and Interrupts (II-B) PP 5-5.
     65  1.1  ross  */
     66  1.1  ross 
     67  1.1  ross #define EXCSUM_SWC	(1LL << 0)	/* Software completion */
     68  1.1  ross #define EXCSUM_INV	(1LL << 1)	/* Invalid operation */
     69  1.1  ross #define EXCSUM_DZE	(1LL << 2)	/* Division by zero */
     70  1.1  ross #define EXCSUM_OVF	(1LL << 3)	/* Overflow */
     71  1.1  ross #define EXCSUM_UNF	(1LL << 4)	/* Underflow */
     72  1.1  ross #define EXCSUM_INE	(1LL << 5)	/* Inexact result */
     73  1.1  ross #define EXCSUM_IOV	(1LL << 6)	/* Integer overflow */
     74  1.1  ross 
     75  1.1  ross /*
     76  1.1  ross  * Definitions for IEEE trap enables.  These are implemented in
     77  1.1  ross  * software and should be compatible with OSF/1 and Linux.
     78  1.1  ross  */
     79  1.1  ross 
     80  1.1  ross /* read/write flags */
     81  1.1  ross #define IEEE_TRAP_ENABLE_INV	(1LL << 1) /* Invalid operation */
     82  1.1  ross #define IEEE_TRAP_ENABLE_DZE	(1LL << 2) /* Division by zero */
     83  1.1  ross #define IEEE_TRAP_ENABLE_OVF	(1LL << 3) /* Overflow */
     84  1.1  ross #define IEEE_TRAP_ENABLE_UNF	(1LL << 4) /* Underflow */
     85  1.1  ross #define IEEE_TRAP_ENABLE_INE	(1LL << 5) /* Inexact result */
     86  1.1  ross #define IEEE_TRAP_ENABLE_MASK	(IEEE_TRAP_ENABLE_INV		\
     87  1.1  ross 				 | IEEE_TRAP_ENABLE_DZE		\
     88  1.1  ross 				 | IEEE_TRAP_ENABLE_OVF		\
     89  1.1  ross 				 | IEEE_TRAP_ENABLE_UNF		\
     90  1.1  ross 				 | IEEE_TRAP_ENABLE_INE)
     91  1.1  ross 
     92  1.1  ross /* read only flags */
     93  1.1  ross #define IEEE_STATUS_INV		(1LL << 17) /* Invalid operation */
     94  1.1  ross #define IEEE_STATUS_DZE		(1LL << 18) /* Division by zero */
     95  1.1  ross #define IEEE_STATUS_OVF		(1LL << 19) /* Overflow */
     96  1.1  ross #define IEEE_STATUS_UNF		(1LL << 20) /* Underflow */
     97  1.1  ross #define IEEE_STATUS_INE		(1LL << 21) /* Inexact result */
     98  1.1  ross #define IEEE_STATUS_MASK	(IEEE_STATUS_INV		\
     99  1.1  ross 				 | IEEE_STATUS_DZE		\
    100  1.1  ross 				 | IEEE_STATUS_OVF		\
    101  1.1  ross 				 | IEEE_STATUS_UNF		\
    102  1.1  ross 				 | IEEE_STATUS_INE)
    103  1.1  ross #define IEEE_STATUS_TO_EXCSUM_SHIFT	16 /* convert to excsum */
    104  1.1  ross #define IEEE_STATUS_TO_FPCR_SHIFT	35 /* convert to fpcr */
    105  1.1  ross 
    106  1.1  ross #define IEEE_INHERIT		(1LL << 63) /* inherit on fork */
    107  1.1  ross 
    108  1.1  ross /* read and write floating point control register */
    109  1.1  ross #define GET_FPCR(x) \
    110  1.1  ross 	__asm__("trapb"); \
    111  1.1  ross 	__asm__("mf_fpcr %0" : "=f" (x)); \
    112  1.1  ross 	__asm__("trapb")
    113  1.1  ross #define SET_FPCR(x) \
    114  1.1  ross 	__asm__("trapb"); \
    115  1.1  ross 	__asm__("mt_fpcr %0" : : "f" (x)); \
    116  1.1  ross 	__asm__("trapb")
    117  1.1  ross 
    118  1.1  ross #ifdef KERNEL
    119  1.1  ross 
    120  1.1  ross extern int fp_software_completion(u_int64_t regmask, struct proc *p);
    121  1.1  ross 
    122  1.1  ross #endif
    123  1.1  ross 
    124  1.1  ross #endif /* ! _MACHINE_FPU_H_ */
    125