mirror of
https://github.com/mii443/nel_os.git
synced 2025-12-03 03:08:25 +00:00
add vmm mod
This commit is contained in:
@@ -14,6 +14,7 @@ pub mod interrupts;
|
||||
pub mod memory;
|
||||
pub mod serial;
|
||||
pub mod vga_buffer;
|
||||
pub mod vmm;
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
|
||||
@@ -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
1
src/vmm/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod support;
|
||||
19
src/vmm/support.rs
Normal file
19
src/vmm/support.rs
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user