root / target-sparc / cpu.h @ 86cc1ce0
History | View | Annotate | Download (7.9 kB)
1 | 7a3f1944 | bellard | #ifndef CPU_SPARC_H
|
---|---|---|---|
2 | 7a3f1944 | bellard | #define CPU_SPARC_H
|
3 | 7a3f1944 | bellard | |
4 | af7bf89b | bellard | #include "config.h" |
5 | af7bf89b | bellard | |
6 | af7bf89b | bellard | #if !defined(TARGET_SPARC64)
|
7 | 3cf1e035 | bellard | #define TARGET_LONG_BITS 32 |
8 | af7bf89b | bellard | #define TARGET_FPREGS 32 |
9 | 83469015 | bellard | #define TARGET_PAGE_BITS 12 /* 4k */ |
10 | af7bf89b | bellard | #else
|
11 | af7bf89b | bellard | #define TARGET_LONG_BITS 64 |
12 | af7bf89b | bellard | #define TARGET_FPREGS 64 |
13 | 83469015 | bellard | #define TARGET_PAGE_BITS 12 /* XXX */ |
14 | af7bf89b | bellard | #endif
|
15 | 3cf1e035 | bellard | |
16 | 7a3f1944 | bellard | #include "cpu-defs.h" |
17 | 7a3f1944 | bellard | |
18 | 7a0e1f41 | bellard | #include "softfloat.h" |
19 | 7a0e1f41 | bellard | |
20 | 1fddef4b | bellard | #define TARGET_HAS_ICE 1 |
21 | 1fddef4b | bellard | |
22 | 9042c0e2 | ths | #if !defined(TARGET_SPARC64)
|
23 | 9042c0e2 | ths | #define ELF_MACHINE EM_SPARC
|
24 | 9042c0e2 | ths | #else
|
25 | 9042c0e2 | ths | #define ELF_MACHINE EM_SPARCV9
|
26 | 9042c0e2 | ths | #endif
|
27 | 9042c0e2 | ths | |
28 | 7a3f1944 | bellard | /*#define EXCP_INTERRUPT 0x100*/
|
29 | 7a3f1944 | bellard | |
30 | cf495bcf | bellard | /* trap definitions */
|
31 | 3475187d | bellard | #ifndef TARGET_SPARC64
|
32 | 878d3096 | bellard | #define TT_TFAULT 0x01 |
33 | cf495bcf | bellard | #define TT_ILL_INSN 0x02 |
34 | e8af50a3 | bellard | #define TT_PRIV_INSN 0x03 |
35 | e80cfcfc | bellard | #define TT_NFPU_INSN 0x04 |
36 | cf495bcf | bellard | #define TT_WIN_OVF 0x05 |
37 | cf495bcf | bellard | #define TT_WIN_UNF 0x06 |
38 | e8af50a3 | bellard | #define TT_FP_EXCP 0x08 |
39 | 878d3096 | bellard | #define TT_DFAULT 0x09 |
40 | e32f879d | blueswir1 | #define TT_TOVF 0x0a |
41 | 878d3096 | bellard | #define TT_EXTINT 0x10 |
42 | cf495bcf | bellard | #define TT_DIV_ZERO 0x2a |
43 | fcc72045 | blueswir1 | #define TT_NCP_INSN 0x24 |
44 | cf495bcf | bellard | #define TT_TRAP 0x80 |
45 | 3475187d | bellard | #else
|
46 | 3475187d | bellard | #define TT_TFAULT 0x08 |
47 | 83469015 | bellard | #define TT_TMISS 0x09 |
48 | 3475187d | bellard | #define TT_ILL_INSN 0x10 |
49 | 3475187d | bellard | #define TT_PRIV_INSN 0x11 |
50 | 3475187d | bellard | #define TT_NFPU_INSN 0x20 |
51 | 3475187d | bellard | #define TT_FP_EXCP 0x21 |
52 | e32f879d | blueswir1 | #define TT_TOVF 0x23 |
53 | 3475187d | bellard | #define TT_CLRWIN 0x24 |
54 | 3475187d | bellard | #define TT_DIV_ZERO 0x28 |
55 | 3475187d | bellard | #define TT_DFAULT 0x30 |
56 | 83469015 | bellard | #define TT_DMISS 0x31 |
57 | 83469015 | bellard | #define TT_DPROT 0x32 |
58 | 83469015 | bellard | #define TT_PRIV_ACT 0x37 |
59 | 3475187d | bellard | #define TT_EXTINT 0x40 |
60 | 3475187d | bellard | #define TT_SPILL 0x80 |
61 | 3475187d | bellard | #define TT_FILL 0xc0 |
62 | 3475187d | bellard | #define TT_WOTHER 0x10 |
63 | 3475187d | bellard | #define TT_TRAP 0x100 |
64 | 3475187d | bellard | #endif
|
65 | 7a3f1944 | bellard | |
66 | 7a3f1944 | bellard | #define PSR_NEG (1<<23) |
67 | 7a3f1944 | bellard | #define PSR_ZERO (1<<22) |
68 | 7a3f1944 | bellard | #define PSR_OVF (1<<21) |
69 | 7a3f1944 | bellard | #define PSR_CARRY (1<<20) |
70 | e8af50a3 | bellard | #define PSR_ICC (PSR_NEG|PSR_ZERO|PSR_OVF|PSR_CARRY)
|
71 | e80cfcfc | bellard | #define PSR_EF (1<<12) |
72 | e80cfcfc | bellard | #define PSR_PIL 0xf00 |
73 | e8af50a3 | bellard | #define PSR_S (1<<7) |
74 | e8af50a3 | bellard | #define PSR_PS (1<<6) |
75 | e8af50a3 | bellard | #define PSR_ET (1<<5) |
76 | e8af50a3 | bellard | #define PSR_CWP 0x1f |
77 | e8af50a3 | bellard | |
78 | e8af50a3 | bellard | /* Trap base register */
|
79 | e8af50a3 | bellard | #define TBR_BASE_MASK 0xfffff000 |
80 | e8af50a3 | bellard | |
81 | 3475187d | bellard | #if defined(TARGET_SPARC64)
|
82 | 83469015 | bellard | #define PS_IG (1<<11) |
83 | 83469015 | bellard | #define PS_MG (1<<10) |
84 | 83469015 | bellard | #define PS_RED (1<<5) |
85 | 3475187d | bellard | #define PS_PEF (1<<4) |
86 | 3475187d | bellard | #define PS_AM (1<<3) |
87 | 3475187d | bellard | #define PS_PRIV (1<<2) |
88 | 3475187d | bellard | #define PS_IE (1<<1) |
89 | 83469015 | bellard | #define PS_AG (1<<0) |
90 | a80dde08 | bellard | |
91 | a80dde08 | bellard | #define FPRS_FEF (1<<2) |
92 | 3475187d | bellard | #endif
|
93 | 3475187d | bellard | |
94 | e8af50a3 | bellard | /* Fcc */
|
95 | e8af50a3 | bellard | #define FSR_RD1 (1<<31) |
96 | e8af50a3 | bellard | #define FSR_RD0 (1<<30) |
97 | e8af50a3 | bellard | #define FSR_RD_MASK (FSR_RD1 | FSR_RD0)
|
98 | e8af50a3 | bellard | #define FSR_RD_NEAREST 0 |
99 | e8af50a3 | bellard | #define FSR_RD_ZERO FSR_RD0
|
100 | e8af50a3 | bellard | #define FSR_RD_POS FSR_RD1
|
101 | e8af50a3 | bellard | #define FSR_RD_NEG (FSR_RD1 | FSR_RD0)
|
102 | e8af50a3 | bellard | |
103 | e8af50a3 | bellard | #define FSR_NVM (1<<27) |
104 | e8af50a3 | bellard | #define FSR_OFM (1<<26) |
105 | e8af50a3 | bellard | #define FSR_UFM (1<<25) |
106 | e8af50a3 | bellard | #define FSR_DZM (1<<24) |
107 | e8af50a3 | bellard | #define FSR_NXM (1<<23) |
108 | e8af50a3 | bellard | #define FSR_TEM_MASK (FSR_NVM | FSR_OFM | FSR_UFM | FSR_DZM | FSR_NXM)
|
109 | e8af50a3 | bellard | |
110 | e8af50a3 | bellard | #define FSR_NVA (1<<9) |
111 | e8af50a3 | bellard | #define FSR_OFA (1<<8) |
112 | e8af50a3 | bellard | #define FSR_UFA (1<<7) |
113 | e8af50a3 | bellard | #define FSR_DZA (1<<6) |
114 | e8af50a3 | bellard | #define FSR_NXA (1<<5) |
115 | e8af50a3 | bellard | #define FSR_AEXC_MASK (FSR_NVA | FSR_OFA | FSR_UFA | FSR_DZA | FSR_NXA)
|
116 | e8af50a3 | bellard | |
117 | e8af50a3 | bellard | #define FSR_NVC (1<<4) |
118 | e8af50a3 | bellard | #define FSR_OFC (1<<3) |
119 | e8af50a3 | bellard | #define FSR_UFC (1<<2) |
120 | e8af50a3 | bellard | #define FSR_DZC (1<<1) |
121 | e8af50a3 | bellard | #define FSR_NXC (1<<0) |
122 | e8af50a3 | bellard | #define FSR_CEXC_MASK (FSR_NVC | FSR_OFC | FSR_UFC | FSR_DZC | FSR_NXC)
|
123 | e8af50a3 | bellard | |
124 | e8af50a3 | bellard | #define FSR_FTT2 (1<<16) |
125 | e8af50a3 | bellard | #define FSR_FTT1 (1<<15) |
126 | e8af50a3 | bellard | #define FSR_FTT0 (1<<14) |
127 | e8af50a3 | bellard | #define FSR_FTT_MASK (FSR_FTT2 | FSR_FTT1 | FSR_FTT0)
|
128 | e80cfcfc | bellard | #define FSR_FTT_IEEE_EXCP (1 << 14) |
129 | e80cfcfc | bellard | #define FSR_FTT_UNIMPFPOP (3 << 14) |
130 | e80cfcfc | bellard | #define FSR_FTT_INVAL_FPR (6 << 14) |
131 | e8af50a3 | bellard | |
132 | e8af50a3 | bellard | #define FSR_FCC1 (1<<11) |
133 | e8af50a3 | bellard | #define FSR_FCC0 (1<<10) |
134 | e8af50a3 | bellard | |
135 | e8af50a3 | bellard | /* MMU */
|
136 | e8af50a3 | bellard | #define MMU_E (1<<0) |
137 | e8af50a3 | bellard | #define MMU_NF (1<<1) |
138 | e8af50a3 | bellard | |
139 | e8af50a3 | bellard | #define PTE_ENTRYTYPE_MASK 3 |
140 | e8af50a3 | bellard | #define PTE_ACCESS_MASK 0x1c |
141 | e8af50a3 | bellard | #define PTE_ACCESS_SHIFT 2 |
142 | 8d5f07fa | bellard | #define PTE_PPN_SHIFT 7 |
143 | e8af50a3 | bellard | #define PTE_ADDR_MASK 0xffffff00 |
144 | e8af50a3 | bellard | |
145 | e8af50a3 | bellard | #define PG_ACCESSED_BIT 5 |
146 | e8af50a3 | bellard | #define PG_MODIFIED_BIT 6 |
147 | e8af50a3 | bellard | #define PG_CACHE_BIT 7 |
148 | e8af50a3 | bellard | |
149 | e8af50a3 | bellard | #define PG_ACCESSED_MASK (1 << PG_ACCESSED_BIT) |
150 | e8af50a3 | bellard | #define PG_MODIFIED_MASK (1 << PG_MODIFIED_BIT) |
151 | e8af50a3 | bellard | #define PG_CACHE_MASK (1 << PG_CACHE_BIT) |
152 | e8af50a3 | bellard | |
153 | 1d6e34fd | bellard | /* 2 <= NWINDOWS <= 32. In QEMU it must also be a power of two. */
|
154 | 1d6e34fd | bellard | #define NWINDOWS 8 |
155 | cf495bcf | bellard | |
156 | 62724a37 | blueswir1 | typedef struct sparc_def_t sparc_def_t; |
157 | 62724a37 | blueswir1 | |
158 | 7a3f1944 | bellard | typedef struct CPUSPARCState { |
159 | af7bf89b | bellard | target_ulong gregs[8]; /* general registers */ |
160 | af7bf89b | bellard | target_ulong *regwptr; /* pointer to current register window */
|
161 | 65ce8c2f | bellard | float32 fpr[TARGET_FPREGS]; /* floating point registers */
|
162 | af7bf89b | bellard | target_ulong pc; /* program counter */
|
163 | af7bf89b | bellard | target_ulong npc; /* next program counter */
|
164 | af7bf89b | bellard | target_ulong y; /* multiply/divide register */
|
165 | cf495bcf | bellard | uint32_t psr; /* processor state register */
|
166 | 3475187d | bellard | target_ulong fsr; /* FPU state register */
|
167 | cf495bcf | bellard | uint32_t cwp; /* index of current register window (extracted
|
168 | cf495bcf | bellard | from PSR) */
|
169 | cf495bcf | bellard | uint32_t wim; /* window invalid mask */
|
170 | 3475187d | bellard | target_ulong tbr; /* trap base register */
|
171 | e8af50a3 | bellard | int psrs; /* supervisor mode (extracted from PSR) */ |
172 | e8af50a3 | bellard | int psrps; /* previous supervisor mode */ |
173 | e8af50a3 | bellard | int psret; /* enable traps */ |
174 | 3475187d | bellard | uint32_t psrpil; /* interrupt level */
|
175 | e80cfcfc | bellard | int psref; /* enable fpu */ |
176 | 62724a37 | blueswir1 | target_ulong version; |
177 | cf495bcf | bellard | jmp_buf jmp_env; |
178 | cf495bcf | bellard | int user_mode_only;
|
179 | cf495bcf | bellard | int exception_index;
|
180 | cf495bcf | bellard | int interrupt_index;
|
181 | cf495bcf | bellard | int interrupt_request;
|
182 | ba3c64fb | bellard | int halted;
|
183 | cf495bcf | bellard | /* NOTE: we allow 8 more registers to handle wrapping */
|
184 | af7bf89b | bellard | target_ulong regbase[NWINDOWS * 16 + 8]; |
185 | d720b93d | bellard | |
186 | a316d335 | bellard | CPU_COMMON |
187 | a316d335 | bellard | |
188 | e8af50a3 | bellard | /* MMU regs */
|
189 | 3475187d | bellard | #if defined(TARGET_SPARC64)
|
190 | 3475187d | bellard | uint64_t lsu; |
191 | 3475187d | bellard | #define DMMU_E 0x8 |
192 | 3475187d | bellard | #define IMMU_E 0x4 |
193 | 3475187d | bellard | uint64_t immuregs[16];
|
194 | 3475187d | bellard | uint64_t dmmuregs[16];
|
195 | 3475187d | bellard | uint64_t itlb_tag[64];
|
196 | 3475187d | bellard | uint64_t itlb_tte[64];
|
197 | 3475187d | bellard | uint64_t dtlb_tag[64];
|
198 | 3475187d | bellard | uint64_t dtlb_tte[64];
|
199 | 3475187d | bellard | #else
|
200 | e8af50a3 | bellard | uint32_t mmuregs[16];
|
201 | 3475187d | bellard | #endif
|
202 | e8af50a3 | bellard | /* temporary float registers */
|
203 | 65ce8c2f | bellard | float32 ft0, ft1; |
204 | 65ce8c2f | bellard | float64 dt0, dt1; |
205 | 7a0e1f41 | bellard | float_status fp_status; |
206 | af7bf89b | bellard | #if defined(TARGET_SPARC64)
|
207 | 3475187d | bellard | #define MAXTL 4 |
208 | 3475187d | bellard | uint64_t t0, t1, t2; |
209 | 3475187d | bellard | uint64_t tpc[MAXTL]; |
210 | 3475187d | bellard | uint64_t tnpc[MAXTL]; |
211 | 3475187d | bellard | uint64_t tstate[MAXTL]; |
212 | 3475187d | bellard | uint32_t tt[MAXTL]; |
213 | 3475187d | bellard | uint32_t xcc; /* Extended integer condition codes */
|
214 | 3475187d | bellard | uint32_t asi; |
215 | 3475187d | bellard | uint32_t pstate; |
216 | 3475187d | bellard | uint32_t tl; |
217 | 3475187d | bellard | uint32_t cansave, canrestore, otherwin, wstate, cleanwin; |
218 | 83469015 | bellard | uint64_t agregs[8]; /* alternate general registers */ |
219 | 83469015 | bellard | uint64_t bgregs[8]; /* backup for normal global registers */ |
220 | 83469015 | bellard | uint64_t igregs[8]; /* interrupt general registers */ |
221 | 83469015 | bellard | uint64_t mgregs[8]; /* mmu general registers */ |
222 | 3475187d | bellard | uint64_t fprs; |
223 | 83469015 | bellard | uint64_t tick_cmpr, stick_cmpr; |
224 | 725cb90b | bellard | uint64_t gsr; |
225 | 3475187d | bellard | #endif
|
226 | 3475187d | bellard | #if !defined(TARGET_SPARC64) && !defined(reg_T2)
|
227 | 3475187d | bellard | target_ulong t2; |
228 | af7bf89b | bellard | #endif
|
229 | 7a3f1944 | bellard | } CPUSPARCState; |
230 | 3475187d | bellard | #if defined(TARGET_SPARC64)
|
231 | 3475187d | bellard | #define GET_FSR32(env) (env->fsr & 0xcfc1ffff) |
232 | 3475187d | bellard | #define PUT_FSR32(env, val) do { uint32_t _tmp = val; \ |
233 | 3475187d | bellard | env->fsr = (_tmp & 0xcfc1c3ff) | (env->fsr & 0x3f00000000ULL); \ |
234 | 3475187d | bellard | } while (0) |
235 | 3475187d | bellard | #define GET_FSR64(env) (env->fsr & 0x3fcfc1ffffULL) |
236 | 3475187d | bellard | #define PUT_FSR64(env, val) do { uint64_t _tmp = val; \ |
237 | 3475187d | bellard | env->fsr = _tmp & 0x3fcfc1c3ffULL; \
|
238 | 3475187d | bellard | } while (0) |
239 | 3475187d | bellard | #else
|
240 | 3475187d | bellard | #define GET_FSR32(env) (env->fsr)
|
241 | 3e736bf4 | blueswir1 | #define PUT_FSR32(env, val) do { uint32_t _tmp = val; \ |
242 | 3e736bf4 | blueswir1 | env->fsr = (_tmp & 0xcfc1ffff) | (env->fsr & 0x000e0000); \ |
243 | 3475187d | bellard | } while (0) |
244 | 3475187d | bellard | #endif
|
245 | 7a3f1944 | bellard | |
246 | 7a3f1944 | bellard | CPUSPARCState *cpu_sparc_init(void);
|
247 | 7a3f1944 | bellard | int cpu_sparc_exec(CPUSPARCState *s);
|
248 | 7a3f1944 | bellard | int cpu_sparc_close(CPUSPARCState *s);
|
249 | 62724a37 | blueswir1 | int sparc_find_by_name (const unsigned char *name, const sparc_def_t **def); |
250 | 62724a37 | blueswir1 | void sparc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, |
251 | 62724a37 | blueswir1 | ...)); |
252 | 62724a37 | blueswir1 | int cpu_sparc_register (CPUSPARCState *env, const sparc_def_t *def); |
253 | 7a3f1944 | bellard | |
254 | 62724a37 | blueswir1 | #define GET_PSR(env) (env->version | (env->psr & PSR_ICC) | \
|
255 | b4ff5987 | bellard | (env->psref? PSR_EF : 0) | \
|
256 | b4ff5987 | bellard | (env->psrpil << 8) | \
|
257 | b4ff5987 | bellard | (env->psrs? PSR_S : 0) | \
|
258 | afc7df11 | bellard | (env->psrps? PSR_PS : 0) | \
|
259 | b4ff5987 | bellard | (env->psret? PSR_ET : 0) | env->cwp)
|
260 | b4ff5987 | bellard | |
261 | b4ff5987 | bellard | #ifndef NO_CPU_IO_DEFS
|
262 | b4ff5987 | bellard | void cpu_set_cwp(CPUSPARCState *env1, int new_cwp); |
263 | b4ff5987 | bellard | #endif
|
264 | b4ff5987 | bellard | |
265 | b4ff5987 | bellard | #define PUT_PSR(env, val) do { int _tmp = val; \ |
266 | af7bf89b | bellard | env->psr = _tmp & PSR_ICC; \ |
267 | b4ff5987 | bellard | env->psref = (_tmp & PSR_EF)? 1 : 0; \ |
268 | b4ff5987 | bellard | env->psrpil = (_tmp & PSR_PIL) >> 8; \
|
269 | b4ff5987 | bellard | env->psrs = (_tmp & PSR_S)? 1 : 0; \ |
270 | b4ff5987 | bellard | env->psrps = (_tmp & PSR_PS)? 1 : 0; \ |
271 | b4ff5987 | bellard | env->psret = (_tmp & PSR_ET)? 1 : 0; \ |
272 | d4218d99 | blueswir1 | cpu_set_cwp(env, _tmp & PSR_CWP); \ |
273 | b4ff5987 | bellard | } while (0) |
274 | b4ff5987 | bellard | |
275 | 3475187d | bellard | #ifdef TARGET_SPARC64
|
276 | 3475187d | bellard | #define GET_CCR(env) ((env->xcc << 4) | (env->psr & PSR_ICC)) |
277 | 3475187d | bellard | #define PUT_CCR(env, val) do { int _tmp = val; \ |
278 | 3475187d | bellard | env->xcc = _tmp >> 4; \
|
279 | 3475187d | bellard | env->psr = (_tmp & 0xf) << 20; \ |
280 | 3475187d | bellard | } while (0) |
281 | 3475187d | bellard | #endif
|
282 | 3475187d | bellard | |
283 | 5a7b542b | ths | int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc); |
284 | 7a3f1944 | bellard | |
285 | 7a3f1944 | bellard | #include "cpu-all.h" |
286 | 7a3f1944 | bellard | |
287 | 7a3f1944 | bellard | #endif |