xref: /openbmc/qemu/include/accel/tcg/cpu-ldst-common.h (revision fc524567087c2537b5103cdfc1d41e4f442892b6)
1*231a1c0fSPhilippe Mathieu-Daudé /*
2*231a1c0fSPhilippe Mathieu-Daudé  * Software MMU support
3*231a1c0fSPhilippe Mathieu-Daudé  *
4*231a1c0fSPhilippe Mathieu-Daudé  * SPDX-License-Identifier: LGPL-2.1-or-later
5*231a1c0fSPhilippe Mathieu-Daudé  */
6*231a1c0fSPhilippe Mathieu-Daudé 
7*231a1c0fSPhilippe Mathieu-Daudé #ifndef ACCEL_TCG_CPU_LDST_COMMON_H
8*231a1c0fSPhilippe Mathieu-Daudé #define ACCEL_TCG_CPU_LDST_COMMON_H
9*231a1c0fSPhilippe Mathieu-Daudé 
10*231a1c0fSPhilippe Mathieu-Daudé #ifndef CONFIG_TCG
11*231a1c0fSPhilippe Mathieu-Daudé #error Can only include this header with TCG
12*231a1c0fSPhilippe Mathieu-Daudé #endif
13*231a1c0fSPhilippe Mathieu-Daudé 
14*231a1c0fSPhilippe Mathieu-Daudé #include "exec/memopidx.h"
15*231a1c0fSPhilippe Mathieu-Daudé #include "exec/vaddr.h"
16*231a1c0fSPhilippe Mathieu-Daudé #include "exec/mmu-access-type.h"
17*231a1c0fSPhilippe Mathieu-Daudé #include "qemu/int128.h"
18*231a1c0fSPhilippe Mathieu-Daudé 
19*231a1c0fSPhilippe Mathieu-Daudé uint8_t cpu_ldb_mmu(CPUArchState *env, vaddr ptr, MemOpIdx oi, uintptr_t ra);
20*231a1c0fSPhilippe Mathieu-Daudé uint16_t cpu_ldw_mmu(CPUArchState *env, vaddr ptr, MemOpIdx oi, uintptr_t ra);
21*231a1c0fSPhilippe Mathieu-Daudé uint32_t cpu_ldl_mmu(CPUArchState *env, vaddr ptr, MemOpIdx oi, uintptr_t ra);
22*231a1c0fSPhilippe Mathieu-Daudé uint64_t cpu_ldq_mmu(CPUArchState *env, vaddr ptr, MemOpIdx oi, uintptr_t ra);
23*231a1c0fSPhilippe Mathieu-Daudé Int128 cpu_ld16_mmu(CPUArchState *env, vaddr addr, MemOpIdx oi, uintptr_t ra);
24*231a1c0fSPhilippe Mathieu-Daudé 
25*231a1c0fSPhilippe Mathieu-Daudé void cpu_stb_mmu(CPUArchState *env, vaddr ptr, uint8_t val,
26*231a1c0fSPhilippe Mathieu-Daudé                  MemOpIdx oi, uintptr_t ra);
27*231a1c0fSPhilippe Mathieu-Daudé void cpu_stw_mmu(CPUArchState *env, vaddr ptr, uint16_t val,
28*231a1c0fSPhilippe Mathieu-Daudé                  MemOpIdx oi, uintptr_t ra);
29*231a1c0fSPhilippe Mathieu-Daudé void cpu_stl_mmu(CPUArchState *env, vaddr ptr, uint32_t val,
30*231a1c0fSPhilippe Mathieu-Daudé                  MemOpIdx oi, uintptr_t ra);
31*231a1c0fSPhilippe Mathieu-Daudé void cpu_stq_mmu(CPUArchState *env, vaddr ptr, uint64_t val,
32*231a1c0fSPhilippe Mathieu-Daudé                  MemOpIdx oi, uintptr_t ra);
33*231a1c0fSPhilippe Mathieu-Daudé void cpu_st16_mmu(CPUArchState *env, vaddr addr, Int128 val,
34*231a1c0fSPhilippe Mathieu-Daudé                   MemOpIdx oi, uintptr_t ra);
35*231a1c0fSPhilippe Mathieu-Daudé 
36*231a1c0fSPhilippe Mathieu-Daudé uint32_t cpu_atomic_cmpxchgb_mmu(CPUArchState *env, vaddr addr,
37*231a1c0fSPhilippe Mathieu-Daudé                                  uint32_t cmpv, uint32_t newv,
38*231a1c0fSPhilippe Mathieu-Daudé                                  MemOpIdx oi, uintptr_t retaddr);
39*231a1c0fSPhilippe Mathieu-Daudé uint32_t cpu_atomic_cmpxchgw_le_mmu(CPUArchState *env, vaddr addr,
40*231a1c0fSPhilippe Mathieu-Daudé                                     uint32_t cmpv, uint32_t newv,
41*231a1c0fSPhilippe Mathieu-Daudé                                     MemOpIdx oi, uintptr_t retaddr);
42*231a1c0fSPhilippe Mathieu-Daudé uint32_t cpu_atomic_cmpxchgl_le_mmu(CPUArchState *env, vaddr addr,
43*231a1c0fSPhilippe Mathieu-Daudé                                     uint32_t cmpv, uint32_t newv,
44*231a1c0fSPhilippe Mathieu-Daudé                                     MemOpIdx oi, uintptr_t retaddr);
45*231a1c0fSPhilippe Mathieu-Daudé uint64_t cpu_atomic_cmpxchgq_le_mmu(CPUArchState *env, vaddr addr,
46*231a1c0fSPhilippe Mathieu-Daudé                                     uint64_t cmpv, uint64_t newv,
47*231a1c0fSPhilippe Mathieu-Daudé                                     MemOpIdx oi, uintptr_t retaddr);
48*231a1c0fSPhilippe Mathieu-Daudé uint32_t cpu_atomic_cmpxchgw_be_mmu(CPUArchState *env, vaddr addr,
49*231a1c0fSPhilippe Mathieu-Daudé                                     uint32_t cmpv, uint32_t newv,
50*231a1c0fSPhilippe Mathieu-Daudé                                     MemOpIdx oi, uintptr_t retaddr);
51*231a1c0fSPhilippe Mathieu-Daudé uint32_t cpu_atomic_cmpxchgl_be_mmu(CPUArchState *env, vaddr addr,
52*231a1c0fSPhilippe Mathieu-Daudé                                     uint32_t cmpv, uint32_t newv,
53*231a1c0fSPhilippe Mathieu-Daudé                                     MemOpIdx oi, uintptr_t retaddr);
54*231a1c0fSPhilippe Mathieu-Daudé uint64_t cpu_atomic_cmpxchgq_be_mmu(CPUArchState *env, vaddr addr,
55*231a1c0fSPhilippe Mathieu-Daudé                                     uint64_t cmpv, uint64_t newv,
56*231a1c0fSPhilippe Mathieu-Daudé                                     MemOpIdx oi, uintptr_t retaddr);
57*231a1c0fSPhilippe Mathieu-Daudé 
58*231a1c0fSPhilippe Mathieu-Daudé #define GEN_ATOMIC_HELPER(NAME, TYPE, SUFFIX)   \
59*231a1c0fSPhilippe Mathieu-Daudé TYPE cpu_atomic_ ## NAME ## SUFFIX ## _mmu      \
60*231a1c0fSPhilippe Mathieu-Daudé     (CPUArchState *env, vaddr addr, TYPE val,   \
61*231a1c0fSPhilippe Mathieu-Daudé      MemOpIdx oi, uintptr_t retaddr);
62*231a1c0fSPhilippe Mathieu-Daudé 
63*231a1c0fSPhilippe Mathieu-Daudé #ifdef CONFIG_ATOMIC64
64*231a1c0fSPhilippe Mathieu-Daudé #define GEN_ATOMIC_HELPER_ALL(NAME)          \
65*231a1c0fSPhilippe Mathieu-Daudé     GEN_ATOMIC_HELPER(NAME, uint32_t, b)     \
66*231a1c0fSPhilippe Mathieu-Daudé     GEN_ATOMIC_HELPER(NAME, uint32_t, w_le)  \
67*231a1c0fSPhilippe Mathieu-Daudé     GEN_ATOMIC_HELPER(NAME, uint32_t, w_be)  \
68*231a1c0fSPhilippe Mathieu-Daudé     GEN_ATOMIC_HELPER(NAME, uint32_t, l_le)  \
69*231a1c0fSPhilippe Mathieu-Daudé     GEN_ATOMIC_HELPER(NAME, uint32_t, l_be)  \
70*231a1c0fSPhilippe Mathieu-Daudé     GEN_ATOMIC_HELPER(NAME, uint64_t, q_le)  \
71*231a1c0fSPhilippe Mathieu-Daudé     GEN_ATOMIC_HELPER(NAME, uint64_t, q_be)
72*231a1c0fSPhilippe Mathieu-Daudé #else
73*231a1c0fSPhilippe Mathieu-Daudé #define GEN_ATOMIC_HELPER_ALL(NAME)          \
74*231a1c0fSPhilippe Mathieu-Daudé     GEN_ATOMIC_HELPER(NAME, uint32_t, b)     \
75*231a1c0fSPhilippe Mathieu-Daudé     GEN_ATOMIC_HELPER(NAME, uint32_t, w_le)  \
76*231a1c0fSPhilippe Mathieu-Daudé     GEN_ATOMIC_HELPER(NAME, uint32_t, w_be)  \
77*231a1c0fSPhilippe Mathieu-Daudé     GEN_ATOMIC_HELPER(NAME, uint32_t, l_le)  \
78*231a1c0fSPhilippe Mathieu-Daudé     GEN_ATOMIC_HELPER(NAME, uint32_t, l_be)
79*231a1c0fSPhilippe Mathieu-Daudé #endif
80*231a1c0fSPhilippe Mathieu-Daudé 
81*231a1c0fSPhilippe Mathieu-Daudé GEN_ATOMIC_HELPER_ALL(fetch_add)
82*231a1c0fSPhilippe Mathieu-Daudé GEN_ATOMIC_HELPER_ALL(fetch_sub)
83*231a1c0fSPhilippe Mathieu-Daudé GEN_ATOMIC_HELPER_ALL(fetch_and)
84*231a1c0fSPhilippe Mathieu-Daudé GEN_ATOMIC_HELPER_ALL(fetch_or)
85*231a1c0fSPhilippe Mathieu-Daudé GEN_ATOMIC_HELPER_ALL(fetch_xor)
86*231a1c0fSPhilippe Mathieu-Daudé GEN_ATOMIC_HELPER_ALL(fetch_smin)
87*231a1c0fSPhilippe Mathieu-Daudé GEN_ATOMIC_HELPER_ALL(fetch_umin)
88*231a1c0fSPhilippe Mathieu-Daudé GEN_ATOMIC_HELPER_ALL(fetch_smax)
89*231a1c0fSPhilippe Mathieu-Daudé GEN_ATOMIC_HELPER_ALL(fetch_umax)
90*231a1c0fSPhilippe Mathieu-Daudé 
91*231a1c0fSPhilippe Mathieu-Daudé GEN_ATOMIC_HELPER_ALL(add_fetch)
92*231a1c0fSPhilippe Mathieu-Daudé GEN_ATOMIC_HELPER_ALL(sub_fetch)
93*231a1c0fSPhilippe Mathieu-Daudé GEN_ATOMIC_HELPER_ALL(and_fetch)
94*231a1c0fSPhilippe Mathieu-Daudé GEN_ATOMIC_HELPER_ALL(or_fetch)
95*231a1c0fSPhilippe Mathieu-Daudé GEN_ATOMIC_HELPER_ALL(xor_fetch)
96*231a1c0fSPhilippe Mathieu-Daudé GEN_ATOMIC_HELPER_ALL(smin_fetch)
97*231a1c0fSPhilippe Mathieu-Daudé GEN_ATOMIC_HELPER_ALL(umin_fetch)
98*231a1c0fSPhilippe Mathieu-Daudé GEN_ATOMIC_HELPER_ALL(smax_fetch)
99*231a1c0fSPhilippe Mathieu-Daudé GEN_ATOMIC_HELPER_ALL(umax_fetch)
100*231a1c0fSPhilippe Mathieu-Daudé 
101*231a1c0fSPhilippe Mathieu-Daudé GEN_ATOMIC_HELPER_ALL(xchg)
102*231a1c0fSPhilippe Mathieu-Daudé 
103*231a1c0fSPhilippe Mathieu-Daudé #undef GEN_ATOMIC_HELPER_ALL
104*231a1c0fSPhilippe Mathieu-Daudé #undef GEN_ATOMIC_HELPER
105*231a1c0fSPhilippe Mathieu-Daudé 
106*231a1c0fSPhilippe Mathieu-Daudé Int128 cpu_atomic_cmpxchgo_le_mmu(CPUArchState *env, vaddr addr,
107*231a1c0fSPhilippe Mathieu-Daudé                                   Int128 cmpv, Int128 newv,
108*231a1c0fSPhilippe Mathieu-Daudé                                   MemOpIdx oi, uintptr_t retaddr);
109*231a1c0fSPhilippe Mathieu-Daudé Int128 cpu_atomic_cmpxchgo_be_mmu(CPUArchState *env, vaddr addr,
110*231a1c0fSPhilippe Mathieu-Daudé                                   Int128 cmpv, Int128 newv,
111*231a1c0fSPhilippe Mathieu-Daudé                                   MemOpIdx oi, uintptr_t retaddr);
112*231a1c0fSPhilippe Mathieu-Daudé 
113*231a1c0fSPhilippe Mathieu-Daudé uint8_t cpu_ldb_code_mmu(CPUArchState *env, vaddr addr,
114*231a1c0fSPhilippe Mathieu-Daudé                          MemOpIdx oi, uintptr_t ra);
115*231a1c0fSPhilippe Mathieu-Daudé uint16_t cpu_ldw_code_mmu(CPUArchState *env, vaddr addr,
116*231a1c0fSPhilippe Mathieu-Daudé                           MemOpIdx oi, uintptr_t ra);
117*231a1c0fSPhilippe Mathieu-Daudé uint32_t cpu_ldl_code_mmu(CPUArchState *env, vaddr addr,
118*231a1c0fSPhilippe Mathieu-Daudé                           MemOpIdx oi, uintptr_t ra);
119*231a1c0fSPhilippe Mathieu-Daudé uint64_t cpu_ldq_code_mmu(CPUArchState *env, vaddr addr,
120*231a1c0fSPhilippe Mathieu-Daudé                           MemOpIdx oi, uintptr_t ra);
121*231a1c0fSPhilippe Mathieu-Daudé 
122*231a1c0fSPhilippe Mathieu-Daudé #endif /* ACCEL_TCG_CPU_LDST_COMMON_H */
123