lib: fix accessors so they actually work
We were taking an address of the address, rather than transmuting the address itself. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
03bfd901f8
commit
fe68f64446
@ -85,14 +85,14 @@ where
|
||||
CSR { base }
|
||||
}
|
||||
pub fn r(&mut self, field: Field) -> T {
|
||||
let usize_base: *mut usize = unsafe { core::mem::transmute(&self.base) };
|
||||
let usize_base: *mut usize = unsafe { core::mem::transmute(self.base) };
|
||||
((unsafe { usize_base.add(field.register.offset).read_volatile() } >> field.offset)
|
||||
& field.mask)
|
||||
.try_into()
|
||||
.unwrap_or_default()
|
||||
}
|
||||
pub fn rw(&mut self, field: Field, value: T) {
|
||||
let usize_base: *mut usize = unsafe { core::mem::transmute(&self.base) };
|
||||
let usize_base: *mut usize = unsafe { core::mem::transmute(self.base) };
|
||||
let value_as_usize: usize = value.try_into().unwrap_or_default() << field.offset;
|
||||
let previous =
|
||||
unsafe { usize_base.add(field.register.offset).read_volatile() } & !field.mask;
|
||||
@ -103,7 +103,7 @@ where
|
||||
};
|
||||
}
|
||||
pub fn ow(&mut self, field: Field, value: T) {
|
||||
let usize_base: *mut usize = unsafe { core::mem::transmute(&self.base) };
|
||||
let usize_base: *mut usize = unsafe { core::mem::transmute(self.base) };
|
||||
let value_as_usize: usize = value.try_into().unwrap_or_default() << field.offset;
|
||||
unsafe {
|
||||
usize_base
|
||||
|
Loading…
Reference in New Issue
Block a user