]> git.proxmox.com Git - qemu.git/blame - target-lm32/op_helper.c
Merge remote-tracking branch 'mst/tags/for_anthony' into staging
[qemu.git] / target-lm32 / op_helper.c
CommitLineData
143e8951 1#include <assert.h>
3e457172 2#include "cpu.h"
143e8951 3#include "helper.h"
1de7afc9 4#include "qemu/host-utils.h"
143e8951
MW
5
6#include "hw/lm32_pic.h"
7#include "hw/lm32_juart.h"
8
9#if !defined(CONFIG_USER_ONLY)
10#define MMUSUFFIX _mmu
11#define SHIFT 0
022c62cb 12#include "exec/softmmu_template.h"
143e8951 13#define SHIFT 1
022c62cb 14#include "exec/softmmu_template.h"
143e8951 15#define SHIFT 2
022c62cb 16#include "exec/softmmu_template.h"
143e8951 17#define SHIFT 3
022c62cb 18#include "exec/softmmu_template.h"
143e8951 19
66350755 20void HELPER(raise_exception)(CPULM32State *env, uint32_t index)
143e8951
MW
21{
22 env->exception_index = index;
1162c041 23 cpu_loop_exit(env);
143e8951
MW
24}
25
66350755 26void HELPER(hlt)(CPULM32State *env)
143e8951 27{
259186a7
AF
28 CPUState *cs = CPU(lm32_env_get_cpu(env));
29
30 cs->halted = 1;
143e8951 31 env->exception_index = EXCP_HLT;
1162c041 32 cpu_loop_exit(env);
143e8951
MW
33}
34
66350755 35void HELPER(wcsr_im)(CPULM32State *env, uint32_t im)
143e8951
MW
36{
37 lm32_pic_set_im(env->pic_state, im);
38}
39
66350755 40void HELPER(wcsr_ip)(CPULM32State *env, uint32_t im)
143e8951
MW
41{
42 lm32_pic_set_ip(env->pic_state, im);
43}
44
66350755 45void HELPER(wcsr_jtx)(CPULM32State *env, uint32_t jtx)
143e8951
MW
46{
47 lm32_juart_set_jtx(env->juart_state, jtx);
48}
49
66350755 50void HELPER(wcsr_jrx)(CPULM32State *env, uint32_t jrx)
143e8951
MW
51{
52 lm32_juart_set_jrx(env->juart_state, jrx);
53}
54
66350755 55uint32_t HELPER(rcsr_im)(CPULM32State *env)
143e8951
MW
56{
57 return lm32_pic_get_im(env->pic_state);
58}
59
66350755 60uint32_t HELPER(rcsr_ip)(CPULM32State *env)
143e8951
MW
61{
62 return lm32_pic_get_ip(env->pic_state);
63}
64
66350755 65uint32_t HELPER(rcsr_jtx)(CPULM32State *env)
143e8951
MW
66{
67 return lm32_juart_get_jtx(env->juart_state);
68}
69
66350755 70uint32_t HELPER(rcsr_jrx)(CPULM32State *env)
143e8951
MW
71{
72 return lm32_juart_get_jrx(env->juart_state);
73}
74
75/* Try to fill the TLB and return an exception if error. If retaddr is
76 NULL, it means that the function was called in C code (i.e. not
77 from generated code or from helper.c) */
32ac0ca2 78void tlb_fill(CPULM32State *env, target_ulong addr, int is_write, int mmu_idx,
20503968 79 uintptr_t retaddr)
143e8951 80{
143e8951
MW
81 int ret;
82
97b348e7 83 ret = cpu_lm32_handle_mmu_fault(env, addr, is_write, mmu_idx);
143e8951
MW
84 if (unlikely(ret)) {
85 if (retaddr) {
86 /* now we have a real cpu fault */
a8a826a3 87 cpu_restore_state(env, retaddr);
143e8951 88 }
1162c041 89 cpu_loop_exit(env);
143e8951 90 }
143e8951
MW
91}
92#endif
93