From f1f9a52153ccfa185181a4ec63287d2de4662504 Mon Sep 17 00:00:00 2001 From: Stefan Butz Date: Fri, 10 Jul 2026 15:08:25 +0200 Subject: [PATCH] Add support for entropy device --- src/entropy.rs | 19 +++++++++++++++++++ src/features.rs | 13 +++++++++++++ src/lib.rs | 3 ++- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/entropy.rs diff --git a/src/entropy.rs b/src/entropy.rs new file mode 100644 index 0000000..e782ecc --- /dev/null +++ b/src/entropy.rs @@ -0,0 +1,19 @@ +use volatile_macro::VolatileFieldAccess; + +pub use super::features::entropy::F; + +/// Entropy Device Configuration Layout +/// +/// Use [`ConfigVolatileFieldAccess`] to work with this struct. +#[doc(alias = "virtio_entropy_config")] +#[cfg_attr( + feature = "zerocopy", + derive( + zerocopy_derive::KnownLayout, + zerocopy_derive::Immutable, + zerocopy_derive::FromBytes, + ) +)] +#[derive(VolatileFieldAccess)] +#[repr(C)] +pub struct Config {} diff --git a/src/features.rs b/src/features.rs index 9443069..5dca303 100644 --- a/src/features.rs +++ b/src/features.rs @@ -369,6 +369,19 @@ pub mod console { impl crate::FeatureBits for F {} } +pub mod entropy { + use crate::le128; + + feature_bits! { + /// Entropy Device Feature Bits + #[doc(alias = "VIRTIO_ENTROPY_F")] + pub struct F: le128 { + } + } + + impl crate::FeatureBits for F {} +} + pub mod net { use crate::le128; diff --git a/src/lib.rs b/src/lib.rs index 03bf587..c8afe80 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -66,7 +66,7 @@ //! | Network Device | ✅ | [`net`] | //! | Block Device | ❌ | | //! | Console Device | ✅ | [`console`] | -//! | Entropy Device | ❌ | | +//! | Entropy Device | ✅ | [`entropy`] | //! | Traditional Memory Balloon Device | ✅ | [`balloon`] | //! | SCSI Host Device | ❌ | | //! | GPU Device | ❌ | | @@ -98,6 +98,7 @@ pub mod balloon; pub mod console; #[cfg(any(feature = "mmio", feature = "pci"))] mod driver_notifications; +pub mod entropy; mod features; pub mod fs; #[cfg(feature = "mmio")]