#[repr(transparent)]pub struct PhysicalAddress {
pub addr: usize,
}Expand description
A physical memory address.
Fields§
§addr: usizeThe underlying address
Implementations§
Source§impl PhysicalAddress
impl PhysicalAddress
Sourcepub const fn new(addr: usize) -> Self
pub const fn new(addr: usize) -> Self
Creates a new PhysicalAddress with the given address.
§Examples
use kernel_api::memory::PhysicalAddress;
let addr = PhysicalAddress::new(0);Sourcepub const fn to_virtual(self) -> VirtualAddress
pub const fn to_virtual(self) -> VirtualAddress
Converts a PhysicalAddress into a VirtualAddress via the physical page map region.
The returned VirtualAddress is only safe to access if the PhysicalAddress points into conventional
RAM.
This is the physical-to-virtual counterpart to to_physical().
§Examples
use kernel_api::memory::PhysicalAddress;
let phys = PhysicalAddress::new(0x1000);
let virt = phys.to_virtual();
// if there was conventional RAM at addr 0x1000,
// `virt` could now be accessed to write to that memorySourcepub const fn align_down_to_frame(self) -> RawFrame
pub const fn align_down_to_frame(self) -> RawFrame
Returns the closest RawFrame at or below the current address.
§Examples
use kernel_api::memory::{PhysicalAddress, PAGE_SIZE};
let address = PhysicalAddress::new(0x1);
let frame = address.align_down_to_frame();
assert!(address >= *frame);
assert!((*frame).is_aligned_to(PAGE_SIZE));
// If the address is already aligned, then the value will remain unchanged.
let address = PhysicalAddress::new(PAGE_SIZE);
let frame = address.align_down_to_frame();
assert!(address == *frame);Sourcepub const fn align_up_to_frame(self) -> RawFrame
pub const fn align_up_to_frame(self) -> RawFrame
Returns the closest RawFrame at or above the current address.
§Examples
use kernel_api::memory::{PhysicalAddress, PAGE_SIZE};
let address = PhysicalAddress::new(0x1);
let frame = address.align_up_to_frame();
assert!(address <= *frame);
assert!((*frame).is_aligned_to(PAGE_SIZE));
// If the address is already aligned, then the value will remain unchanged.
let address = PhysicalAddress::new(PAGE_SIZE);
let frame = address.align_up_to_frame();
assert!(address == *frame);Sourcepub const fn is_aligned_to(self, align: usize) -> bool
pub const fn is_aligned_to(self, align: usize) -> bool
Trait Implementations§
Source§impl Add<isize> for PhysicalAddress
impl Add<isize> for PhysicalAddress
Source§impl Add<usize> for PhysicalAddress
impl Add<usize> for PhysicalAddress
Source§impl Clone for PhysicalAddress
impl Clone for PhysicalAddress
Source§fn clone(&self) -> PhysicalAddress
fn clone(&self) -> PhysicalAddress
Returns a duplicate of the value. Read more
1.0.0 (const: unstable)§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for PhysicalAddress
Source§impl Debug for PhysicalAddress
impl Debug for PhysicalAddress
impl Eq for PhysicalAddress
Source§impl From<RawFrame> for PhysicalAddress
impl From<RawFrame> for PhysicalAddress
Source§impl Hash for PhysicalAddress
impl Hash for PhysicalAddress
Source§impl LowerHex for PhysicalAddress
impl LowerHex for PhysicalAddress
Source§impl Ord for PhysicalAddress
impl Ord for PhysicalAddress
Source§fn cmp(&self, other: &PhysicalAddress) -> Ordering
fn cmp(&self, other: &PhysicalAddress) -> Ordering
1.21.0 (const: unstable)§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable)§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for PhysicalAddress
impl PartialEq for PhysicalAddress
Source§impl PartialOrd for PhysicalAddress
impl PartialOrd for PhysicalAddress
Source§impl Step for PhysicalAddress
impl Step for PhysicalAddress
Source§fn steps_between(start: &Self, end: &Self) -> (usize, Option<usize>)
fn steps_between(start: &Self, end: &Self) -> (usize, Option<usize>)
🔬This is a nightly-only experimental API. (
step_trait)Returns the bounds on the number of successor steps required to get from
start to end
like [Iterator::size_hint()][Iterator::size_hint()]. Read moreSource§fn forward_checked(start: Self, count: usize) -> Option<Self>
fn forward_checked(start: Self, count: usize) -> Option<Self>
🔬This is a nightly-only experimental API. (
step_trait)Source§fn forward_overflowing(start: Self, count: usize) -> (Self, bool)
fn forward_overflowing(start: Self, count: usize) -> (Self, bool)
🔬This is a nightly-only experimental API. (
step_trait)Returns the value that would be obtained by taking the successor
of
self count times along with a boolean tracking whether overflow
occurred. Read moreSource§fn backward_checked(start: Self, count: usize) -> Option<Self>
fn backward_checked(start: Self, count: usize) -> Option<Self>
🔬This is a nightly-only experimental API. (
step_trait)Source§fn backward_overflowing(start: Self, count: usize) -> (Self, bool)
fn backward_overflowing(start: Self, count: usize) -> (Self, bool)
🔬This is a nightly-only experimental API. (
step_trait)Returns the value that would be obtained by taking the successor
of
self count times along with a boolean tracking whether overflow
occurred. Read more§fn forward(start: Self, count: usize) -> Self
fn forward(start: Self, count: usize) -> Self
🔬This is a nightly-only experimental API. (
step_trait)§unsafe fn forward_unchecked(start: Self, count: usize) -> Self
unsafe fn forward_unchecked(start: Self, count: usize) -> Self
🔬This is a nightly-only experimental API. (
step_trait)§fn backward(start: Self, count: usize) -> Self
fn backward(start: Self, count: usize) -> Self
🔬This is a nightly-only experimental API. (
step_trait)§unsafe fn backward_unchecked(start: Self, count: usize) -> Self
unsafe fn backward_unchecked(start: Self, count: usize) -> Self
🔬This is a nightly-only experimental API. (
step_trait)impl StructuralPartialEq for PhysicalAddress
Source§impl Sub for PhysicalAddress
Returns the number of bytes between self and rhs.
impl Sub for PhysicalAddress
Returns the number of bytes between self and rhs.
Source§impl Sub<isize> for PhysicalAddress
impl Sub<isize> for PhysicalAddress
Auto Trait Implementations§
impl Freeze for PhysicalAddress
impl RefUnwindSafe for PhysicalAddress
impl Send for PhysicalAddress
impl Sync for PhysicalAddress
impl Unpin for PhysicalAddress
impl UnsafeUnpin for PhysicalAddress
impl UnwindSafe for PhysicalAddress
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more