Skip to main content

dope_core/driver/storage/
mapping.rs

1use std::mem;
2
3use dope_sys::ring::layout;
4
5use crate::driver::{
6    result,
7    result::IoOperation,
8    storage::{Address, Bytes, Count},
9};
10
11#[derive(Clone, Copy, Debug, PartialEq, Eq)]
12pub enum Mapping {
13    Unregister {
14        cause: crate::Errno,
15    },
16    Length {
17        element: Bytes,
18        count: Count,
19    },
20    Alignment {
21        element: Bytes,
22        supported: Bytes,
23    },
24    Syscall {
25        operation: IoOperation,
26        bytes: Bytes,
27        cause: result::Kernel,
28    },
29    Ring {
30        operation: IoOperation,
31        region: layout::Region,
32        bytes: Bytes,
33        cause: result::Kernel,
34    },
35    Unmap {
36        operation: IoOperation,
37        address: Address,
38        bytes: Bytes,
39        cause: result::Kernel,
40    },
41    Null {
42        operation: IoOperation,
43        bytes: Bytes,
44    },
45    RingNull {
46        operation: IoOperation,
47        region: layout::Region,
48        bytes: Bytes,
49    },
50}
51
52impl Mapping {
53    pub(crate) const fn unmap(
54        op: IoOperation,
55        address: Address,
56        bytes: Bytes,
57        cause: result::Kernel,
58    ) -> Self {
59        Self::Unmap {
60            operation: op,
61            address,
62            bytes,
63            cause,
64        }
65    }
66}
67
68const _: () = {
69    assert!(mem::size_of::<Address>() == mem::size_of::<*mut core::ffi::c_void>());
70    assert!(mem::size_of::<Bytes>() == mem::size_of::<usize>());
71};