root / target-sparc / cpu.h @ 275ea265
History | View | Annotate | Download (20.5 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 | 058ed88c | Richard Henderson | #define TARGET_PHYS_ADDR_SPACE_BITS 36 |
11 | 058ed88c | Richard Henderson | #define TARGET_VIRT_ADDR_SPACE_BITS 32 |
12 | 058ed88c | Richard Henderson | #else
|
13 | 058ed88c | Richard Henderson | #define TARGET_LONG_BITS 64 |
14 | 058ed88c | Richard Henderson | #define TARGET_FPREGS 64 |
15 | 058ed88c | Richard Henderson | #define TARGET_PAGE_BITS 13 /* 8k */ |
16 | 52705890 | Richard Henderson | #define TARGET_PHYS_ADDR_SPACE_BITS 41 |
17 | 52705890 | Richard Henderson | # ifdef TARGET_ABI32
|
18 | 52705890 | Richard Henderson | # define TARGET_VIRT_ADDR_SPACE_BITS 32 |
19 | 52705890 | Richard Henderson | # else
|
20 | 52705890 | Richard Henderson | # define TARGET_VIRT_ADDR_SPACE_BITS 44 |
21 | 52705890 | Richard Henderson | # endif
|
22 | af7bf89b | bellard | #endif
|
23 | 3cf1e035 | bellard | |
24 | c2764719 | pbrook | #define CPUState struct CPUSPARCState |
25 | c2764719 | pbrook | |
26 | 7a3f1944 | bellard | #include "cpu-defs.h" |
27 | 7a3f1944 | bellard | |
28 | 7a0e1f41 | bellard | #include "softfloat.h" |
29 | 7a0e1f41 | bellard | |
30 | 1fddef4b | bellard | #define TARGET_HAS_ICE 1 |
31 | 1fddef4b | bellard | |
32 | 9042c0e2 | ths | #if !defined(TARGET_SPARC64)
|
33 | 0f8a249a | blueswir1 | #define ELF_MACHINE EM_SPARC
|
34 | 9042c0e2 | ths | #else
|
35 | 0f8a249a | blueswir1 | #define ELF_MACHINE EM_SPARCV9
|
36 | 9042c0e2 | ths | #endif
|
37 | 9042c0e2 | ths | |
38 | 7a3f1944 | bellard | /*#define EXCP_INTERRUPT 0x100*/
|
39 | 7a3f1944 | bellard | |
40 | cf495bcf | bellard | /* trap definitions */
|
41 | 3475187d | bellard | #ifndef TARGET_SPARC64
|
42 | 878d3096 | bellard | #define TT_TFAULT 0x01 |
43 | cf495bcf | bellard | #define TT_ILL_INSN 0x02 |
44 | e8af50a3 | bellard | #define TT_PRIV_INSN 0x03 |
45 | e80cfcfc | bellard | #define TT_NFPU_INSN 0x04 |
46 | cf495bcf | bellard | #define TT_WIN_OVF 0x05 |
47 | 5fafdf24 | ths | #define TT_WIN_UNF 0x06 |
48 | d2889a3e | blueswir1 | #define TT_UNALIGNED 0x07 |
49 | e8af50a3 | bellard | #define TT_FP_EXCP 0x08 |
50 | 878d3096 | bellard | #define TT_DFAULT 0x09 |
51 | e32f879d | blueswir1 | #define TT_TOVF 0x0a |
52 | 878d3096 | bellard | #define TT_EXTINT 0x10 |
53 | 1b2e93c1 | blueswir1 | #define TT_CODE_ACCESS 0x21 |
54 | 64a88d5d | blueswir1 | #define TT_UNIMP_FLUSH 0x25 |
55 | b4f0a316 | blueswir1 | #define TT_DATA_ACCESS 0x29 |
56 | cf495bcf | bellard | #define TT_DIV_ZERO 0x2a |
57 | fcc72045 | blueswir1 | #define TT_NCP_INSN 0x24 |
58 | cf495bcf | bellard | #define TT_TRAP 0x80 |
59 | 3475187d | bellard | #else
|
60 | 8194f35a | Igor Kovalenko | #define TT_POWER_ON_RESET 0x01 |
61 | 3475187d | bellard | #define TT_TFAULT 0x08 |
62 | 1b2e93c1 | blueswir1 | #define TT_CODE_ACCESS 0x0a |
63 | 3475187d | bellard | #define TT_ILL_INSN 0x10 |
64 | 64a88d5d | blueswir1 | #define TT_UNIMP_FLUSH TT_ILL_INSN
|
65 | 3475187d | bellard | #define TT_PRIV_INSN 0x11 |
66 | 3475187d | bellard | #define TT_NFPU_INSN 0x20 |
67 | 3475187d | bellard | #define TT_FP_EXCP 0x21 |
68 | e32f879d | blueswir1 | #define TT_TOVF 0x23 |
69 | 3475187d | bellard | #define TT_CLRWIN 0x24 |
70 | 3475187d | bellard | #define TT_DIV_ZERO 0x28 |
71 | 3475187d | bellard | #define TT_DFAULT 0x30 |
72 | b4f0a316 | blueswir1 | #define TT_DATA_ACCESS 0x32 |
73 | d2889a3e | blueswir1 | #define TT_UNALIGNED 0x34 |
74 | 83469015 | bellard | #define TT_PRIV_ACT 0x37 |
75 | 3475187d | bellard | #define TT_EXTINT 0x40 |
76 | 74b9decc | blueswir1 | #define TT_IVEC 0x60 |
77 | e19e4efe | blueswir1 | #define TT_TMISS 0x64 |
78 | e19e4efe | blueswir1 | #define TT_DMISS 0x68 |
79 | 74b9decc | blueswir1 | #define TT_DPROT 0x6c |
80 | 3475187d | bellard | #define TT_SPILL 0x80 |
81 | 3475187d | bellard | #define TT_FILL 0xc0 |
82 | 3475187d | bellard | #define TT_WOTHER 0x10 |
83 | 3475187d | bellard | #define TT_TRAP 0x100 |
84 | 3475187d | bellard | #endif
|
85 | 7a3f1944 | bellard | |
86 | 4b8b8b76 | blueswir1 | #define PSR_NEG_SHIFT 23 |
87 | 4b8b8b76 | blueswir1 | #define PSR_NEG (1 << PSR_NEG_SHIFT) |
88 | 4b8b8b76 | blueswir1 | #define PSR_ZERO_SHIFT 22 |
89 | 4b8b8b76 | blueswir1 | #define PSR_ZERO (1 << PSR_ZERO_SHIFT) |
90 | 4b8b8b76 | blueswir1 | #define PSR_OVF_SHIFT 21 |
91 | 4b8b8b76 | blueswir1 | #define PSR_OVF (1 << PSR_OVF_SHIFT) |
92 | 4b8b8b76 | blueswir1 | #define PSR_CARRY_SHIFT 20 |
93 | 4b8b8b76 | blueswir1 | #define PSR_CARRY (1 << PSR_CARRY_SHIFT) |
94 | e8af50a3 | bellard | #define PSR_ICC (PSR_NEG|PSR_ZERO|PSR_OVF|PSR_CARRY)
|
95 | e80cfcfc | bellard | #define PSR_EF (1<<12) |
96 | e80cfcfc | bellard | #define PSR_PIL 0xf00 |
97 | e8af50a3 | bellard | #define PSR_S (1<<7) |
98 | e8af50a3 | bellard | #define PSR_PS (1<<6) |
99 | e8af50a3 | bellard | #define PSR_ET (1<<5) |
100 | e8af50a3 | bellard | #define PSR_CWP 0x1f |
101 | e8af50a3 | bellard | |
102 | 8393617c | Blue Swirl | #define CC_SRC (env->cc_src)
|
103 | 8393617c | Blue Swirl | #define CC_SRC2 (env->cc_src2)
|
104 | 8393617c | Blue Swirl | #define CC_DST (env->cc_dst)
|
105 | 8393617c | Blue Swirl | #define CC_OP (env->cc_op)
|
106 | 8393617c | Blue Swirl | |
107 | 8393617c | Blue Swirl | enum {
|
108 | 8393617c | Blue Swirl | CC_OP_DYNAMIC, /* must use dynamic code to get cc_op */
|
109 | 8393617c | Blue Swirl | CC_OP_FLAGS, /* all cc are back in status register */
|
110 | 8393617c | Blue Swirl | CC_OP_DIV, /* modify N, Z and V, C = 0*/
|
111 | 8393617c | Blue Swirl | CC_OP_ADD, /* modify all flags, CC_DST = res, CC_SRC = src1 */
|
112 | 8393617c | Blue Swirl | CC_OP_ADDX, /* modify all flags, CC_DST = res, CC_SRC = src1 */
|
113 | 8393617c | Blue Swirl | CC_OP_TADD, /* modify all flags, CC_DST = res, CC_SRC = src1 */
|
114 | 8393617c | Blue Swirl | CC_OP_TADDTV, /* modify all flags except V, CC_DST = res, CC_SRC = src1 */
|
115 | 8393617c | Blue Swirl | CC_OP_SUB, /* modify all flags, CC_DST = res, CC_SRC = src1 */
|
116 | 8393617c | Blue Swirl | CC_OP_SUBX, /* modify all flags, CC_DST = res, CC_SRC = src1 */
|
117 | 8393617c | Blue Swirl | CC_OP_TSUB, /* modify all flags, CC_DST = res, CC_SRC = src1 */
|
118 | 8393617c | Blue Swirl | CC_OP_TSUBTV, /* modify all flags except V, CC_DST = res, CC_SRC = src1 */
|
119 | 8393617c | Blue Swirl | CC_OP_LOGIC, /* modify N and Z, C = V = 0, CC_DST = res */
|
120 | 8393617c | Blue Swirl | CC_OP_NB, |
121 | 8393617c | Blue Swirl | }; |
122 | 8393617c | Blue Swirl | |
123 | e8af50a3 | bellard | /* Trap base register */
|
124 | e8af50a3 | bellard | #define TBR_BASE_MASK 0xfffff000 |
125 | e8af50a3 | bellard | |
126 | 3475187d | bellard | #if defined(TARGET_SPARC64)
|
127 | 5210977a | Igor Kovalenko | #define PS_TCT (1<<12) /* UA2007, impl.dep. trap on control transfer */ |
128 | 5210977a | Igor Kovalenko | #define PS_IG (1<<11) /* v9, zero on UA2007 */ |
129 | 5210977a | Igor Kovalenko | #define PS_MG (1<<10) /* v9, zero on UA2007 */ |
130 | 5210977a | Igor Kovalenko | #define PS_CLE (1<<9) /* UA2007 */ |
131 | 5210977a | Igor Kovalenko | #define PS_TLE (1<<8) /* UA2007 */ |
132 | 6ef905f6 | blueswir1 | #define PS_RMO (1<<7) |
133 | 5210977a | Igor Kovalenko | #define PS_RED (1<<5) /* v9, zero on UA2007 */ |
134 | 5210977a | Igor Kovalenko | #define PS_PEF (1<<4) /* enable fpu */ |
135 | 5210977a | Igor Kovalenko | #define PS_AM (1<<3) /* address mask */ |
136 | 3475187d | bellard | #define PS_PRIV (1<<2) |
137 | 3475187d | bellard | #define PS_IE (1<<1) |
138 | 5210977a | Igor Kovalenko | #define PS_AG (1<<0) /* v9, zero on UA2007 */ |
139 | a80dde08 | bellard | |
140 | a80dde08 | bellard | #define FPRS_FEF (1<<2) |
141 | 6f27aba6 | blueswir1 | |
142 | 6f27aba6 | blueswir1 | #define HS_PRIV (1<<2) |
143 | 3475187d | bellard | #endif
|
144 | 3475187d | bellard | |
145 | e8af50a3 | bellard | /* Fcc */
|
146 | ba6a9d8c | blueswir1 | #define FSR_RD1 (1ULL << 31) |
147 | ba6a9d8c | blueswir1 | #define FSR_RD0 (1ULL << 30) |
148 | e8af50a3 | bellard | #define FSR_RD_MASK (FSR_RD1 | FSR_RD0)
|
149 | e8af50a3 | bellard | #define FSR_RD_NEAREST 0 |
150 | e8af50a3 | bellard | #define FSR_RD_ZERO FSR_RD0
|
151 | e8af50a3 | bellard | #define FSR_RD_POS FSR_RD1
|
152 | e8af50a3 | bellard | #define FSR_RD_NEG (FSR_RD1 | FSR_RD0)
|
153 | e8af50a3 | bellard | |
154 | ba6a9d8c | blueswir1 | #define FSR_NVM (1ULL << 27) |
155 | ba6a9d8c | blueswir1 | #define FSR_OFM (1ULL << 26) |
156 | ba6a9d8c | blueswir1 | #define FSR_UFM (1ULL << 25) |
157 | ba6a9d8c | blueswir1 | #define FSR_DZM (1ULL << 24) |
158 | ba6a9d8c | blueswir1 | #define FSR_NXM (1ULL << 23) |
159 | e8af50a3 | bellard | #define FSR_TEM_MASK (FSR_NVM | FSR_OFM | FSR_UFM | FSR_DZM | FSR_NXM)
|
160 | e8af50a3 | bellard | |
161 | ba6a9d8c | blueswir1 | #define FSR_NVA (1ULL << 9) |
162 | ba6a9d8c | blueswir1 | #define FSR_OFA (1ULL << 8) |
163 | ba6a9d8c | blueswir1 | #define FSR_UFA (1ULL << 7) |
164 | ba6a9d8c | blueswir1 | #define FSR_DZA (1ULL << 6) |
165 | ba6a9d8c | blueswir1 | #define FSR_NXA (1ULL << 5) |
166 | e8af50a3 | bellard | #define FSR_AEXC_MASK (FSR_NVA | FSR_OFA | FSR_UFA | FSR_DZA | FSR_NXA)
|
167 | e8af50a3 | bellard | |
168 | ba6a9d8c | blueswir1 | #define FSR_NVC (1ULL << 4) |
169 | ba6a9d8c | blueswir1 | #define FSR_OFC (1ULL << 3) |
170 | ba6a9d8c | blueswir1 | #define FSR_UFC (1ULL << 2) |
171 | ba6a9d8c | blueswir1 | #define FSR_DZC (1ULL << 1) |
172 | ba6a9d8c | blueswir1 | #define FSR_NXC (1ULL << 0) |
173 | e8af50a3 | bellard | #define FSR_CEXC_MASK (FSR_NVC | FSR_OFC | FSR_UFC | FSR_DZC | FSR_NXC)
|
174 | e8af50a3 | bellard | |
175 | ba6a9d8c | blueswir1 | #define FSR_FTT2 (1ULL << 16) |
176 | ba6a9d8c | blueswir1 | #define FSR_FTT1 (1ULL << 15) |
177 | ba6a9d8c | blueswir1 | #define FSR_FTT0 (1ULL << 14) |
178 | 47ad35f1 | blueswir1 | //gcc warns about constant overflow for ~FSR_FTT_MASK
|
179 | 47ad35f1 | blueswir1 | //#define FSR_FTT_MASK (FSR_FTT2 | FSR_FTT1 | FSR_FTT0)
|
180 | 47ad35f1 | blueswir1 | #ifdef TARGET_SPARC64
|
181 | 47ad35f1 | blueswir1 | #define FSR_FTT_NMASK 0xfffffffffffe3fffULL |
182 | 47ad35f1 | blueswir1 | #define FSR_FTT_CEXC_NMASK 0xfffffffffffe3fe0ULL |
183 | 3a3b925d | blueswir1 | #define FSR_LDFSR_OLDMASK 0x0000003f000fc000ULL |
184 | 3a3b925d | blueswir1 | #define FSR_LDXFSR_MASK 0x0000003fcfc00fffULL |
185 | 3a3b925d | blueswir1 | #define FSR_LDXFSR_OLDMASK 0x00000000000fc000ULL |
186 | 47ad35f1 | blueswir1 | #else
|
187 | 47ad35f1 | blueswir1 | #define FSR_FTT_NMASK 0xfffe3fffULL |
188 | 47ad35f1 | blueswir1 | #define FSR_FTT_CEXC_NMASK 0xfffe3fe0ULL |
189 | 3a3b925d | blueswir1 | #define FSR_LDFSR_OLDMASK 0x000fc000ULL |
190 | 47ad35f1 | blueswir1 | #endif
|
191 | 3a3b925d | blueswir1 | #define FSR_LDFSR_MASK 0xcfc00fffULL |
192 | ba6a9d8c | blueswir1 | #define FSR_FTT_IEEE_EXCP (1ULL << 14) |
193 | ba6a9d8c | blueswir1 | #define FSR_FTT_UNIMPFPOP (3ULL << 14) |
194 | ba6a9d8c | blueswir1 | #define FSR_FTT_SEQ_ERROR (4ULL << 14) |
195 | ba6a9d8c | blueswir1 | #define FSR_FTT_INVAL_FPR (6ULL << 14) |
196 | e8af50a3 | bellard | |
197 | 4b8b8b76 | blueswir1 | #define FSR_FCC1_SHIFT 11 |
198 | ba6a9d8c | blueswir1 | #define FSR_FCC1 (1ULL << FSR_FCC1_SHIFT) |
199 | 4b8b8b76 | blueswir1 | #define FSR_FCC0_SHIFT 10 |
200 | ba6a9d8c | blueswir1 | #define FSR_FCC0 (1ULL << FSR_FCC0_SHIFT) |
201 | e8af50a3 | bellard | |
202 | e8af50a3 | bellard | /* MMU */
|
203 | 0f8a249a | blueswir1 | #define MMU_E (1<<0) |
204 | 0f8a249a | blueswir1 | #define MMU_NF (1<<1) |
205 | e8af50a3 | bellard | |
206 | e8af50a3 | bellard | #define PTE_ENTRYTYPE_MASK 3 |
207 | e8af50a3 | bellard | #define PTE_ACCESS_MASK 0x1c |
208 | e8af50a3 | bellard | #define PTE_ACCESS_SHIFT 2 |
209 | 8d5f07fa | bellard | #define PTE_PPN_SHIFT 7 |
210 | e8af50a3 | bellard | #define PTE_ADDR_MASK 0xffffff00 |
211 | e8af50a3 | bellard | |
212 | 0f8a249a | blueswir1 | #define PG_ACCESSED_BIT 5 |
213 | 0f8a249a | blueswir1 | #define PG_MODIFIED_BIT 6 |
214 | e8af50a3 | bellard | #define PG_CACHE_BIT 7 |
215 | e8af50a3 | bellard | |
216 | e8af50a3 | bellard | #define PG_ACCESSED_MASK (1 << PG_ACCESSED_BIT) |
217 | e8af50a3 | bellard | #define PG_MODIFIED_MASK (1 << PG_MODIFIED_BIT) |
218 | e8af50a3 | bellard | #define PG_CACHE_MASK (1 << PG_CACHE_BIT) |
219 | e8af50a3 | bellard | |
220 | 1a14026e | blueswir1 | /* 3 <= NWINDOWS <= 32. */
|
221 | 1a14026e | blueswir1 | #define MIN_NWINDOWS 3 |
222 | 1a14026e | blueswir1 | #define MAX_NWINDOWS 32 |
223 | cf495bcf | bellard | |
224 | 6f27aba6 | blueswir1 | #if !defined(TARGET_SPARC64)
|
225 | 6ebbf390 | j_mayer | #define NB_MMU_MODES 2 |
226 | 6f27aba6 | blueswir1 | #else
|
227 | 2065061e | Igor V. Kovalenko | #define NB_MMU_MODES 6 |
228 | 375ee38b | blueswir1 | typedef struct trap_state { |
229 | 375ee38b | blueswir1 | uint64_t tpc; |
230 | 375ee38b | blueswir1 | uint64_t tnpc; |
231 | 375ee38b | blueswir1 | uint64_t tstate; |
232 | 375ee38b | blueswir1 | uint32_t tt; |
233 | 375ee38b | blueswir1 | } trap_state; |
234 | 6f27aba6 | blueswir1 | #endif
|
235 | 6ebbf390 | j_mayer | |
236 | 5578ceab | blueswir1 | typedef struct sparc_def_t { |
237 | 5578ceab | blueswir1 | const char *name; |
238 | 5578ceab | blueswir1 | target_ulong iu_version; |
239 | 5578ceab | blueswir1 | uint32_t fpu_version; |
240 | 5578ceab | blueswir1 | uint32_t mmu_version; |
241 | 5578ceab | blueswir1 | uint32_t mmu_bm; |
242 | 5578ceab | blueswir1 | uint32_t mmu_ctpr_mask; |
243 | 5578ceab | blueswir1 | uint32_t mmu_cxr_mask; |
244 | 5578ceab | blueswir1 | uint32_t mmu_sfsr_mask; |
245 | 5578ceab | blueswir1 | uint32_t mmu_trcr_mask; |
246 | 963262de | blueswir1 | uint32_t mxcc_version; |
247 | 5578ceab | blueswir1 | uint32_t features; |
248 | 5578ceab | blueswir1 | uint32_t nwindows; |
249 | 5578ceab | blueswir1 | uint32_t maxtl; |
250 | 5578ceab | blueswir1 | } sparc_def_t; |
251 | 5578ceab | blueswir1 | |
252 | 5578ceab | blueswir1 | #define CPU_FEATURE_FLOAT (1 << 0) |
253 | 5578ceab | blueswir1 | #define CPU_FEATURE_FLOAT128 (1 << 1) |
254 | 5578ceab | blueswir1 | #define CPU_FEATURE_SWAP (1 << 2) |
255 | 5578ceab | blueswir1 | #define CPU_FEATURE_MUL (1 << 3) |
256 | 5578ceab | blueswir1 | #define CPU_FEATURE_DIV (1 << 4) |
257 | 5578ceab | blueswir1 | #define CPU_FEATURE_FLUSH (1 << 5) |
258 | 5578ceab | blueswir1 | #define CPU_FEATURE_FSQRT (1 << 6) |
259 | 5578ceab | blueswir1 | #define CPU_FEATURE_FMUL (1 << 7) |
260 | 5578ceab | blueswir1 | #define CPU_FEATURE_VIS1 (1 << 8) |
261 | 5578ceab | blueswir1 | #define CPU_FEATURE_VIS2 (1 << 9) |
262 | 5578ceab | blueswir1 | #define CPU_FEATURE_FSMULD (1 << 10) |
263 | 5578ceab | blueswir1 | #define CPU_FEATURE_HYPV (1 << 11) |
264 | 5578ceab | blueswir1 | #define CPU_FEATURE_CMT (1 << 12) |
265 | 5578ceab | blueswir1 | #define CPU_FEATURE_GL (1 << 13) |
266 | 5578ceab | blueswir1 | #ifndef TARGET_SPARC64
|
267 | 5578ceab | blueswir1 | #define CPU_DEFAULT_FEATURES (CPU_FEATURE_FLOAT | CPU_FEATURE_SWAP | \
|
268 | 5578ceab | blueswir1 | CPU_FEATURE_MUL | CPU_FEATURE_DIV | \ |
269 | 5578ceab | blueswir1 | CPU_FEATURE_FLUSH | CPU_FEATURE_FSQRT | \ |
270 | 5578ceab | blueswir1 | CPU_FEATURE_FMUL | CPU_FEATURE_FSMULD) |
271 | 5578ceab | blueswir1 | #else
|
272 | 5578ceab | blueswir1 | #define CPU_DEFAULT_FEATURES (CPU_FEATURE_FLOAT | CPU_FEATURE_SWAP | \
|
273 | 5578ceab | blueswir1 | CPU_FEATURE_MUL | CPU_FEATURE_DIV | \ |
274 | 5578ceab | blueswir1 | CPU_FEATURE_FLUSH | CPU_FEATURE_FSQRT | \ |
275 | 5578ceab | blueswir1 | CPU_FEATURE_FMUL | CPU_FEATURE_VIS1 | \ |
276 | 5578ceab | blueswir1 | CPU_FEATURE_VIS2 | CPU_FEATURE_FSMULD) |
277 | 5578ceab | blueswir1 | enum {
|
278 | 5578ceab | blueswir1 | mmu_us_12, // Ultrasparc < III (64 entry TLB)
|
279 | 5578ceab | blueswir1 | mmu_us_3, // Ultrasparc III (512 entry TLB)
|
280 | 5578ceab | blueswir1 | mmu_us_4, // Ultrasparc IV (several TLBs, 32 and 256MB pages)
|
281 | 5578ceab | blueswir1 | mmu_sun4v, // T1, T2
|
282 | 5578ceab | blueswir1 | }; |
283 | 5578ceab | blueswir1 | #endif
|
284 | 5578ceab | blueswir1 | |
285 | f707726e | Igor Kovalenko | #define TTE_VALID_BIT (1ULL << 63) |
286 | f707726e | Igor Kovalenko | #define TTE_USED_BIT (1ULL << 41) |
287 | f707726e | Igor Kovalenko | #define TTE_LOCKED_BIT (1ULL << 6) |
288 | 2a90358f | Blue Swirl | #define TTE_GLOBAL_BIT (1ULL << 0) |
289 | f707726e | Igor Kovalenko | |
290 | f707726e | Igor Kovalenko | #define TTE_IS_VALID(tte) ((tte) & TTE_VALID_BIT)
|
291 | f707726e | Igor Kovalenko | #define TTE_IS_USED(tte) ((tte) & TTE_USED_BIT)
|
292 | f707726e | Igor Kovalenko | #define TTE_IS_LOCKED(tte) ((tte) & TTE_LOCKED_BIT)
|
293 | 2a90358f | Blue Swirl | #define TTE_IS_GLOBAL(tte) ((tte) & TTE_GLOBAL_BIT)
|
294 | f707726e | Igor Kovalenko | |
295 | f707726e | Igor Kovalenko | #define TTE_SET_USED(tte) ((tte) |= TTE_USED_BIT)
|
296 | f707726e | Igor Kovalenko | #define TTE_SET_UNUSED(tte) ((tte) &= ~TTE_USED_BIT)
|
297 | f707726e | Igor Kovalenko | |
298 | 6e8e7d4c | Igor Kovalenko | typedef struct SparcTLBEntry { |
299 | 6e8e7d4c | Igor Kovalenko | uint64_t tag; |
300 | 6e8e7d4c | Igor Kovalenko | uint64_t tte; |
301 | 6e8e7d4c | Igor Kovalenko | } SparcTLBEntry; |
302 | 6e8e7d4c | Igor Kovalenko | |
303 | 8f4efc55 | Igor V. Kovalenko | struct CPUTimer
|
304 | 8f4efc55 | Igor V. Kovalenko | { |
305 | 8f4efc55 | Igor V. Kovalenko | const char *name; |
306 | 8f4efc55 | Igor V. Kovalenko | uint32_t frequency; |
307 | 8f4efc55 | Igor V. Kovalenko | uint32_t disabled; |
308 | 8f4efc55 | Igor V. Kovalenko | uint64_t disabled_mask; |
309 | 8f4efc55 | Igor V. Kovalenko | int64_t clock_offset; |
310 | 8f4efc55 | Igor V. Kovalenko | struct QEMUTimer *qtimer;
|
311 | 8f4efc55 | Igor V. Kovalenko | }; |
312 | 8f4efc55 | Igor V. Kovalenko | |
313 | 8f4efc55 | Igor V. Kovalenko | typedef struct CPUTimer CPUTimer; |
314 | 8f4efc55 | Igor V. Kovalenko | |
315 | 8f4efc55 | Igor V. Kovalenko | struct QEMUFile;
|
316 | 8f4efc55 | Igor V. Kovalenko | void cpu_put_timer(struct QEMUFile *f, CPUTimer *s); |
317 | 8f4efc55 | Igor V. Kovalenko | void cpu_get_timer(struct QEMUFile *f, CPUTimer *s); |
318 | 8f4efc55 | Igor V. Kovalenko | |
319 | 7a3f1944 | bellard | typedef struct CPUSPARCState { |
320 | af7bf89b | bellard | target_ulong gregs[8]; /* general registers */ |
321 | af7bf89b | bellard | target_ulong *regwptr; /* pointer to current register window */
|
322 | af7bf89b | bellard | target_ulong pc; /* program counter */
|
323 | af7bf89b | bellard | target_ulong npc; /* next program counter */
|
324 | af7bf89b | bellard | target_ulong y; /* multiply/divide register */
|
325 | dc99a3f2 | blueswir1 | |
326 | dc99a3f2 | blueswir1 | /* emulator internal flags handling */
|
327 | d9bdab86 | blueswir1 | target_ulong cc_src, cc_src2; |
328 | dc99a3f2 | blueswir1 | target_ulong cc_dst; |
329 | 8393617c | Blue Swirl | uint32_t cc_op; |
330 | dc99a3f2 | blueswir1 | |
331 | 7c60cc4b | bellard | target_ulong t0, t1; /* temporaries live across basic blocks */
|
332 | 7c60cc4b | bellard | target_ulong cond; /* conditional branch result (XXX: save it in a
|
333 | 7c60cc4b | bellard | temporary register when possible) */
|
334 | 7c60cc4b | bellard | |
335 | cf495bcf | bellard | uint32_t psr; /* processor state register */
|
336 | 3475187d | bellard | target_ulong fsr; /* FPU state register */
|
337 | 7c60cc4b | bellard | float32 fpr[TARGET_FPREGS]; /* floating point registers */
|
338 | cf495bcf | bellard | uint32_t cwp; /* index of current register window (extracted
|
339 | cf495bcf | bellard | from PSR) */
|
340 | 5210977a | Igor Kovalenko | #if !defined(TARGET_SPARC64) || defined(TARGET_ABI32)
|
341 | cf495bcf | bellard | uint32_t wim; /* window invalid mask */
|
342 | 5210977a | Igor Kovalenko | #endif
|
343 | 3475187d | bellard | target_ulong tbr; /* trap base register */
|
344 | e8af50a3 | bellard | int psrs; /* supervisor mode (extracted from PSR) */ |
345 | e8af50a3 | bellard | int psrps; /* previous supervisor mode */ |
346 | 5210977a | Igor Kovalenko | #if !defined(TARGET_SPARC64)
|
347 | e8af50a3 | bellard | int psret; /* enable traps */ |
348 | 5210977a | Igor Kovalenko | #endif
|
349 | 327ac2e7 | blueswir1 | uint32_t psrpil; /* interrupt blocking level */
|
350 | 327ac2e7 | blueswir1 | uint32_t pil_in; /* incoming interrupt level bitmap */
|
351 | e80cfcfc | bellard | int psref; /* enable fpu */ |
352 | 62724a37 | blueswir1 | target_ulong version; |
353 | cf495bcf | bellard | int interrupt_index;
|
354 | 1a14026e | blueswir1 | uint32_t nwindows; |
355 | cf495bcf | bellard | /* NOTE: we allow 8 more registers to handle wrapping */
|
356 | 1a14026e | blueswir1 | target_ulong regbase[MAX_NWINDOWS * 16 + 8]; |
357 | d720b93d | bellard | |
358 | a316d335 | bellard | CPU_COMMON |
359 | a316d335 | bellard | |
360 | e8af50a3 | bellard | /* MMU regs */
|
361 | 3475187d | bellard | #if defined(TARGET_SPARC64)
|
362 | 3475187d | bellard | uint64_t lsu; |
363 | 3475187d | bellard | #define DMMU_E 0x8 |
364 | 3475187d | bellard | #define IMMU_E 0x4 |
365 | 6e8e7d4c | Igor Kovalenko | //typedef struct SparcMMU
|
366 | 6e8e7d4c | Igor Kovalenko | union {
|
367 | 6e8e7d4c | Igor Kovalenko | uint64_t immuregs[16];
|
368 | 6e8e7d4c | Igor Kovalenko | struct {
|
369 | 6e8e7d4c | Igor Kovalenko | uint64_t tsb_tag_target; |
370 | 6e8e7d4c | Igor Kovalenko | uint64_t unused_mmu_primary_context; // use DMMU
|
371 | 6e8e7d4c | Igor Kovalenko | uint64_t unused_mmu_secondary_context; // use DMMU
|
372 | 6e8e7d4c | Igor Kovalenko | uint64_t sfsr; |
373 | 6e8e7d4c | Igor Kovalenko | uint64_t sfar; |
374 | 6e8e7d4c | Igor Kovalenko | uint64_t tsb; |
375 | 6e8e7d4c | Igor Kovalenko | uint64_t tag_access; |
376 | 6e8e7d4c | Igor Kovalenko | } immu; |
377 | 6e8e7d4c | Igor Kovalenko | }; |
378 | 6e8e7d4c | Igor Kovalenko | union {
|
379 | 6e8e7d4c | Igor Kovalenko | uint64_t dmmuregs[16];
|
380 | 6e8e7d4c | Igor Kovalenko | struct {
|
381 | 6e8e7d4c | Igor Kovalenko | uint64_t tsb_tag_target; |
382 | 6e8e7d4c | Igor Kovalenko | uint64_t mmu_primary_context; |
383 | 6e8e7d4c | Igor Kovalenko | uint64_t mmu_secondary_context; |
384 | 6e8e7d4c | Igor Kovalenko | uint64_t sfsr; |
385 | 6e8e7d4c | Igor Kovalenko | uint64_t sfar; |
386 | 6e8e7d4c | Igor Kovalenko | uint64_t tsb; |
387 | 6e8e7d4c | Igor Kovalenko | uint64_t tag_access; |
388 | 6e8e7d4c | Igor Kovalenko | } dmmu; |
389 | 6e8e7d4c | Igor Kovalenko | }; |
390 | 6e8e7d4c | Igor Kovalenko | SparcTLBEntry itlb[64];
|
391 | 6e8e7d4c | Igor Kovalenko | SparcTLBEntry dtlb[64];
|
392 | fb79ceb9 | blueswir1 | uint32_t mmu_version; |
393 | 3475187d | bellard | #else
|
394 | 3dd9a152 | blueswir1 | uint32_t mmuregs[32];
|
395 | 952a328f | blueswir1 | uint64_t mxccdata[4];
|
396 | 952a328f | blueswir1 | uint64_t mxccregs[8];
|
397 | 4017190e | blueswir1 | uint64_t mmubpregs[4];
|
398 | 3ebf5aaf | blueswir1 | uint64_t prom_addr; |
399 | 3475187d | bellard | #endif
|
400 | e8af50a3 | bellard | /* temporary float registers */
|
401 | 65ce8c2f | bellard | float64 dt0, dt1; |
402 | 1f587329 | blueswir1 | float128 qt0, qt1; |
403 | 7a0e1f41 | bellard | float_status fp_status; |
404 | af7bf89b | bellard | #if defined(TARGET_SPARC64)
|
405 | c19148bd | blueswir1 | #define MAXTL_MAX 8 |
406 | c19148bd | blueswir1 | #define MAXTL_MASK (MAXTL_MAX - 1) |
407 | c19148bd | blueswir1 | trap_state ts[MAXTL_MAX]; |
408 | 0f8a249a | blueswir1 | uint32_t xcc; /* Extended integer condition codes */
|
409 | 3475187d | bellard | uint32_t asi; |
410 | 3475187d | bellard | uint32_t pstate; |
411 | 3475187d | bellard | uint32_t tl; |
412 | c19148bd | blueswir1 | uint32_t maxtl; |
413 | 3475187d | bellard | uint32_t cansave, canrestore, otherwin, wstate, cleanwin; |
414 | 83469015 | bellard | uint64_t agregs[8]; /* alternate general registers */ |
415 | 83469015 | bellard | uint64_t bgregs[8]; /* backup for normal global registers */ |
416 | 83469015 | bellard | uint64_t igregs[8]; /* interrupt general registers */ |
417 | 83469015 | bellard | uint64_t mgregs[8]; /* mmu general registers */ |
418 | 3475187d | bellard | uint64_t fprs; |
419 | 83469015 | bellard | uint64_t tick_cmpr, stick_cmpr; |
420 | 8f4efc55 | Igor V. Kovalenko | CPUTimer *tick, *stick; |
421 | 709f2c1b | Igor V. Kovalenko | #define TICK_NPT_MASK 0x8000000000000000ULL |
422 | 709f2c1b | Igor V. Kovalenko | #define TICK_INT_DIS 0x8000000000000000ULL |
423 | 725cb90b | bellard | uint64_t gsr; |
424 | e9ebed4d | blueswir1 | uint32_t gl; // UA2005
|
425 | e9ebed4d | blueswir1 | /* UA 2005 hyperprivileged registers */
|
426 | c19148bd | blueswir1 | uint64_t hpstate, htstate[MAXTL_MAX], hintp, htba, hver, hstick_cmpr, ssr; |
427 | 8f4efc55 | Igor V. Kovalenko | CPUTimer *hstick; // UA 2005
|
428 | 9d926598 | blueswir1 | uint32_t softint; |
429 | 8fa211e8 | blueswir1 | #define SOFTINT_TIMER 1 |
430 | 8fa211e8 | blueswir1 | #define SOFTINT_STIMER (1 << 16) |
431 | 709f2c1b | Igor V. Kovalenko | #define SOFTINT_INTRMASK (0xFFFE) |
432 | 709f2c1b | Igor V. Kovalenko | #define SOFTINT_REG_MASK (SOFTINT_STIMER|SOFTINT_INTRMASK|SOFTINT_TIMER)
|
433 | 3475187d | bellard | #endif
|
434 | 5578ceab | blueswir1 | sparc_def_t *def; |
435 | 7a3f1944 | bellard | } CPUSPARCState; |
436 | 64a88d5d | blueswir1 | |
437 | 91736d37 | blueswir1 | /* helper.c */
|
438 | aaed909a | bellard | CPUSPARCState *cpu_sparc_init(const char *cpu_model); |
439 | 91736d37 | blueswir1 | void cpu_sparc_set_id(CPUSPARCState *env, unsigned int cpu); |
440 | 62724a37 | blueswir1 | void sparc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, |
441 | 62724a37 | blueswir1 | ...)); |
442 | 48585ec5 | blueswir1 | void cpu_lock(void); |
443 | 48585ec5 | blueswir1 | void cpu_unlock(void); |
444 | 48585ec5 | blueswir1 | int cpu_sparc_handle_mmu_fault(CPUSPARCState *env1, target_ulong address, int rw, |
445 | 48585ec5 | blueswir1 | int mmu_idx, int is_softmmu); |
446 | 0b5c1ce8 | Nathan Froyd | #define cpu_handle_mmu_fault cpu_sparc_handle_mmu_fault
|
447 | 48585ec5 | blueswir1 | target_ulong mmu_probe(CPUSPARCState *env, target_ulong address, int mmulev);
|
448 | 48585ec5 | blueswir1 | void dump_mmu(CPUSPARCState *env);
|
449 | 91736d37 | blueswir1 | |
450 | 91736d37 | blueswir1 | /* translate.c */
|
451 | 91736d37 | blueswir1 | void gen_intermediate_code_init(CPUSPARCState *env);
|
452 | 91736d37 | blueswir1 | |
453 | 91736d37 | blueswir1 | /* cpu-exec.c */
|
454 | 91736d37 | blueswir1 | int cpu_sparc_exec(CPUSPARCState *s);
|
455 | 7a3f1944 | bellard | |
456 | 5210977a | Igor Kovalenko | #if !defined (TARGET_SPARC64)
|
457 | 62724a37 | blueswir1 | #define GET_PSR(env) (env->version | (env->psr & PSR_ICC) | \
|
458 | 0f8a249a | blueswir1 | (env->psref? PSR_EF : 0) | \
|
459 | 0f8a249a | blueswir1 | (env->psrpil << 8) | \
|
460 | 0f8a249a | blueswir1 | (env->psrs? PSR_S : 0) | \
|
461 | 0f8a249a | blueswir1 | (env->psrps? PSR_PS : 0) | \
|
462 | 0f8a249a | blueswir1 | (env->psret? PSR_ET : 0) | env->cwp)
|
463 | 5210977a | Igor Kovalenko | #else
|
464 | 5210977a | Igor Kovalenko | #define GET_PSR(env) (env->version | (env->psr & PSR_ICC) | \
|
465 | 5210977a | Igor Kovalenko | (env->psref? PSR_EF : 0) | \
|
466 | 5210977a | Igor Kovalenko | (env->psrpil << 8) | \
|
467 | 5210977a | Igor Kovalenko | (env->psrs? PSR_S : 0) | \
|
468 | 5210977a | Igor Kovalenko | (env->psrps? PSR_PS : 0) | \
|
469 | 5210977a | Igor Kovalenko | env->cwp) |
470 | 5210977a | Igor Kovalenko | #endif
|
471 | b4ff5987 | bellard | |
472 | b4ff5987 | bellard | #ifndef NO_CPU_IO_DEFS
|
473 | 4c6aa085 | Blue Swirl | |
474 | 4c6aa085 | Blue Swirl | static inline int cpu_cwp_inc(CPUSPARCState *env1, int cwp) |
475 | 4c6aa085 | Blue Swirl | { |
476 | 4c6aa085 | Blue Swirl | if (unlikely(cwp >= env1->nwindows))
|
477 | 4c6aa085 | Blue Swirl | cwp -= env1->nwindows; |
478 | 4c6aa085 | Blue Swirl | return cwp;
|
479 | 4c6aa085 | Blue Swirl | } |
480 | 4c6aa085 | Blue Swirl | |
481 | 4c6aa085 | Blue Swirl | static inline int cpu_cwp_dec(CPUSPARCState *env1, int cwp) |
482 | 4c6aa085 | Blue Swirl | { |
483 | 4c6aa085 | Blue Swirl | if (unlikely(cwp < 0)) |
484 | 4c6aa085 | Blue Swirl | cwp += env1->nwindows; |
485 | 4c6aa085 | Blue Swirl | return cwp;
|
486 | 4c6aa085 | Blue Swirl | } |
487 | 4c6aa085 | Blue Swirl | #endif
|
488 | 4c6aa085 | Blue Swirl | |
489 | 91736d37 | blueswir1 | static inline void memcpy32(target_ulong *dst, const target_ulong *src) |
490 | 91736d37 | blueswir1 | { |
491 | 91736d37 | blueswir1 | dst[0] = src[0]; |
492 | 91736d37 | blueswir1 | dst[1] = src[1]; |
493 | 91736d37 | blueswir1 | dst[2] = src[2]; |
494 | 91736d37 | blueswir1 | dst[3] = src[3]; |
495 | 91736d37 | blueswir1 | dst[4] = src[4]; |
496 | 91736d37 | blueswir1 | dst[5] = src[5]; |
497 | 91736d37 | blueswir1 | dst[6] = src[6]; |
498 | 91736d37 | blueswir1 | dst[7] = src[7]; |
499 | 91736d37 | blueswir1 | } |
500 | 91736d37 | blueswir1 | |
501 | 91736d37 | blueswir1 | static inline void cpu_set_cwp(CPUSPARCState *env1, int new_cwp) |
502 | 91736d37 | blueswir1 | { |
503 | 91736d37 | blueswir1 | /* put the modified wrap registers at their proper location */
|
504 | 91736d37 | blueswir1 | if (env1->cwp == env1->nwindows - 1) |
505 | 91736d37 | blueswir1 | memcpy32(env1->regbase, env1->regbase + env1->nwindows * 16);
|
506 | 91736d37 | blueswir1 | env1->cwp = new_cwp; |
507 | 91736d37 | blueswir1 | /* put the wrap registers at their temporary location */
|
508 | 91736d37 | blueswir1 | if (new_cwp == env1->nwindows - 1) |
509 | 91736d37 | blueswir1 | memcpy32(env1->regbase + env1->nwindows * 16, env1->regbase);
|
510 | 91736d37 | blueswir1 | env1->regwptr = env1->regbase + (new_cwp * 16);
|
511 | 91736d37 | blueswir1 | } |
512 | 1a14026e | blueswir1 | |
513 | 4c6aa085 | Blue Swirl | /* sun4m.c, sun4u.c */
|
514 | 4c6aa085 | Blue Swirl | void cpu_check_irqs(CPUSPARCState *env);
|
515 | 1a14026e | blueswir1 | |
516 | 299b520c | Igor V. Kovalenko | #if defined (TARGET_SPARC64)
|
517 | 299b520c | Igor V. Kovalenko | |
518 | 299b520c | Igor V. Kovalenko | static inline int compare_masked(uint64_t x, uint64_t y, uint64_t mask) |
519 | 299b520c | Igor V. Kovalenko | { |
520 | 299b520c | Igor V. Kovalenko | return (x & mask) == (y & mask);
|
521 | 299b520c | Igor V. Kovalenko | } |
522 | 299b520c | Igor V. Kovalenko | |
523 | 299b520c | Igor V. Kovalenko | #define MMU_CONTEXT_BITS 13 |
524 | 299b520c | Igor V. Kovalenko | #define MMU_CONTEXT_MASK ((1 << MMU_CONTEXT_BITS) - 1) |
525 | 299b520c | Igor V. Kovalenko | |
526 | 299b520c | Igor V. Kovalenko | static inline int tlb_compare_context(const SparcTLBEntry *tlb, |
527 | 299b520c | Igor V. Kovalenko | uint64_t context) |
528 | 299b520c | Igor V. Kovalenko | { |
529 | 299b520c | Igor V. Kovalenko | return compare_masked(context, tlb->tag, MMU_CONTEXT_MASK);
|
530 | 299b520c | Igor V. Kovalenko | } |
531 | 299b520c | Igor V. Kovalenko | |
532 | 299b520c | Igor V. Kovalenko | #endif
|
533 | 299b520c | Igor V. Kovalenko | |
534 | 4c6aa085 | Blue Swirl | static inline void PUT_PSR(CPUSPARCState *env1, target_ulong val) |
535 | 1a14026e | blueswir1 | { |
536 | 4c6aa085 | Blue Swirl | env1->psr = val & PSR_ICC; |
537 | 4c6aa085 | Blue Swirl | env1->psref = (val & PSR_EF)? 1 : 0; |
538 | 4c6aa085 | Blue Swirl | env1->psrpil = (val & PSR_PIL) >> 8;
|
539 | 4c6aa085 | Blue Swirl | #if ((!defined (TARGET_SPARC64)) && !defined(CONFIG_USER_ONLY))
|
540 | 4c6aa085 | Blue Swirl | cpu_check_irqs(env1); |
541 | b4ff5987 | bellard | #endif
|
542 | 4c6aa085 | Blue Swirl | env1->psrs = (val & PSR_S)? 1 : 0; |
543 | 4c6aa085 | Blue Swirl | env1->psrps = (val & PSR_PS)? 1 : 0; |
544 | 5210977a | Igor Kovalenko | #if !defined (TARGET_SPARC64)
|
545 | 4c6aa085 | Blue Swirl | env1->psret = (val & PSR_ET)? 1 : 0; |
546 | 5210977a | Igor Kovalenko | #endif
|
547 | 4c6aa085 | Blue Swirl | cpu_set_cwp(env1, val & PSR_CWP); |
548 | 4c6aa085 | Blue Swirl | env1->cc_op = CC_OP_FLAGS; |
549 | 4c6aa085 | Blue Swirl | } |
550 | b4ff5987 | bellard | |
551 | 3475187d | bellard | #ifdef TARGET_SPARC64
|
552 | 17d996e1 | blueswir1 | #define GET_CCR(env) (((env->xcc >> 20) << 4) | ((env->psr & PSR_ICC) >> 20)) |
553 | 0f8a249a | blueswir1 | #define PUT_CCR(env, val) do { int _tmp = val; \ |
554 | 77f193da | blueswir1 | env->xcc = (_tmp >> 4) << 20; \ |
555 | 0f8a249a | blueswir1 | env->psr = (_tmp & 0xf) << 20; \ |
556 | 8393617c | Blue Swirl | CC_OP = CC_OP_FLAGS; \ |
557 | 3475187d | bellard | } while (0) |
558 | 1a14026e | blueswir1 | #define GET_CWP64(env) (env->nwindows - 1 - (env)->cwp) |
559 | 1a14026e | blueswir1 | |
560 | 0bbd4a0d | blueswir1 | #ifndef NO_CPU_IO_DEFS
|
561 | 1a14026e | blueswir1 | static inline void PUT_CWP64(CPUSPARCState *env1, int cwp) |
562 | 1a14026e | blueswir1 | { |
563 | 1a14026e | blueswir1 | if (unlikely(cwp >= env1->nwindows || cwp < 0)) |
564 | 4f690853 | Igor V. Kovalenko | cwp %= env1->nwindows; |
565 | 1a14026e | blueswir1 | cpu_set_cwp(env1, env1->nwindows - 1 - cwp);
|
566 | 1a14026e | blueswir1 | } |
567 | 0bbd4a0d | blueswir1 | #endif
|
568 | 3475187d | bellard | #endif
|
569 | 3475187d | bellard | |
570 | 91736d37 | blueswir1 | /* cpu-exec.c */
|
571 | 3c7b48b7 | Paul Brook | #if !defined(CONFIG_USER_ONLY)
|
572 | c227f099 | Anthony Liguori | void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, |
573 | e18231a3 | blueswir1 | int is_asi, int size); |
574 | 2065061e | Igor V. Kovalenko | target_phys_addr_t cpu_get_phys_page_nofault(CPUState *env, target_ulong addr, |
575 | 2065061e | Igor V. Kovalenko | int mmu_idx);
|
576 | 2065061e | Igor V. Kovalenko | |
577 | 3c7b48b7 | Paul Brook | #endif
|
578 | f0d5e471 | blueswir1 | int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc); |
579 | 7a3f1944 | bellard | |
580 | 9467d44c | ths | #define cpu_init cpu_sparc_init
|
581 | 9467d44c | ths | #define cpu_exec cpu_sparc_exec
|
582 | 9467d44c | ths | #define cpu_gen_code cpu_sparc_gen_code
|
583 | 9467d44c | ths | #define cpu_signal_handler cpu_sparc_signal_handler
|
584 | c732abe2 | j_mayer | #define cpu_list sparc_cpu_list
|
585 | 9467d44c | ths | |
586 | 8f4efc55 | Igor V. Kovalenko | #define CPU_SAVE_VERSION 6 |
587 | b3c7724c | pbrook | |
588 | 6ebbf390 | j_mayer | /* MMU modes definitions */
|
589 | 6f27aba6 | blueswir1 | #define MMU_MODE0_SUFFIX _user
|
590 | 6f27aba6 | blueswir1 | #define MMU_MODE1_SUFFIX _kernel
|
591 | 6f27aba6 | blueswir1 | #ifdef TARGET_SPARC64
|
592 | 6f27aba6 | blueswir1 | #define MMU_MODE2_SUFFIX _hypv
|
593 | 2065061e | Igor V. Kovalenko | #define MMU_MODE3_SUFFIX _nucleus
|
594 | 2065061e | Igor V. Kovalenko | #define MMU_MODE4_SUFFIX _user_secondary
|
595 | 2065061e | Igor V. Kovalenko | #define MMU_MODE5_SUFFIX _kernel_secondary
|
596 | 6f27aba6 | blueswir1 | #endif
|
597 | 9e31b9e2 | blueswir1 | #define MMU_USER_IDX 0 |
598 | 9e31b9e2 | blueswir1 | #define MMU_KERNEL_IDX 1 |
599 | 9e31b9e2 | blueswir1 | #define MMU_HYPV_IDX 2 |
600 | 2065061e | Igor V. Kovalenko | #ifdef TARGET_SPARC64
|
601 | 2065061e | Igor V. Kovalenko | #define MMU_NUCLEUS_IDX 3 |
602 | 2065061e | Igor V. Kovalenko | #define MMU_USER_SECONDARY_IDX 4 |
603 | 2065061e | Igor V. Kovalenko | #define MMU_KERNEL_SECONDARY_IDX 5 |
604 | 2065061e | Igor V. Kovalenko | #endif
|
605 | 9e31b9e2 | blueswir1 | |
606 | 22548760 | blueswir1 | static inline int cpu_mmu_index(CPUState *env1) |
607 | 6ebbf390 | j_mayer | { |
608 | 6f27aba6 | blueswir1 | #if defined(CONFIG_USER_ONLY)
|
609 | 9e31b9e2 | blueswir1 | return MMU_USER_IDX;
|
610 | 6f27aba6 | blueswir1 | #elif !defined(TARGET_SPARC64)
|
611 | 22548760 | blueswir1 | return env1->psrs;
|
612 | 6f27aba6 | blueswir1 | #else
|
613 | 22548760 | blueswir1 | if (!env1->psrs)
|
614 | 9e31b9e2 | blueswir1 | return MMU_USER_IDX;
|
615 | 22548760 | blueswir1 | else if ((env1->hpstate & HS_PRIV) == 0) |
616 | 9e31b9e2 | blueswir1 | return MMU_KERNEL_IDX;
|
617 | 6f27aba6 | blueswir1 | else
|
618 | 9e31b9e2 | blueswir1 | return MMU_HYPV_IDX;
|
619 | 6f27aba6 | blueswir1 | #endif
|
620 | 6f27aba6 | blueswir1 | } |
621 | 6f27aba6 | blueswir1 | |
622 | 2df6c2d0 | Igor V. Kovalenko | static inline int cpu_interrupts_enabled(CPUState *env1) |
623 | 2df6c2d0 | Igor V. Kovalenko | { |
624 | 2df6c2d0 | Igor V. Kovalenko | #if !defined (TARGET_SPARC64)
|
625 | 2df6c2d0 | Igor V. Kovalenko | if (env1->psret != 0) |
626 | 2df6c2d0 | Igor V. Kovalenko | return 1; |
627 | 2df6c2d0 | Igor V. Kovalenko | #else
|
628 | 2df6c2d0 | Igor V. Kovalenko | if (env1->pstate & PS_IE)
|
629 | 2df6c2d0 | Igor V. Kovalenko | return 1; |
630 | 2df6c2d0 | Igor V. Kovalenko | #endif
|
631 | 2df6c2d0 | Igor V. Kovalenko | |
632 | 2df6c2d0 | Igor V. Kovalenko | return 0; |
633 | 2df6c2d0 | Igor V. Kovalenko | } |
634 | 2df6c2d0 | Igor V. Kovalenko | |
635 | d532b26c | Igor V. Kovalenko | static inline int cpu_pil_allowed(CPUState *env1, int pil) |
636 | d532b26c | Igor V. Kovalenko | { |
637 | d532b26c | Igor V. Kovalenko | #if !defined(TARGET_SPARC64)
|
638 | d532b26c | Igor V. Kovalenko | /* level 15 is non-maskable on sparc v8 */
|
639 | d532b26c | Igor V. Kovalenko | return pil == 15 || pil > env1->psrpil; |
640 | d532b26c | Igor V. Kovalenko | #else
|
641 | d532b26c | Igor V. Kovalenko | return pil > env1->psrpil;
|
642 | d532b26c | Igor V. Kovalenko | #endif
|
643 | d532b26c | Igor V. Kovalenko | } |
644 | d532b26c | Igor V. Kovalenko | |
645 | 22548760 | blueswir1 | static inline int cpu_fpu_enabled(CPUState *env1) |
646 | 6f27aba6 | blueswir1 | { |
647 | 6f27aba6 | blueswir1 | #if defined(CONFIG_USER_ONLY)
|
648 | 6f27aba6 | blueswir1 | return 1; |
649 | 6f27aba6 | blueswir1 | #elif !defined(TARGET_SPARC64)
|
650 | 22548760 | blueswir1 | return env1->psref;
|
651 | 6f27aba6 | blueswir1 | #else
|
652 | 22548760 | blueswir1 | return ((env1->pstate & PS_PEF) != 0) && ((env1->fprs & FPRS_FEF) != 0); |
653 | 6f27aba6 | blueswir1 | #endif
|
654 | 6ebbf390 | j_mayer | } |
655 | 6ebbf390 | j_mayer | |
656 | 6e68e076 | pbrook | #if defined(CONFIG_USER_ONLY)
|
657 | 6e68e076 | pbrook | static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) |
658 | 6e68e076 | pbrook | { |
659 | f8ed7070 | pbrook | if (newsp)
|
660 | 6e68e076 | pbrook | env->regwptr[22] = newsp;
|
661 | 6e68e076 | pbrook | env->regwptr[0] = 0; |
662 | 6e68e076 | pbrook | /* FIXME: Do we also need to clear CF? */
|
663 | 6e68e076 | pbrook | /* XXXXX */
|
664 | 6e68e076 | pbrook | printf ("HELPME: %s:%d\n", __FILE__, __LINE__);
|
665 | 6e68e076 | pbrook | } |
666 | 6e68e076 | pbrook | #endif
|
667 | 6e68e076 | pbrook | |
668 | 7a3f1944 | bellard | #include "cpu-all.h" |
669 | 622ed360 | aliguori | #include "exec-all.h" |
670 | 7a3f1944 | bellard | |
671 | f4b1a842 | blueswir1 | #ifdef TARGET_SPARC64
|
672 | f4b1a842 | blueswir1 | /* sun4u.c */
|
673 | 8f4efc55 | Igor V. Kovalenko | void cpu_tick_set_count(CPUTimer *timer, uint64_t count);
|
674 | 8f4efc55 | Igor V. Kovalenko | uint64_t cpu_tick_get_count(CPUTimer *timer); |
675 | 8f4efc55 | Igor V. Kovalenko | void cpu_tick_set_limit(CPUTimer *timer, uint64_t limit);
|
676 | 8194f35a | Igor Kovalenko | trap_state* cpu_tsptr(CPUState* env); |
677 | f4b1a842 | blueswir1 | #endif
|
678 | f4b1a842 | blueswir1 | |
679 | 622ed360 | aliguori | static inline void cpu_pc_from_tb(CPUState *env, TranslationBlock *tb) |
680 | 622ed360 | aliguori | { |
681 | 622ed360 | aliguori | env->pc = tb->pc; |
682 | 622ed360 | aliguori | env->npc = tb->cs_base; |
683 | 622ed360 | aliguori | } |
684 | 622ed360 | aliguori | |
685 | 6b917547 | aliguori | static inline void cpu_get_tb_cpu_state(CPUState *env, target_ulong *pc, |
686 | 6b917547 | aliguori | target_ulong *cs_base, int *flags)
|
687 | 6b917547 | aliguori | { |
688 | 6b917547 | aliguori | *pc = env->pc; |
689 | 6b917547 | aliguori | *cs_base = env->npc; |
690 | 6b917547 | aliguori | #ifdef TARGET_SPARC64
|
691 | 6b917547 | aliguori | // AM . Combined FPU enable bits . PRIV . DMMU enabled . IMMU enabled
|
692 | 6b917547 | aliguori | *flags = ((env->pstate & PS_AM) << 2)
|
693 | 6b917547 | aliguori | | (((env->pstate & PS_PEF) >> 1) | ((env->fprs & FPRS_FEF) << 2)) |
694 | 6b917547 | aliguori | | (env->pstate & PS_PRIV) | ((env->lsu & (DMMU_E | IMMU_E)) >> 2);
|
695 | 6b917547 | aliguori | #else
|
696 | 6b917547 | aliguori | // FPU enable . Supervisor
|
697 | 6b917547 | aliguori | *flags = (env->psref << 4) | env->psrs;
|
698 | 6b917547 | aliguori | #endif
|
699 | 6b917547 | aliguori | } |
700 | 6b917547 | aliguori | |
701 | 7a3f1944 | bellard | #endif |