pub trait Cpu: AccessCpuState {
type Error;
// Required methods
fn read_instruction(
&mut self,
gva: u64,
bytes: &mut [u8],
) -> impl Future<Output = Result<(), Self::Error>>;
fn read_memory(
&mut self,
gva: u64,
bytes: &mut [u8],
) -> impl Future<Output = Result<(), Self::Error>>;
fn read_physical_memory(
&mut self,
gpa: u64,
bytes: &mut [u8],
) -> impl Future<Output = Result<(), Self::Error>>;
fn write_memory(
&mut self,
gva: u64,
bytes: &[u8],
) -> impl Future<Output = Result<(), Self::Error>>;
fn write_physical_memory(
&mut self,
gpa: u64,
bytes: &[u8],
) -> impl Future<Output = Result<(), Self::Error>>;
fn compare_and_write_memory(
&mut self,
gva: u64,
current: &[u8],
new: &[u8],
success: &mut bool,
) -> impl Future<Output = Result<(), Self::Error>>;
}
Required Associated Types§
Required Methods§
Sourcefn read_instruction(
&mut self,
gva: u64,
bytes: &mut [u8],
) -> impl Future<Output = Result<(), Self::Error>>
fn read_instruction( &mut self, gva: u64, bytes: &mut [u8], ) -> impl Future<Output = Result<(), Self::Error>>
Performs a memory read of an instruction to execute.
Sourcefn read_memory(
&mut self,
gva: u64,
bytes: &mut [u8],
) -> impl Future<Output = Result<(), Self::Error>>
fn read_memory( &mut self, gva: u64, bytes: &mut [u8], ) -> impl Future<Output = Result<(), Self::Error>>
Performs a memory read of 1, 2, 4, or 8 bytes.
Sourcefn read_physical_memory(
&mut self,
gpa: u64,
bytes: &mut [u8],
) -> impl Future<Output = Result<(), Self::Error>>
fn read_physical_memory( &mut self, gpa: u64, bytes: &mut [u8], ) -> impl Future<Output = Result<(), Self::Error>>
Performs a memory read of 1, 2, 4, or 8 bytes on a guest physical address.
Sourcefn write_memory(
&mut self,
gva: u64,
bytes: &[u8],
) -> impl Future<Output = Result<(), Self::Error>>
fn write_memory( &mut self, gva: u64, bytes: &[u8], ) -> impl Future<Output = Result<(), Self::Error>>
Performs a memory write of 1, 2, 4, or 8 bytes.
Sourcefn write_physical_memory(
&mut self,
gpa: u64,
bytes: &[u8],
) -> impl Future<Output = Result<(), Self::Error>>
fn write_physical_memory( &mut self, gpa: u64, bytes: &[u8], ) -> impl Future<Output = Result<(), Self::Error>>
Performs a memory write of 1, 2, 4, or 8 bytes on a guest physical address.
Sourcefn compare_and_write_memory(
&mut self,
gva: u64,
current: &[u8],
new: &[u8],
success: &mut bool,
) -> impl Future<Output = Result<(), Self::Error>>
fn compare_and_write_memory( &mut self, gva: u64, current: &[u8], new: &[u8], success: &mut bool, ) -> impl Future<Output = Result<(), Self::Error>>
Performs an atomic, sequentially-consistent compare exchange on a memory location.
The caller has already fetched current
via read_memory
, so the
implementor only needs to perform an atomic compare+write if the memory
could have mutated concurrently and supports atomic operation. This
includes ordinary RAM, but does not include device registers.
Sets *success
to true
if the exchange succeeded, false
otherwise.
FUTURE: just return success
when we can directly use async functions
in traits.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.