use dma_api::*;
// ----- Driver Side -----
// use global allocator to alloc `to device` type memory
let mut dma: DVec<u32> = DVec::zeros(10, 0x1000, Direction::ToDevice).unwrap();
// flush cache to memory.
dma.set(0, 1);
// do nothing with cache
let o = dma.get(0).unwrap();
assert_eq!(o, 1);
// ----- OS Side -----
struct Impled;
impl Impl for Impled {
fn map(addr: std::ptr::NonNull<u8>, size: usize, direction: Direction) -> u64 {
println!("map @{:?}, size {size:#x}, {direction:?}", addr);
addr.as_ptr() as usize as _
}
fn unmap(addr: std::ptr::NonNull<u8>, size: usize) {
println!("unmap @{:?}, size {size:#x}", addr);
}
fn flush(addr: std::ptr::NonNull<u8>, size: usize) {
println!("flush @{:?}, size {size:#x}", addr);
}
fn invalidate(addr: std::ptr::NonNull<u8>, size: usize) {
println!("invalidate @{:?}, size {size:#x}", addr);
}
}
set_impl!(Impled);
// then you can do some thing with the driver.
forked from drivercraft/dma-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Rust trait for DMA alloc and some collections
kern-crates/dma-api
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Rust trait for DMA alloc and some collections
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- Rust 100.0%