2 * LatticeMico32 virtual CPU header.
4 * Copyright (c) 2010 Michael Walle <michael@walle.cc>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
23 #define TARGET_LONG_BITS 32
25 #define CPUArchState struct CPULM32State
27 #include "qemu-common.h"
28 #include "exec/cpu-defs.h"
30 typedef struct CPULM32State CPULM32State
;
32 #define NB_MMU_MODES 1
33 #define TARGET_PAGE_BITS 12
34 static inline int cpu_mmu_index(CPULM32State
*env
, bool ifetch
)
39 #define TARGET_PHYS_ADDR_SPACE_BITS 32
40 #define TARGET_VIRT_ADDR_SPACE_BITS 32
42 /* Exceptions indices */
56 R_R0
= 0, R_R1
, R_R2
, R_R3
, R_R4
, R_R5
, R_R6
, R_R7
, R_R8
, R_R9
, R_R10
,
57 R_R11
, R_R12
, R_R13
, R_R14
, R_R15
, R_R16
, R_R17
, R_R18
, R_R19
, R_R20
,
58 R_R21
, R_R22
, R_R23
, R_R24
, R_R25
, R_R26
, R_R27
, R_R28
, R_R29
, R_R30
,
62 /* Register aliases */
134 LM32_FEATURE_MULTIPLY
= 1,
135 LM32_FEATURE_DIVIDE
= 2,
136 LM32_FEATURE_SHIFT
= 4,
137 LM32_FEATURE_SIGN_EXTEND
= 8,
138 LM32_FEATURE_I_CACHE
= 16,
139 LM32_FEATURE_D_CACHE
= 32,
140 LM32_FEATURE_CYCLE_COUNT
= 64,
144 LM32_FLAG_IGNORE_MSB
= 1,
147 struct CPULM32State
{
148 /* general registers */
151 /* special registers */
152 uint32_t pc
; /* program counter */
153 uint32_t ie
; /* interrupt enable */
154 uint32_t icc
; /* instruction cache control */
155 uint32_t dcc
; /* data cache control */
156 uint32_t cc
; /* cycle counter */
157 uint32_t cfg
; /* configuration */
159 /* debug registers */
160 uint32_t dc
; /* debug control */
161 uint32_t bp
[4]; /* breakpoints */
162 uint32_t wp
[4]; /* watchpoints */
164 struct CPUBreakpoint
*cpu_breakpoint
[4];
165 struct CPUWatchpoint
*cpu_watchpoint
[4];
169 /* Fields from here on are preserved across CPU reset. */
170 uint32_t eba
; /* exception base address */
171 uint32_t deba
; /* debug exception base address */
173 /* interrupt controller handle for callbacks */
174 DeviceState
*pic_state
;
175 /* JTAG UART handle for callbacks */
176 DeviceState
*juart_state
;
178 /* processor core features */
184 LM32_WP_DISABLED
= 0,
190 static inline lm32_wp_t
lm32_wp_type(uint32_t dc
, int idx
)
193 return (dc
>> (idx
+1)*2) & 0x3;
198 LM32CPU
*cpu_lm32_init(const char *cpu_model
);
199 int cpu_lm32_exec(CPUState
*cpu
);
200 /* you can call this signal handler from your SIGBUS and SIGSEGV
201 signal handlers to inform the virtual CPU of exceptions. non zero
202 is returned if the signal was handled by the virtual CPU. */
203 int cpu_lm32_signal_handler(int host_signum
, void *pinfo
,
205 void lm32_cpu_list(FILE *f
, fprintf_function cpu_fprintf
);
206 void lm32_translate_init(void);
207 void cpu_lm32_set_phys_msb_ignore(CPULM32State
*env
, int value
);
208 void QEMU_NORETURN
raise_exception(CPULM32State
*env
, int index
);
209 void lm32_debug_excp_handler(CPUState
*cs
);
210 void lm32_breakpoint_insert(CPULM32State
*env
, int index
, target_ulong address
);
211 void lm32_breakpoint_remove(CPULM32State
*env
, int index
);
212 void lm32_watchpoint_insert(CPULM32State
*env
, int index
, target_ulong address
,
214 void lm32_watchpoint_remove(CPULM32State
*env
, int index
);
215 bool lm32_cpu_do_semihosting(CPUState
*cs
);
217 #define cpu_init(cpu_model) CPU(cpu_lm32_init(cpu_model))
219 #define cpu_list lm32_cpu_list
220 #define cpu_exec cpu_lm32_exec
221 #define cpu_signal_handler cpu_lm32_signal_handler
223 int lm32_cpu_handle_mmu_fault(CPUState
*cpu
, vaddr address
, int rw
,
226 #include "exec/cpu-all.h"
228 static inline void cpu_get_tb_cpu_state(CPULM32State
*env
, target_ulong
*pc
,
229 target_ulong
*cs_base
, int *flags
)
236 #include "exec/exec-all.h"