mirror of
https://github.com/rcore-os/rCore-Tutorial-v3.git
synced 2024-11-22 17:36:25 +04:00
Fix issue #123
This commit is contained in:
parent
8e663030cb
commit
c462545bfb
@ -107,8 +107,12 @@ impl VirtAddr {
|
||||
}
|
||||
///`VirtAddr`->`VirtPageNum`
|
||||
pub fn ceil(&self) -> VirtPageNum {
|
||||
if self.0 == 0 {
|
||||
VirtPageNum(0)
|
||||
} else {
|
||||
VirtPageNum((self.0 - 1 + PAGE_SIZE) / PAGE_SIZE)
|
||||
}
|
||||
}
|
||||
///Get page offset
|
||||
pub fn page_offset(&self) -> usize {
|
||||
self.0 & (PAGE_SIZE - 1)
|
||||
@ -136,8 +140,12 @@ impl PhysAddr {
|
||||
}
|
||||
///`PhysAddr`->`PhysPageNum`
|
||||
pub fn ceil(&self) -> PhysPageNum {
|
||||
if self.0 == 0 {
|
||||
PhysPageNum(0)
|
||||
} else {
|
||||
PhysPageNum((self.0 - 1 + PAGE_SIZE) / PAGE_SIZE)
|
||||
}
|
||||
}
|
||||
///Get page offset
|
||||
pub fn page_offset(&self) -> usize {
|
||||
self.0 & (PAGE_SIZE - 1)
|
||||
|
Loading…
Reference in New Issue
Block a user