Skip to main content

xen/foreignmemory/
mod.rs

1mod handle;
2pub use self::handle::XenForeignMemoryHandle;
3
4mod mapped;
5use std::rc::Rc;
6
7pub use self::mapped::XenForeignMemoryMapped;
8use crate::{XenDomainId, XenError};
9
10bitflags::bitflags! {
11    #[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
12    pub struct XenForeignMemoryProtection: i32 {
13        const READ = libc::PROT_READ;
14        const WRITE = libc::PROT_WRITE;
15        const EXECUTE = libc::PROT_EXEC;
16    }
17}
18
19#[derive(Debug, Clone)]
20pub struct XenForeignMemory {
21    pub(crate) handle: Rc<XenForeignMemoryHandle>,
22}
23
24impl XenForeignMemory {
25    pub fn new() -> Result<Self, XenError> {
26        Ok(Self {
27            handle: Rc::new(XenForeignMemoryHandle::new()?),
28        })
29    }
30
31    pub fn map(
32        &self,
33        domain_id: XenDomainId,
34        protection: XenForeignMemoryProtection,
35        arr: &[u64],
36        err: Option<&mut [i32]>,
37    ) -> Result<XenForeignMemoryMapped, XenError> {
38        XenForeignMemoryMapped::new(self.clone(), domain_id, protection, arr, err)
39    }
40}