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                                                   |
   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 #ifdef PARANOID
  64 extern char emulating;
  65 #  define RE_ENTRANT_CHECK_OFF emulating = 0;
  66 #  define RE_ENTRANT_CHECK_ON emulating = 1;
  67 #else
  68 #  define RE_ENTRANT_CHECK_OFF
  69 #  define RE_ENTRANT_CHECK_ON
  70 #endif PARANOID
  71 
  72 /* These are to defeat the default action, giving the instruction
  73    no net effect: */
  74 #define NO_NET_DATA_EFFECT \
  75       { FPU_data_address = (void *)data_operand_offset; \
  76         FPU_data_selector = operand_selector; }
  77 #define NO_NET_INSTR_EFFECT \
  78       { FPU_entry_eip = ip_offset; \
  79         FPU_entry_op_cs = cs_selector; }
  80 
  81 
  82 typedef void (*FUNC)(void);
  83 typedef struct fpu_reg FPU_REG;
  84 
  85 #define st(x)   ( regs[((top+x) &7 )] )
  86 
  87 #define STACK_OVERFLOW  (st_new_ptr = &st(-1), st_new_ptr->tag != TW_Empty)
  88 #define NOT_EMPTY(i)    (st(i).tag != TW_Empty)
  89 #define NOT_EMPTY_0     (FPU_st0_tag ^ TW_Empty)
  90 
  91 extern unsigned char FPU_rm;
  92 
  93 extern  char    FPU_st0_tag;
  94 extern  FPU_REG *FPU_st0_ptr;
  95 
  96 /* ###### These need to be shifted to somewhere safe. */
  97 /* extern void  *FPU_data_address; has been shifted */
  98 extern unsigned short FPU_data_selector;
  99 extern unsigned long FPU_entry_op_cs;
 100 
 101 extern  FPU_REG  FPU_loaded_data;
 102 
 103 #define pop()   { FPU_st0_ptr->tag = TW_Empty; top++; }
 104 
 105 /* push() does not affect the tags */
 106 #define push()  { top--; FPU_st0_ptr = st_new_ptr; }
 107 
 108 
 109 #define reg_move(x, y) { \
 110                  *(short *)&((y)->sign) = *(short *)&((x)->sign); \
 111                  *(long *)&((y)->exp) = *(long *)&((x)->exp); \
 112                  *(long long *)&((y)->sigl) = *(long long *)&((x)->sigl); }
 113 
 114 #define significand(x) ( ((unsigned long long *)&((x)->sigl))[0] )
 115 
 116 
 117 /*----- Prototypes for functions written in assembler -----*/
 118 /* extern void reg_move(FPU_REG *a, FPU_REG *b); */
 119 
 120 asmlinkage void mul64(unsigned long long const *a, unsigned long long const *b,
 121                       unsigned long long *result);
 122 asmlinkage void poly_div2(unsigned long long *x);
 123 asmlinkage void poly_div4(unsigned long long *x);
 124 asmlinkage void poly_div16(unsigned long long *x);
 125 asmlinkage void polynomial(unsigned accum[], unsigned const x[],
 126                        unsigned short const terms[][4], int const n);
 127 asmlinkage void normalize(FPU_REG *x);
 128 asmlinkage void normalize_nuo(FPU_REG *x);
 129 asmlinkage int reg_div(FPU_REG const *arg1, FPU_REG const *arg2,
 130                        FPU_REG *answ, unsigned int control_w);
 131 asmlinkage int reg_u_sub(FPU_REG const *arg1, FPU_REG const *arg2,
 132                          FPU_REG *answ, unsigned int control_w);
 133 asmlinkage int reg_u_mul(FPU_REG const *arg1, FPU_REG const *arg2,
 134                          FPU_REG *answ, unsigned int control_w);
 135 asmlinkage int reg_u_div(FPU_REG const *arg1, FPU_REG const *arg2,
 136                          FPU_REG *answ, unsigned int control_w);
 137 asmlinkage int reg_u_add(FPU_REG const *arg1, FPU_REG const *arg2,
 138                          FPU_REG *answ, unsigned int control_w);
 139 asmlinkage int wm_sqrt(FPU_REG *n, unsigned int control_w);
 140 asmlinkage unsigned     shrx(void *l, unsigned x);
 141 asmlinkage unsigned     shrxs(void *v, unsigned x);
 142 asmlinkage unsigned long div_small(unsigned long long *x, unsigned long y);
 143 asmlinkage void round_reg(FPU_REG *arg, unsigned int extent,
 144                       unsigned int control_w);
 145 
 146 #ifndef MAKING_PROTO
 147 #include "fpu_proto.h"
 148 #endif
 149 
 150 #endif __ASSEMBLER__
 151 
 152 #endif _FPU_EMU_H_

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