mirror of
https://github.com/mii443/nel_os.git
synced 2025-08-22 16:15:38 +00:00
add vmm mod
This commit is contained in:
21
Cargo.lock
generated
21
Cargo.lock
generated
@ -72,6 +72,7 @@ dependencies = [
|
||||
"spin 0.5.2",
|
||||
"uart_16550",
|
||||
"volatile 0.2.7",
|
||||
"x86",
|
||||
"x86_64 0.14.13",
|
||||
]
|
||||
|
||||
@ -90,6 +91,15 @@ dependencies = [
|
||||
"x86_64 0.15.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raw-cpuid"
|
||||
version = "10.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.20"
|
||||
@ -146,6 +156,17 @@ version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "442887c63f2c839b346c192d047a7c87e73d0689c9157b00b53dcc27dd5ea793"
|
||||
|
||||
[[package]]
|
||||
name = "x86"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2781db97787217ad2a2845c396a5efe286f87467a5810836db6d74926e94a385"
|
||||
dependencies = [
|
||||
"bit_field",
|
||||
"bitflags 1.3.2",
|
||||
"raw-cpuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "x86_64"
|
||||
version = "0.14.13"
|
||||
|
@ -12,6 +12,7 @@ uart_16550 = "0.2.0"
|
||||
pic8259 = "0.11.0"
|
||||
pc-keyboard = "0.8.0"
|
||||
linked_list_allocator = "0.9.0"
|
||||
x86 = "0.52.0"
|
||||
|
||||
[dependencies.lazy_static]
|
||||
version = "1.0"
|
||||
|
@ -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