Struct PhysFrame
#[repr(C)]pub struct PhysFrame<S = Size4KiB>where
S: PageSize,{
pub(crate) start_address: PhysAddr,
size: PhantomData<S>,
}Expand description
A physical memory frame.
Fields§
§start_address: PhysAddr§size: PhantomData<S>Implementations§
§impl<S> PhysFrame<S>where
S: PageSize,
impl<S> PhysFrame<S>where
S: PageSize,
pub const fn from_start_address(
address: PhysAddr,
) -> Result<PhysFrame<S>, AddressNotAligned>
pub const fn from_start_address( address: PhysAddr, ) -> Result<PhysFrame<S>, AddressNotAligned>
Returns the frame that starts at the given virtual address.
Returns an error if the address is not correctly aligned (i.e. is not a valid frame start).
pub const unsafe fn from_start_address_unchecked(
start_address: PhysAddr,
) -> PhysFrame<S>
pub const unsafe fn from_start_address_unchecked( start_address: PhysAddr, ) -> PhysFrame<S>
Returns the frame that starts at the given virtual address.
§Safety
The address must be correctly aligned.
pub const fn from_pfn(pfn: u64) -> PhysFrame<S>
pub const fn from_pfn(pfn: u64) -> PhysFrame<S>
Returns the frame by a physical frame number.
use x86_64::{PhysAddr, structures::paging::{PhysFrame, Size4KiB}};
assert_eq!(PhysFrame::<Size4KiB>::from_pfn(0x123), PhysFrame::<Size4KiB>::containing_address(PhysAddr::new(0x123000)));§Panics
This function will panic if the resulting address is not valid.
pub const fn try_from_pfn(pfn: u64) -> Result<PhysFrame<S>, PfnNotValid>
pub const fn try_from_pfn(pfn: u64) -> Result<PhysFrame<S>, PfnNotValid>
Returns the frame by a physical frame number.
use x86_64::{PhysAddr, structures::paging::{PhysFrame, Size4KiB}};
assert_eq!(PhysFrame::<Size4KiB>::try_from_pfn(0x123), Ok(PhysFrame::<Size4KiB>::containing_address(PhysAddr::new(0x123000))));§Error
This function will return an error if the resulting address is not valid.
pub const unsafe fn from_pfn_unchecked(pfn: u64) -> PhysFrame<S>
pub const unsafe fn from_pfn_unchecked(pfn: u64) -> PhysFrame<S>
pub const fn containing_address(address: PhysAddr) -> PhysFrame<S>
pub const fn containing_address(address: PhysAddr) -> PhysFrame<S>
Returns the frame that contains the given physical address.
pub const fn start_address(self) -> PhysAddr
pub const fn start_address(self) -> PhysAddr
Returns the start address of the frame.
pub const fn pfn(self) -> u64
pub const fn pfn(self) -> u64
Returns the PFN of the current frame.
The PFN is defined to be the address divided by the page size.
use x86_64::{PhysAddr, structures::paging::{PhysFrame, Size1GiB, Size2MiB, Size4KiB}};
assert_eq!(PhysFrame::<Size4KiB>::containing_address(PhysAddr::new(0x123000)).pfn(), 0x123);
// Note that this means that the PFN for the same address will be
// different for different page sizes.
assert_eq!(PhysFrame::<Size4KiB>::containing_address(PhysAddr::new(0xC000_0000)).pfn(), 0xC0000);
assert_eq!(PhysFrame::<Size2MiB>::containing_address(PhysAddr::new(0xC000_0000)).pfn(), 0x600);
assert_eq!(PhysFrame::<Size1GiB>::containing_address(PhysAddr::new(0xC000_0000)).pfn(), 0x3);pub const fn range(start: PhysFrame<S>, end: PhysFrame<S>) -> PhysFrameRange<S> ⓘ
pub const fn range(start: PhysFrame<S>, end: PhysFrame<S>) -> PhysFrameRange<S> ⓘ
Returns a range of frames, exclusive end.
pub const fn range_inclusive(
start: PhysFrame<S>,
end: PhysFrame<S>,
) -> PhysFrameRangeInclusive<S> ⓘ
pub const fn range_inclusive( start: PhysFrame<S>, end: PhysFrame<S>, ) -> PhysFrameRangeInclusive<S> ⓘ
Returns a range of frames, inclusive end.
Trait Implementations§
§impl<S> AddAssign<u64> for PhysFrame<S>where
S: PageSize,
impl<S> AddAssign<u64> for PhysFrame<S>where
S: PageSize,
§fn add_assign(&mut self, rhs: u64)
fn add_assign(&mut self, rhs: u64)
+= operation. Read moreimpl<S> Copy for PhysFrame<S>
impl<S> Eq for PhysFrame<S>
§impl<S> Ord for PhysFrame<S>
impl<S> Ord for PhysFrame<S>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
§impl<S> PartialOrd for PhysFrame<S>where
S: PartialOrd + PageSize,
impl<S> PartialOrd for PhysFrame<S>where
S: PartialOrd + PageSize,
impl<S> StructuralPartialEq for PhysFrame<S>
Auto Trait Implementations§
impl<S> Freeze for PhysFrame<S>
impl<S> RefUnwindSafe for PhysFrame<S>where
S: RefUnwindSafe,
impl<S> Send for PhysFrame<S>where
S: Send,
impl<S> Sync for PhysFrame<S>where
S: Sync,
impl<S> Unpin for PhysFrame<S>where
S: Unpin,
impl<S> UnsafeUnpin for PhysFrame<S>
impl<S> UnwindSafe for PhysFrame<S>where
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more