wip
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
use acpi::PlatformInfo;
|
||||
use alloc::alloc::Global;
|
||||
use spin::{Lazy, Once};
|
||||
use spin::Once;
|
||||
use x86_64::instructions::port::Port;
|
||||
|
||||
use crate::interrupt::idt::IRQ_TIMER;
|
||||
|
@ -157,13 +157,8 @@ pub extern "sysv64" fn main(boot_info: &nel_os_common::BootInfo) {
|
||||
|
||||
info!("Interrupts enabled");
|
||||
|
||||
if platform::is_amd() {
|
||||
info!("AMD CPU detected");
|
||||
} else if platform::is_intel() {
|
||||
info!("Intel CPU detected");
|
||||
} else {
|
||||
info!("Unknown CPU vendor");
|
||||
}
|
||||
let mut vcpu = vmm::get_vcpu();
|
||||
vcpu.run();
|
||||
|
||||
hlt_loop();
|
||||
}
|
||||
|
@ -1,4 +1,22 @@
|
||||
use alloc::boxed::Box;
|
||||
|
||||
use crate::{
|
||||
platform,
|
||||
vmm::x86_64::{amd::AMDVCpu, intel::IntelVCpu},
|
||||
};
|
||||
|
||||
pub mod x86_64;
|
||||
|
||||
pub trait VCpu {
|
||||
fn init() -> Self;
|
||||
fn run(&mut self);
|
||||
}
|
||||
|
||||
pub fn get_vcpu() -> Box<dyn VCpu> {
|
||||
if platform::is_amd() {
|
||||
Box::new(AMDVCpu::new())
|
||||
} else if platform::is_intel() {
|
||||
Box::new(IntelVCpu::new())
|
||||
} else {
|
||||
panic!("Unsupported CPU architecture");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
use crate::{info, vmm::VCpu};
|
||||
|
||||
pub struct AMDVCpu;
|
||||
|
||||
impl AMDVCpu {
|
||||
pub fn new() -> Self {
|
||||
AMDVCpu
|
||||
}
|
||||
}
|
||||
|
||||
impl VCpu for AMDVCpu {
|
||||
fn run(&mut self) {
|
||||
info!("VCpu on AMD");
|
||||
}
|
||||
}
|
||||
|
0
nel_os_kernel/src/vmm/x86_64/common/mod.rs
Normal file
0
nel_os_kernel/src/vmm/x86_64/common/mod.rs
Normal file
@ -0,0 +1,15 @@
|
||||
use crate::{info, vmm::VCpu};
|
||||
|
||||
pub struct IntelVCpu;
|
||||
|
||||
impl IntelVCpu {
|
||||
pub fn new() -> Self {
|
||||
IntelVCpu
|
||||
}
|
||||
}
|
||||
|
||||
impl VCpu for IntelVCpu {
|
||||
fn run(&mut self) {
|
||||
info!("VCpu on Intel");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,3 @@
|
||||
pub mod amd;
|
||||
pub mod common;
|
||||
pub mod intel;
|
||||
|
Reference in New Issue
Block a user