add vmm mod

This commit is contained in:
mii443
2025-04-14 17:51:37 +09:00
parent 19253f1d95
commit c4f610b6a2
6 changed files with 47 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ pub mod interrupts;
pub mod memory;
pub mod serial;
pub mod vga_buffer;
pub mod vmm;
use core::panic::PanicInfo;

View File

@@ -12,6 +12,7 @@ use nel_os::{
allocator,
memory::{self, BootInfoFrameAllocator},
println,
vmm::support::{has_intel_cpu, has_vmx_support},
};
use x86_64::VirtAddr;
@@ -41,6 +42,9 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! {
allocator::init_heap(&mut mapper, &mut frame_allocator).expect("heap initialization failed");
println!("has_intel_cpu: {}", has_intel_cpu());
println!("has_vmx_support: {}", has_vmx_support());
#[cfg(test)]
test_main();

1
src/vmm/mod.rs Normal file
View File

@@ -0,0 +1 @@
pub mod support;

19
src/vmm/support.rs Normal file
View File

@@ -0,0 +1,19 @@
pub fn has_intel_cpu() -> bool {
let cpuid = x86::cpuid::CpuId::new();
if let Some(vi) = cpuid.get_vendor_info() {
if vi.as_str() == "GenuineIntel" {
return true;
}
}
false
}
pub fn has_vmx_support() -> bool {
let cpuid = x86::cpuid::CpuId::new();
if let Some(fi) = cpuid.get_feature_info() {
if fi.has_vmx() {
return true;
}
}
false
}