]>
Commit | Line | Data |
---|---|---|
ccd38087 PM |
1 | /* |
2 | * QEMU ARM CPU -- internal functions and types | |
3 | * | |
4 | * Copyright (c) 2014 Linaro Ltd | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU General Public License | |
8 | * as published by the Free Software Foundation; either version 2 | |
9 | * of the License, or (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, see | |
18 | * <http://www.gnu.org/licenses/gpl-2.0.html> | |
19 | * | |
20 | * This header defines functions, types, etc which need to be shared | |
21 | * between different source files within target-arm/ but which are | |
22 | * private to it and not required by the rest of QEMU. | |
23 | */ | |
24 | ||
25 | #ifndef TARGET_ARM_INTERNALS_H | |
26 | #define TARGET_ARM_INTERNALS_H | |
27 | ||
d4a2dc67 PM |
28 | static inline bool excp_is_internal(int excp) |
29 | { | |
30 | /* Return true if this exception number represents a QEMU-internal | |
31 | * exception that will not be passed to the guest. | |
32 | */ | |
33 | return excp == EXCP_INTERRUPT | |
34 | || excp == EXCP_HLT | |
35 | || excp == EXCP_DEBUG | |
36 | || excp == EXCP_HALTED | |
37 | || excp == EXCP_EXCEPTION_EXIT | |
38 | || excp == EXCP_KERNEL_TRAP | |
39 | || excp == EXCP_STREX; | |
40 | } | |
41 | ||
ccd38087 PM |
42 | /* Scale factor for generic timers, ie number of ns per tick. |
43 | * This gives a 62.5MHz timer. | |
44 | */ | |
45 | #define GTIMER_SCALE 16 | |
46 | ||
47 | int bank_number(int mode); | |
48 | void switch_mode(CPUARMState *, int); | |
49 | void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu); | |
50 | void arm_translate_init(void); | |
51 | ||
52 | enum arm_fprounding { | |
53 | FPROUNDING_TIEEVEN, | |
54 | FPROUNDING_POSINF, | |
55 | FPROUNDING_NEGINF, | |
56 | FPROUNDING_ZERO, | |
57 | FPROUNDING_TIEAWAY, | |
58 | FPROUNDING_ODD | |
59 | }; | |
60 | ||
61 | int arm_rmode_to_sf(int rmode); | |
62 | ||
8bcbf37c PM |
63 | /* Valid Syndrome Register EC field values */ |
64 | enum arm_exception_class { | |
65 | EC_UNCATEGORIZED = 0x00, | |
66 | EC_WFX_TRAP = 0x01, | |
67 | EC_CP15RTTRAP = 0x03, | |
68 | EC_CP15RRTTRAP = 0x04, | |
69 | EC_CP14RTTRAP = 0x05, | |
70 | EC_CP14DTTRAP = 0x06, | |
71 | EC_ADVSIMDFPACCESSTRAP = 0x07, | |
72 | EC_FPIDTRAP = 0x08, | |
73 | EC_CP14RRTTRAP = 0x0c, | |
74 | EC_ILLEGALSTATE = 0x0e, | |
75 | EC_AA32_SVC = 0x11, | |
76 | EC_AA32_HVC = 0x12, | |
77 | EC_AA32_SMC = 0x13, | |
78 | EC_AA64_SVC = 0x15, | |
79 | EC_AA64_HVC = 0x16, | |
80 | EC_AA64_SMC = 0x17, | |
81 | EC_SYSTEMREGISTERTRAP = 0x18, | |
82 | EC_INSNABORT = 0x20, | |
83 | EC_INSNABORT_SAME_EL = 0x21, | |
84 | EC_PCALIGNMENT = 0x22, | |
85 | EC_DATAABORT = 0x24, | |
86 | EC_DATAABORT_SAME_EL = 0x25, | |
87 | EC_SPALIGNMENT = 0x26, | |
88 | EC_AA32_FPTRAP = 0x28, | |
89 | EC_AA64_FPTRAP = 0x2c, | |
90 | EC_SERROR = 0x2f, | |
91 | EC_BREAKPOINT = 0x30, | |
92 | EC_BREAKPOINT_SAME_EL = 0x31, | |
93 | EC_SOFTWARESTEP = 0x32, | |
94 | EC_SOFTWARESTEP_SAME_EL = 0x33, | |
95 | EC_WATCHPOINT = 0x34, | |
96 | EC_WATCHPOINT_SAME_EL = 0x35, | |
97 | EC_AA32_BKPT = 0x38, | |
98 | EC_VECTORCATCH = 0x3a, | |
99 | EC_AA64_BKPT = 0x3c, | |
100 | }; | |
101 | ||
102 | #define ARM_EL_EC_SHIFT 26 | |
103 | #define ARM_EL_IL_SHIFT 25 | |
104 | #define ARM_EL_IL (1 << ARM_EL_IL_SHIFT) | |
105 | ||
106 | /* Utility functions for constructing various kinds of syndrome value. | |
107 | * Note that in general we follow the AArch64 syndrome values; in a | |
108 | * few cases the value in HSR for exceptions taken to AArch32 Hyp | |
109 | * mode differs slightly, so if we ever implemented Hyp mode then the | |
110 | * syndrome value would need some massaging on exception entry. | |
111 | * (One example of this is that AArch64 defaults to IL bit set for | |
112 | * exceptions which don't specifically indicate information about the | |
113 | * trapping instruction, whereas AArch32 defaults to IL bit clear.) | |
114 | */ | |
115 | static inline uint32_t syn_uncategorized(void) | |
116 | { | |
117 | return (EC_UNCATEGORIZED << ARM_EL_EC_SHIFT) | ARM_EL_IL; | |
118 | } | |
119 | ||
120 | static inline uint32_t syn_aa64_svc(uint32_t imm16) | |
121 | { | |
122 | return (EC_AA64_SVC << ARM_EL_EC_SHIFT) | ARM_EL_IL | (imm16 & 0xffff); | |
123 | } | |
124 | ||
125 | static inline uint32_t syn_aa32_svc(uint32_t imm16, bool is_thumb) | |
126 | { | |
127 | return (EC_AA32_SVC << ARM_EL_EC_SHIFT) | (imm16 & 0xffff) | |
128 | | (is_thumb ? 0 : ARM_EL_IL); | |
129 | } | |
130 | ||
131 | static inline uint32_t syn_aa64_bkpt(uint32_t imm16) | |
132 | { | |
133 | return (EC_AA64_BKPT << ARM_EL_EC_SHIFT) | ARM_EL_IL | (imm16 & 0xffff); | |
134 | } | |
135 | ||
136 | static inline uint32_t syn_aa32_bkpt(uint32_t imm16, bool is_thumb) | |
137 | { | |
138 | return (EC_AA32_BKPT << ARM_EL_EC_SHIFT) | (imm16 & 0xffff) | |
139 | | (is_thumb ? 0 : ARM_EL_IL); | |
140 | } | |
141 | ||
142 | static inline uint32_t syn_aa64_sysregtrap(int op0, int op1, int op2, | |
143 | int crn, int crm, int rt, | |
144 | int isread) | |
145 | { | |
146 | return (EC_SYSTEMREGISTERTRAP << ARM_EL_EC_SHIFT) | ARM_EL_IL | |
147 | | (op0 << 20) | (op2 << 17) | (op1 << 14) | (crn << 10) | (rt << 5) | |
148 | | (crm << 1) | isread; | |
149 | } | |
150 | ||
151 | static inline uint32_t syn_cp14_rt_trap(int cv, int cond, int opc1, int opc2, | |
152 | int crn, int crm, int rt, int isread, | |
153 | bool is_thumb) | |
154 | { | |
155 | return (EC_CP14RTTRAP << ARM_EL_EC_SHIFT) | |
156 | | (is_thumb ? 0 : ARM_EL_IL) | |
157 | | (cv << 24) | (cond << 20) | (opc2 << 17) | (opc1 << 14) | |
158 | | (crn << 10) | (rt << 5) | (crm << 1) | isread; | |
159 | } | |
160 | ||
161 | static inline uint32_t syn_cp15_rt_trap(int cv, int cond, int opc1, int opc2, | |
162 | int crn, int crm, int rt, int isread, | |
163 | bool is_thumb) | |
164 | { | |
165 | return (EC_CP15RTTRAP << ARM_EL_EC_SHIFT) | |
166 | | (is_thumb ? 0 : ARM_EL_IL) | |
167 | | (cv << 24) | (cond << 20) | (opc2 << 17) | (opc1 << 14) | |
168 | | (crn << 10) | (rt << 5) | (crm << 1) | isread; | |
169 | } | |
170 | ||
171 | static inline uint32_t syn_cp14_rrt_trap(int cv, int cond, int opc1, int crm, | |
172 | int rt, int rt2, int isread, | |
173 | bool is_thumb) | |
174 | { | |
175 | return (EC_CP14RRTTRAP << ARM_EL_EC_SHIFT) | |
176 | | (is_thumb ? 0 : ARM_EL_IL) | |
177 | | (cv << 24) | (cond << 20) | (opc1 << 16) | |
178 | | (rt2 << 10) | (rt << 5) | (crm << 1) | isread; | |
179 | } | |
180 | ||
181 | static inline uint32_t syn_cp15_rrt_trap(int cv, int cond, int opc1, int crm, | |
182 | int rt, int rt2, int isread, | |
183 | bool is_thumb) | |
184 | { | |
185 | return (EC_CP15RRTTRAP << ARM_EL_EC_SHIFT) | |
186 | | (is_thumb ? 0 : ARM_EL_IL) | |
187 | | (cv << 24) | (cond << 20) | (opc1 << 16) | |
188 | | (rt2 << 10) | (rt << 5) | (crm << 1) | isread; | |
189 | } | |
190 | ||
8c6afa6a PM |
191 | static inline uint32_t syn_fp_access_trap(int cv, int cond, bool is_thumb) |
192 | { | |
193 | return (EC_ADVSIMDFPACCESSTRAP << ARM_EL_EC_SHIFT) | |
194 | | (is_thumb ? 0 : ARM_EL_IL) | |
195 | | (cv << 24) | (cond << 20); | |
196 | } | |
197 | ||
00892383 RH |
198 | static inline uint32_t syn_insn_abort(int same_el, int ea, int s1ptw, int fsc) |
199 | { | |
200 | return (EC_INSNABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT) | |
201 | | (ea << 9) | (s1ptw << 7) | fsc; | |
202 | } | |
203 | ||
204 | static inline uint32_t syn_data_abort(int same_el, int ea, int cm, int s1ptw, | |
205 | int wnr, int fsc) | |
206 | { | |
207 | return (EC_DATAABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT) | |
208 | | (ea << 9) | (cm << 8) | (s1ptw << 7) | (wnr << 6) | fsc; | |
209 | } | |
210 | ||
ccd38087 | 211 | #endif |