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
28 #include "qemu-common.h"
31 typedef struct CPULM32State CPULM32State
;
33 #define TARGET_HAS_ICE 1
35 #define ELF_MACHINE EM_LATTICEMICO32
37 #define NB_MMU_MODES 1
38 #define TARGET_PAGE_BITS 12
39 static inline int cpu_mmu_index(CPULM32State
*env
)
44 #define TARGET_PHYS_ADDR_SPACE_BITS 32
45 #define TARGET_VIRT_ADDR_SPACE_BITS 32
47 /* Exceptions indices */
61 R_R0
= 0, R_R1
, R_R2
, R_R3
, R_R4
, R_R5
, R_R6
, R_R7
, R_R8
, R_R9
, R_R10
,
62 R_R11
, R_R12
, R_R13
, R_R14
, R_R15
, R_R16
, R_R17
, R_R18
, R_R19
, R_R20
,
63 R_R21
, R_R22
, R_R23
, R_R24
, R_R25
, R_R26
, R_R27
, R_R28
, R_R29
, R_R30
,
67 /* Register aliases */
139 LM32_FEATURE_MULTIPLY
= 1,
140 LM32_FEATURE_DIVIDE
= 2,
141 LM32_FEATURE_SHIFT
= 4,
142 LM32_FEATURE_SIGN_EXTEND
= 8,
143 LM32_FEATURE_I_CACHE
= 16,
144 LM32_FEATURE_D_CACHE
= 32,
145 LM32_FEATURE_CYCLE_COUNT
= 64,
149 LM32_FLAG_IGNORE_MSB
= 1,
152 struct CPULM32State
{
153 /* general registers */
156 /* special registers */
157 uint32_t pc
; /* program counter */
158 uint32_t ie
; /* interrupt enable */
159 uint32_t icc
; /* instruction cache control */
160 uint32_t dcc
; /* data cache control */
161 uint32_t cc
; /* cycle counter */
162 uint32_t cfg
; /* configuration */
164 /* debug registers */
165 uint32_t dc
; /* debug control */
166 uint32_t bp
[4]; /* breakpoint addresses */
167 uint32_t wp
[4]; /* watchpoint addresses */
171 uint32_t eba
; /* exception base address */
172 uint32_t deba
; /* debug exception base address */
174 /* interrupt controller handle for callbacks */
175 DeviceState
*pic_state
;
176 /* JTAG UART handle for callbacks */
177 DeviceState
*juart_state
;
179 /* processor core features */
188 CPULM32State
*cpu_lm32_init(const char *cpu_model
);
189 void cpu_lm32_list(FILE *f
, fprintf_function cpu_fprintf
);
190 int cpu_lm32_exec(CPULM32State
*s
);
191 void cpu_lm32_close(CPULM32State
*s
);
192 void do_interrupt(CPULM32State
*env
);
193 /* you can call this signal handler from your SIGBUS and SIGSEGV
194 signal handlers to inform the virtual CPU of exceptions. non zero
195 is returned if the signal was handled by the virtual CPU. */
196 int cpu_lm32_signal_handler(int host_signum
, void *pinfo
,
198 void lm32_translate_init(void);
199 void cpu_lm32_set_phys_msb_ignore(CPULM32State
*env
, int value
);
201 #define cpu_list cpu_lm32_list
202 #define cpu_init cpu_lm32_init
203 #define cpu_exec cpu_lm32_exec
204 #define cpu_gen_code cpu_lm32_gen_code
205 #define cpu_signal_handler cpu_lm32_signal_handler
207 #define CPU_SAVE_VERSION 1
209 int cpu_lm32_handle_mmu_fault(CPULM32State
*env
, target_ulong address
, int rw
,
211 #define cpu_handle_mmu_fault cpu_lm32_handle_mmu_fault
213 #if defined(CONFIG_USER_ONLY)
214 static inline void cpu_clone_regs(CPULM32State
*env
, target_ulong newsp
)
217 env
->regs
[R_SP
] = newsp
;
223 static inline void cpu_set_tls(CPULM32State
*env
, target_ulong newtls
)
227 static inline int cpu_interrupts_enabled(CPULM32State
*env
)
229 return env
->ie
& IE_IE
;
234 static inline target_ulong
cpu_get_pc(CPULM32State
*env
)
239 static inline void cpu_get_tb_cpu_state(CPULM32State
*env
, target_ulong
*pc
,
240 target_ulong
*cs_base
, int *flags
)
247 static inline bool cpu_has_work(CPULM32State
*env
)
249 return env
->interrupt_request
& CPU_INTERRUPT_HARD
;
252 #include "exec-all.h"
254 static inline void cpu_pc_from_tb(CPULM32State
*env
, TranslationBlock
*tb
)