Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003     NetWinder Floating Point Emulator
0004     (c) Rebel.com, 1998-1999
0005     
0006     Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
0007 
0008 */
0009 
0010 #ifndef __FPA11_H__
0011 #define __FPA11_H__
0012 
0013 #define GET_FPA11() ((FPA11 *)(&current_thread_info()->fpstate))
0014 
0015 /*
0016  * The processes registers are always at the very top of the 8K
0017  * stack+task struct.  Use the same method as 'current' uses to
0018  * reach them.
0019  */
0020 #define GET_USERREG() ((struct pt_regs *)(THREAD_START_SP + (unsigned long)current_thread_info()) - 1)
0021 
0022 #include <linux/thread_info.h>
0023 
0024 /* includes */
0025 #include "fpsr.h"       /* FP control and status register definitions */
0026 #include "milieu.h"
0027 
0028 struct roundingData {
0029     int8 mode;
0030     int8 precision;
0031     signed char exception;
0032 };
0033 
0034 #include "softfloat.h"
0035 
0036 #define     typeNone        0x00
0037 #define     typeSingle      0x01
0038 #define     typeDouble      0x02
0039 #define     typeExtended        0x03
0040 
0041 /*
0042  * This must be no more and no less than 12 bytes.
0043  */
0044 typedef union tagFPREG {
0045     float32 fSingle;
0046     float64 fDouble;
0047 #ifdef CONFIG_FPE_NWFPE_XP
0048     floatx80 fExtended;
0049 #else
0050     u32 padding[3];
0051 #endif
0052 } __attribute__ ((packed,aligned(4))) FPREG;
0053 
0054 /*
0055  * FPA11 device model.
0056  *
0057  * This structure is exported to user space.  Do not re-order.
0058  * Only add new stuff to the end, and do not change the size of
0059  * any element.  Elements of this structure are used by user
0060  * space, and must match struct user_fp in <asm/user.h>.
0061  * We include the byte offsets below for documentation purposes.
0062  *
0063  * The size of this structure and FPREG are checked by fpmodule.c
0064  * on initialisation.  If the rules have been broken, NWFPE will
0065  * not initialise.
0066  */
0067 typedef struct tagFPA11 {
0068 /*   0 */ FPREG fpreg[8];   /* 8 floating point registers */
0069 /*  96 */ FPSR fpsr;        /* floating point status register */
0070 /* 100 */ FPCR fpcr;        /* floating point control register */
0071 /* 104 */ unsigned char fType[8];   /* type of floating point value held in
0072                        floating point registers.  One of
0073                        none, single, double or extended. */
0074 /* 112 */ int initflag;     /* this is special.  The kernel guarantees
0075                    to set it to 0 when a thread is launched,
0076                    so we can use it to detect whether this
0077                    instance of the emulator needs to be
0078                    initialised. */
0079 } __attribute__ ((packed,aligned(4))) FPA11;
0080 
0081 extern int8 SetRoundingMode(const unsigned int);
0082 extern int8 SetRoundingPrecision(const unsigned int);
0083 extern void nwfpe_init_fpa(union fp_state *fp);
0084 
0085 extern unsigned int EmulateAll(unsigned int opcode);
0086 
0087 extern unsigned int EmulateCPDT(const unsigned int opcode);
0088 extern unsigned int EmulateCPDO(const unsigned int opcode);
0089 extern unsigned int EmulateCPRT(const unsigned int opcode);
0090 
0091 /* fpa11_cpdt.c */
0092 extern unsigned int PerformLDF(const unsigned int opcode);
0093 extern unsigned int PerformSTF(const unsigned int opcode);
0094 extern unsigned int PerformLFM(const unsigned int opcode);
0095 extern unsigned int PerformSFM(const unsigned int opcode);
0096 
0097 /* single_cpdo.c */
0098 
0099 extern unsigned int SingleCPDO(struct roundingData *roundData,
0100                    const unsigned int opcode, FPREG * rFd);
0101 /* double_cpdo.c */
0102 extern unsigned int DoubleCPDO(struct roundingData *roundData,
0103                    const unsigned int opcode, FPREG * rFd);
0104 
0105 /* extneded_cpdo.c */
0106 extern unsigned int ExtendedCPDO(struct roundingData *roundData,
0107                  const unsigned int opcode, FPREG * rFd);
0108 
0109 #endif