pvmfw: Move MemoryTracker to a global variable
Exception handlers that maniplulate memory need access to MemoryTracker. To
prepare for the implementation of such handlers, move the MemoryTracker
into a global variable, and wrap it with a SpinMutex.
Bug: 245267332
Test: atest MicrodroidTestApp
Change-Id: Ib5b16006e25addca991c6c6d7854c9368d60a28b
diff --git a/pvmfw/src/memory.rs b/pvmfw/src/memory.rs
index 2d5eb5c..d90808b 100644
--- a/pvmfw/src/memory.rs
+++ b/pvmfw/src/memory.rs
@@ -31,6 +31,7 @@
use core::result;
use hyp::get_hypervisor;
use log::error;
+use spin::mutex::SpinMutex;
use tinyvec::ArrayVec;
/// Base of the system's contiguous "main" memory.
@@ -40,6 +41,9 @@
pub type MemoryRange = Range<usize>;
+pub static MEMORY: SpinMutex<Option<MemoryTracker>> = SpinMutex::new(None);
+unsafe impl Send for MemoryTracker {}
+
#[derive(Clone, Copy, Debug, Default)]
enum MemoryType {
#[default]