Statistics
| Branch: | Revision:

root / target-lm32 / op_helper.c @ 3dd3a2b9

History | View | Annotate | Download (3.2 kB)

1
#include <assert.h>
2
#include "cpu.h"
3
#include "helper.h"
4
#include "qemu/host-utils.h"
5

    
6
#include "hw/lm32/lm32_pic.h"
7
#include "hw/char/lm32_juart.h"
8

    
9
#include "exec/softmmu_exec.h"
10

    
11
#if !defined(CONFIG_USER_ONLY)
12
#define MMUSUFFIX _mmu
13
#define SHIFT 0
14
#include "exec/softmmu_template.h"
15
#define SHIFT 1
16
#include "exec/softmmu_template.h"
17
#define SHIFT 2
18
#include "exec/softmmu_template.h"
19
#define SHIFT 3
20
#include "exec/softmmu_template.h"
21

    
22
void raise_exception(CPULM32State *env, int index)
23
{
24
    env->exception_index = index;
25
    cpu_loop_exit(env);
26
}
27

    
28
void HELPER(raise_exception)(CPULM32State *env, uint32_t index)
29
{
30
    raise_exception(env, index);
31
}
32

    
33
void HELPER(hlt)(CPULM32State *env)
34
{
35
    CPUState *cs = CPU(lm32_env_get_cpu(env));
36

    
37
    cs->halted = 1;
38
    env->exception_index = EXCP_HLT;
39
    cpu_loop_exit(env);
40
}
41

    
42
void HELPER(wcsr_bp)(CPULM32State *env, uint32_t bp, uint32_t idx)
43
{
44
    uint32_t addr = bp & ~1;
45

    
46
    assert(idx < 4);
47

    
48
    env->bp[idx] = bp;
49
    lm32_breakpoint_remove(env, idx);
50
    if (bp & 1) {
51
        lm32_breakpoint_insert(env, idx, addr);
52
    }
53
}
54

    
55
void HELPER(wcsr_wp)(CPULM32State *env, uint32_t wp, uint32_t idx)
56
{
57
    lm32_wp_t wp_type;
58

    
59
    assert(idx < 4);
60

    
61
    env->wp[idx] = wp;
62

    
63
    wp_type = lm32_wp_type(env->dc, idx);
64
    lm32_watchpoint_remove(env, idx);
65
    if (wp_type != LM32_WP_DISABLED) {
66
        lm32_watchpoint_insert(env, idx, wp, wp_type);
67
    }
68
}
69

    
70
void HELPER(wcsr_dc)(CPULM32State *env, uint32_t dc)
71
{
72
    uint32_t old_dc;
73
    int i;
74
    lm32_wp_t old_type;
75
    lm32_wp_t new_type;
76

    
77
    old_dc = env->dc;
78
    env->dc = dc;
79

    
80
    for (i = 0; i < 4; i++) {
81
        old_type = lm32_wp_type(old_dc, i);
82
        new_type = lm32_wp_type(dc, i);
83

    
84
        if (old_type != new_type) {
85
            lm32_watchpoint_remove(env, i);
86
            if (new_type != LM32_WP_DISABLED) {
87
                lm32_watchpoint_insert(env, i, env->wp[i], new_type);
88
            }
89
        }
90
    }
91
}
92

    
93
void HELPER(wcsr_im)(CPULM32State *env, uint32_t im)
94
{
95
    lm32_pic_set_im(env->pic_state, im);
96
}
97

    
98
void HELPER(wcsr_ip)(CPULM32State *env, uint32_t im)
99
{
100
    lm32_pic_set_ip(env->pic_state, im);
101
}
102

    
103
void HELPER(wcsr_jtx)(CPULM32State *env, uint32_t jtx)
104
{
105
    lm32_juart_set_jtx(env->juart_state, jtx);
106
}
107

    
108
void HELPER(wcsr_jrx)(CPULM32State *env, uint32_t jrx)
109
{
110
    lm32_juart_set_jrx(env->juart_state, jrx);
111
}
112

    
113
uint32_t HELPER(rcsr_im)(CPULM32State *env)
114
{
115
    return lm32_pic_get_im(env->pic_state);
116
}
117

    
118
uint32_t HELPER(rcsr_ip)(CPULM32State *env)
119
{
120
    return lm32_pic_get_ip(env->pic_state);
121
}
122

    
123
uint32_t HELPER(rcsr_jtx)(CPULM32State *env)
124
{
125
    return lm32_juart_get_jtx(env->juart_state);
126
}
127

    
128
uint32_t HELPER(rcsr_jrx)(CPULM32State *env)
129
{
130
    return lm32_juart_get_jrx(env->juart_state);
131
}
132

    
133
/* Try to fill the TLB and return an exception if error. If retaddr is
134
   NULL, it means that the function was called in C code (i.e. not
135
   from generated code or from helper.c) */
136
void tlb_fill(CPULM32State *env, target_ulong addr, int is_write, int mmu_idx,
137
              uintptr_t retaddr)
138
{
139
    int ret;
140

    
141
    ret = cpu_lm32_handle_mmu_fault(env, addr, is_write, mmu_idx);
142
    if (unlikely(ret)) {
143
        if (retaddr) {
144
            /* now we have a real cpu fault */
145
            cpu_restore_state(env, retaddr);
146
        }
147
        cpu_loop_exit(env);
148
    }
149
}
150
#endif
151