forked from microsoft/openvmm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdma.rs
More file actions
31 lines (27 loc) · 820 Bytes
/
dma.rs
File metadata and controls
31 lines (27 loc) · 820 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#[derive(Debug)]
pub enum DmaError {
InitializationFailed,
MapFailed,
UnmapFailed,
PinFailed,
BounceBufferFailed,
}
// Structure encapsulating the result of a DMA mapping operation
pub struct DmaTransactionHandler {
pub transactions: Vec<DmaTransaction>,
}
// Structure representing a DMA transaction with address and metadata
pub struct DmaTransaction {
pub original_addr: usize,
pub dma_addr: usize,
pub size: usize,
pub is_pinned: bool,
pub is_bounce_buffer: bool,
pub is_physical: bool,
pub is_prepinned: bool,
}
// Trait for the DMA interface
pub trait DmaInterface {
fn map_dma_ranges(&self, ranges: &[MemoryRange]) -> Result<DmaTransactionHandler, DmaError>;
fn unmap_dma_ranges(&self, dma_transactions: &[DmaTransaction]) -> Result<(), DmaError>;
}