mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-22 08:53:29 +00:00
Extend Safeptr to support DmaStream
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
345ab8f838
commit
2256f6ae8a
@ -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 {
|
||||
|
Reference in New Issue
Block a user