[−][src]Trait flp_framework::Address
The Address
trait exposes all the basic operations (arithmetic, etc.) that
can be performed on an address of a Floorplan type. These are all intrinsically
unsafe operations, and intended for use by developers of the Floorplan compiler, or other developers extending the capability of Floorplan. Directly accessing these
trait functions from memory management code is ill-advised, and unsupported.
Required methods
fn as_usize(&self) -> usize
An address can be constructed from a usize
value.
Accessing this function directly from memory management code is unsupported
fn from_usize(_: usize) -> Self
An address can be decronstructed into a raw usize
value.
Accessing this function directly from memory management code is unsupported
fn verify(self) -> bool
Does this address appear valid accoring to the layout / address type?
Accessing this function directly from memory management code is unsupported
Provided methods
fn plus<A: Address>(&self, bytes: usize) -> A
Add some number of bytes
to this address, producing an address of type A
.
Accessing this function directly from memory management code is unsupported
fn sub<A: Address>(&self, bytes: usize) -> A
Subtract some number of bytes
from this address, producing an address of type A
.
Accessing this function directly from memory management code is unsupported
fn offset<T, A: Address>(&self, offset: usize) -> A
Offset this &self
address some number of instances of type T
, producing an address of
type A
.
Accessing this function directly from memory management code is unsupported
fn load<T: Copy>(&self) -> T
Read a single instance of a value of type T
from this address.
Accessing this function directly from memory management code is unsupported
fn store<T>(&self, value: T)
Store a single instance value
into the memory at this address.
Accessing this function directly from memory management code is unsupported
fn is_zero(&self) -> bool
Is the value of this address equivalent to the (universal) null value?
Accessing this function directly from memory management code is unsupported
fn align_up<A: Address>(&self, align: usize) -> A
Align this pointer up (increasing value) to the nearest address with a value
aligned to align
bytes. For example the following properties hold:
let a = WordAddr::from_usize(0xff); assert!(a.align_up::<WordAddr>(2).as_usize() == 0x100); assert!(a.align_up::<WordAddr>(16).as_usize() == 0x100); assert!(a.align_up::<WordAddr>(512).as_usize() == 0x200); let b = WordAddr::from_usize(0x100); assert!(b.align_up::<WordAddr>(256).as_usize() == 0x100);
Accessing this function directly from memory management code is unsupported
fn gte<A: Address>(&self, addr: A) -> bool
Is the value of this address greater than or equal to the value of the given address?
Accessing this function directly from memory management code is unsupported
fn greater<A: Address>(&self, addr: A) -> bool
Is the value of this address greater than the value of the given address?
Accessing this function directly from memory management code is unsupported
fn lte<A: Address>(&self, addr: A) -> bool
Is the value of this address less than or equal to the value of the given address?
Accessing this function directly from memory management code is unsupported
fn less<A: Address>(&self, addr: A) -> bool
Is the value of this address less than the value of the given address?
Accessing this function directly from memory management code is unsupported
fn is_aligned_to(&self, align: usize) -> bool
Is the value of this address exactly aligned to the given alignment?
assert!(WordAddr::from_usize(0xFF).is_aligned_to(2) == false); assert!(WordAddr::from_usize(0xF0).is_aligned_to(2) == true);
Accessing this function directly from memory management code is unsupported
fn from_ptr<T>(ptr: *const T) -> Self
Construct an address from an immutable constant Rust pointer type.
Accessing this function directly from memory management code is unsupported
fn to_ptr<T>(&self) -> *const T
Deconstruct an address into an immutable constant Rust pointer type.
Accessing this function directly from memory management code is unsupported
fn to_ptr_mut<T>(&self) -> *mut T
Construct an address from a mutable constant Rust pointer type.
Accessing this function directly from memory management code is unsupported
fn zero() -> Self
Construct the (universal) null address.
Accessing this function directly from memory management code is unsupported
fn diff<A: Address>(&self, another: A) -> usize
Compute the number of bytes before this address (exclusive) and after
another
address (inclusive).
let wa1 : WordAddr = WordAddr::from_usize(0xFF); let wa2 : WordAddr = WordAddr::zero(); // The null address assert!(wa1.diff(wa2) == 0xFF)
Accessing this function directly from memory management code is unsupported
fn memset(&self, val: u8, length: usize)
Set the first length
bytes pointed to by this address to the byte val
.
Accessing this function directly from memory management code is unsupported
Implementors
impl Address for AddrAddr
[src]
fn from_usize(val: usize) -> AddrAddr
[src]
Construct an address of this type from a raw usize
value.
fn as_usize(&self) -> usize
[src]
Deconstruct this address into a raw usize
value.
fn verify(self) -> bool
[src]
Default verification of proper address alignment.
impl Address for Byte
[src]
fn from_usize(val: usize) -> Byte
[src]
Constructor for a byte value from a raw usize
.
let w = Byte::from_usize(0xff);
fn as_usize(&self) -> usize
[src]
Deconstructor for a byte value into a raw usize
value.
let w = Byte::from_usize(0xff); assert!(w.as_usize() == 255);
fn verify(self) -> bool
[src]
All possible byte values are valid:
let w = Byte::from_usize(0xff); assert!(w.verify());
fn load<T: Copy>(&self) -> T
[src]
A byte cannot be accessed.
fn store<T>(&self, _value: T)
[src]
A byte cannot be accessed.
fn memset(&self, _char: u8, _length: usize)
[src]
Raw byte values are not writeable.
impl Address for ByteAddr
[src]
fn from_usize(val: usize) -> ByteAddr
[src]
Constructor for a byte address from a raw usize
.
let ba = ByteAddr::from_usize(0xdeadbeef);
fn as_usize(&self) -> usize
[src]
Deconstructor for a byte address into a raw usize
value.
let ba = ByteAddr::from_usize(0xdeadbeef); assert!(ba.as_usize() == 3735928559);
fn verify(self) -> bool
[src]
All byte addresses are valid:
let ba = ByteAddr::from_usize(0xdeadbeef); assert!(ba.verify());
fn load<T: Copy>(&self) -> T
[src]
A generic address to a raw byte cannot be accessed.
fn store<T>(&self, value: T)
[src]
A generic address to a raw byte cannot be accessed.
impl Address for VoidAddr
[src]
fn from_usize(val: usize) -> VoidAddr
[src]
Construct a void address:
let va = VoidAddr::from_usize(0xdeadbeef);
fn as_usize(&self) -> usize
[src]
Deconstruct a void address:
let va = VoidAddr::from_usize(0xdeadbeef); assert!(va.as_usize() == 3735928559);
fn verify(self) -> bool
[src]
Trivially verify that this void address looks valid. All values are valid:
let va = VoidAddr::from_usize(0xdeadbeef); assert!(va.verify());
fn load<T: Copy>(&self) -> T
[src]
Void addresses cannot be accessed.
fn store<T>(&self, _value: T)
[src]
Void addresses cannot be accessed.
fn memset(&self, _char: u8, _length: usize)
[src]
Void addresses cannot be accessed.
impl Address for Word
[src]
fn from_usize(val: usize) -> Word
[src]
Constructor for a word value from a raw usize
.
let w = Word::from_usize(0xff);
fn as_usize(&self) -> usize
[src]
Deconstructor for a word value into a raw usize
value.
let w = Word::from_usize(0xff); assert!(w.as_usize() == 255);
fn verify(self) -> bool
[src]
All possible word values are valid:
let w = Word::from_usize(0xff); assert!(w.verify());
fn load<T: Copy>(&self) -> T
[src]
A word cannot be accessed.
fn store<T>(&self, _value: T)
[src]
A word cannot be accessed.
fn memset(&self, _char: u8, _length: usize)
[src]
Raw word values are not writeable.
impl Address for WordAddr
[src]
fn from_usize(val: usize) -> WordAddr
[src]
Constructor for a word address from a raw usize
.
let wa = WordAddr::from_usize(0xdeadbeef);
fn as_usize(&self) -> usize
[src]
Deconstructor for a word address into a raw usize
value.
let wa = WordAddr::from_usize(0xdeadbeef); assert!(wa.as_usize() == 3735928559);
fn verify(self) -> bool
[src]
All possible word values are valid:
let wa = WordAddr::from_usize(0xdeadbeef); assert!(wa.verify());
fn load<T: Copy>(&self) -> T
[src]
A generic address to a raw word cannot be accessed.
fn store<T>(&self, value: T)
[src]
A generic address to a raw word cannot be accessed.