diff options
author | Richard Purdie <rpurdie@rpsys.net> | 2005-08-03 14:49:17 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2005-08-03 14:49:17 -0400 |
commit | f148af2593ef76ac705d1cc6abe48f455c9912cc (patch) | |
tree | cd1e0b0959624234ca3489df8888434ffea5050e /arch/arm/nwfpe/fpa11_cprt.c | |
parent | 1fcf844861eb08ee05e05dba13b5436f2f2e29ed (diff) |
[PATCH] ARM: 2837/2: Re: ARM: Make NWFPE preempt safe
Patch from Richard Purdie
NWFPE used global variables which meant it wasn't safe for use with
preemptive kernels. This patch removes them and communicates the
information between functions in a preempt safe manner. Generation
of some exceptions was broken and this has also been corrected.
Tests with glibc's maths test suite show no change in the results
before/after this patch.
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/nwfpe/fpa11_cprt.c')
-rw-r--r-- | arch/arm/nwfpe/fpa11_cprt.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/arch/arm/nwfpe/fpa11_cprt.c b/arch/arm/nwfpe/fpa11_cprt.c index db01fbc97216..adf8d3000540 100644 --- a/arch/arm/nwfpe/fpa11_cprt.c +++ b/arch/arm/nwfpe/fpa11_cprt.c | |||
@@ -33,8 +33,6 @@ extern flag floatx80_is_nan(floatx80); | |||
33 | extern flag float64_is_nan(float64); | 33 | extern flag float64_is_nan(float64); |
34 | extern flag float32_is_nan(float32); | 34 | extern flag float32_is_nan(float32); |
35 | 35 | ||
36 | void SetRoundingMode(const unsigned int opcode); | ||
37 | |||
38 | unsigned int PerformFLT(const unsigned int opcode); | 36 | unsigned int PerformFLT(const unsigned int opcode); |
39 | unsigned int PerformFIX(const unsigned int opcode); | 37 | unsigned int PerformFIX(const unsigned int opcode); |
40 | 38 | ||
@@ -77,14 +75,17 @@ unsigned int EmulateCPRT(const unsigned int opcode) | |||
77 | unsigned int PerformFLT(const unsigned int opcode) | 75 | unsigned int PerformFLT(const unsigned int opcode) |
78 | { | 76 | { |
79 | FPA11 *fpa11 = GET_FPA11(); | 77 | FPA11 *fpa11 = GET_FPA11(); |
80 | SetRoundingMode(opcode); | 78 | struct roundingData roundData; |
81 | SetRoundingPrecision(opcode); | 79 | |
80 | roundData.mode = SetRoundingMode(opcode); | ||
81 | roundData.precision = SetRoundingPrecision(opcode); | ||
82 | roundData.exception = 0; | ||
82 | 83 | ||
83 | switch (opcode & MASK_ROUNDING_PRECISION) { | 84 | switch (opcode & MASK_ROUNDING_PRECISION) { |
84 | case ROUND_SINGLE: | 85 | case ROUND_SINGLE: |
85 | { | 86 | { |
86 | fpa11->fType[getFn(opcode)] = typeSingle; | 87 | fpa11->fType[getFn(opcode)] = typeSingle; |
87 | fpa11->fpreg[getFn(opcode)].fSingle = int32_to_float32(readRegister(getRd(opcode))); | 88 | fpa11->fpreg[getFn(opcode)].fSingle = int32_to_float32(&roundData, readRegister(getRd(opcode))); |
88 | } | 89 | } |
89 | break; | 90 | break; |
90 | 91 | ||
@@ -108,6 +109,9 @@ unsigned int PerformFLT(const unsigned int opcode) | |||
108 | return 0; | 109 | return 0; |
109 | } | 110 | } |
110 | 111 | ||
112 | if (roundData.exception) | ||
113 | float_raise(roundData.exception); | ||
114 | |||
111 | return 1; | 115 | return 1; |
112 | } | 116 | } |
113 | 117 | ||
@@ -115,26 +119,29 @@ unsigned int PerformFIX(const unsigned int opcode) | |||
115 | { | 119 | { |
116 | FPA11 *fpa11 = GET_FPA11(); | 120 | FPA11 *fpa11 = GET_FPA11(); |
117 | unsigned int Fn = getFm(opcode); | 121 | unsigned int Fn = getFm(opcode); |
122 | struct roundingData roundData; | ||
118 | 123 | ||
119 | SetRoundingMode(opcode); | 124 | roundData.mode = SetRoundingMode(opcode); |
125 | roundData.precision = SetRoundingPrecision(opcode); | ||
126 | roundData.exception = 0; | ||
120 | 127 | ||
121 | switch (fpa11->fType[Fn]) { | 128 | switch (fpa11->fType[Fn]) { |
122 | case typeSingle: | 129 | case typeSingle: |
123 | { | 130 | { |
124 | writeRegister(getRd(opcode), float32_to_int32(fpa11->fpreg[Fn].fSingle)); | 131 | writeRegister(getRd(opcode), float32_to_int32(&roundData, fpa11->fpreg[Fn].fSingle)); |
125 | } | 132 | } |
126 | break; | 133 | break; |
127 | 134 | ||
128 | case typeDouble: | 135 | case typeDouble: |
129 | { | 136 | { |
130 | writeRegister(getRd(opcode), float64_to_int32(fpa11->fpreg[Fn].fDouble)); | 137 | writeRegister(getRd(opcode), float64_to_int32(&roundData, fpa11->fpreg[Fn].fDouble)); |
131 | } | 138 | } |
132 | break; | 139 | break; |
133 | 140 | ||
134 | #ifdef CONFIG_FPE_NWFPE_XP | 141 | #ifdef CONFIG_FPE_NWFPE_XP |
135 | case typeExtended: | 142 | case typeExtended: |
136 | { | 143 | { |
137 | writeRegister(getRd(opcode), floatx80_to_int32(fpa11->fpreg[Fn].fExtended)); | 144 | writeRegister(getRd(opcode), floatx80_to_int32(&roundData, fpa11->fpreg[Fn].fExtended)); |
138 | } | 145 | } |
139 | break; | 146 | break; |
140 | #endif | 147 | #endif |
@@ -143,6 +150,9 @@ unsigned int PerformFIX(const unsigned int opcode) | |||
143 | return 0; | 150 | return 0; |
144 | } | 151 | } |
145 | 152 | ||
153 | if (roundData.exception) | ||
154 | float_raise(roundData.exception); | ||
155 | |||
146 | return 1; | 156 | return 1; |
147 | } | 157 | } |
148 | 158 | ||