op_helper.c 2.0 KB
Newer Older
M
Michael Walle 已提交
1
#include <assert.h>
B
Blue Swirl 已提交
2
#include "cpu.h"
M
Michael Walle 已提交
3
#include "helper.h"
4
#include "qemu/host-utils.h"
M
Michael Walle 已提交
5 6 7 8 9 10 11

#include "hw/lm32_pic.h"
#include "hw/lm32_juart.h"

#if !defined(CONFIG_USER_ONLY)
#define MMUSUFFIX _mmu
#define SHIFT 0
12
#include "exec/softmmu_template.h"
M
Michael Walle 已提交
13
#define SHIFT 1
14
#include "exec/softmmu_template.h"
M
Michael Walle 已提交
15
#define SHIFT 2
16
#include "exec/softmmu_template.h"
M
Michael Walle 已提交
17
#define SHIFT 3
18
#include "exec/softmmu_template.h"
M
Michael Walle 已提交
19

M
Michael Walle 已提交
20
void HELPER(raise_exception)(CPULM32State *env, uint32_t index)
M
Michael Walle 已提交
21 22
{
    env->exception_index = index;
B
Blue Swirl 已提交
23
    cpu_loop_exit(env);
M
Michael Walle 已提交
24 25
}

M
Michael Walle 已提交
26
void HELPER(hlt)(CPULM32State *env)
M
Michael Walle 已提交
27
{
28 29 30
    CPUState *cs = CPU(lm32_env_get_cpu(env));

    cs->halted = 1;
M
Michael Walle 已提交
31
    env->exception_index = EXCP_HLT;
B
Blue Swirl 已提交
32
    cpu_loop_exit(env);
M
Michael Walle 已提交
33 34
}

M
Michael Walle 已提交
35
void HELPER(wcsr_im)(CPULM32State *env, uint32_t im)
M
Michael Walle 已提交
36 37 38 39
{
    lm32_pic_set_im(env->pic_state, im);
}

M
Michael Walle 已提交
40
void HELPER(wcsr_ip)(CPULM32State *env, uint32_t im)
M
Michael Walle 已提交
41 42 43 44
{
    lm32_pic_set_ip(env->pic_state, im);
}

M
Michael Walle 已提交
45
void HELPER(wcsr_jtx)(CPULM32State *env, uint32_t jtx)
M
Michael Walle 已提交
46 47 48 49
{
    lm32_juart_set_jtx(env->juart_state, jtx);
}

M
Michael Walle 已提交
50
void HELPER(wcsr_jrx)(CPULM32State *env, uint32_t jrx)
M
Michael Walle 已提交
51 52 53 54
{
    lm32_juart_set_jrx(env->juart_state, jrx);
}

M
Michael Walle 已提交
55
uint32_t HELPER(rcsr_im)(CPULM32State *env)
M
Michael Walle 已提交
56 57 58 59
{
    return lm32_pic_get_im(env->pic_state);
}

M
Michael Walle 已提交
60
uint32_t HELPER(rcsr_ip)(CPULM32State *env)
M
Michael Walle 已提交
61 62 63 64
{
    return lm32_pic_get_ip(env->pic_state);
}

M
Michael Walle 已提交
65
uint32_t HELPER(rcsr_jtx)(CPULM32State *env)
M
Michael Walle 已提交
66 67 68 69
{
    return lm32_juart_get_jtx(env->juart_state);
}

M
Michael Walle 已提交
70
uint32_t HELPER(rcsr_jrx)(CPULM32State *env)
M
Michael Walle 已提交
71 72 73 74 75 76 77
{
    return lm32_juart_get_jrx(env->juart_state);
}

/* Try to fill the TLB and return an exception if error. If retaddr is
   NULL, it means that the function was called in C code (i.e. not
   from generated code or from helper.c) */
78
void tlb_fill(CPULM32State *env, target_ulong addr, int is_write, int mmu_idx,
79
              uintptr_t retaddr)
M
Michael Walle 已提交
80 81 82
{
    int ret;

83
    ret = cpu_lm32_handle_mmu_fault(env, addr, is_write, mmu_idx);
M
Michael Walle 已提交
84 85 86
    if (unlikely(ret)) {
        if (retaddr) {
            /* now we have a real cpu fault */
B
Blue Swirl 已提交
87
            cpu_restore_state(env, retaddr);
M
Michael Walle 已提交
88
        }
B
Blue Swirl 已提交
89
        cpu_loop_exit(env);
M
Michael Walle 已提交
90 91 92 93
    }
}
#endif