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 "cpu.h"
11 #include "exec/helper-proto.h"
12 
13 #define GET_MEMTXATTRS(cas) \
14         ((MemTxAttrs){.requester_id = env_cpu(cas)->cpu_index})
15 
16 uint64_t helper_lcsr_rdcsr(CPUMIPSState *env, target_ulong r_addr)
17 {
18     return address_space_ldl(&env->iocsr.as, r_addr,
19                              GET_MEMTXATTRS(env), NULL);
20 }
21 
22 uint64_t helper_lcsr_drdcsr(CPUMIPSState *env, target_ulong r_addr)
23 {
24     return address_space_ldq(&env->iocsr.as, r_addr,
25                              GET_MEMTXATTRS(env), NULL);
26 }
27 
28 void helper_lcsr_wrcsr(CPUMIPSState *env, target_ulong w_addr,
29                       target_ulong val)
30 {
31     address_space_stl(&env->iocsr.as, w_addr,
32                       val, GET_MEMTXATTRS(env), NULL);
33 }
34 
35 void helper_lcsr_dwrcsr(CPUMIPSState *env, target_ulong w_addr,
36                       target_ulong val)
37 {
38     address_space_stq(&env->iocsr.as, w_addr,
39                       val, GET_MEMTXATTRS(env), NULL);
40 }
41