xref: /cloud-hypervisor/vm-device/src/dma_mapping/mod.rs (revision fa7a000dbe9637eb256af18ae8c3c4a8d5bf9c8f)
1 // Copyright © 2021 Intel Corporation
2 //
3 // SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
4 
5 /// Trait meant for triggering the DMA mapping update related to an external
6 /// device not managed fully through virtio. It is dedicated to virtio-iommu
7 /// in order to trigger the map update anytime the mapping is updated from the
8 /// guest.
9 pub trait ExternalDmaMapping: Send + Sync {
10     /// Map a memory range
11     fn map(&self, iova: u64, gpa: u64, size: u64) -> std::result::Result<(), std::io::Error>;
12 
13     /// Unmap a memory range
14     fn unmap(&self, iova: u64, size: u64) -> std::result::Result<(), std::io::Error>;
15 }
16