mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
add a clone function for AtomicCsr
this is useful for the performance profiling framework where we want to stick the allocatde CSRs into structures that help manage things.
This commit is contained in:
parent
e1781bfcbe
commit
b60ad06134
1 changed files with 11 additions and 0 deletions
|
|
@ -655,6 +655,17 @@ where
|
|||
base: AtomicPtr::new(base)
|
||||
}
|
||||
}
|
||||
/// In reality, we should wrap this in an `Arc` so we can be truly safe across a multi-core
|
||||
/// implementation, but for our single-core system this is fine. The reason we don't do it
|
||||
/// immediately is that UTRA also needs to work in a `no_std` environment, where `Arc`
|
||||
/// does not exist, and so additional config flags would need to be introduced to not break
|
||||
/// that compability issue. If migrating to multicore, this technical debt would have to be
|
||||
/// addressed.
|
||||
pub fn clone(&self) -> Self {
|
||||
AtomicCsr {
|
||||
base: AtomicPtr::new(self.base.load(core::sync::atomic::Ordering::SeqCst))
|
||||
}
|
||||
}
|
||||
/// Read the contents of this register
|
||||
pub fn r(&self, reg: Register) -> T {
|
||||
// prevent re-ordering
|
||||
|
|
|
|||
Loading…
Reference in a new issue