mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-23 09:23:25 +00:00
Fix accesses to VirtIO queue DMA
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
3deff2e842
commit
b1ea422efa
@ -7,7 +7,7 @@ use aster_rights_proc::require;
|
||||
use inherit_methods_macro::inherit_methods;
|
||||
pub use ostd::Pod;
|
||||
use ostd::{
|
||||
mm::{Daddr, DmaStream, HasDaddr, HasPaddr, Paddr, VmIo},
|
||||
mm::{Daddr, DmaStream, HasDaddr, HasPaddr, Paddr, PodOnce, VmIo, VmIoOnce},
|
||||
Result,
|
||||
};
|
||||
pub use typeflags_util::SetContain;
|
||||
@ -324,6 +324,28 @@ impl<T: Pod, M: VmIo, R: TRights> SafePtr<T, M, TRightSet<R>> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: PodOnce, M: VmIoOnce, R: TRights> SafePtr<T, M, TRightSet<R>> {
|
||||
/// Reads the value from the pointer using one non-tearing instruction.
|
||||
///
|
||||
/// # Access rights
|
||||
///
|
||||
/// This method requires the `Read` right.
|
||||
#[require(R > Read)]
|
||||
pub fn read_once(&self) -> Result<T> {
|
||||
self.vm_obj.read_once(self.offset)
|
||||
}
|
||||
|
||||
/// Overwrites the value at the pointer using one non-tearing instruction.
|
||||
///
|
||||
/// # Access rights
|
||||
///
|
||||
/// This method requires the `Write` right.
|
||||
#[require(R > Write)]
|
||||
pub fn write_once(&self, val: &T) -> Result<()> {
|
||||
self.vm_obj.write_once(self.offset, val)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, M: HasDaddr, R> HasDaddr for SafePtr<T, M, R> {
|
||||
fn daddr(&self) -> Daddr {
|
||||
self.offset + self.vm_obj.daddr()
|
||||
|
Reference in New Issue
Block a user