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