Commit a8d3431ae931aa44ee6228ffecf6277714389de7
1 parent
7ff4d218
endianness fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1268 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
3 changed files
with
25 additions
and
2 deletions
target-arm/nwfpe/double_cpdo.c
@@ -150,7 +150,11 @@ unsigned int DoubleCPDO(const unsigned int opcode) | @@ -150,7 +150,11 @@ unsigned int DoubleCPDO(const unsigned int opcode) | ||
150 | case MNF_CODE: | 150 | case MNF_CODE: |
151 | { | 151 | { |
152 | unsigned int *p = (unsigned int*)&rFm; | 152 | unsigned int *p = (unsigned int*)&rFm; |
153 | +#ifdef WORDS_BIGENDIAN | ||
154 | + p[0] ^= 0x80000000; | ||
155 | +#else | ||
153 | p[1] ^= 0x80000000; | 156 | p[1] ^= 0x80000000; |
157 | +#endif | ||
154 | fpa11->fpreg[Fd].fDouble = rFm; | 158 | fpa11->fpreg[Fd].fDouble = rFm; |
155 | } | 159 | } |
156 | break; | 160 | break; |
@@ -158,7 +162,11 @@ unsigned int DoubleCPDO(const unsigned int opcode) | @@ -158,7 +162,11 @@ unsigned int DoubleCPDO(const unsigned int opcode) | ||
158 | case ABS_CODE: | 162 | case ABS_CODE: |
159 | { | 163 | { |
160 | unsigned int *p = (unsigned int*)&rFm; | 164 | unsigned int *p = (unsigned int*)&rFm; |
165 | +#ifdef WORDS_BIGENDIAN | ||
166 | + p[0] &= 0x7fffffff; | ||
167 | +#else | ||
161 | p[1] &= 0x7fffffff; | 168 | p[1] &= 0x7fffffff; |
169 | +#endif | ||
162 | fpa11->fpreg[Fd].fDouble = rFm; | 170 | fpa11->fpreg[Fd].fDouble = rFm; |
163 | } | 171 | } |
164 | break; | 172 | break; |
target-arm/nwfpe/fpa11.h
@@ -22,6 +22,10 @@ | @@ -22,6 +22,10 @@ | ||
22 | #ifndef __FPA11_H__ | 22 | #ifndef __FPA11_H__ |
23 | #define __FPA11_H__ | 23 | #define __FPA11_H__ |
24 | 24 | ||
25 | +#include <stdlib.h> | ||
26 | +#include <stdio.h> | ||
27 | +#include <errno.h> | ||
28 | + | ||
25 | #define GET_FPA11() (qemufpa) | 29 | #define GET_FPA11() (qemufpa) |
26 | 30 | ||
27 | /* | 31 | /* |
@@ -87,8 +91,6 @@ extern void resetFPA11(void); | @@ -87,8 +91,6 @@ extern void resetFPA11(void); | ||
87 | extern void SetRoundingMode(const unsigned int); | 91 | extern void SetRoundingMode(const unsigned int); |
88 | extern void SetRoundingPrecision(const unsigned int); | 92 | extern void SetRoundingPrecision(const unsigned int); |
89 | 93 | ||
90 | -#define get_user(x,y) ((x)=*(y)) | ||
91 | -#define put_user(x,y) (*(y)=(x)) | ||
92 | static inline unsigned int readRegister(unsigned int reg) | 94 | static inline unsigned int readRegister(unsigned int reg) |
93 | { | 95 | { |
94 | return (user_registers[(reg)]); | 96 | return (user_registers[(reg)]); |
@@ -128,4 +130,7 @@ unsigned int ZF; | @@ -128,4 +130,7 @@ unsigned int ZF; | ||
128 | 130 | ||
129 | unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa, unsigned int* qregs); | 131 | unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa, unsigned int* qregs); |
130 | 132 | ||
133 | +/* included only for get_user/put_user macros */ | ||
134 | +#include "qemu.h" | ||
135 | + | ||
131 | #endif | 136 | #endif |
target-arm/nwfpe/fpa11_cpdt.c
@@ -43,8 +43,13 @@ void loadDouble(const unsigned int Fn,const unsigned int *pMem) | @@ -43,8 +43,13 @@ void loadDouble(const unsigned int Fn,const unsigned int *pMem) | ||
43 | unsigned int *p; | 43 | unsigned int *p; |
44 | p = (unsigned int*)&fpa11->fpreg[Fn].fDouble; | 44 | p = (unsigned int*)&fpa11->fpreg[Fn].fDouble; |
45 | fpa11->fType[Fn] = typeDouble; | 45 | fpa11->fType[Fn] = typeDouble; |
46 | +#ifdef WORDS_BIGENDIAN | ||
47 | + get_user(p[0], &pMem[0]); /* sign & exponent */ | ||
48 | + get_user(p[1], &pMem[1]); | ||
49 | +#else | ||
46 | get_user(p[0], &pMem[1]); | 50 | get_user(p[0], &pMem[1]); |
47 | get_user(p[1], &pMem[0]); /* sign & exponent */ | 51 | get_user(p[1], &pMem[0]); /* sign & exponent */ |
52 | +#endif | ||
48 | } | 53 | } |
49 | 54 | ||
50 | static inline | 55 | static inline |
@@ -133,8 +138,13 @@ void storeDouble(const unsigned int Fn,unsigned int *pMem) | @@ -133,8 +138,13 @@ void storeDouble(const unsigned int Fn,unsigned int *pMem) | ||
133 | 138 | ||
134 | default: val = fpa11->fpreg[Fn].fDouble; | 139 | default: val = fpa11->fpreg[Fn].fDouble; |
135 | } | 140 | } |
141 | +#ifdef WORDS_BIGENDIAN | ||
142 | + put_user(p[0], &pMem[0]); /* msw */ | ||
143 | + put_user(p[1], &pMem[1]); /* lsw */ | ||
144 | +#else | ||
136 | put_user(p[1], &pMem[0]); /* msw */ | 145 | put_user(p[1], &pMem[0]); /* msw */ |
137 | put_user(p[0], &pMem[1]); /* lsw */ | 146 | put_user(p[0], &pMem[1]); /* lsw */ |
147 | +#endif | ||
138 | } | 148 | } |
139 | 149 | ||
140 | static inline | 150 | static inline |