root/drivers/FPU-emu/fpu_emu.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*---------------------------------------------------------------------------+
   2  |  fpu_emu.h                                                                |
   3  |                                                                           |
   4  | Copyright (C) 1992,1993,1994                                              |
   5  |                       W. Metzenthen, 22 Parker St, Ormond, Vic 3163,      |
   6  |                       Australia.  E-mail   billm@vaxc.cc.monash.edu.au    |
   7  |                                                                           |
   8  +---------------------------------------------------------------------------*/
   9 
  10 
  11 #ifndef _FPU_EMU_H_
  12 #define _FPU_EMU_H_
  13 
  14 /*
  15  * Define DENORM_OPERAND to make the emulator detect denormals
  16  * and use the denormal flag of the status word. Note: this only
  17  * affects the flag and corresponding interrupt, the emulator
  18  * will always generate denormals and operate upon them as required.
  19  */
  20 #define DENORM_OPERAND
  21 
  22 /*
  23  * Define PECULIAR_486 to get a closer approximation to 80486 behaviour,
  24  * rather than behaviour which appears to be cleaner.
  25  * This is a matter of opinion: for all I know, the 80486 may simply
  26  * be complying with the IEEE spec. Maybe one day I'll get to see the
  27  * spec...
  28  */
  29 #define PECULIAR_486
  30 
  31 #ifdef __ASSEMBLER__
  32 #include "fpu_asm.h"
  33 #define Const(x)        $##x
  34 #else
  35 #define Const(x)        x
  36 #endif
  37 
  38 #define EXP_BIAS        Const(0)
  39 #define EXP_OVER        Const(0x4000)    /* smallest invalid large exponent */
  40 #define EXP_UNDER       Const(-0x3fff)   /* largest invalid small exponent */
  41 #define EXP_Infinity    EXP_OVER
  42 #define EXP_NaN         EXP_OVER
  43 
  44 #define SIGN_POS        Const(0)
  45 #define SIGN_NEG        Const(1)
  46 
  47 /* Keep the order TW_Valid, TW_Zero, TW_Denormal */
  48 #define TW_Valid        Const(0)        /* valid */
  49 #define TW_Zero         Const(1)        /* zero */
  50 /* The following fold to 2 (Special) in the Tag Word */
  51 /* #define TW_Denormal     Const(4) */       /* De-normal */
  52 #define TW_Infinity     Const(5)        /* + or - infinity */
  53 #define TW_NaN          Const(6)        /* Not a Number */
  54 
  55 #define TW_Empty        Const(7)        /* empty */
  56 
  57 
  58 #ifndef __ASSEMBLER__
  59 
  60 #include <linux/math_emu.h>
  61 #include <linux/linkage.h>
  62 
  63 /*
  64 #define RE_ENTRANT_CHECKING
  65  */
  66 
  67 #ifdef RE_ENTRANT_CHECKING
  68 extern char emulating;
  69 #  define RE_ENTRANT_CHECK_OFF emulating = 0
  70 #  define RE_ENTRANT_CHECK_ON emulating = 1
  71 #else
  72 #  define RE_ENTRANT_CHECK_OFF
  73 #  define RE_ENTRANT_CHECK_ON
  74 #endif RE_ENTRANT_CHECKING
  75 
  76 #define FWAIT_OPCODE 0x9b
  77 #define OP_SIZE_PREFIX 0x66
  78 #define ADDR_SIZE_PREFIX 0x67
  79 #define PREFIX_CS 0x2e
  80 #define PREFIX_DS 0x3e
  81 #define PREFIX_ES 0x26
  82 #define PREFIX_SS 0x36
  83 #define PREFIX_FS 0x64
  84 #define PREFIX_GS 0x65
  85 #define PREFIX_REPE 0xf3
  86 #define PREFIX_REPNE 0xf2
  87 #define PREFIX_LOCK 0xf0
  88 #define PREFIX_CS_ 1
  89 #define PREFIX_DS_ 2
  90 #define PREFIX_ES_ 3
  91 #define PREFIX_FS_ 4
  92 #define PREFIX_GS_ 5
  93 #define PREFIX_SS_ 6
  94 #define PREFIX_DEFAULT 7
  95 
  96 struct address {
  97   unsigned int offset;
  98   unsigned int selector:16;
  99   unsigned int opcode:11;
 100   unsigned int empty:5;
 101 };
 102 typedef void (*FUNC)(void);
 103 typedef struct fpu_reg FPU_REG;
 104 typedef void (*FUNC_ST0)(FPU_REG *st0_ptr);
 105 typedef struct { unsigned char address_size, operand_size, segment; }
 106         overrides;
 107 /* This structure is 32 bits: */
 108 typedef struct { overrides override;
 109                  unsigned char default_mode; } fpu_addr_modes;
 110 /* PROTECTED has a restricted meaning in the emulator; it is used
 111    to signal that the emulator needs to do special things to ensure
 112    that protection is respected in a segmented model. */
 113 #define PROTECTED 4
 114 #define SIXTEEN   1         /* We rely upon this being 1 (true) */
 115 #define VM86      SIXTEEN
 116 #define PM16      (SIXTEEN | PROTECTED)
 117 #define SEG32     PROTECTED
 118 extern unsigned char const data_sizes_16[32];
 119 
 120 #define st(x)   ( regs[((top+x) &7 )] )
 121 
 122 #define STACK_OVERFLOW  (st_new_ptr = &st(-1), st_new_ptr->tag != TW_Empty)
 123 #define NOT_EMPTY(i)    (st(i).tag != TW_Empty)
 124 #define NOT_EMPTY_ST0   (st0_tag ^ TW_Empty)
 125 
 126 #define pop()   { regs[(top++ & 7 )].tag = TW_Empty; }
 127 #define poppop() { regs[((top + 1) & 7 )].tag \
 128                      = regs[(top & 7 )].tag = TW_Empty; \
 129                    top += 2; }
 130 
 131 /* push() does not affect the tags */
 132 #define push()  { top--; }
 133 
 134 
 135 #define reg_move(x, y) { \
 136                  *(short *)&((y)->sign) = *(short *)&((x)->sign); \
 137                  *(long *)&((y)->exp) = *(long *)&((x)->exp); \
 138                  *(long long *)&((y)->sigl) = *(long long *)&((x)->sigl); }
 139 
 140 #define significand(x) ( ((unsigned long long *)&((x)->sigl))[0] )
 141 
 142 
 143 /*----- Prototypes for functions written in assembler -----*/
 144 /* extern void reg_move(FPU_REG *a, FPU_REG *b); */
 145 
 146 asmlinkage void mul64(unsigned long long const *a, unsigned long long const *b,
 147                       unsigned long long *result);
 148 asmlinkage void poly_div2(unsigned long long *x);
 149 asmlinkage void poly_div4(unsigned long long *x);
 150 asmlinkage void poly_div16(unsigned long long *x);
 151 asmlinkage void polynomial(unsigned accum[], unsigned const x[],
 152                        unsigned short const terms[][4], int const n);
 153 asmlinkage void normalize(FPU_REG *x);
 154 asmlinkage void normalize_nuo(FPU_REG *x);
 155 asmlinkage int reg_div(FPU_REG const *arg1, FPU_REG const *arg2,
 156                        FPU_REG *answ, unsigned int control_w);
 157 asmlinkage int reg_u_sub(FPU_REG const *arg1, FPU_REG const *arg2,
 158                          FPU_REG *answ, unsigned int control_w);
 159 asmlinkage int reg_u_mul(FPU_REG const *arg1, FPU_REG const *arg2,
 160                          FPU_REG *answ, unsigned int control_w);
 161 asmlinkage int reg_u_div(FPU_REG const *arg1, FPU_REG const *arg2,
 162                          FPU_REG *answ, unsigned int control_w);
 163 asmlinkage int reg_u_add(FPU_REG const *arg1, FPU_REG const *arg2,
 164                          FPU_REG *answ, unsigned int control_w);
 165 asmlinkage int wm_sqrt(FPU_REG *n, unsigned int control_w);
 166 asmlinkage unsigned     shrx(void *l, unsigned x);
 167 asmlinkage unsigned     shrxs(void *v, unsigned x);
 168 asmlinkage unsigned long div_small(unsigned long long *x, unsigned long y);
 169 asmlinkage void round_reg(FPU_REG *arg, unsigned int extent,
 170                       unsigned int control_w);
 171 
 172 #ifndef MAKING_PROTO
 173 #include "fpu_proto.h"
 174 #endif
 175 
 176 #endif __ASSEMBLER__
 177 
 178 #endif _FPU_EMU_H_

/* [previous][next][first][last][top][bottom][index][help] */