From b4aadd583413844bc63aba0dc912ac89a1f440c0 Mon Sep 17 00:00:00 2001
From: Stefan Lankes <slankes@eonerc.rwth-aachen.de>
Date: Sat, 29 Apr 2023 08:24:54 +0200
Subject: [PATCH] move hardware independent functions is_uhyve to env

---
 src/arch/x86_64/kernel/mod.rs | 7 +------
 src/env.rs                    | 9 ++++++++-
 src/lib.rs                    | 2 +-
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/arch/x86_64/kernel/mod.rs b/src/arch/x86_64/kernel/mod.rs
index 5284b1eb8..7eeec9058 100644
--- a/src/arch/x86_64/kernel/mod.rs
+++ b/src/arch/x86_64/kernel/mod.rs
@@ -9,7 +9,7 @@ use x86::controlregs::{cr0, cr0_write, cr4, Cr0};
 use self::serial::SerialPort;
 use crate::arch::mm::{PhysAddr, VirtAddr};
 use crate::arch::x86_64::kernel::core_local::*;
-use crate::env;
+use crate::env::{self, is_uhyve};
 
 #[cfg(feature = "acpi")]
 pub mod acpi;
@@ -141,11 +141,6 @@ pub fn get_processor_count() -> u32 {
 	1
 }
 
-/// Whether HermitCore is running under the "uhyve" hypervisor.
-pub fn is_uhyve() -> bool {
-	matches!(boot_info().platform_info, PlatformInfo::Uhyve { .. })
-}
-
 pub fn is_uhyve_with_pci() -> bool {
 	match boot_info().platform_info {
 		PlatformInfo::Multiboot { .. } => false,
diff --git a/src/env.rs b/src/env.rs
index e7dac28f9..b7e788b9f 100644
--- a/src/env.rs
+++ b/src/env.rs
@@ -7,12 +7,14 @@ use core::{slice, str};
 use ahash::RandomState;
 use hashbrown::hash_map::Iter;
 use hashbrown::HashMap;
+use hermit_entry::boot_info::PlatformInfo;
 use hermit_sync::OnceCell;
 
 pub use crate::arch::kernel::{
 	get_base_address, get_cmdline, get_cmdsize, get_image_size, get_ram_address, get_tls_align,
-	get_tls_filesz, get_tls_memsz, get_tls_start, is_uhyve,
+	get_tls_filesz, get_tls_memsz, get_tls_start,
 };
+use crate::kernel::boot_info;
 
 static CLI: OnceCell<Cli> = OnceCell::new();
 
@@ -29,6 +31,11 @@ struct Cli {
 	args: Vec<String>,
 }
 
+/// Whether HermitCore is running under the "uhyve" hypervisor.
+pub fn is_uhyve() -> bool {
+	matches!(boot_info().platform_info, PlatformInfo::Uhyve { .. })
+}
+
 fn get_cmdline_str() -> &'static str {
 	let cmdsize = get_cmdsize();
 	let cmdline = get_cmdline().as_ptr::<u8>();
diff --git a/src/lib.rs b/src/lib.rs
index 3eef3c77b..582daa549 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -47,7 +47,7 @@ use core::sync::atomic::{AtomicU32, Ordering};
 use arch::core_local::*;
 // Used for integration test status.
 #[doc(hidden)]
-pub use arch::kernel::is_uhyve as _is_uhyve;
+pub use env::is_uhyve as _is_uhyve;
 use mm::allocator::LockedAllocator;
 #[cfg(target_arch = "aarch64")]
 use qemu_exit::QEMUExit;
-- 
GitLab