cortex_a/registers/sctlr_el1.rs
1// SPDX-License-Identifier: Apache-2.0 OR MIT
2//
3// Copyright (c) 2018-2022 by the author(s)
4//
5// Author(s):
6// - Andre Richter <andre.o.richter@gmail.com>
7
8//! System Control Register - EL1
9//!
10//! Provides top level control of the system, including its memory system, at EL1 and EL0.
11
12use tock_registers::{
13 interfaces::{Readable, Writeable},
14 register_bitfields,
15};
16
17register_bitfields! {u64,
18 pub SCTLR_EL1 [
19 /// Traps EL0 execution of cache maintenance instructions to EL1, from AArch64 state only.
20 ///
21 /// 0 Any attempt to execute a DC CVAU, DC CIVAC, DC CVAC, DC CVAP, or IC IVAU
22 /// instruction at EL0 using AArch64 is trapped to EL1.
23 /// 1 This control does not cause any instructions to be trapped.
24 ///
25 /// When ARMv8.1-VHE is implemented, and the value of HCR_EL2.{E2H, TGE} is {1, 1}, this bit
26 /// has no effect on execution at EL0.
27 ///
28 /// If the Point of Coherency is before any level of data cache, it is IMPLEMENTATION DEFINED whether
29 /// the execution of any data or unified cache clean, or clean and invalidate instruction that operates by
30 /// VA to the point of coherency can be trapped when the value of this control is 1.
31 ///
32 /// If the Point of Unification is before any level of data cache, it is IMPLEMENTATION DEFINED whether
33 /// the execution of any data or unified cache clean by VA to the point of unification instruction can be
34 /// trapped when the value of this control is 1.
35 ///
36 /// If the Point of Unification is before any level of instruction cache, it is IMPLEMENTATION DEFINED
37 /// whether the execution of any instruction cache invalidate by VA to the point of unification
38 /// instruction can be trapped when the value of this control is 1.
39 UCI OFFSET(26) NUMBITS(1) [
40 Trap = 0,
41 DontTrap = 1,
42 ],
43
44 /// Endianness of data accesses at EL1, and stage 1 translation table walks in the EL1&0 translation regime.
45 ///
46 /// 0 Explicit data accesses at EL1, and stage 1 translation table walks in the EL1&0
47 /// translation regime are little-endian.
48 /// 1 Explicit data accesses at EL1, and stage 1 translation table walks in the EL1&0
49 /// translation regime are big-endian.
50 ///
51 /// If an implementation does not provide Big-endian support at Exception Levels higher than EL0, this
52 /// bit is RES 0.
53 ///
54 /// If an implementation does not provide Little-endian support at Exception Levels higher than EL0,
55 /// this bit is RES 1.
56 ///
57 /// The EE bit is permitted to be cached in a TLB.
58 ///
59 /// When ARMv8.1-VHE is implemented, and the value of HCR_EL2.{E2H, TGE} is {1, 1}, this bit
60 /// has no effect on the PE.
61 EE OFFSET(25) NUMBITS(1) [
62 LittleEndian = 0,
63 BigEndian = 1,
64 ],
65
66 /// Endianness of data accesses at EL0.
67 ///
68 /// 0 Explicit data accesses at EL0 are little-endian.
69 ///
70 /// 1 Explicit data accesses at EL0 are big-endian.
71 ///
72 /// If an implementation only supports Little-endian accesses at EL0 then this bit is RES 0. This option
73 /// is not permitted when SCTLR_EL1.EE is RES 1.
74 ///
75 /// If an implementation only supports Big-endian accesses at EL0 then this bit is RES 1. This option is
76 /// not permitted when SCTLR_EL1.EE is RES 0.
77 ///
78 /// This bit has no effect on the endianness of LDTR , LDTRH , LDTRSH , LDTRSW , STTR , and STTRH instructions
79 /// executed at EL1.
80 ///
81 /// When ARMv8.1-VHE is implemented, and the value of HCR_EL2.{E2H, TGE} is {1, 1}, this bit
82 /// has no effect on execution at EL0.
83 E0E OFFSET(24) NUMBITS(1) [
84 LittleEndian = 0,
85 BigEndian = 1,
86 ],
87
88 /// Write permission implies XN (Execute-never). For the EL1&0 translation regime, this bit can force
89 /// all memory regions that are writable to be treated as XN.
90 ///
91 /// 0 This control has no effect on memory access permissions.
92 ///
93 /// 1 Any region that is writable in the EL1&0 translation regime is forced to XN for accesses
94 /// from software executing at EL1 or EL0.
95 ///
96 /// The WXN bit is permitted to be cached in a TLB.
97 ///
98 /// When ARMv8.1-VHE is implemented, and the value of HCR_EL2.{E2H, TGE} is {1, 1}, this bit
99 /// has no effect on the PE.
100 WXN OFFSET(19) NUMBITS(1) [
101 Disable = 0,
102 Enable = 1,
103 ],
104
105 /// Traps EL0 execution of WFE instructions to EL1, from both Execution states.
106 ///
107 /// 0 Any attempt to execute a WFE instruction at EL0 is trapped to EL1, if the instruction
108 /// would otherwise have caused the PE to enter a low-power state.
109 ///
110 /// 1 This control does not cause any instructions to be trapped.
111 ///
112 /// In AArch32 state, the attempted execution of a conditional WFE instruction is only trapped if the
113 /// instruction passes its condition code check.
114 ///
115 /// **Note:**
116 ///
117 /// Since a WFE or WFI can complete at any time, even without a Wakeup event, the traps on WFE of
118 /// WFI are not guaranteed to be taken, even if the WFE or WFI is executed when there is no Wakeup
119 /// event. The only guarantee is that if the instruction does not complete in finite time in the
120 /// absence of a Wakeup event, the trap will be taken.
121 ///
122 /// When ARMv8.1-VHE is implemented, and the value of HCR_EL2.{E2H, TGE} is {1, 1}, this bit
123 /// has no effect on execution at EL0.
124 NTWE OFFSET(18) NUMBITS(1) [
125 Trap = 0,
126 DontTrap = 1,
127 ],
128
129 /// Traps EL0 executions of WFI instructions to EL1, from both execution states:
130 ///
131 /// 0 Any attempt to execute a WFI instruction at EL0 is trapped EL1, if the instruction would
132 /// otherwise have caused the PE to enter a low-power state.
133 ///
134 /// 1 This control does not cause any instructions to be trapped.
135 ///
136 /// In AArch32 state, the attempted execution of a conditional WFI instruction is only trapped if the
137 /// instruction passes its condition code check.
138 ///
139 /// **Note:**
140 ///
141 /// Since a WFE or WFI can complete at any time, even without a Wakeup event, the traps on WFE of
142 /// WFI are not guaranteed to be taken, even if the WFE or WFI is executed when there is no Wakeup
143 /// event. The only guarantee is that if the instruction does not complete in finite time in the
144 /// absence of a Wakeup event, the trap will be taken.
145 ///
146 /// When ARMv8.1-VHE is implemented, and the value of HCR_EL2.{E2H, TGE} is {1, 1}, this bit
147 /// has no effect on execution at EL0.
148 NTWI OFFSET(16) NUMBITS(1) [
149 Trap = 0,
150 DontTrap = 1,
151 ],
152
153 /// Traps EL0 accesses to the CTR_EL0 to EL1, from AArch64 state only.
154 ///
155 /// 0 Accesses to the CTR_EL0 from EL0 using AArch64 are trapped to EL1.
156 ///
157 /// 1 This control does not cause any instructions to be trapped.
158 ///
159 /// When ARMv8.1-VHE is implemented, and the value of HCR_EL2.{E2H, TGE} is {1, 1}, this bit
160 /// has no effect on execution at EL0.
161 UCT OFFSET(15) NUMBITS(1) [
162 Trap = 0,
163 DontTrap = 1,
164 ],
165
166 /// Traps EL0 execution of DC ZVA instructions to EL1, from AArch64 state only.
167 ///
168 /// 0 Any attempt to execute a DC ZVA instruction at EL0 using AArch64 is trapped to EL1.
169 /// Reading DCZID_EL0.DZP from EL0 returns 1, indicating that DC ZVA instructions
170 /// are not supported.
171 ///
172 /// 1 This control does not cause any instructions to be trapped.
173 ///
174 /// When ARMv8.1-VHE is implemented, and the value of HCR_EL2.{E2H, TGE} is {1, 1}, this bit
175 /// has no effect on execution at EL0.
176 DZE OFFSET(14) NUMBITS(1) [
177 Trap = 0,
178 DontTrap = 1,
179 ],
180
181 /// Instruction access Cacheability control, for accesses at EL0 and
182 /// EL1:
183 ///
184 /// 0 All instruction access to Normal memory from EL0 and EL1 are Non-cacheable for all
185 /// levels of instruction and unified cache.
186 ///
187 /// If the value of SCTLR_EL1.M is 0, instruction accesses from stage 1 of the EL1&0
188 /// translation regime are to Normal, Outer Shareable, Inner Non-cacheable, Outer
189 /// Non-cacheable memory.
190 ///
191 /// 1 This control has no effect on the Cacheability of instruction access to Normal memory
192 /// from EL0 and EL1.
193 ///
194 /// If the value of SCTLR_EL1.M is 0, instruction accesses from stage 1 of the EL1&0
195 /// translation regime are to Normal, Outer Shareable, Inner Write-Through, Outer
196 /// Write-Through memory.
197 ///
198 /// When the value of the HCR_EL2.DC bit is 1, then instruction access to Normal memory from
199 /// EL0 and EL1 are Cacheable regardless of the value of the SCTLR_EL1.I bit.
200 ///
201 /// When ARMv8.1-VHE is implemented, and the value of HCR_EL2.{E2H, TGE} is {1, 1}, this bit
202 /// has no effect on the PE.
203 ///
204 /// When this register has an architecturally-defined reset value, this field resets to 0.
205 I OFFSET(12) NUMBITS(1) [
206 NonCacheable = 0,
207 Cacheable = 1
208 ],
209
210 /// User Mask Access. Traps EL0 execution of MSR and MRS instructions that access the
211 /// PSTATE.{D, A, I, F} masks to EL1, from AArch64 state only.
212 ///
213 /// 0 Any attempt at EL0 using AArch64 to execute an MRS , MSR(register) , or MSR(immediate)
214 /// instruction that accesses the [`DAIF`](module@super::super::DAIF) is trapped to EL1.
215 ///
216 /// 1 This control does not cause any instructions to be trapped.
217 ///
218 /// When ARMv8.1-VHE is implemented, and the value of HCR_EL2.{E2H, TGE} is {1, 1}, this bit
219 /// has no effect on execution at EL0.
220 UMA OFFSET(9) NUMBITS(1) [
221 Trap = 0,
222 DontTrap = 1,
223 ],
224
225 /// Non-aligned access. This bit controls generation of Alignment faults at EL1 and EL0 under certain conditions.
226 ///
227 /// LDAPR, LDAPRH, LDAPUR, LDAPURH, LDAPURSH, LDAPURSW, LDAR, LDARH, LDLAR, LDLARH,
228 /// STLLR, STLLRH, STLR, STLRH, STLUR, and STLURH will or will not generate an Alignment
229 /// fault if all bytes being accessed are not within a single 16-byte quantity,
230 /// aligned to 16 bytes for accesses.
231 NAA OFFSET(6) NUMBITS(1) [
232 Disable = 0,
233 Enable = 1
234 ],
235
236 /// SP Alignment check enable for EL0.
237 ///
238 /// When set to 1, if a load or store instruction executed at EL0 uses the SP
239 /// as the base address and the SP is not aligned to a 16-byte boundary,
240 /// then a SP alignment fault exception is generated.
241 SA0 OFFSET(4) NUMBITS(1) [
242 Disable = 0,
243 Enable = 1
244 ],
245
246 /// SP Alignment check enable.
247 ///
248 /// When set to 1, if a load or store instruction executed at EL1 uses the SP
249 /// as the base address and the SP is not aligned to a 16-byte boundary,
250 /// then a SP alignment fault exception is generated.
251 SA OFFSET(3) NUMBITS(1) [
252 Disable = 0,
253 Enable = 1
254 ],
255
256 /// Cacheability control, for data accesses.
257 ///
258 /// 0 All data access to Normal memory from EL0 and EL1, and all Normal memory accesses to
259 /// the EL1&0 stage 1 translation tables, are Non-cacheable for all levels of data and
260 /// unified cache.
261 ///
262 /// 1 This control has no effect on the Cacheability of:
263 /// - Data access to Normal memory from EL0 and EL1.
264 /// - Normal memory accesses to the EL1&0 stage 1 translation tables.
265 ///
266 /// When the value of the HCR_EL2.DC bit is 1, the PE ignores SCLTR.C. This means that
267 /// Non-secure EL0 and Non-secure EL1 data accesses to Normal memory are Cacheable.
268 ///
269 /// When ARMv8.1-VHE is implemented, and the value of HCR_EL2.{E2H, TGE} is {1, 1}, this bit
270 /// has no effect on the PE.
271 ///
272 /// When this register has an architecturally-defined reset value, this field resets to 0.
273 C OFFSET(2) NUMBITS(1) [
274 NonCacheable = 0,
275 Cacheable = 1
276 ],
277
278 /// Alignment check enable. This is the enable bit for Alignment fault checking at EL1 and EL0.
279 ///
280 /// Instructions that load or store one or more registers, other than load/store exclusive
281 /// and load-acquire/store-release, will or will not check that the address being accessed
282 /// is aligned to the size of the data element(s) being accessed depending on this flag.
283 ///
284 /// Load/store exclusive and load-acquire/store-release instructions have an alignment check
285 /// regardless of the value of the A bit.
286 A OFFSET(1) NUMBITS(1) [
287 Disable = 0,
288 Enable = 1
289 ],
290
291 /// MMU enable for EL1 and EL0 stage 1 address translation. Possible values of this bit are:
292 ///
293 /// 0 EL1 and EL0 stage 1 address translation disabled.
294 /// - See the SCTLR_EL1.I field for the behavior of instruction accesses to Normal memory.
295 ///
296 /// 1 EL1 and EL0 stage 1 address translation enabled.
297 M OFFSET(0) NUMBITS(1) [
298 Disable = 0,
299 Enable = 1
300 ]
301 ]
302}
303
304pub struct Reg;
305
306impl Readable for Reg {
307 type T = u64;
308 type R = SCTLR_EL1::Register;
309
310 sys_coproc_read_raw!(u64, "SCTLR_EL1", "x");
311}
312
313impl Writeable for Reg {
314 type T = u64;
315 type R = SCTLR_EL1::Register;
316
317 sys_coproc_write_raw!(u64, "SCTLR_EL1", "x");
318}
319
320pub const SCTLR_EL1: Reg = Reg {};