]> Git Repo - qemu.git/blob - include/exec/cpu_ldst_useronly_template.h
hw/arm/bcm2835: Use TYPE_PL011 instead of hardcoded string
[qemu.git] / include / exec / cpu_ldst_useronly_template.h
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  */
25
26 #if !defined(CODE_ACCESS)
27 #include "trace-root.h"
28 #endif
29
30 #include "trace/mem.h"
31
32 #if DATA_SIZE == 8
33 #define SUFFIX q
34 #define USUFFIX q
35 #define DATA_TYPE uint64_t
36 #define SHIFT 3
37 #elif DATA_SIZE == 4
38 #define SUFFIX l
39 #define USUFFIX l
40 #define DATA_TYPE uint32_t
41 #define SHIFT 2
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
47 #define SHIFT 1
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
53 #define SHIFT 0
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
64 static inline RES_TYPE
65 glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
66 {
67 #if !defined(CODE_ACCESS)
68     trace_guest_mem_before_exec(
69         ENV_GET_CPU(env), ptr,
70         trace_mem_build_info(SHIFT, false, MO_TE, false));
71 #endif
72     return glue(glue(ld, USUFFIX), _p)(g2h(ptr));
73 }
74
75 static inline RES_TYPE
76 glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
77                                                   abi_ptr ptr,
78                                                   uintptr_t retaddr)
79 {
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;
85 }
86
87 #if DATA_SIZE <= 2
88 static inline int
89 glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
90 {
91 #if !defined(CODE_ACCESS)
92     trace_guest_mem_before_exec(
93         ENV_GET_CPU(env), ptr,
94         trace_mem_build_info(SHIFT, true, MO_TE, false));
95 #endif
96     return glue(glue(lds, SUFFIX), _p)(g2h(ptr));
97 }
98
99 static inline int
100 glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
101                                                   abi_ptr ptr,
102                                                   uintptr_t retaddr)
103 {
104     int ret;
105     helper_retaddr = retaddr;
106     ret = glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(env, ptr);
107     helper_retaddr = 0;
108     return ret;
109 }
110 #endif
111
112 #ifndef CODE_ACCESS
113 static inline void
114 glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr,
115                                       RES_TYPE v)
116 {
117 #if !defined(CODE_ACCESS)
118     trace_guest_mem_before_exec(
119         ENV_GET_CPU(env), ptr,
120         trace_mem_build_info(SHIFT, false, MO_TE, true));
121 #endif
122     glue(glue(st, SUFFIX), _p)(g2h(ptr), v);
123 }
124
125 static inline void
126 glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
127                                                   abi_ptr ptr,
128                                                   RES_TYPE v,
129                                                   uintptr_t retaddr)
130 {
131     helper_retaddr = retaddr;
132     glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(env, ptr, v);
133     helper_retaddr = 0;
134 }
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
143 #undef SHIFT
This page took 0.032651 seconds and 4 git commands to generate.