use patina_paging::{MemoryAttributes, PtError};
cfg_if::cfg_if! {
if #[cfg(all(target_arch = "x86_64"))] {
mod x64;
pub use x64::create_cpu_x64_paging as create_cpu_paging;
pub use x64::open_active_cpu_x64_paging as open_active_cpu_paging;
} else if #[cfg(all(target_arch = "aarch64"))] {
mod aarch64;
pub use aarch64::create_cpu_aarch64_paging as create_cpu_paging;
pub use aarch64::open_active_cpu_aarch64_paging as open_active_cpu_paging;
} else {
mod null;
pub use null::create_cpu_null_paging as create_cpu_paging;
pub use null::open_active_cpu_null_paging as open_active_cpu_paging;
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CacheAttributeValue {
Valid(MemoryAttributes),
Unmapped,
NotSupported,
}
pub trait PatinaPageTable {
fn map_memory_region(&mut self, address: u64, size: u64, attributes: MemoryAttributes) -> Result<(), PtError>;
fn map_aliased_memory_region(
&mut self,
va: u64,
pa: u64,
size: u64,
attributes: MemoryAttributes,
) -> Result<(), PtError>;
fn unmap_memory_region(&mut self, address: u64, size: u64) -> Result<(), PtError>;
fn install_page_table(&mut self) -> Result<(), PtError>;
fn query_memory_region(&self, address: u64, size: u64) -> Result<MemoryAttributes, (PtError, CacheAttributeValue)>;
fn dump_page_tables(&self, address: u64, size: u64) -> Result<(), PtError>;
fn handle_cacheability_change(
&self,
address: u64,
size: u64,
old_cache_attributes: MemoryAttributes,
new_cache_attributes: MemoryAttributes,
);
}