This commit is contained in:
mii443
2025-08-03 21:47:34 +09:00
parent 68dd963738
commit 9ff305ad24
7 changed files with 55 additions and 9 deletions

View File

@ -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;

View File

@ -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();
}

View File

@ -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");
}
}

View File

@ -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");
}
}

View 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");
}
}

View File

@ -0,0 +1,3 @@
pub mod amd;
pub mod common;
pub mod intel;