mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-29 04:13:24 +00:00
Replace InFramePtr with SafePtr
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
ab4b1b47dc
commit
c38e4f0800
@ -3,7 +3,7 @@ use pod::Pod;
|
||||
use spin::Once;
|
||||
|
||||
use crate::{
|
||||
vm::{Paddr, Vaddr, VmIo},
|
||||
vm::{HasPaddr, Paddr, Vaddr, VmIo},
|
||||
Error,
|
||||
};
|
||||
|
||||
@ -60,6 +60,12 @@ impl VmIo for IoMem {
|
||||
}
|
||||
}
|
||||
|
||||
impl HasPaddr for IoMem {
|
||||
fn paddr(&self) -> Paddr {
|
||||
crate::vm::vaddr_to_paddr(self.virtual_address).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl IoMem {
|
||||
pub fn new(range: Range<Paddr>) -> Option<IoMem> {
|
||||
if CHECKER.get().unwrap().check(&range) {
|
||||
@ -72,10 +78,6 @@ impl IoMem {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn paddr(&self) -> Paddr {
|
||||
crate::vm::vaddr_to_paddr(self.virtual_address).unwrap()
|
||||
}
|
||||
|
||||
fn check_range(&self, offset: usize, len: usize) -> crate::Result<()> {
|
||||
let sum = offset.checked_add(len).ok_or(Error::InvalidArgs)?;
|
||||
if sum > self.limit {
|
||||
|
Reference in New Issue
Block a user