]> git.proxmox.com Git - mirror_qemu.git/blame - include/exec/cpu_ldst_useronly_template.h
cpu: Replace ENV_GET_CPU with env_cpu
[mirror_qemu.git] / include / exec / cpu_ldst_useronly_template.h
CommitLineData
9220fe54
PM
1/*
2 * User-only accessor function support
3 *
4 * Generate inline load/store functions for one data size.
5 *
6 * Generate a store function as well as signed and unsigned loads.
7 *
8 * Not used directly but included from cpu_ldst.h.
9 *
10 * Copyright (c) 2015 Linaro Limited
11 *
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
16 *
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
24 */
dcdaadb6
LV
25
26#if !defined(CODE_ACCESS)
0ab8ed18 27#include "trace-root.h"
dcdaadb6
LV
28#endif
29
30#include "trace/mem.h"
31
9220fe54
PM
32#if DATA_SIZE == 8
33#define SUFFIX q
34#define USUFFIX q
35#define DATA_TYPE uint64_t
32c07234 36#define SHIFT 3
9220fe54
PM
37#elif DATA_SIZE == 4
38#define SUFFIX l
39#define USUFFIX l
40#define DATA_TYPE uint32_t
32c07234 41#define SHIFT 2
9220fe54
PM
42#elif DATA_SIZE == 2
43#define SUFFIX w
44#define USUFFIX uw
45#define DATA_TYPE uint16_t
46#define DATA_STYPE int16_t
32c07234 47#define SHIFT 1
9220fe54
PM
48#elif DATA_SIZE == 1
49#define SUFFIX b
50#define USUFFIX ub
51#define DATA_TYPE uint8_t
52#define DATA_STYPE int8_t
32c07234 53#define SHIFT 0
9220fe54
PM
54#else
55#error unsupported data size
56#endif
57
58#if DATA_SIZE == 8
59#define RES_TYPE uint64_t
60#else
61#define RES_TYPE uint32_t
62#endif
63
64static inline RES_TYPE
3e23de15 65glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
9220fe54 66{
dcdaadb6
LV
67#if !defined(CODE_ACCESS)
68 trace_guest_mem_before_exec(
29a0af61 69 env_cpu(env), ptr,
32c07234 70 trace_mem_build_info(SHIFT, false, MO_TE, false));
dcdaadb6 71#endif
9220fe54
PM
72 return glue(glue(ld, USUFFIX), _p)(g2h(ptr));
73}
74
282dffc8
PD
75static inline RES_TYPE
76glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
3e23de15 77 abi_ptr ptr,
282dffc8
PD
78 uintptr_t retaddr)
79{
ec603b55
RH
80 RES_TYPE ret;
81 helper_retaddr = retaddr;
82 ret = glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(env, ptr);
83 helper_retaddr = 0;
84 return ret;
282dffc8
PD
85}
86
9220fe54
PM
87#if DATA_SIZE <= 2
88static inline int
3e23de15 89glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
9220fe54 90{
dcdaadb6
LV
91#if !defined(CODE_ACCESS)
92 trace_guest_mem_before_exec(
29a0af61 93 env_cpu(env), ptr,
32c07234 94 trace_mem_build_info(SHIFT, true, MO_TE, false));
dcdaadb6 95#endif
9220fe54
PM
96 return glue(glue(lds, SUFFIX), _p)(g2h(ptr));
97}
282dffc8
PD
98
99static inline int
100glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
3e23de15 101 abi_ptr ptr,
282dffc8
PD
102 uintptr_t retaddr)
103{
ec603b55
RH
104 int ret;
105 helper_retaddr = retaddr;
106 ret = glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(env, ptr);
107 helper_retaddr = 0;
108 return ret;
282dffc8 109}
9220fe54
PM
110#endif
111
112#ifndef CODE_ACCESS
113static inline void
3e23de15 114glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr,
9220fe54
PM
115 RES_TYPE v)
116{
dcdaadb6
LV
117#if !defined(CODE_ACCESS)
118 trace_guest_mem_before_exec(
29a0af61 119 env_cpu(env), ptr,
32c07234 120 trace_mem_build_info(SHIFT, false, MO_TE, true));
dcdaadb6 121#endif
9220fe54
PM
122 glue(glue(st, SUFFIX), _p)(g2h(ptr), v);
123}
282dffc8
PD
124
125static inline void
126glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
3e23de15 127 abi_ptr ptr,
282dffc8
PD
128 RES_TYPE v,
129 uintptr_t retaddr)
130{
ec603b55 131 helper_retaddr = retaddr;
282dffc8 132 glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(env, ptr, v);
ec603b55 133 helper_retaddr = 0;
282dffc8 134}
9220fe54
PM
135#endif
136
137#undef RES_TYPE
138#undef DATA_TYPE
139#undef DATA_STYPE
140#undef SUFFIX
141#undef USUFFIX
142#undef DATA_SIZE
32c07234 143#undef SHIFT