root / target-cris / cpu.h @ 6ebbf390
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 | 81fdc5f8 | ths | #define EXCP_MMU_MISS 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 | uint32_t sr; |
101 | 81fdc5f8 | ths | uint32_t flag_mask; /* Per insn mask of affected flags. */
|
102 | 81fdc5f8 | ths | |
103 | 81fdc5f8 | ths | /* SSP and USP. */
|
104 | 81fdc5f8 | ths | int current_sp;
|
105 | 81fdc5f8 | ths | uint32_t sp[2];
|
106 | 81fdc5f8 | ths | |
107 | 81fdc5f8 | ths | /* These are setup up by the guest code just before transfering the
|
108 | 81fdc5f8 | ths | control back to the host. */
|
109 | 81fdc5f8 | ths | int jmp;
|
110 | 81fdc5f8 | ths | uint32_t btarget; |
111 | 81fdc5f8 | ths | int btaken;
|
112 | 81fdc5f8 | ths | |
113 | 81fdc5f8 | ths | /* for traps. */
|
114 | 81fdc5f8 | ths | int trapnr;
|
115 | 81fdc5f8 | ths | |
116 | 81fdc5f8 | ths | /* Condition flag tracking. */
|
117 | 81fdc5f8 | ths | uint32_t cc_op; |
118 | 81fdc5f8 | ths | uint32_t cc_mask; |
119 | 81fdc5f8 | ths | uint32_t cc_dest; |
120 | 81fdc5f8 | ths | uint32_t cc_src; |
121 | 81fdc5f8 | ths | uint32_t cc_result; |
122 | 81fdc5f8 | ths | |
123 | 81fdc5f8 | ths | /* size of the operation, 1 = byte, 2 = word, 4 = dword. */
|
124 | 81fdc5f8 | ths | int cc_size;
|
125 | 81fdc5f8 | ths | |
126 | 81fdc5f8 | ths | /* extended arithmetics. */
|
127 | 81fdc5f8 | ths | int cc_x_live;
|
128 | 81fdc5f8 | ths | int cc_x;
|
129 | 81fdc5f8 | ths | |
130 | 81fdc5f8 | ths | int features;
|
131 | 81fdc5f8 | ths | |
132 | 81fdc5f8 | ths | uint64_t pending_interrupts; |
133 | 81fdc5f8 | ths | int interrupt_request;
|
134 | 81fdc5f8 | ths | int exception_index;
|
135 | 81fdc5f8 | ths | int user_mode_only;
|
136 | 81fdc5f8 | ths | int halted;
|
137 | 81fdc5f8 | ths | |
138 | 81fdc5f8 | ths | struct
|
139 | 81fdc5f8 | ths | { |
140 | 81fdc5f8 | ths | int exec_insns;
|
141 | 81fdc5f8 | ths | int exec_loads;
|
142 | 81fdc5f8 | ths | int exec_stores;
|
143 | 81fdc5f8 | ths | } stats; |
144 | 81fdc5f8 | ths | |
145 | 81fdc5f8 | ths | |
146 | 81fdc5f8 | ths | jmp_buf jmp_env; |
147 | 81fdc5f8 | ths | CPU_COMMON |
148 | 81fdc5f8 | ths | } CPUCRISState; |
149 | 81fdc5f8 | ths | |
150 | 81fdc5f8 | ths | CPUCRISState *cpu_cris_init(void);
|
151 | 81fdc5f8 | ths | int cpu_cris_exec(CPUCRISState *s);
|
152 | 81fdc5f8 | ths | void cpu_cris_close(CPUCRISState *s);
|
153 | 81fdc5f8 | ths | void do_interrupt(CPUCRISState *env);
|
154 | 81fdc5f8 | ths | /* you can call this signal handler from your SIGBUS and SIGSEGV
|
155 | 81fdc5f8 | ths | signal handlers to inform the virtual CPU of exceptions. non zero
|
156 | 81fdc5f8 | ths | is returned if the signal was handled by the virtual CPU. */
|
157 | 81fdc5f8 | ths | int cpu_cris_signal_handler(int host_signum, void *pinfo, |
158 | 81fdc5f8 | ths | void *puc);
|
159 | 81fdc5f8 | ths | void cpu_cris_flush_flags(CPUCRISState *, int); |
160 | 81fdc5f8 | ths | |
161 | 81fdc5f8 | ths | |
162 | 81fdc5f8 | ths | void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, |
163 | 81fdc5f8 | ths | int is_asi);
|
164 | 81fdc5f8 | ths | |
165 | 81fdc5f8 | ths | enum {
|
166 | 81fdc5f8 | ths | CC_OP_DYNAMIC, /* Use env->cc_op */
|
167 | 81fdc5f8 | ths | CC_OP_FLAGS, |
168 | 81fdc5f8 | ths | CC_OP_LOGIC, |
169 | 81fdc5f8 | ths | CC_OP_CMP, |
170 | 81fdc5f8 | ths | CC_OP_MOVE, |
171 | 81fdc5f8 | ths | CC_OP_MOVE_PD, |
172 | 81fdc5f8 | ths | CC_OP_MOVE_SD, |
173 | 81fdc5f8 | ths | CC_OP_ADD, |
174 | 81fdc5f8 | ths | CC_OP_ADDC, |
175 | 81fdc5f8 | ths | CC_OP_MCP, |
176 | 81fdc5f8 | ths | CC_OP_ADDU, |
177 | 81fdc5f8 | ths | CC_OP_SUB, |
178 | 81fdc5f8 | ths | CC_OP_SUBU, |
179 | 81fdc5f8 | ths | CC_OP_NEG, |
180 | 81fdc5f8 | ths | CC_OP_BTST, |
181 | 81fdc5f8 | ths | CC_OP_MULS, |
182 | 81fdc5f8 | ths | CC_OP_MULU, |
183 | 81fdc5f8 | ths | CC_OP_DSTEP, |
184 | 81fdc5f8 | ths | CC_OP_BOUND, |
185 | 81fdc5f8 | ths | |
186 | 81fdc5f8 | ths | CC_OP_OR, |
187 | 81fdc5f8 | ths | CC_OP_AND, |
188 | 81fdc5f8 | ths | CC_OP_XOR, |
189 | 81fdc5f8 | ths | CC_OP_LSL, |
190 | 81fdc5f8 | ths | CC_OP_LSR, |
191 | 81fdc5f8 | ths | CC_OP_ASR, |
192 | 81fdc5f8 | ths | CC_OP_LZ |
193 | 81fdc5f8 | ths | }; |
194 | 81fdc5f8 | ths | |
195 | 81fdc5f8 | ths | #define CCF_C 0x01 |
196 | 81fdc5f8 | ths | #define CCF_V 0x02 |
197 | 81fdc5f8 | ths | #define CCF_Z 0x04 |
198 | 81fdc5f8 | ths | #define CCF_N 0x08 |
199 | 81fdc5f8 | ths | #define CCF_X 0x10 |
200 | 81fdc5f8 | ths | |
201 | 81fdc5f8 | ths | #define CRIS_SSP 0 |
202 | 81fdc5f8 | ths | #define CRIS_USP 1 |
203 | 81fdc5f8 | ths | |
204 | 81fdc5f8 | ths | typedef struct cris_def_t cris_def_t; |
205 | 81fdc5f8 | ths | |
206 | 81fdc5f8 | ths | int cpu_cris_set_model(CPUCRISState *env, const char * name); |
207 | 81fdc5f8 | ths | |
208 | 81fdc5f8 | ths | void cris_set_irq_level(CPUCRISState *env, int level, uint8_t vector); |
209 | 81fdc5f8 | ths | void cris_set_macsr(CPUCRISState *env, uint32_t val);
|
210 | 81fdc5f8 | ths | void cris_switch_sp(CPUCRISState *env);
|
211 | 81fdc5f8 | ths | |
212 | 81fdc5f8 | ths | void do_cris_semihosting(CPUCRISState *env, int nr); |
213 | 81fdc5f8 | ths | |
214 | 81fdc5f8 | ths | enum cris_features {
|
215 | 81fdc5f8 | ths | CRIS_FEATURE_CF_ISA_MUL, |
216 | 81fdc5f8 | ths | }; |
217 | 81fdc5f8 | ths | |
218 | 81fdc5f8 | ths | static inline int cris_feature(CPUCRISState *env, int feature) |
219 | 81fdc5f8 | ths | { |
220 | 81fdc5f8 | ths | return (env->features & (1u << feature)) != 0; |
221 | 81fdc5f8 | ths | } |
222 | 81fdc5f8 | ths | |
223 | 81fdc5f8 | ths | void register_cris_insns (CPUCRISState *env);
|
224 | 81fdc5f8 | ths | |
225 | 81fdc5f8 | ths | /* CRIS uses 8k pages. */
|
226 | 81fdc5f8 | ths | #define TARGET_PAGE_BITS 13 |
227 | 81fdc5f8 | ths | |
228 | 81fdc5f8 | ths | #define CPUState CPUCRISState
|
229 | 81fdc5f8 | ths | #define cpu_init cpu_cris_init
|
230 | 81fdc5f8 | ths | #define cpu_exec cpu_cris_exec
|
231 | 81fdc5f8 | ths | #define cpu_gen_code cpu_cris_gen_code
|
232 | 81fdc5f8 | ths | #define cpu_signal_handler cpu_cris_signal_handler
|
233 | 81fdc5f8 | ths | |
234 | 6ebbf390 | j_mayer | /* MMU modes definitions */
|
235 | 6ebbf390 | j_mayer | #define MMU_MODE0_SUFFIX _kernel
|
236 | 6ebbf390 | j_mayer | #define MMU_MODE1_SUFFIX _user
|
237 | 6ebbf390 | j_mayer | #define MMU_USER_IDX 1 |
238 | 6ebbf390 | j_mayer | /* CRIS FIXME: I guess we want to validate supervisor mode acceses here. */
|
239 | 6ebbf390 | j_mayer | static inline int cpu_mmu_index (CPUState *env) |
240 | 6ebbf390 | j_mayer | { |
241 | 6ebbf390 | j_mayer | return 0; |
242 | 6ebbf390 | j_mayer | } |
243 | 6ebbf390 | j_mayer | |
244 | 81fdc5f8 | ths | #include "cpu-all.h" |
245 | 81fdc5f8 | ths | |
246 | 81fdc5f8 | ths | /* Register aliases. */
|
247 | 81fdc5f8 | ths | #define REG_SP 14 |
248 | 81fdc5f8 | ths | #define REG_ACR 15 |
249 | 81fdc5f8 | ths | #define REG_MOF 7 |
250 | 81fdc5f8 | ths | |
251 | 81fdc5f8 | ths | /* Support regs. */
|
252 | 81fdc5f8 | ths | #define SR_PID 2 |
253 | 81fdc5f8 | ths | #define SR_SRS 3 |
254 | 81fdc5f8 | ths | #define SR_EBP 9 |
255 | 81fdc5f8 | ths | #define SR_ERP 10 |
256 | 81fdc5f8 | ths | #define SR_CCS 13 |
257 | 81fdc5f8 | ths | |
258 | 81fdc5f8 | ths | /* Support func regs. */
|
259 | 81fdc5f8 | ths | #define SFR_RW_GC_CFG 0][0 |
260 | 81fdc5f8 | ths | #define SFR_RW_MM_CFG 1][0 |
261 | 81fdc5f8 | ths | #define SFR_RW_MM_KBASE_LO 1][1 |
262 | 81fdc5f8 | ths | #define SFR_RW_MM_KBASE_HI 1][2 |
263 | 81fdc5f8 | ths | #define SFR_R_MM_CAUSE 1][3 |
264 | 81fdc5f8 | ths | #define SFR_RW_MM_TLB_SEL 1][4 |
265 | 81fdc5f8 | ths | #define SFR_RW_MM_TLB_LO 1][5 |
266 | 81fdc5f8 | ths | #define SFR_RW_MM_TLB_HI 1][6 |
267 | 81fdc5f8 | ths | |
268 | 81fdc5f8 | ths | #endif |