blob: 9677ae8448e85f92ee742fe900faac31c70600a5 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 NetWinder Floating Point Emulator
3 (c) Rebel.com, 1998-1999
4
5 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#ifndef __FPA11_H__
23#define __FPA11_H__
24
25#define GET_FPA11() ((FPA11 *)(&current_thread_info()->fpstate))
26
27/*
28 * The processes registers are always at the very top of the 8K
29 * stack+task struct. Use the same method as 'current' uses to
30 * reach them.
31 */
Russell Kingb66da4a2005-07-17 10:54:50 +010032#define GET_USERREG() ((struct pt_regs *)(THREAD_START_SP + (unsigned long)current_thread_info()) - 1)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
34#include <linux/config.h>
35#include <linux/thread_info.h>
36
37/* includes */
38#include "fpsr.h" /* FP control and status register definitions */
39#include "milieu.h"
Richard Purdief148af22005-08-03 19:49:17 +010040
41struct roundingData {
42 int8 mode;
43 int8 precision;
44 signed char exception;
45};
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#include "softfloat.h"
48
49#define typeNone 0x00
50#define typeSingle 0x01
51#define typeDouble 0x02
52#define typeExtended 0x03
53
54/*
55 * This must be no more and no less than 12 bytes.
56 */
57typedef union tagFPREG {
58 float32 fSingle;
59 float64 fDouble;
60#ifdef CONFIG_FPE_NWFPE_XP
61 floatx80 fExtended;
62#else
63 int padding[3];
64#endif
65} FPREG;
66
67/*
68 * FPA11 device model.
69 *
70 * This structure is exported to user space. Do not re-order.
71 * Only add new stuff to the end, and do not change the size of
72 * any element. Elements of this structure are used by user
73 * space, and must match struct user_fp in include/asm-arm/user.h.
74 * We include the byte offsets below for documentation purposes.
75 *
76 * The size of this structure and FPREG are checked by fpmodule.c
77 * on initialisation. If the rules have been broken, NWFPE will
78 * not initialise.
79 */
80typedef struct tagFPA11 {
81/* 0 */ FPREG fpreg[8]; /* 8 floating point registers */
82/* 96 */ FPSR fpsr; /* floating point status register */
83/* 100 */ FPCR fpcr; /* floating point control register */
84/* 104 */ unsigned char fType[8]; /* type of floating point value held in
85 floating point registers. One of
86 none, single, double or extended. */
87/* 112 */ int initflag; /* this is special. The kernel guarantees
88 to set it to 0 when a thread is launched,
89 so we can use it to detect whether this
90 instance of the emulator needs to be
91 initialised. */
92} FPA11;
93
Richard Purdief148af22005-08-03 19:49:17 +010094extern int8 SetRoundingMode(const unsigned int);
95extern int8 SetRoundingPrecision(const unsigned int);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096extern void nwfpe_init_fpa(union fp_state *fp);
97
Ben Dooks6ec5e7f2005-10-12 19:58:10 +010098extern unsigned int EmulateAll(unsigned int opcode);
99
100extern unsigned int EmulateCPDT(const unsigned int opcode);
101extern unsigned int EmulateCPDO(const unsigned int opcode);
102extern unsigned int EmulateCPRT(const unsigned int opcode);
103
104/* fpa11_cpdt.c */
105extern unsigned int PerformLDF(const unsigned int opcode);
106extern unsigned int PerformSTF(const unsigned int opcode);
107extern unsigned int PerformLFM(const unsigned int opcode);
108extern unsigned int PerformSFM(const unsigned int opcode);
109
110/* single_cpdo.c */
111
112extern unsigned int SingleCPDO(struct roundingData *roundData,
113 const unsigned int opcode, FPREG * rFd);
114/* double_cpdo.c */
115extern unsigned int DoubleCPDO(struct roundingData *roundData,
116 const unsigned int opcode, FPREG * rFd);
117
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118#endif