Skip to content

Commit 8899496

Browse files
committed
Fix bit ranges for permissions and ranges. Fully tested to be working :) cargo fmt.
1 parent f877219 commit 8899496

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/register/pmpcfgx.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub struct PmpEntry {
3535
pub index: usize,
3636
pub permission: Option<Permission>,
3737
pub range: Option<Range>,
38-
pub locked: bool
38+
pub locked: bool,
3939
}
4040

4141
impl Pmpcfg {
@@ -52,16 +52,18 @@ impl Pmpcfg {
5252
index,
5353
permission: self.get_permission(index),
5454
range: self.get_range(index),
55-
locked: self.is_locked(index)
55+
locked: self.is_locked(index),
5656
}
5757
}
5858

5959
/// PmpByte methods to get a pmp configuration attributes
60-
pub fn get_byte(&self, index: usize) -> usize { self.bits.get_bits(8 * index..=(8 * index) + 7) as usize }
60+
pub fn get_byte(&self, index: usize) -> usize {
61+
self.bits.get_bits(8 * index..=(8 * index) + 7) as usize
62+
}
6163

6264
#[inline]
6365
pub fn is_locked(&self, index: usize) -> bool {
64-
self.bits.get_bit(7 + (8 * index))
66+
self.bits.get_bit(7 + 8 * index)
6567
}
6668

6769
#[inline]
@@ -111,7 +113,7 @@ pub mod pmpcfg0 {
111113
assert!(index < 8);
112114

113115
let mut value = _read();
114-
value.set_bits(8 * index..=8 * index + 2,permission as usize);
116+
value.set_bits(8 * index..=8 * index + 2, permission as usize);
115117
_write(value);
116118
}
117119

@@ -124,7 +126,7 @@ pub mod pmpcfg0 {
124126
assert!(index < 8);
125127

126128
let mut value = _read();
127-
value.set_bits(8 * index + 3..=8 * index + 4,range as usize);
129+
value.set_bits(8 * index + 3..=8 * index + 4, range as usize);
128130
_write(value);
129131
}
130132

@@ -161,7 +163,7 @@ pub mod pmpcfg1 {
161163
assert!(index < 8);
162164

163165
let mut value = _read();
164-
value.set_bits(8 * index..=8 * index + 2,permission as usize);
166+
value.set_bits(8 * index..=8 * index + 2, permission as usize);
165167
_write(value);
166168
}
167169

@@ -174,7 +176,7 @@ pub mod pmpcfg1 {
174176
assert!(index < 8);
175177

176178
let mut value = _read();
177-
value.set_bits(8 * index + 3..=8 * index + 4,range as usize);
179+
value.set_bits(8 * index + 3..=8 * index + 4, range as usize);
178180
_write(value);
179181
}
180182

@@ -211,7 +213,7 @@ pub mod pmpcfg2 {
211213
assert!(index < 8);
212214

213215
let mut value = _read();
214-
value.set_bits(8 * index..=8 * index + 2,permission as usize);
216+
value.set_bits(8 * index..=8 * index + 2, permission as usize);
215217
_write(value);
216218
}
217219

@@ -224,7 +226,7 @@ pub mod pmpcfg2 {
224226
assert!(index < 8);
225227

226228
let mut value = _read();
227-
value.set_bits(8 * index + 3..=8 * index + 4,range as usize);
229+
value.set_bits(8 * index + 3..=8 * index + 4, range as usize);
228230
_write(value);
229231
}
230232

@@ -261,7 +263,7 @@ pub mod pmpcfg3 {
261263
assert!(index < 8);
262264

263265
let mut value = _read();
264-
value.set_bits(8 * index..=8 * index + 2,permission as usize);
266+
value.set_bits(8 * index..=8 * index + 2, permission as usize);
265267
_write(value);
266268
}
267269

@@ -274,7 +276,7 @@ pub mod pmpcfg3 {
274276
assert!(index < 8);
275277

276278
let mut value = _read();
277-
value.set_bits(8 * index + 3..=8 * index + 4,range as usize);
279+
value.set_bits(8 * index + 3..=8 * index + 4, range as usize);
278280
_write(value);
279281
}
280282

0 commit comments

Comments
 (0)