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