Extend Safeptr to support DmaStream

This commit is contained in:
Jianfeng Jiang
2024-04-28 10:41:18 +00:00
committed by Tate, Hongliang Tian
parent 345ab8f838
commit 2256f6ae8a
2 changed files with 27 additions and 46 deletions

View File

@ -3,7 +3,7 @@
use core::{fmt::Debug, marker::PhantomData};
use aster_frame::{
vm::{HasPaddr, Paddr, VmIo},
vm::{Daddr, DmaStream, HasDaddr, HasPaddr, Paddr, VmIo},
Result,
};
use aster_rights::{Dup, Exec, Full, Read, Signal, TRightSet, TRights, Write};
@ -323,6 +323,20 @@ impl<T: Pod, M: VmIo, R: TRights> SafePtr<T, M, TRightSet<R>> {
}
}
impl<T, M: HasDaddr, R> HasDaddr for SafePtr<T, M, R> {
fn daddr(&self) -> Daddr {
self.offset + self.vm_obj.daddr()
}
}
impl<T, R> SafePtr<T, DmaStream, R> {
/// Synchronize the object in the streaming DMA mapping
pub fn sync(&self) -> Result<()> {
self.vm_obj
.sync(self.offset..self.offset + core::mem::size_of::<T>())
}
}
#[require(R > Dup)]
impl<T, M: Clone, R: TRights> Clone for SafePtr<T, M, TRightSet<R>> {
fn clone(&self) -> Self {