OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [i386/] [math-emu/] [fpu_emu.h] - Blame information for rev 1777

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1623 jcastillo
/*---------------------------------------------------------------------------+
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 __ASSEMBLY__
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 __ASSEMBLY__
59
 
60
#include <asm/sigcontext.h>     /* for struct _fpstate */
61
#include <asm/math_emu.h>
62
 
63
#include <linux/linkage.h>
64
 
65
/*
66
#define RE_ENTRANT_CHECKING
67
 */
68
 
69
#ifdef RE_ENTRANT_CHECKING
70
extern char emulating;
71
#  define RE_ENTRANT_CHECK_OFF emulating = 0
72
#  define RE_ENTRANT_CHECK_ON emulating = 1
73
#else
74
#  define RE_ENTRANT_CHECK_OFF
75
#  define RE_ENTRANT_CHECK_ON
76
#endif RE_ENTRANT_CHECKING
77
 
78
#define FWAIT_OPCODE 0x9b
79
#define OP_SIZE_PREFIX 0x66
80
#define ADDR_SIZE_PREFIX 0x67
81
#define PREFIX_CS 0x2e
82
#define PREFIX_DS 0x3e
83
#define PREFIX_ES 0x26
84
#define PREFIX_SS 0x36
85
#define PREFIX_FS 0x64
86
#define PREFIX_GS 0x65
87
#define PREFIX_REPE 0xf3
88
#define PREFIX_REPNE 0xf2
89
#define PREFIX_LOCK 0xf0
90
#define PREFIX_CS_ 1
91
#define PREFIX_DS_ 2
92
#define PREFIX_ES_ 3
93
#define PREFIX_FS_ 4
94
#define PREFIX_GS_ 5
95
#define PREFIX_SS_ 6
96
#define PREFIX_DEFAULT 7
97
 
98
struct address {
99
  unsigned int offset;
100
  unsigned short selector;
101
  unsigned short opcode:11,
102
                 empty:5;
103
};
104
typedef void (*FUNC)(void);
105
typedef struct fpu_reg FPU_REG;
106
typedef void (*FUNC_ST0)(FPU_REG *st0_ptr);
107
typedef struct { unsigned char address_size, operand_size, segment; }
108
        overrides;
109
/* This structure is 32 bits: */
110
typedef struct { overrides override;
111
                 unsigned char default_mode; } fpu_addr_modes;
112
/* PROTECTED has a restricted meaning in the emulator; it is used
113
   to signal that the emulator needs to do special things to ensure
114
   that protection is respected in a segmented model. */
115
#define PROTECTED 4
116
#define SIXTEEN   1         /* We rely upon this being 1 (true) */
117
#define VM86      SIXTEEN
118
#define PM16      (SIXTEEN | PROTECTED)
119
#define SEG32     PROTECTED
120
extern unsigned char const data_sizes_16[32];
121
 
122
#define st(x)   ( regs[((top+x) &7 )] )
123
 
124
#define STACK_OVERFLOW  (st_new_ptr = &st(-1), st_new_ptr->tag != TW_Empty)
125
#define NOT_EMPTY(i)    (st(i).tag != TW_Empty)
126
#define NOT_EMPTY_ST0   (st0_tag ^ TW_Empty)
127
 
128
#define pop()   { regs[(top++ & 7 )].tag = TW_Empty; }
129
#define poppop() { regs[((top + 1) & 7 )].tag \
130
                     = regs[(top & 7 )].tag = TW_Empty; \
131
                   top += 2; }
132
 
133
/* push() does not affect the tags */
134
#define push()  { top--; }
135
 
136
 
137
#define reg_move(x, y) { \
138
                 *(short *)&((y)->sign) = *(const short *)&((x)->sign); \
139
                 *(long *)&((y)->exp) = *(const long *)&((x)->exp); \
140
                 *(long long *)&((y)->sigl) = *(const long long *)&((x)->sigl); }
141
 
142
#define significand(x) ( ((unsigned long long *)&((x)->sigl))[0] )
143
 
144
 
145
/*----- Prototypes for functions written in assembler -----*/
146
/* extern void reg_move(FPU_REG *a, FPU_REG *b); */
147
 
148
asmlinkage void normalize(FPU_REG *x);
149
asmlinkage void normalize_nuo(FPU_REG *x);
150
asmlinkage int reg_div(FPU_REG const *arg1, FPU_REG const *arg2,
151
                       FPU_REG *answ, unsigned int control_w);
152
asmlinkage int reg_u_sub(FPU_REG const *arg1, FPU_REG const *arg2,
153
                         FPU_REG *answ, unsigned int control_w);
154
asmlinkage int reg_u_mul(FPU_REG const *arg1, FPU_REG const *arg2,
155
                         FPU_REG *answ, unsigned int control_w);
156
asmlinkage int reg_u_div(FPU_REG const *arg1, FPU_REG const *arg2,
157
                         FPU_REG *answ, unsigned int control_w);
158
asmlinkage int reg_u_add(FPU_REG const *arg1, FPU_REG const *arg2,
159
                         FPU_REG *answ, unsigned int control_w);
160
asmlinkage int wm_sqrt(FPU_REG *n, unsigned int control_w);
161
asmlinkage unsigned     shrx(void *l, unsigned x);
162
asmlinkage unsigned     shrxs(void *v, unsigned x);
163
asmlinkage unsigned long div_small(unsigned long long *x, unsigned long y);
164
asmlinkage void round_reg(FPU_REG *arg, unsigned int extent,
165
                      unsigned int control_w);
166
 
167
#ifndef MAKING_PROTO
168
#include "fpu_proto.h"
169
#endif
170
 
171
#endif __ASSEMBLY__
172
 
173
#endif _FPU_EMU_H_

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.