| 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | /* |
| 3 | * Copyright (c) 2021 Loongson Technology Corporation Limited |
| 4 | * |
| 5 | * Helpers for IOCSR reads/writes |
| 6 | */ |
| 7 | |
| 8 | #include "qemu/osdep.h" |
| 9 | #include "cpu.h" |
| 10 | #include "qemu/host-utils.h" |
| 11 | #include "exec/helper-proto.h" |
| 12 | #include "accel/tcg/cpu-ldst.h" |
| 13 | |
| 14 | #define GET_MEMTXATTRS(cas) \ |
| 15 | ((MemTxAttrs){.requester_id = env_cpu(cas)->cpu_index}) |
| 16 | |
| 17 | uint64_t helper_iocsrrd_b(CPULoongArchState *env, target_ulong r_addr) |
| 18 | { |
| 19 | return address_space_ldub(env->address_space_iocsr, r_addr, |
| 20 | GET_MEMTXATTRS(env), NULL); |
| 21 | } |
| 22 | |
| 23 | uint64_t helper_iocsrrd_h(CPULoongArchState *env, target_ulong r_addr) |
| 24 | { |
| 25 | return address_space_lduw_le(env->address_space_iocsr, r_addr, |
| 26 | GET_MEMTXATTRS(env), NULL); |
| 27 | } |
| 28 | |
| 29 | uint64_t helper_iocsrrd_w(CPULoongArchState *env, target_ulong r_addr) |
| 30 | { |
| 31 | return address_space_ldl_le(env->address_space_iocsr, r_addr, |
| 32 | GET_MEMTXATTRS(env), NULL); |
| 33 | } |
| 34 | |
| 35 | uint64_t helper_iocsrrd_d(CPULoongArchState *env, target_ulong r_addr) |
| 36 | { |
| 37 | return address_space_ldq_le(env->address_space_iocsr, r_addr, |
| 38 | GET_MEMTXATTRS(env), NULL); |
| 39 | } |
| 40 | |
| 41 | void helper_iocsrwr_b(CPULoongArchState *env, target_ulong w_addr, |
| 42 | target_ulong val) |
| 43 | { |
| 44 | address_space_stb(env->address_space_iocsr, w_addr, |
| 45 | val, GET_MEMTXATTRS(env), NULL); |
| 46 | } |
| 47 | |
| 48 | void helper_iocsrwr_h(CPULoongArchState *env, target_ulong w_addr, |
| 49 | target_ulong val) |
| 50 | { |
| 51 | address_space_stw_le(env->address_space_iocsr, w_addr, |
| 52 | val, GET_MEMTXATTRS(env), NULL); |
| 53 | } |
| 54 | |
| 55 | void helper_iocsrwr_w(CPULoongArchState *env, target_ulong w_addr, |
| 56 | target_ulong val) |
| 57 | { |
| 58 | address_space_stl_le(env->address_space_iocsr, w_addr, |
| 59 | val, GET_MEMTXATTRS(env), NULL); |
| 60 | } |
| 61 | |
| 62 | void helper_iocsrwr_d(CPULoongArchState *env, target_ulong w_addr, |
| 63 | target_ulong val) |
| 64 | { |
| 65 | address_space_stq_le(env->address_space_iocsr, w_addr, |
| 66 | val, GET_MEMTXATTRS(env), NULL); |
| 67 | } |