Expand description
Implementation of physical and virtual address and page number.
+Expand description
Implementation of physical and virtual address and page number.
Structs
Definitions
physical page number
a simple range structure for type T
diff --git a/ch4/os/mm/address/struct.PhysAddr.html b/ch4/os/mm/address/struct.PhysAddr.html index 005682ad..caacaa88 100644 --- a/ch4/os/mm/address/struct.PhysAddr.html +++ b/ch4/os/mm/address/struct.PhysAddr.html @@ -1,10 +1,10 @@pub struct PhysAddr(pub usize);
Expand description
Definitions
-Tuple Fields
0: usize
Implementations
sourceimpl PhysAddr
impl PhysAddr
pub fn floor(&self) -> PhysPageNum
pub fn ceil(&self) -> PhysPageNum
pub fn page_offset(&self) -> usize
pub fn aligned(&self) -> bool
Trait Implementations
sourceimpl Clone for PhysAddr
impl Clone for PhysAddr
Tuple Fields
0: usize
Implementations
sourceimpl PhysAddr
impl PhysAddr
pub fn floor(&self) -> PhysPageNum
pub fn ceil(&self) -> PhysPageNum
pub fn page_offset(&self) -> usize
pub fn aligned(&self) -> bool
Trait Implementations
sourceimpl From<PhysAddr> for PhysPageNum
impl From<PhysAddr> for PhysPageNum
sourceimpl From<PhysAddr> for PhysPageNum
impl From<PhysAddr> for PhysPageNum
sourceimpl From<PhysPageNum> for PhysAddr
impl From<PhysPageNum> for PhysAddr
sourcefn from(v: PhysPageNum) -> Self
fn from(v: PhysPageNum) -> Self
Converts to this type from the input type.
+sourceimpl From<PhysPageNum> for PhysAddr
impl From<PhysPageNum> for PhysAddr
sourcefn from(v: PhysPageNum) -> Self
fn from(v: PhysPageNum) -> Self
Converts to this type from the input type.
sourceimpl From<usize> for PhysAddr
impl From<usize> for PhysAddr
T: {PhysAddr, VirtAddr, PhysPageNum, VirtPageNum} T -> usize: T.0 usize -> T: usize.into()
diff --git a/ch4/os/mm/address/struct.PhysPageNum.html b/ch4/os/mm/address/struct.PhysPageNum.html index 1aecf8c2..4ae168e1 100644 --- a/ch4/os/mm/address/struct.PhysPageNum.html +++ b/ch4/os/mm/address/struct.PhysPageNum.html @@ -1,9 +1,9 @@pub struct PhysPageNum(pub usize);
Expand description
physical page number
-Tuple Fields
0: usize
Implementations
sourceimpl PhysPageNum
impl PhysPageNum
pub fn get_pte_array(&self) -> &'static mut [PageTableEntry]
pub fn get_bytes_array(&self) -> &'static mut [u8]
pub fn get_mut<T>(&self) -> &'static mut T
Trait Implementations
sourceimpl Clone for PhysPageNum
impl Clone for PhysPageNum
sourcefn clone(&self) -> PhysPageNum
fn clone(&self) -> PhysPageNum
Returns a copy of the value. Read more
+Tuple Fields
0: usize
Implementations
sourceimpl PhysPageNum
impl PhysPageNum
pub fn get_pte_array(&self) -> &'static mut [PageTableEntry]
pub fn get_bytes_array(&self) -> &'static mut [u8]
pub fn get_mut<T>(&self) -> &'static mut T
Trait Implementations
sourceimpl Clone for PhysPageNum
impl Clone for PhysPageNum
sourcefn clone(&self) -> PhysPageNum
fn clone(&self) -> PhysPageNum
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for PhysPageNum
impl Debug for PhysPageNum
sourceimpl From<PhysAddr> for PhysPageNum
impl From<PhysAddr> for PhysPageNum
sourceimpl From<PhysPageNum> for PhysAddr
impl From<PhysPageNum> for PhysAddr
sourcefn from(v: PhysPageNum) -> Self
fn from(v: PhysPageNum) -> Self
Converts to this type from the input type.
+sourceimpl From<PhysAddr> for PhysPageNum
impl From<PhysAddr> for PhysPageNum
sourceimpl From<PhysPageNum> for PhysAddr
impl From<PhysPageNum> for PhysAddr
sourcefn from(v: PhysPageNum) -> Self
fn from(v: PhysPageNum) -> Self
Converts to this type from the input type.
sourceimpl From<PhysPageNum> for usize
impl From<PhysPageNum> for usize
sourcefn from(v: PhysPageNum) -> Self
fn from(v: PhysPageNum) -> Self
Converts to this type from the input type.
sourceimpl From<usize> for PhysPageNum
impl From<usize> for PhysPageNum
sourceimpl Ord for PhysPageNum
impl Ord for PhysPageNum
sourcefn cmp(&self, other: &PhysPageNum) -> Ordering
fn cmp(&self, other: &PhysPageNum) -> Ordering
This method returns an Ordering
between self
and other
. Read more
pub struct SimpleRange<T> where
T: StepByOne + Copy + PartialEq + PartialOrd + Debug, {
+SimpleRange in os::mm::address - Rust pub struct SimpleRange<T> where
T: StepByOne + Copy + PartialEq + PartialOrd + Debug, {
l: T,
r: T,
}
Expand description
a simple range structure for type T
-Fields
l: T
r: T
Implementations
Trait Implementations
sourceimpl<T: Clone> Clone for SimpleRange<T> where
T: StepByOne + Copy + PartialEq + PartialOrd + Debug,
sourcefn clone(&self) -> SimpleRange<T>
Returns a copy of the value. Read more
+Fields
l: T
r: T
Implementations
Trait Implementations
sourceimpl<T: Clone> Clone for SimpleRange<T> where
T: StepByOne + Copy + PartialEq + PartialOrd + Debug,
sourcefn clone(&self) -> SimpleRange<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
-sourceimpl<T> IntoIterator for SimpleRange<T> where
T: StepByOne + Copy + PartialEq + PartialOrd + Debug,
type Item = T
The type of the elements being iterated over.
+sourceimpl<T> IntoIterator for SimpleRange<T> where
T: StepByOne + Copy + PartialEq + PartialOrd + Debug,
sourceimpl<T: Copy> Copy for SimpleRange<T> where
T: StepByOne + Copy + PartialEq + PartialOrd + Debug,
Auto Trait Implementations
impl<T> RefUnwindSafe for SimpleRange<T> where
T: RefUnwindSafe,
impl<T> Send for SimpleRange<T> where
T: Send,
impl<T> Sync for SimpleRange<T> where
T: Sync,
impl<T> Unpin for SimpleRange<T> where
T: Unpin,
impl<T> UnwindSafe for SimpleRange<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T: Copy> Copy for SimpleRange<T> where
T: StepByOne + Copy + PartialEq + PartialOrd + Debug,
Auto Trait Implementations
impl<T> RefUnwindSafe for SimpleRange<T> where
T: RefUnwindSafe,
impl<T> Send for SimpleRange<T> where
T: Send,
impl<T> Sync for SimpleRange<T> where
T: Sync,
impl<T> Unpin for SimpleRange<T> where
T: Unpin,
impl<T> UnwindSafe for SimpleRange<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> From<T> for T
const: unstable · sourcefn from(t: T) -> T
Returns the argument unchanged.
diff --git a/ch4/os/mm/address/struct.SimpleRangeIterator.html b/ch4/os/mm/address/struct.SimpleRangeIterator.html
index 48082e68..044e299d 100644
--- a/ch4/os/mm/address/struct.SimpleRangeIterator.html
+++ b/ch4/os/mm/address/struct.SimpleRangeIterator.html
@@ -1,9 +1,9 @@
-SimpleRangeIterator in os::mm::address - Rust pub struct SimpleRangeIterator<T> where
T: StepByOne + Copy + PartialEq + PartialOrd + Debug, {
+SimpleRangeIterator in os::mm::address - Rust pub struct SimpleRangeIterator<T> where
T: StepByOne + Copy + PartialEq + PartialOrd + Debug, {
current: T,
end: T,
}
Expand description
iterator for the simple range structure
-Fields
current: T
end: T
Implementations
sourceimpl<T> SimpleRangeIterator<T> where
T: StepByOne + Copy + PartialEq + PartialOrd + Debug,
Trait Implementations
sourceimpl<T> Iterator for SimpleRangeIterator<T> where
T: StepByOne + Copy + PartialEq + PartialOrd + Debug,
type Item = T
The type of the elements being iterated over.
-sourcefn next(&mut self) -> Option<Self::Item>
Advances the iterator and returns the next value. Read more
+Fields
current: T
end: T
Implementations
sourceimpl<T> SimpleRangeIterator<T> where
T: StepByOne + Copy + PartialEq + PartialOrd + Debug,
Trait Implementations
sourceimpl<T> Iterator for SimpleRangeIterator<T> where
T: StepByOne + Copy + PartialEq + PartialOrd + Debug,
type Item = T
The type of the elements being iterated over.
+sourcefn next(&mut self) -> Option<Self::Item>
Advances the iterator and returns the next value. Read more
sourcefn next_chunk<const N: usize>(
&mut self
) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>
🔬 This is a nightly-only experimental API. (iter_next_chunk
)Advances the iterator and returns an array containing the next N
values. Read more
1.0.0 · sourcefn size_hint(&self) -> (usize, Option<usize>)
Returns the bounds on the remaining length of the iterator. Read more
1.0.0 · sourcefn count(self) -> usize
Consumes the iterator, counting the number of iterations and returning it. Read more
diff --git a/ch4/os/mm/address/struct.VirtAddr.html b/ch4/os/mm/address/struct.VirtAddr.html
index 82220c98..c327c574 100644
--- a/ch4/os/mm/address/struct.VirtAddr.html
+++ b/ch4/os/mm/address/struct.VirtAddr.html
@@ -1,11 +1,11 @@
VirtAddr in os::mm::address - Rust pub struct VirtAddr(pub usize);
Expand description
virtual address
-Tuple Fields
0: usize
Implementations
sourceimpl VirtAddr
sourcepub fn floor(&self) -> VirtPageNum
sourcepub fn ceil(&self) -> VirtPageNum
sourcepub fn page_offset(&self) -> usize
sourcepub fn aligned(&self) -> bool
Trait Implementations
sourceimpl Clone for VirtAddr
Tuple Fields
0: usize
Implementations
sourceimpl VirtAddr
sourcepub fn floor(&self) -> VirtPageNum
sourcepub fn ceil(&self) -> VirtPageNum
sourcepub fn page_offset(&self) -> usize
sourcepub fn aligned(&self) -> bool
Trait Implementations
sourceimpl From<VirtAddr> for VirtPageNum
sourceimpl From<VirtAddr> for VirtPageNum
sourceimpl From<VirtPageNum> for VirtAddr
sourcefn from(v: VirtPageNum) -> Self
Converts to this type from the input type.
+sourceimpl From<VirtPageNum> for VirtAddr
sourcefn from(v: VirtPageNum) -> Self
Converts to this type from the input type.
sourceimpl Ord for VirtAddr
1.21.0 · sourcefn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
diff --git a/ch4/os/mm/address/struct.VirtPageNum.html b/ch4/os/mm/address/struct.VirtPageNum.html
index 5a7e5d4a..dd2ab9ba 100644
--- a/ch4/os/mm/address/struct.VirtPageNum.html
+++ b/ch4/os/mm/address/struct.VirtPageNum.html
@@ -1,9 +1,9 @@
VirtPageNum in os::mm::address - Rust pub struct VirtPageNum(pub usize);
Expand description
virtual page number
-Tuple Fields
0: usize
Implementations
Trait Implementations
sourceimpl Clone for VirtPageNum
sourcefn clone(&self) -> VirtPageNum
Returns a copy of the value. Read more
+Tuple Fields
0: usize
Implementations
Trait Implementations
sourceimpl Clone for VirtPageNum
sourcefn clone(&self) -> VirtPageNum
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for VirtPageNum
sourceimpl From<VirtAddr> for VirtPageNum
sourceimpl From<VirtPageNum> for VirtAddr
sourcefn from(v: VirtPageNum) -> Self
Converts to this type from the input type.
+sourceimpl From<VirtAddr> for VirtPageNum
sourceimpl From<VirtPageNum> for VirtAddr
sourcefn from(v: VirtPageNum) -> Self
Converts to this type from the input type.
sourceimpl From<VirtPageNum> for usize
sourcefn from(v: VirtPageNum) -> Self
Converts to this type from the input type.
sourceimpl From<usize> for VirtPageNum
sourceimpl Ord for VirtPageNum
sourcefn cmp(&self, other: &VirtPageNum) -> Ordering
sourceimpl StepByOne for VirtPageNum
sourceimpl Copy for VirtPageNum
sourceimpl Eq for VirtPageNum
sourceimpl StructuralEq for VirtPageNum
sourceimpl StructuralPartialEq for VirtPageNum
Auto Trait Implementations
impl RefUnwindSafe for VirtPageNum
impl Send for VirtPageNum
impl Sync for VirtPageNum
impl Unpin for VirtPageNum
impl UnwindSafe for VirtPageNum
Blanket Implementations
sourceimpl StepByOne for VirtPageNum
sourceimpl Copy for VirtPageNum
sourceimpl Eq for VirtPageNum
sourceimpl StructuralEq for VirtPageNum
sourceimpl StructuralPartialEq for VirtPageNum
Auto Trait Implementations
impl RefUnwindSafe for VirtPageNum
impl Send for VirtPageNum
impl Sync for VirtPageNum
impl Unpin for VirtPageNum
impl UnwindSafe for VirtPageNum
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> From<T> for T
const: unstable · sourcefn from(t: T) -> T
Returns the argument unchanged.
diff --git a/ch4/os/mm/address/trait.StepByOne.html b/ch4/os/mm/address/trait.StepByOne.html
index dca8d751..bb16e96e 100644
--- a/ch4/os/mm/address/trait.StepByOne.html
+++ b/ch4/os/mm/address/trait.StepByOne.html
@@ -1,3 +1,3 @@
-StepByOne in os::mm::address - Rust pub trait StepByOne {
+StepByOne in os::mm::address - Rust
\ No newline at end of file
+}
Required Methods
Implementors
sourceimpl StepByOne for VirtPageNum
\ No newline at end of file
diff --git a/ch4/os/mm/address/type.VPNRange.html b/ch4/os/mm/address/type.VPNRange.html
index 257a95b3..d45c4e12 100644
--- a/ch4/os/mm/address/type.VPNRange.html
+++ b/ch4/os/mm/address/type.VPNRange.html
@@ -1,2 +1,2 @@
-VPNRange in os::mm::address - Rust pub type VPNRange = SimpleRange<VirtPageNum>;
Expand description
a simple range structure for virtual page number
+VPNRange in os::mm::address - Rust pub type VPNRange = SimpleRange<VirtPageNum>;
Expand description
a simple range structure for virtual page number
\ No newline at end of file
diff --git a/ch4/src/os/mm/address.rs.html b/ch4/src/os/mm/address.rs.html
index 7a9e32bf..abcbefdf 100644
--- a/ch4/src/os/mm/address.rs.html
+++ b/ch4/src/os/mm/address.rs.html
@@ -253,6 +253,14 @@
253
254
255
+256
+257
+258
+259
+260
+261
+262
+263
//! Implementation of physical and virtual address and page number.
use super::PageTableEntry;
@@ -358,7 +366,11 @@
VirtPageNum(self.0 / PAGE_SIZE)
}
pub fn ceil(&self) -> VirtPageNum {
- VirtPageNum((self.0 - 1 + PAGE_SIZE) / PAGE_SIZE)
+ if self.0 == 0 {
+ VirtPageNum(0)
+ } else {
+ VirtPageNum((self.0 - 1 + PAGE_SIZE) / PAGE_SIZE)
+ }
}
pub fn page_offset(&self) -> usize {
self.0 & (PAGE_SIZE - 1)
@@ -383,7 +395,11 @@
PhysPageNum(self.0 / PAGE_SIZE)
}
pub fn ceil(&self) -> PhysPageNum {
- PhysPageNum((self.0 - 1 + PAGE_SIZE) / PAGE_SIZE)
+ if self.0 == 0 {
+ PhysPageNum(0)
+ } else {
+ PhysPageNum((self.0 - 1 + PAGE_SIZE) / PAGE_SIZE)
+ }
}
pub fn page_offset(&self) -> usize {
self.0 & (PAGE_SIZE - 1)