Change so that Powerpc & ia64 do not have KVM_EXTRA_PAGES set
[qemu-kvm/fedora.git] / target-cris / cpu.h
blob56b0497f1280628a8ba276c34acc414587ec82c4
1 /*
2 * CRIS virtual CPU header
4 * Copyright (c) 2007 AXIS Communications AB
5 * Written by Edgar E. Iglesias
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.
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.
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
21 #ifndef CPU_CRIS_H
22 #define CPU_CRIS_H
24 #define TARGET_LONG_BITS 32
26 #include "cpu-defs.h"
28 #include "softfloat.h"
30 #define TARGET_HAS_ICE 1
32 #define ELF_MACHINE EM_CRIS
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. */
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
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
74 /* Internal flags for the implementation. */
75 #define F_DELAYSLOT 1
77 #define NB_MMU_MODES 2
79 typedef struct CPUCRISState {
80 uint32_t debug1;
81 uint32_t debug2;
82 uint32_t debug3;
85 * We just store the stores to the tlbset here for later evaluation
86 * when the hw needs access to them.
88 * One for I and another for D.
90 struct
92 uint32_t hi;
93 uint32_t lo;
94 } tlbsets[2][4][16];
96 uint32_t sregs[256][16]; /* grrr why so many?? */
97 uint32_t regs[16];
98 uint32_t pregs[16];
99 uint32_t pc;
100 uint32_t sr;
101 uint32_t flag_mask; /* Per insn mask of affected flags. */
103 /* SSP and USP. */
104 int current_sp;
105 uint32_t sp[2];
107 /* These are setup up by the guest code just before transfering the
108 control back to the host. */
109 int jmp;
110 uint32_t btarget;
111 int btaken;
113 /* for traps. */
114 int trapnr;
116 /* Condition flag tracking. */
117 uint32_t cc_op;
118 uint32_t cc_mask;
119 uint32_t cc_dest;
120 uint32_t cc_src;
121 uint32_t cc_result;
123 /* size of the operation, 1 = byte, 2 = word, 4 = dword. */
124 int cc_size;
126 /* extended arithmetics. */
127 int cc_x_live;
128 int cc_x;
130 int features;
132 uint64_t pending_interrupts;
133 int interrupt_request;
134 int exception_index;
135 int user_mode_only;
136 int halted;
138 struct
140 int exec_insns;
141 int exec_loads;
142 int exec_stores;
143 } stats;
146 jmp_buf jmp_env;
147 CPU_COMMON
148 } CPUCRISState;
150 CPUCRISState *cpu_cris_init(const char *cpu_model);
151 int cpu_cris_exec(CPUCRISState *s);
152 void cpu_cris_close(CPUCRISState *s);
153 void do_interrupt(CPUCRISState *env);
154 /* you can call this signal handler from your SIGBUS and SIGSEGV
155 signal handlers to inform the virtual CPU of exceptions. non zero
156 is returned if the signal was handled by the virtual CPU. */
157 int cpu_cris_signal_handler(int host_signum, void *pinfo,
158 void *puc);
159 void cpu_cris_flush_flags(CPUCRISState *, int);
162 void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec,
163 int is_asi);
165 enum {
166 CC_OP_DYNAMIC, /* Use env->cc_op */
167 CC_OP_FLAGS,
168 CC_OP_LOGIC,
169 CC_OP_CMP,
170 CC_OP_MOVE,
171 CC_OP_MOVE_PD,
172 CC_OP_MOVE_SD,
173 CC_OP_ADD,
174 CC_OP_ADDC,
175 CC_OP_MCP,
176 CC_OP_ADDU,
177 CC_OP_SUB,
178 CC_OP_SUBU,
179 CC_OP_NEG,
180 CC_OP_BTST,
181 CC_OP_MULS,
182 CC_OP_MULU,
183 CC_OP_DSTEP,
184 CC_OP_BOUND,
186 CC_OP_OR,
187 CC_OP_AND,
188 CC_OP_XOR,
189 CC_OP_LSL,
190 CC_OP_LSR,
191 CC_OP_ASR,
192 CC_OP_LZ
195 #define CCF_C 0x01
196 #define CCF_V 0x02
197 #define CCF_Z 0x04
198 #define CCF_N 0x08
199 #define CCF_X 0x10
201 #define CRIS_SSP 0
202 #define CRIS_USP 1
204 void cris_set_irq_level(CPUCRISState *env, int level, uint8_t vector);
205 void cris_set_macsr(CPUCRISState *env, uint32_t val);
206 void cris_switch_sp(CPUCRISState *env);
208 void do_cris_semihosting(CPUCRISState *env, int nr);
210 enum cris_features {
211 CRIS_FEATURE_CF_ISA_MUL,
214 static inline int cris_feature(CPUCRISState *env, int feature)
216 return (env->features & (1u << feature)) != 0;
219 void register_cris_insns (CPUCRISState *env);
221 /* CRIS uses 8k pages. */
222 #define TARGET_PAGE_BITS 13
224 #define CPUState CPUCRISState
225 #define cpu_init cpu_cris_init
226 #define cpu_exec cpu_cris_exec
227 #define cpu_gen_code cpu_cris_gen_code
228 #define cpu_signal_handler cpu_cris_signal_handler
230 /* MMU modes definitions */
231 #define MMU_MODE0_SUFFIX _kernel
232 #define MMU_MODE1_SUFFIX _user
233 #define MMU_USER_IDX 1
234 /* CRIS FIXME: I guess we want to validate supervisor mode acceses here. */
235 static inline int cpu_mmu_index (CPUState *env)
237 return 0;
240 #include "cpu-all.h"
242 /* Register aliases. */
243 #define REG_SP 14
244 #define REG_ACR 15
245 #define REG_MOF 7
247 /* Support regs. */
248 #define SR_PID 2
249 #define SR_SRS 3
250 #define SR_EBP 9
251 #define SR_ERP 10
252 #define SR_CCS 13
254 /* Support func regs. */
255 #define SFR_RW_GC_CFG 0][0
256 #define SFR_RW_MM_CFG 1][0
257 #define SFR_RW_MM_KBASE_LO 1][1
258 #define SFR_RW_MM_KBASE_HI 1][2
259 #define SFR_R_MM_CAUSE 1][3
260 #define SFR_RW_MM_TLB_SEL 1][4
261 #define SFR_RW_MM_TLB_LO 1][5
262 #define SFR_RW_MM_TLB_HI 1][6
264 #endif