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