root/kernel/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 apm233m@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 
  42 #define SIGN_POS        Const(0)
  43 #define SIGN_NEG        Const(1)
  44 
  45 /* Keep the order TW_Valid, TW_Zero, TW_Denormal */
  46 #define TW_Valid        Const(0)        /* valid */
  47 #define TW_Zero         Const(1)        /* zero */
  48 /* The following fold to 2 (Special) in the Tag Word */
  49 #define TW_Denormal     Const(4)        /* De-normal */
  50 #define TW_Infinity     Const(5)        /* + or - infinity */
  51 #define TW_NaN          Const(6)        /* Not a Number */
  52 
  53 #define TW_Empty        Const(7)        /* empty */
  54 
  55 /* #define TW_FPU_Interrupt Const(0x80) */    /* Signals an interrupt */
  56 
  57 
  58 #ifndef __ASSEMBLER__
  59 
  60 #include <linux/math_emu.h>
  61 
  62 #ifdef PARANOID
  63 extern char emulating;
  64 #  define RE_ENTRANT_CHECK_OFF emulating = 0;
  65 #  define RE_ENTRANT_CHECK_ON emulating = 1;
  66 #else
  67 #  define RE_ENTRANT_CHECK_OFF
  68 #  define RE_ENTRANT_CHECK_ON
  69 #endif PARANOID
  70 
  71 typedef void (*FUNC)(void);
  72 typedef struct fpu_reg FPU_REG;
  73 
  74 #define st(x)   ( regs[((top+x) &7 )] )
  75 
  76 #define STACK_OVERFLOW  (st_new_ptr = &st(-1), st_new_ptr->tag != TW_Empty)
  77 #define NOT_EMPTY(i)    (st(i).tag != TW_Empty)
  78 #define NOT_EMPTY_0     (FPU_st0_tag ^ TW_Empty)
  79 
  80 extern unsigned char FPU_rm;
  81 
  82 extern  char    FPU_st0_tag;
  83 extern  FPU_REG *FPU_st0_ptr;
  84 
  85 extern void  *FPU_data_address;
  86 
  87 extern  FPU_REG  FPU_loaded_data;
  88 
  89 #define pop()   { FPU_st0_ptr->tag = TW_Empty; top++; }
  90 
  91 /* push() does not affect the tags */
  92 #define push()  { top--; FPU_st0_ptr = st_new_ptr; }
  93 
  94 
  95 #define reg_move(x, y) { \
  96                  *(short *)&((y)->sign) = *(short *)&((x)->sign); \
  97                  *(long *)&((y)->exp) = *(long *)&((x)->exp); \
  98                  *(long long *)&((y)->sigl) = *(long long *)&((x)->sigl); }
  99 
 100 
 101 /*----- Prototypes for functions written in assembler -----*/
 102 /* extern "C" void reg_move(FPU_REG *a, FPU_REG *b); */
 103 
 104 extern "C" void mul64(long long *a, long long *b, long long *result);
 105 extern "C" void poly_div2(long long *x);
 106 extern "C" void poly_div4(long long *x);
 107 extern "C" void poly_div16(long long *x);
 108 extern "C" void polynomial(unsigned accum[], unsigned x[],
 109                        unsigned short terms[][4], int n);
 110 extern "C" void normalize(FPU_REG *x);
 111 extern "C" void normalize_nuo(FPU_REG *x);
 112 extern "C" void reg_div(FPU_REG *arg1, FPU_REG *arg2, FPU_REG *answ,
 113                     unsigned int control_w);
 114 extern "C" void reg_u_sub(FPU_REG *arg1, FPU_REG *arg2, FPU_REG *answ,
 115                       unsigned int control_w);
 116 extern "C" void reg_u_mul(FPU_REG *arg1, FPU_REG *arg2, FPU_REG *answ,
 117                       unsigned int control_w);
 118 extern "C" void reg_u_div(FPU_REG *arg1, FPU_REG *arg2, FPU_REG *answ,
 119                       unsigned int control_w);
 120 extern "C" void reg_u_add(FPU_REG *arg1, FPU_REG *arg2, FPU_REG *answ,
 121                       unsigned int control_w);
 122 extern "C" void wm_sqrt(FPU_REG *n, unsigned int control_w);
 123 extern "C" unsigned     shrx(void *l, unsigned x);
 124 extern "C" unsigned     shrxs(void *v, unsigned x);
 125 extern "C" unsigned long div_small(unsigned long long *x, unsigned long y);
 126 extern "C" void round_reg(FPU_REG *arg, unsigned int extent,
 127                       unsigned int control_w);
 128 
 129 #ifndef MAKING_PROTO
 130 #include "fpu_proto.h"
 131 #endif
 132 
 133 #endif __ASSEMBLER__
 134 
 135 #endif _FPU_EMU_H_

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