Skip to content

Commit d8383dd

Browse files
committed
riscv: add more pmpcfg CSRs
Adds the remaining `pmpcfg` CSRs from the RISC-V privileged specification.
1 parent abdce51 commit d8383dd

File tree

2 files changed

+151
-0
lines changed

2 files changed

+151
-0
lines changed

riscv/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3838
- Use CSR helper macros to define `scounteren` field types
3939
- Use CSR helper macros to define `sip` register
4040
- Use CSR helper macros to define `sstatus` field types
41+
- Add remaining `pmpcfg` CSRs from RISC-V privileged spec
4142

4243
## [v0.12.1] - 2024-10-20
4344

riscv/src/register/pmpcfgx.rs

+150
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,153 @@ pub mod pmpcfg3 {
157157
set_pmp!();
158158
clear_pmp!();
159159
}
160+
161+
/// Physical memory protection configuration
162+
/// pmpcfg4 struct contains pmp16cfg - pmp19cfg for RV32, or pmp16cfg - pmp23cfg for RV64
163+
pub mod pmpcfg4 {
164+
use super::{Permission, Pmpcsr, Range};
165+
166+
read_csr_as!(Pmpcsr, 0x3A4);
167+
write_csr_as_usize!(0x3A4);
168+
169+
set_pmp!();
170+
clear_pmp!();
171+
}
172+
173+
/// Physical memory protection configuration
174+
/// pmpcfg5 struct contains pmp20cfg - pmp23cfg for RV32 only
175+
#[cfg(riscv32)]
176+
pub mod pmpcfg5 {
177+
use super::{Permission, Pmpcsr, Range};
178+
179+
read_csr_as!(Pmpcsr, 0x3A5);
180+
write_csr_as_usize_rv32!(0x3A5);
181+
182+
set_pmp!();
183+
clear_pmp!();
184+
}
185+
186+
/// Physical memory protection configuration
187+
/// pmpcfg6 struct contains pmp24cfg - pmp27cfg for RV32, or pmp24cfg - pmp31cfg for RV64
188+
pub mod pmpcfg6 {
189+
use super::{Permission, Pmpcsr, Range};
190+
191+
read_csr_as!(Pmpcsr, 0x3A6);
192+
write_csr_as_usize!(0x3A6);
193+
194+
set_pmp!();
195+
clear_pmp!();
196+
}
197+
198+
/// Physical memory protection configuration
199+
/// pmpcfg7 struct contains pmp28cfg - pmp31cfg for RV32 only
200+
#[cfg(riscv32)]
201+
pub mod pmpcfg7 {
202+
use super::{Permission, Pmpcsr, Range};
203+
204+
read_csr_as!(Pmpcsr, 0x3A7);
205+
write_csr_as_usize_rv32!(0x3A7);
206+
207+
set_pmp!();
208+
clear_pmp!();
209+
}
210+
211+
/// Physical memory protection configuration
212+
/// pmpcfg8 struct contains pmp32cfg - pmp35cfg for RV32, or pmp32cfg - pmp39cfg for RV64
213+
pub mod pmpcfg8 {
214+
use super::{Permission, Pmpcsr, Range};
215+
216+
read_csr_as!(Pmpcsr, 0x3A8);
217+
write_csr_as_usize!(0x3A8);
218+
219+
set_pmp!();
220+
clear_pmp!();
221+
}
222+
223+
/// Physical memory protection configuration
224+
/// pmpcfg9 struct contains pmp36cfg - pmp39cfg for RV32 only
225+
#[cfg(riscv32)]
226+
pub mod pmpcfg9 {
227+
use super::{Permission, Pmpcsr, Range};
228+
229+
read_csr_as!(Pmpcsr, 0x3A9);
230+
write_csr_as_usize_rv32!(0x3A9);
231+
232+
set_pmp!();
233+
clear_pmp!();
234+
}
235+
236+
/// Physical memory protection configuration
237+
/// pmpcfg10 struct contains pmp40cfg - pmp43cfg for RV32, or pmp40cfg - pmp47cfg for RV64
238+
pub mod pmpcfg10 {
239+
use super::{Permission, Pmpcsr, Range};
240+
241+
read_csr_as!(Pmpcsr, 0x3AA);
242+
write_csr_as_usize!(0x3AA);
243+
244+
set_pmp!();
245+
clear_pmp!();
246+
}
247+
248+
/// Physical memory protection configuration
249+
/// pmpcfg11 struct contains pmp44cfg - pmp47cfg for RV32 only
250+
#[cfg(riscv32)]
251+
pub mod pmpcfg11 {
252+
use super::{Permission, Pmpcsr, Range};
253+
254+
read_csr_as!(Pmpcsr, 0x3AB);
255+
write_csr_as_usize_rv32!(0x3AB);
256+
257+
set_pmp!();
258+
clear_pmp!();
259+
}
260+
261+
/// Physical memory protection configuration
262+
/// pmpcfg12 struct contains pmp48cfg - pmp51cfg for RV32, or pmp48cfg - pmp55cfg for RV64
263+
pub mod pmpcfg12 {
264+
use super::{Permission, Pmpcsr, Range};
265+
266+
read_csr_as!(Pmpcsr, 0x3AC);
267+
write_csr_as_usize!(0x3AC);
268+
269+
set_pmp!();
270+
clear_pmp!();
271+
}
272+
273+
/// Physical memory protection configuration
274+
/// pmpcfg13 struct contains pmp52cfg - pmp55cfg for RV32 only
275+
#[cfg(riscv32)]
276+
pub mod pmpcfg13 {
277+
use super::{Permission, Pmpcsr, Range};
278+
279+
read_csr_as!(Pmpcsr, 0x3AD);
280+
write_csr_as_usize_rv32!(0x3AD);
281+
282+
set_pmp!();
283+
clear_pmp!();
284+
}
285+
286+
/// Physical memory protection configuration
287+
/// pmpcfg14 struct contains pmp56cfg - pmp59cfg for RV32, or pmp56cfg - pmp63cfg for RV64
288+
pub mod pmpcfg14 {
289+
use super::{Permission, Pmpcsr, Range};
290+
291+
read_csr_as!(Pmpcsr, 0x3AE);
292+
write_csr_as_usize!(0x3AE);
293+
294+
set_pmp!();
295+
clear_pmp!();
296+
}
297+
298+
/// Physical memory protection configuration
299+
/// pmpcfg15 struct contains pmp60cfg - pmp63cfg for RV32 only
300+
#[cfg(riscv32)]
301+
pub mod pmpcfg15 {
302+
use super::{Permission, Pmpcsr, Range};
303+
304+
read_csr_as!(Pmpcsr, 0x3AF);
305+
write_csr_as_usize_rv32!(0x3AF);
306+
307+
set_pmp!();
308+
clear_pmp!();
309+
}

0 commit comments

Comments
 (0)