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