[PATCH] mips: task_pt_regs()
[linux-2.6/cjktty.git] / arch / arm / nwfpe / fpa11.c
blob7b3d74d73c809c7c8d1855dcca4794ede2cc9316
1 /*
2 NetWinder Floating Point Emulator
3 (c) Rebel.COM, 1998,1999
4 (c) Philip Blundell, 2001
6 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "fpa11.h"
24 #include "fpopcode.h"
26 #include "fpmodule.h"
27 #include "fpmodule.inl"
29 #include <linux/config.h>
30 #include <linux/compiler.h>
31 #include <linux/string.h>
32 #include <asm/system.h>
34 /* Reset the FPA11 chip. Called to initialize and reset the emulator. */
35 static void resetFPA11(void)
37 int i;
38 FPA11 *fpa11 = GET_FPA11();
40 /* initialize the register type array */
41 for (i = 0; i <= 7; i++) {
42 fpa11->fType[i] = typeNone;
45 /* FPSR: set system id to FP_EMULATOR, set AC, clear all other bits */
46 fpa11->fpsr = FP_EMULATOR | BIT_AC;
49 int8 SetRoundingMode(const unsigned int opcode)
51 switch (opcode & MASK_ROUNDING_MODE) {
52 default:
53 case ROUND_TO_NEAREST:
54 return float_round_nearest_even;
56 case ROUND_TO_PLUS_INFINITY:
57 return float_round_up;
59 case ROUND_TO_MINUS_INFINITY:
60 return float_round_down;
62 case ROUND_TO_ZERO:
63 return float_round_to_zero;
67 int8 SetRoundingPrecision(const unsigned int opcode)
69 #ifdef CONFIG_FPE_NWFPE_XP
70 switch (opcode & MASK_ROUNDING_PRECISION) {
71 case ROUND_SINGLE:
72 return 32;
74 case ROUND_DOUBLE:
75 return 64;
77 case ROUND_EXTENDED:
78 return 80;
80 default:
81 return 80;
83 #endif
84 return 80;
87 void nwfpe_init_fpa(union fp_state *fp)
89 FPA11 *fpa11 = (FPA11 *)fp;
90 #ifdef NWFPE_DEBUG
91 printk("NWFPE: setting up state.\n");
92 #endif
93 memset(fpa11, 0, sizeof(FPA11));
94 resetFPA11();
95 fpa11->initflag = 1;
98 /* Emulate the instruction in the opcode. */
99 unsigned int EmulateAll(unsigned int opcode)
101 unsigned int code;
103 #ifdef NWFPE_DEBUG
104 printk("NWFPE: emulating opcode %08x\n", opcode);
105 #endif
106 code = opcode & 0x00000f00;
107 if (code == 0x00000100 || code == 0x00000200) {
108 /* For coprocessor 1 or 2 (FPA11) */
109 code = opcode & 0x0e000000;
110 if (code == 0x0e000000) {
111 if (opcode & 0x00000010) {
112 /* Emulate conversion opcodes. */
113 /* Emulate register transfer opcodes. */
114 /* Emulate comparison opcodes. */
115 return EmulateCPRT(opcode);
116 } else {
117 /* Emulate monadic arithmetic opcodes. */
118 /* Emulate dyadic arithmetic opcodes. */
119 return EmulateCPDO(opcode);
121 } else if (code == 0x0c000000) {
122 /* Emulate load/store opcodes. */
123 /* Emulate load/store multiple opcodes. */
124 return EmulateCPDT(opcode);
128 /* Invalid instruction detected. Return FALSE. */
129 return 0;