Statistics
| Branch: | Revision:

root / target-lm32 / op_helper.c @ 1de7afc9

History | View | Annotate | Download (2 kB)

1 143e8951 Michael Walle
#include <assert.h>
2 3e457172 Blue Swirl
#include "cpu.h"
3 143e8951 Michael Walle
#include "helper.h"
4 1de7afc9 Paolo Bonzini
#include "qemu/host-utils.h"
5 143e8951 Michael Walle
6 143e8951 Michael Walle
#include "hw/lm32_pic.h"
7 143e8951 Michael Walle
#include "hw/lm32_juart.h"
8 143e8951 Michael Walle
9 143e8951 Michael Walle
#if !defined(CONFIG_USER_ONLY)
10 143e8951 Michael Walle
#define MMUSUFFIX _mmu
11 143e8951 Michael Walle
#define SHIFT 0
12 022c62cb Paolo Bonzini
#include "exec/softmmu_template.h"
13 143e8951 Michael Walle
#define SHIFT 1
14 022c62cb Paolo Bonzini
#include "exec/softmmu_template.h"
15 143e8951 Michael Walle
#define SHIFT 2
16 022c62cb Paolo Bonzini
#include "exec/softmmu_template.h"
17 143e8951 Michael Walle
#define SHIFT 3
18 022c62cb Paolo Bonzini
#include "exec/softmmu_template.h"
19 143e8951 Michael Walle
20 32ac0ca2 Blue Swirl
void helper_raise_exception(CPULM32State *env, uint32_t index)
21 143e8951 Michael Walle
{
22 143e8951 Michael Walle
    env->exception_index = index;
23 1162c041 Blue Swirl
    cpu_loop_exit(env);
24 143e8951 Michael Walle
}
25 143e8951 Michael Walle
26 32ac0ca2 Blue Swirl
void helper_hlt(CPULM32State *env)
27 143e8951 Michael Walle
{
28 143e8951 Michael Walle
    env->halted = 1;
29 143e8951 Michael Walle
    env->exception_index = EXCP_HLT;
30 1162c041 Blue Swirl
    cpu_loop_exit(env);
31 143e8951 Michael Walle
}
32 143e8951 Michael Walle
33 32ac0ca2 Blue Swirl
void helper_wcsr_im(CPULM32State *env, uint32_t im)
34 143e8951 Michael Walle
{
35 143e8951 Michael Walle
    lm32_pic_set_im(env->pic_state, im);
36 143e8951 Michael Walle
}
37 143e8951 Michael Walle
38 32ac0ca2 Blue Swirl
void helper_wcsr_ip(CPULM32State *env, uint32_t im)
39 143e8951 Michael Walle
{
40 143e8951 Michael Walle
    lm32_pic_set_ip(env->pic_state, im);
41 143e8951 Michael Walle
}
42 143e8951 Michael Walle
43 32ac0ca2 Blue Swirl
void helper_wcsr_jtx(CPULM32State *env, uint32_t jtx)
44 143e8951 Michael Walle
{
45 143e8951 Michael Walle
    lm32_juart_set_jtx(env->juart_state, jtx);
46 143e8951 Michael Walle
}
47 143e8951 Michael Walle
48 32ac0ca2 Blue Swirl
void helper_wcsr_jrx(CPULM32State *env, uint32_t jrx)
49 143e8951 Michael Walle
{
50 143e8951 Michael Walle
    lm32_juart_set_jrx(env->juart_state, jrx);
51 143e8951 Michael Walle
}
52 143e8951 Michael Walle
53 32ac0ca2 Blue Swirl
uint32_t helper_rcsr_im(CPULM32State *env)
54 143e8951 Michael Walle
{
55 143e8951 Michael Walle
    return lm32_pic_get_im(env->pic_state);
56 143e8951 Michael Walle
}
57 143e8951 Michael Walle
58 32ac0ca2 Blue Swirl
uint32_t helper_rcsr_ip(CPULM32State *env)
59 143e8951 Michael Walle
{
60 143e8951 Michael Walle
    return lm32_pic_get_ip(env->pic_state);
61 143e8951 Michael Walle
}
62 143e8951 Michael Walle
63 32ac0ca2 Blue Swirl
uint32_t helper_rcsr_jtx(CPULM32State *env)
64 143e8951 Michael Walle
{
65 143e8951 Michael Walle
    return lm32_juart_get_jtx(env->juart_state);
66 143e8951 Michael Walle
}
67 143e8951 Michael Walle
68 32ac0ca2 Blue Swirl
uint32_t helper_rcsr_jrx(CPULM32State *env)
69 143e8951 Michael Walle
{
70 143e8951 Michael Walle
    return lm32_juart_get_jrx(env->juart_state);
71 143e8951 Michael Walle
}
72 143e8951 Michael Walle
73 143e8951 Michael Walle
/* Try to fill the TLB and return an exception if error. If retaddr is
74 143e8951 Michael Walle
   NULL, it means that the function was called in C code (i.e. not
75 143e8951 Michael Walle
   from generated code or from helper.c) */
76 32ac0ca2 Blue Swirl
void tlb_fill(CPULM32State *env, target_ulong addr, int is_write, int mmu_idx,
77 20503968 Blue Swirl
              uintptr_t retaddr)
78 143e8951 Michael Walle
{
79 143e8951 Michael Walle
    int ret;
80 143e8951 Michael Walle
81 97b348e7 Blue Swirl
    ret = cpu_lm32_handle_mmu_fault(env, addr, is_write, mmu_idx);
82 143e8951 Michael Walle
    if (unlikely(ret)) {
83 143e8951 Michael Walle
        if (retaddr) {
84 143e8951 Michael Walle
            /* now we have a real cpu fault */
85 a8a826a3 Blue Swirl
            cpu_restore_state(env, retaddr);
86 143e8951 Michael Walle
        }
87 1162c041 Blue Swirl
        cpu_loop_exit(env);
88 143e8951 Michael Walle
    }
89 143e8951 Michael Walle
}
90 143e8951 Michael Walle
#endif