root / target-cris / cpu.h @ 298e01b6
History | View | Annotate | Download (5.7 kB)
1 | 81fdc5f8 | ths | /*
|
---|---|---|---|
2 | 81fdc5f8 | ths | * CRIS virtual CPU header
|
3 | 81fdc5f8 | ths | *
|
4 | 81fdc5f8 | ths | * Copyright (c) 2007 AXIS Communications AB
|
5 | 81fdc5f8 | ths | * Written by Edgar E. Iglesias
|
6 | 81fdc5f8 | ths | *
|
7 | 81fdc5f8 | ths | * This library is free software; you can redistribute it and/or
|
8 | 81fdc5f8 | ths | * modify it under the terms of the GNU Lesser General Public
|
9 | 81fdc5f8 | ths | * License as published by the Free Software Foundation; either
|
10 | 81fdc5f8 | ths | * version 2 of the License, or (at your option) any later version.
|
11 | 81fdc5f8 | ths | *
|
12 | 81fdc5f8 | ths | * This library is distributed in the hope that it will be useful,
|
13 | 81fdc5f8 | ths | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 | 81fdc5f8 | ths | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15 | 81fdc5f8 | ths | * General Public License for more details.
|
16 | 81fdc5f8 | ths | *
|
17 | 81fdc5f8 | ths | * You should have received a copy of the GNU Lesser General Public
|
18 | 81fdc5f8 | ths | * License along with this library; if not, write to the Free Software
|
19 | 81fdc5f8 | ths | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
20 | 81fdc5f8 | ths | */
|
21 | 81fdc5f8 | ths | #ifndef CPU_CRIS_H
|
22 | 81fdc5f8 | ths | #define CPU_CRIS_H
|
23 | 81fdc5f8 | ths | |
24 | 81fdc5f8 | ths | #define TARGET_LONG_BITS 32 |
25 | 81fdc5f8 | ths | |
26 | 81fdc5f8 | ths | #include "cpu-defs.h" |
27 | 81fdc5f8 | ths | |
28 | 81fdc5f8 | ths | #include "softfloat.h" |
29 | 81fdc5f8 | ths | |
30 | 81fdc5f8 | ths | #define TARGET_HAS_ICE 1 |
31 | 81fdc5f8 | ths | |
32 | 81fdc5f8 | ths | #define ELF_MACHINE EM_CRIS
|
33 | 81fdc5f8 | ths | |
34 | 81fdc5f8 | ths | #define EXCP_MMU_EXEC 0 |
35 | 81fdc5f8 | ths | #define EXCP_MMU_READ 1 |
36 | 81fdc5f8 | ths | #define EXCP_MMU_WRITE 2 |
37 | 81fdc5f8 | ths | #define EXCP_MMU_FLUSH 3 |
38 | 786c02f1 | edgar_igl | #define EXCP_MMU_FAULT 4 |
39 | 81fdc5f8 | ths | #define EXCP_BREAK 16 /* trap. */ |
40 | 81fdc5f8 | ths | |
41 | 81fdc5f8 | ths | /* CPU flags. */
|
42 | 81fdc5f8 | ths | #define S_FLAG 0x200 |
43 | 81fdc5f8 | ths | #define R_FLAG 0x100 |
44 | 81fdc5f8 | ths | #define P_FLAG 0x80 |
45 | 81fdc5f8 | ths | #define U_FLAG 0x40 |
46 | 81fdc5f8 | ths | #define P_FLAG 0x80 |
47 | 81fdc5f8 | ths | #define U_FLAG 0x40 |
48 | 81fdc5f8 | ths | #define I_FLAG 0x20 |
49 | 81fdc5f8 | ths | #define X_FLAG 0x10 |
50 | 81fdc5f8 | ths | #define N_FLAG 0x08 |
51 | 81fdc5f8 | ths | #define Z_FLAG 0x04 |
52 | 81fdc5f8 | ths | #define V_FLAG 0x02 |
53 | 81fdc5f8 | ths | #define C_FLAG 0x01 |
54 | 81fdc5f8 | ths | #define ALU_FLAGS 0x1F |
55 | 81fdc5f8 | ths | |
56 | 81fdc5f8 | ths | /* Condition codes. */
|
57 | 81fdc5f8 | ths | #define CC_CC 0 |
58 | 81fdc5f8 | ths | #define CC_CS 1 |
59 | 81fdc5f8 | ths | #define CC_NE 2 |
60 | 81fdc5f8 | ths | #define CC_EQ 3 |
61 | 81fdc5f8 | ths | #define CC_VC 4 |
62 | 81fdc5f8 | ths | #define CC_VS 5 |
63 | 81fdc5f8 | ths | #define CC_PL 6 |
64 | 81fdc5f8 | ths | #define CC_MI 7 |
65 | 81fdc5f8 | ths | #define CC_LS 8 |
66 | 81fdc5f8 | ths | #define CC_HI 9 |
67 | 81fdc5f8 | ths | #define CC_GE 10 |
68 | 81fdc5f8 | ths | #define CC_LT 11 |
69 | 81fdc5f8 | ths | #define CC_GT 12 |
70 | 81fdc5f8 | ths | #define CC_LE 13 |
71 | 81fdc5f8 | ths | #define CC_A 14 |
72 | 81fdc5f8 | ths | #define CC_P 15 |
73 | 81fdc5f8 | ths | |
74 | 81fdc5f8 | ths | /* Internal flags for the implementation. */
|
75 | 81fdc5f8 | ths | #define F_DELAYSLOT 1 |
76 | 81fdc5f8 | ths | |
77 | 6ebbf390 | j_mayer | #define NB_MMU_MODES 2 |
78 | 6ebbf390 | j_mayer | |
79 | 81fdc5f8 | ths | typedef struct CPUCRISState { |
80 | 81fdc5f8 | ths | uint32_t debug1; |
81 | 81fdc5f8 | ths | uint32_t debug2; |
82 | 81fdc5f8 | ths | uint32_t debug3; |
83 | 81fdc5f8 | ths | |
84 | 81fdc5f8 | ths | /*
|
85 | 81fdc5f8 | ths | * We just store the stores to the tlbset here for later evaluation
|
86 | 81fdc5f8 | ths | * when the hw needs access to them.
|
87 | 81fdc5f8 | ths | *
|
88 | 81fdc5f8 | ths | * One for I and another for D.
|
89 | 81fdc5f8 | ths | */
|
90 | 81fdc5f8 | ths | struct
|
91 | 81fdc5f8 | ths | { |
92 | 81fdc5f8 | ths | uint32_t hi; |
93 | 81fdc5f8 | ths | uint32_t lo; |
94 | 81fdc5f8 | ths | } tlbsets[2][4][16]; |
95 | 81fdc5f8 | ths | |
96 | 81fdc5f8 | ths | uint32_t sregs[256][16]; /* grrr why so many?? */ |
97 | 81fdc5f8 | ths | uint32_t regs[16];
|
98 | 81fdc5f8 | ths | uint32_t pregs[16];
|
99 | 81fdc5f8 | ths | uint32_t pc; |
100 | 81fdc5f8 | ths | |
101 | 81fdc5f8 | ths | /* These are setup up by the guest code just before transfering the
|
102 | 81fdc5f8 | ths | control back to the host. */
|
103 | 81fdc5f8 | ths | int jmp;
|
104 | 81fdc5f8 | ths | uint32_t btarget; |
105 | 81fdc5f8 | ths | int btaken;
|
106 | 81fdc5f8 | ths | |
107 | 81fdc5f8 | ths | /* Condition flag tracking. */
|
108 | 81fdc5f8 | ths | uint32_t cc_op; |
109 | 81fdc5f8 | ths | uint32_t cc_mask; |
110 | 81fdc5f8 | ths | uint32_t cc_dest; |
111 | 81fdc5f8 | ths | uint32_t cc_src; |
112 | 81fdc5f8 | ths | uint32_t cc_result; |
113 | 81fdc5f8 | ths | |
114 | 81fdc5f8 | ths | /* size of the operation, 1 = byte, 2 = word, 4 = dword. */
|
115 | 81fdc5f8 | ths | int cc_size;
|
116 | 81fdc5f8 | ths | |
117 | 81fdc5f8 | ths | /* extended arithmetics. */
|
118 | 81fdc5f8 | ths | int cc_x_live;
|
119 | 81fdc5f8 | ths | int cc_x;
|
120 | 81fdc5f8 | ths | |
121 | 81fdc5f8 | ths | int features;
|
122 | 81fdc5f8 | ths | |
123 | 81fdc5f8 | ths | int exception_index;
|
124 | 786c02f1 | edgar_igl | int interrupt_request;
|
125 | 786c02f1 | edgar_igl | int interrupt_vector;
|
126 | 786c02f1 | edgar_igl | int fault_vector;
|
127 | 786c02f1 | edgar_igl | int trap_vector;
|
128 | 786c02f1 | edgar_igl | |
129 | 81fdc5f8 | ths | int user_mode_only;
|
130 | 81fdc5f8 | ths | int halted;
|
131 | 81fdc5f8 | ths | |
132 | 81fdc5f8 | ths | struct
|
133 | 81fdc5f8 | ths | { |
134 | 81fdc5f8 | ths | int exec_insns;
|
135 | 81fdc5f8 | ths | int exec_loads;
|
136 | 81fdc5f8 | ths | int exec_stores;
|
137 | 81fdc5f8 | ths | } stats; |
138 | 81fdc5f8 | ths | |
139 | 81fdc5f8 | ths | jmp_buf jmp_env; |
140 | 81fdc5f8 | ths | CPU_COMMON |
141 | 81fdc5f8 | ths | } CPUCRISState; |
142 | 81fdc5f8 | ths | |
143 | aaed909a | bellard | CPUCRISState *cpu_cris_init(const char *cpu_model); |
144 | 81fdc5f8 | ths | int cpu_cris_exec(CPUCRISState *s);
|
145 | 81fdc5f8 | ths | void cpu_cris_close(CPUCRISState *s);
|
146 | 81fdc5f8 | ths | void do_interrupt(CPUCRISState *env);
|
147 | 81fdc5f8 | ths | /* you can call this signal handler from your SIGBUS and SIGSEGV
|
148 | 81fdc5f8 | ths | signal handlers to inform the virtual CPU of exceptions. non zero
|
149 | 81fdc5f8 | ths | is returned if the signal was handled by the virtual CPU. */
|
150 | 81fdc5f8 | ths | int cpu_cris_signal_handler(int host_signum, void *pinfo, |
151 | 81fdc5f8 | ths | void *puc);
|
152 | 81fdc5f8 | ths | void cpu_cris_flush_flags(CPUCRISState *, int); |
153 | 81fdc5f8 | ths | |
154 | 81fdc5f8 | ths | |
155 | 81fdc5f8 | ths | void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, |
156 | 81fdc5f8 | ths | int is_asi);
|
157 | 81fdc5f8 | ths | |
158 | 81fdc5f8 | ths | enum {
|
159 | 81fdc5f8 | ths | CC_OP_DYNAMIC, /* Use env->cc_op */
|
160 | 81fdc5f8 | ths | CC_OP_FLAGS, |
161 | 81fdc5f8 | ths | CC_OP_LOGIC, |
162 | 81fdc5f8 | ths | CC_OP_CMP, |
163 | 81fdc5f8 | ths | CC_OP_MOVE, |
164 | 81fdc5f8 | ths | CC_OP_MOVE_PD, |
165 | 81fdc5f8 | ths | CC_OP_MOVE_SD, |
166 | 81fdc5f8 | ths | CC_OP_ADD, |
167 | 81fdc5f8 | ths | CC_OP_ADDC, |
168 | 81fdc5f8 | ths | CC_OP_MCP, |
169 | 81fdc5f8 | ths | CC_OP_ADDU, |
170 | 81fdc5f8 | ths | CC_OP_SUB, |
171 | 81fdc5f8 | ths | CC_OP_SUBU, |
172 | 81fdc5f8 | ths | CC_OP_NEG, |
173 | 81fdc5f8 | ths | CC_OP_BTST, |
174 | 81fdc5f8 | ths | CC_OP_MULS, |
175 | 81fdc5f8 | ths | CC_OP_MULU, |
176 | 81fdc5f8 | ths | CC_OP_DSTEP, |
177 | 81fdc5f8 | ths | CC_OP_BOUND, |
178 | 81fdc5f8 | ths | |
179 | 81fdc5f8 | ths | CC_OP_OR, |
180 | 81fdc5f8 | ths | CC_OP_AND, |
181 | 81fdc5f8 | ths | CC_OP_XOR, |
182 | 81fdc5f8 | ths | CC_OP_LSL, |
183 | 81fdc5f8 | ths | CC_OP_LSR, |
184 | 81fdc5f8 | ths | CC_OP_ASR, |
185 | 81fdc5f8 | ths | CC_OP_LZ |
186 | 81fdc5f8 | ths | }; |
187 | 81fdc5f8 | ths | |
188 | 81fdc5f8 | ths | #define CCF_C 0x01 |
189 | 81fdc5f8 | ths | #define CCF_V 0x02 |
190 | 81fdc5f8 | ths | #define CCF_Z 0x04 |
191 | 81fdc5f8 | ths | #define CCF_N 0x08 |
192 | 81fdc5f8 | ths | #define CCF_X 0x10 |
193 | 81fdc5f8 | ths | |
194 | 81fdc5f8 | ths | #define CRIS_SSP 0 |
195 | 81fdc5f8 | ths | #define CRIS_USP 1 |
196 | 81fdc5f8 | ths | |
197 | 81fdc5f8 | ths | void cris_set_irq_level(CPUCRISState *env, int level, uint8_t vector); |
198 | 81fdc5f8 | ths | void cris_set_macsr(CPUCRISState *env, uint32_t val);
|
199 | 81fdc5f8 | ths | void cris_switch_sp(CPUCRISState *env);
|
200 | 81fdc5f8 | ths | |
201 | 81fdc5f8 | ths | void do_cris_semihosting(CPUCRISState *env, int nr); |
202 | 81fdc5f8 | ths | |
203 | 81fdc5f8 | ths | enum cris_features {
|
204 | 81fdc5f8 | ths | CRIS_FEATURE_CF_ISA_MUL, |
205 | 81fdc5f8 | ths | }; |
206 | 81fdc5f8 | ths | |
207 | 81fdc5f8 | ths | static inline int cris_feature(CPUCRISState *env, int feature) |
208 | 81fdc5f8 | ths | { |
209 | 81fdc5f8 | ths | return (env->features & (1u << feature)) != 0; |
210 | 81fdc5f8 | ths | } |
211 | 81fdc5f8 | ths | |
212 | 81fdc5f8 | ths | void register_cris_insns (CPUCRISState *env);
|
213 | 81fdc5f8 | ths | |
214 | 81fdc5f8 | ths | /* CRIS uses 8k pages. */
|
215 | 81fdc5f8 | ths | #define TARGET_PAGE_BITS 13 |
216 | bb7ec043 | pbrook | #define MMAP_SHIFT TARGET_PAGE_BITS
|
217 | 81fdc5f8 | ths | |
218 | 81fdc5f8 | ths | #define CPUState CPUCRISState
|
219 | 81fdc5f8 | ths | #define cpu_init cpu_cris_init
|
220 | 81fdc5f8 | ths | #define cpu_exec cpu_cris_exec
|
221 | 81fdc5f8 | ths | #define cpu_gen_code cpu_cris_gen_code
|
222 | 81fdc5f8 | ths | #define cpu_signal_handler cpu_cris_signal_handler
|
223 | 81fdc5f8 | ths | |
224 | 6ebbf390 | j_mayer | /* MMU modes definitions */
|
225 | 6ebbf390 | j_mayer | #define MMU_MODE0_SUFFIX _kernel
|
226 | 6ebbf390 | j_mayer | #define MMU_MODE1_SUFFIX _user
|
227 | 6ebbf390 | j_mayer | #define MMU_USER_IDX 1 |
228 | 6ebbf390 | j_mayer | /* CRIS FIXME: I guess we want to validate supervisor mode acceses here. */
|
229 | 6ebbf390 | j_mayer | static inline int cpu_mmu_index (CPUState *env) |
230 | 6ebbf390 | j_mayer | { |
231 | 6ebbf390 | j_mayer | return 0; |
232 | 6ebbf390 | j_mayer | } |
233 | 6ebbf390 | j_mayer | |
234 | 81fdc5f8 | ths | #include "cpu-all.h" |
235 | 81fdc5f8 | ths | |
236 | 9004627f | edgar_igl | /* Register aliases. R0 - R15 */
|
237 | 9004627f | edgar_igl | #define R_FP 8 |
238 | 9004627f | edgar_igl | #define R_SP 14 |
239 | 9004627f | edgar_igl | #define R_ACR 15 |
240 | 9004627f | edgar_igl | |
241 | 9004627f | edgar_igl | /* Support regs, P0 - P15 */
|
242 | 786c02f1 | edgar_igl | #define PR_BZ 0 |
243 | 786c02f1 | edgar_igl | #define PR_VR 1 |
244 | 9004627f | edgar_igl | #define PR_PID 2 |
245 | 9004627f | edgar_igl | #define PR_SRS 3 |
246 | 786c02f1 | edgar_igl | #define PR_WZ 4 |
247 | 9004627f | edgar_igl | #define PR_MOF 7 |
248 | 786c02f1 | edgar_igl | #define PR_DZ 8 |
249 | 9004627f | edgar_igl | #define PR_EBP 9 |
250 | 9004627f | edgar_igl | #define PR_ERP 10 |
251 | 9004627f | edgar_igl | #define PR_SRP 11 |
252 | 9004627f | edgar_igl | #define PR_CCS 13 |
253 | 9004627f | edgar_igl | |
254 | 9004627f | edgar_igl | /* Support function regs. */
|
255 | 81fdc5f8 | ths | #define SFR_RW_GC_CFG 0][0 |
256 | 786c02f1 | edgar_igl | #define SFR_RW_MM_CFG 2][0 |
257 | 786c02f1 | edgar_igl | #define SFR_RW_MM_KBASE_LO 2][1 |
258 | 786c02f1 | edgar_igl | #define SFR_RW_MM_KBASE_HI 2][2 |
259 | 786c02f1 | edgar_igl | #define SFR_R_MM_CAUSE 2][3 |
260 | 786c02f1 | edgar_igl | #define SFR_RW_MM_TLB_SEL 2][4 |
261 | 786c02f1 | edgar_igl | #define SFR_RW_MM_TLB_LO 2][5 |
262 | 786c02f1 | edgar_igl | #define SFR_RW_MM_TLB_HI 2][6 |
263 | 81fdc5f8 | ths | |
264 | 81fdc5f8 | ths | #endif |