vm_memory/
lib.rs

1// Portions Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2//
3// Portions Copyright 2017 The Chromium OS Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style license that can be
5// found in the LICENSE-BSD-3-Clause file.
6//
7// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
8
9//! Traits for allocating, handling and interacting with the VM's physical memory.
10//!
11//! For a typical hypervisor, there are several components, such as boot loader, virtual device
12//! drivers, virtio backend drivers and vhost drivers etc, that need to access VM's physical memory.
13//! This crate aims to provide a set of stable traits to decouple VM memory consumers from VM
14//! memory providers. Based on these traits, VM memory consumers could access VM's physical memory
15//! without knowing the implementation details of the VM memory provider. Thus hypervisor
16//! components, such as boot loader, virtual device drivers, virtio backend drivers and vhost
17//! drivers etc, could be shared and reused by multiple hypervisors.
18
19#![deny(clippy::doc_markdown)]
20#![deny(missing_docs)]
21
22#[macro_use]
23pub mod address;
24pub use address::{Address, AddressValue};
25
26#[cfg(feature = "backend-atomic")]
27pub mod atomic;
28#[cfg(feature = "backend-atomic")]
29pub use atomic::{GuestMemoryAtomic, GuestMemoryLoadGuard};
30
31mod atomic_integer;
32pub use atomic_integer::AtomicInteger;
33
34pub mod bitmap;
35
36pub mod bytes;
37pub use bytes::{AtomicAccess, ByteValued, Bytes};
38
39pub mod endian;
40pub use endian::{Be16, Be32, Be64, BeSize, Le16, Le32, Le64, LeSize};
41
42pub mod guest_memory;
43pub use guest_memory::{
44    Error as GuestMemoryError, FileOffset, GuestAddress, GuestAddressSpace, GuestMemory,
45    GuestMemoryRegion, GuestUsize, MemoryRegionAddress, Result as GuestMemoryResult,
46};
47
48#[cfg(all(feature = "backend-mmap", unix))]
49mod mmap_unix;
50
51#[cfg(all(feature = "backend-mmap", windows))]
52mod mmap_windows;
53
54#[cfg(feature = "backend-mmap")]
55pub mod mmap;
56#[cfg(feature = "backend-mmap")]
57pub use mmap::{Error, GuestMemoryMmap, GuestRegionMmap, MmapRegion};
58
59pub mod volatile_memory;
60pub use volatile_memory::{
61    Error as VolatileMemoryError, Result as VolatileMemoryResult, VolatileArrayRef, VolatileMemory,
62    VolatileRef, VolatileSlice,
63};