pub trait MemoryInterface<ERR = Error>{
Show 25 methods
// Required methods
fn supports_native_64bit_access(&mut self) -> bool;
fn read_64(&mut self, address: u64, data: &mut [u64]) -> Result<(), ERR>;
fn read_32(&mut self, address: u64, data: &mut [u32]) -> Result<(), ERR>;
fn read_16(&mut self, address: u64, data: &mut [u16]) -> Result<(), ERR>;
fn read_8(&mut self, address: u64, data: &mut [u8]) -> Result<(), ERR>;
fn write_64(&mut self, address: u64, data: &[u64]) -> Result<(), ERR>;
fn write_32(&mut self, address: u64, data: &[u32]) -> Result<(), ERR>;
fn write_16(&mut self, address: u64, data: &[u16]) -> Result<(), ERR>;
fn write_8(&mut self, address: u64, data: &[u8]) -> Result<(), ERR>;
fn supports_8bit_transfers(&self) -> Result<bool, ERR>;
fn flush(&mut self) -> Result<(), ERR>;
// Provided methods
fn read_word_64(&mut self, address: u64) -> Result<u64, ERR> { ... }
fn read_word_32(&mut self, address: u64) -> Result<u32, ERR> { ... }
fn read_word_16(&mut self, address: u64) -> Result<u16, ERR> { ... }
fn read_word_8(&mut self, address: u64) -> Result<u8, ERR> { ... }
fn read_mem_64bit(
&mut self,
address: u64,
data: &mut [u8],
) -> Result<(), ERR> { ... }
fn read_mem_32bit(
&mut self,
address: u64,
data: &mut [u8],
) -> Result<(), ERR> { ... }
fn read(&mut self, address: u64, data: &mut [u8]) -> Result<(), ERR> { ... }
fn write_word_64(&mut self, address: u64, data: u64) -> Result<(), ERR> { ... }
fn write_word_32(&mut self, address: u64, data: u32) -> Result<(), ERR> { ... }
fn write_word_16(&mut self, address: u64, data: u16) -> Result<(), ERR> { ... }
fn write_word_8(&mut self, address: u64, data: u8) -> Result<(), ERR> { ... }
fn write_mem_64bit(&mut self, address: u64, data: &[u8]) -> Result<(), ERR> { ... }
fn write_mem_32bit(&mut self, address: u64, data: &[u8]) -> Result<(), ERR> { ... }
fn write(&mut self, address: u64, data: &[u8]) -> Result<(), ERR> { ... }
}
Expand description
An interface to be implemented for drivers that allow target memory access.
Required Methods§
Sourcefn supports_native_64bit_access(&mut self) -> bool
fn supports_native_64bit_access(&mut self) -> bool
Does this interface support native 64-bit wide accesses
If false all 64-bit operations may be split into 32 or 8 bit operations. Most callers will not need to pivot on this but it can be useful for picking the fastest bulk data transfer method.
Sourcefn read_64(&mut self, address: u64, data: &mut [u64]) -> Result<(), ERR>
fn read_64(&mut self, address: u64, data: &mut [u64]) -> Result<(), ERR>
Read a block of 64bit words at address
.
The number of words read is data.len()
.
The address where the read should be performed at has to be a multiple of 8.
Returns Error::MemoryNotAligned
if this does not hold true.
Sourcefn read_32(&mut self, address: u64, data: &mut [u32]) -> Result<(), ERR>
fn read_32(&mut self, address: u64, data: &mut [u32]) -> Result<(), ERR>
Read a block of 32bit words at address
.
The number of words read is data.len()
.
The address where the read should be performed at has to be a multiple of 4.
Returns Error::MemoryNotAligned
if this does not hold true.
Sourcefn read_16(&mut self, address: u64, data: &mut [u16]) -> Result<(), ERR>
fn read_16(&mut self, address: u64, data: &mut [u16]) -> Result<(), ERR>
Read a block of 16bit words at address
.
The number of words read is data.len()
.
The address where the read should be performed at has to be a multiple of 2.
Returns Error::MemoryNotAligned
if this does not hold true.
Sourcefn read_8(&mut self, address: u64, data: &mut [u8]) -> Result<(), ERR>
fn read_8(&mut self, address: u64, data: &mut [u8]) -> Result<(), ERR>
Read a block of 8bit words at address
.
Sourcefn write_64(&mut self, address: u64, data: &[u64]) -> Result<(), ERR>
fn write_64(&mut self, address: u64, data: &[u64]) -> Result<(), ERR>
Write a block of 64bit words at address
.
The number of words written is data.len()
.
The address where the write should be performed at has to be a multiple of 8.
Returns Error::MemoryNotAligned
if this does not hold true.
Sourcefn write_32(&mut self, address: u64, data: &[u32]) -> Result<(), ERR>
fn write_32(&mut self, address: u64, data: &[u32]) -> Result<(), ERR>
Write a block of 32bit words at address
.
The number of words written is data.len()
.
The address where the write should be performed at has to be a multiple of 4.
Returns Error::MemoryNotAligned
if this does not hold true.
Sourcefn write_16(&mut self, address: u64, data: &[u16]) -> Result<(), ERR>
fn write_16(&mut self, address: u64, data: &[u16]) -> Result<(), ERR>
Write a block of 16bit words at address
.
The number of words written is data.len()
.
The address where the write should be performed at has to be a multiple of 2.
Returns Error::MemoryNotAligned
if this does not hold true.
Sourcefn write_8(&mut self, address: u64, data: &[u8]) -> Result<(), ERR>
fn write_8(&mut self, address: u64, data: &[u8]) -> Result<(), ERR>
Write a block of 8bit words at address
.
Sourcefn supports_8bit_transfers(&self) -> Result<bool, ERR>
fn supports_8bit_transfers(&self) -> Result<bool, ERR>
Returns whether the current platform supports native 8bit transfers.
Sourcefn flush(&mut self) -> Result<(), ERR>
fn flush(&mut self) -> Result<(), ERR>
Flush any outstanding operations.
For performance, debug probe implementations may choose to batch writes;
to assure that any such batched writes have in fact been issued, flush
can be called. Takes no arguments, but may return failure if a batched
operation fails.
Provided Methods§
Sourcefn read_word_64(&mut self, address: u64) -> Result<u64, ERR>
fn read_word_64(&mut self, address: u64) -> Result<u64, ERR>
Read a 64bit word of at address
.
The address where the read should be performed at has to be a multiple of 8.
Returns AccessPortError::MemoryNotAligned
if this does not hold true.
Sourcefn read_word_32(&mut self, address: u64) -> Result<u32, ERR>
fn read_word_32(&mut self, address: u64) -> Result<u32, ERR>
Read a 32bit word of at address
.
The address where the read should be performed at has to be a multiple of 4.
Returns Error::MemoryNotAligned
if this does not hold true.
Sourcefn read_word_16(&mut self, address: u64) -> Result<u16, ERR>
fn read_word_16(&mut self, address: u64) -> Result<u16, ERR>
Read a 16bit word of at address
.
The address where the read should be performed at has to be a multiple of 2.
Returns Error::MemoryNotAligned
if this does not hold true.
Sourcefn read_word_8(&mut self, address: u64) -> Result<u8, ERR>
fn read_word_8(&mut self, address: u64) -> Result<u8, ERR>
Read an 8bit word of at address
.
Sourcefn read_mem_64bit(&mut self, address: u64, data: &mut [u8]) -> Result<(), ERR>
fn read_mem_64bit(&mut self, address: u64, data: &mut [u8]) -> Result<(), ERR>
Reads bytes using 64 bit memory access.
The address where the read should be performed at has to be a multiple of 8.
Returns Error::MemoryNotAligned
if this does not hold true.
Sourcefn read_mem_32bit(&mut self, address: u64, data: &mut [u8]) -> Result<(), ERR>
fn read_mem_32bit(&mut self, address: u64, data: &mut [u8]) -> Result<(), ERR>
Reads bytes using 32 bit memory access.
The address where the read should be performed at has to be a multiple of 4.
Returns Error::MemoryNotAligned
if this does not hold true.
Sourcefn read(&mut self, address: u64, data: &mut [u8]) -> Result<(), ERR>
fn read(&mut self, address: u64, data: &mut [u8]) -> Result<(), ERR>
Read data from address
.
This function tries to use the fastest way of reading data, so there is no guarantee which kind of memory access is used. The function might also read more data than requested, e.g. when the start address is not aligned to a 32-bit boundary.
For more control, the read_x
functions, e.g. MemoryInterface::read_32()
, can be
used.
Generally faster than read_8
.
Sourcefn write_word_64(&mut self, address: u64, data: u64) -> Result<(), ERR>
fn write_word_64(&mut self, address: u64, data: u64) -> Result<(), ERR>
Write a 64bit word at address
.
The address where the write should be performed at has to be a multiple of 8.
Returns Error::MemoryNotAligned
if this does not hold true.
Sourcefn write_word_32(&mut self, address: u64, data: u32) -> Result<(), ERR>
fn write_word_32(&mut self, address: u64, data: u32) -> Result<(), ERR>
Write a 32bit word at address
.
The address where the write should be performed at has to be a multiple of 4.
Returns Error::MemoryNotAligned
if this does not hold true.
Sourcefn write_word_16(&mut self, address: u64, data: u16) -> Result<(), ERR>
fn write_word_16(&mut self, address: u64, data: u16) -> Result<(), ERR>
Write a 16bit word at address
.
The address where the write should be performed at has to be a multiple of 2.
Returns Error::MemoryNotAligned
if this does not hold true.
Sourcefn write_word_8(&mut self, address: u64, data: u8) -> Result<(), ERR>
fn write_word_8(&mut self, address: u64, data: u8) -> Result<(), ERR>
Write an 8bit word at address
.
Sourcefn write_mem_64bit(&mut self, address: u64, data: &[u8]) -> Result<(), ERR>
fn write_mem_64bit(&mut self, address: u64, data: &[u8]) -> Result<(), ERR>
Writes bytes using 64 bit memory access. Address must be 64 bit aligned and data must be an exact multiple of 8.
Sourcefn write_mem_32bit(&mut self, address: u64, data: &[u8]) -> Result<(), ERR>
fn write_mem_32bit(&mut self, address: u64, data: &[u8]) -> Result<(), ERR>
Writes bytes using 32 bit memory access. Address must be 32 bit aligned and data must be an exact multiple of 8.
Sourcefn write(&mut self, address: u64, data: &[u8]) -> Result<(), ERR>
fn write(&mut self, address: u64, data: &[u8]) -> Result<(), ERR>
Write a block of 8bit words at address
. May use 64 bit memory access,
so should only be used if reading memory locations that don’t have side
effects. Generally faster than MemoryInterface::write_8
.
If the target does not support 8-bit aligned access, and address
is not
aligned on a 32-bit boundary, this function will return a Error::MemoryNotAligned
error.