Merge "Introduce VirtualMachineAppConfig::CustomConfig struct"
diff --git a/pvmfw/src/entry.rs b/pvmfw/src/entry.rs
index 2582d55..78383d2 100644
--- a/pvmfw/src/entry.rs
+++ b/pvmfw/src/entry.rs
@@ -20,7 +20,6 @@
 use crate::fdt;
 use crate::heap;
 use crate::memory;
-use crate::rand;
 use core::arch::asm;
 use core::mem::{drop, size_of};
 use core::num::NonZeroUsize;
@@ -39,6 +38,7 @@
     logger, main,
     memory::{min_dcache_line_size, MemoryTracker, MEMORY, SIZE_128KB, SIZE_4KB},
     power::reboot,
+    rand,
 };
 use zeroize::Zeroize;
 
diff --git a/pvmfw/src/instance.rs b/pvmfw/src/instance.rs
index 56468b2..1035559 100644
--- a/pvmfw/src/instance.rs
+++ b/pvmfw/src/instance.rs
@@ -21,7 +21,6 @@
 use crate::gpt;
 use crate::gpt::Partition;
 use crate::gpt::Partitions;
-use crate::rand;
 use core::fmt;
 use core::mem::size_of;
 use diced_open_dice::DiceMode;
@@ -30,6 +29,7 @@
 use log::trace;
 use uuid::Uuid;
 use virtio_drivers::transport::{pci::bus::PciRoot, DeviceType, Transport};
+use vmbase::rand;
 use vmbase::util::ceiling_div;
 use vmbase::virtio::pci::{PciTransportIterator, VirtIOBlk};
 use zerocopy::AsBytes;
diff --git a/pvmfw/src/main.rs b/pvmfw/src/main.rs
index c826cd8..8c5d5d5 100644
--- a/pvmfw/src/main.rs
+++ b/pvmfw/src/main.rs
@@ -30,10 +30,8 @@
 mod gpt;
 mod heap;
 mod helpers;
-mod hvc;
 mod instance;
 mod memory;
-mod rand;
 
 use crate::bcc::Bcc;
 use crate::dice::PartialInputs;
diff --git a/pvmfw/src/hvc.rs b/vmbase/src/hvc.rs
similarity index 95%
rename from pvmfw/src/hvc.rs
rename to vmbase/src/hvc.rs
index e03c9d3..9a5e716 100644
--- a/pvmfw/src/hvc.rs
+++ b/vmbase/src/hvc.rs
@@ -21,7 +21,6 @@
     hvc64,
 };
 
-// TODO(b/272226230): Move all the trng functions to trng module
 const ARM_SMCCC_TRNG_VERSION: u32 = 0x8400_0050;
 #[allow(dead_code)]
 const ARM_SMCCC_TRNG_FEATURES: u32 = 0x8400_0051;
diff --git a/pvmfw/src/hvc/trng.rs b/vmbase/src/hvc/trng.rs
similarity index 100%
rename from pvmfw/src/hvc/trng.rs
rename to vmbase/src/hvc/trng.rs
diff --git a/vmbase/src/lib.rs b/vmbase/src/lib.rs
index 54f3384..7fc7b20 100644
--- a/vmbase/src/lib.rs
+++ b/vmbase/src/lib.rs
@@ -23,11 +23,13 @@
 pub mod console;
 mod entry;
 pub mod fdt;
+mod hvc;
 pub mod layout;
 mod linker;
 pub mod logger;
 pub mod memory;
 pub mod power;
+pub mod rand;
 pub mod uart;
 pub mod util;
 pub mod virtio;
diff --git a/pvmfw/src/rand.rs b/vmbase/src/rand.rs
similarity index 94%
rename from pvmfw/src/rand.rs
rename to vmbase/src/rand.rs
index b45538a..00567b8 100644
--- a/pvmfw/src/rand.rs
+++ b/vmbase/src/rand.rs
@@ -12,10 +12,13 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+//! Functions and drivers for obtaining true entropy.
+
 use crate::hvc;
 use core::fmt;
 use core::mem::size_of;
 
+/// Error type for rand operations.
 pub enum Error {
     /// Error during SMCCC TRNG call.
     Trng(hvc::trng::Error),
@@ -29,6 +32,7 @@
     }
 }
 
+/// Result type for rand operations.
 pub type Result<T> = core::result::Result<T, Error>;
 
 impl fmt::Display for Error {
@@ -96,6 +100,7 @@
     }
 }
 
+/// Generate an array of fixed-size initialized with true-random bytes.
 pub fn random_array<const N: usize>() -> Result<[u8; N]> {
     let mut arr = [0; N];
     fill_with_entropy(&mut arr)?;