1 /*
2  * Loongson CSR instructions translation routines
3  *
4  *  Copyright (c) 2023 Jiaxun Yang <jiaxun.yang@flygoat.com>
5  *
6  * SPDX-License-Identifier: GPL-2.0-or-later
7  */
8 
9 #include "qemu/osdep.h"
10 #include "qemu/main-loop.h"
11 #include "cpu.h"
12 #include "internal.h"
13 #include "qemu/host-utils.h"
14 #include "exec/helper-proto.h"
15 #include "exec/exec-all.h"
16 
17 #define GET_MEMTXATTRS(cas) \
18         ((MemTxAttrs){.requester_id = env_cpu(cas)->cpu_index})
19 
20 uint64_t helper_lcsr_rdcsr(CPUMIPSState *env, target_ulong r_addr)
21 {
22     return address_space_ldl(&env->iocsr.as, r_addr,
23                              GET_MEMTXATTRS(env), NULL);
24 }
25 
26 uint64_t helper_lcsr_drdcsr(CPUMIPSState *env, target_ulong r_addr)
27 {
28     return address_space_ldq(&env->iocsr.as, r_addr,
29                              GET_MEMTXATTRS(env), NULL);
30 }
31 
32 void helper_lcsr_wrcsr(CPUMIPSState *env, target_ulong w_addr,
33                       target_ulong val)
34 {
35     address_space_stl(&env->iocsr.as, w_addr,
36                       val, GET_MEMTXATTRS(env), NULL);
37 }
38 
39 void helper_lcsr_dwrcsr(CPUMIPSState *env, target_ulong w_addr,
40                       target_ulong val)
41 {
42     address_space_stq(&env->iocsr.as, w_addr,
43                       val, GET_MEMTXATTRS(env), NULL);
44 }
45