wip
This commit is contained in:
@ -15,7 +15,7 @@ pub trait VCpu {
|
||||
fn is_supported() -> bool
|
||||
where
|
||||
Self: Sized;
|
||||
fn run(&mut self);
|
||||
fn run(&mut self) -> Result<(), &'static str>;
|
||||
}
|
||||
|
||||
pub fn get_vcpu(
|
||||
|
@ -9,8 +9,10 @@ use crate::{
|
||||
pub struct AMDVCpu;
|
||||
|
||||
impl VCpu for AMDVCpu {
|
||||
fn run(&mut self) {
|
||||
fn run(&mut self) -> Result<(), &'static str> {
|
||||
info!("VCpu on AMD");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn new(_frame_allocator: &mut impl FrameAllocator<Size4KiB>) -> Result<Self, &'static str>
|
||||
|
4
nel_os_kernel/src/vmm/x86_64/intel/controls.rs
Normal file
4
nel_os_kernel/src/vmm/x86_64/intel/controls.rs
Normal file
@ -0,0 +1,4 @@
|
||||
pub fn setup_exec_controls() -> Result<(), &'static str> {
|
||||
// TODO
|
||||
Ok(())
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
mod controls;
|
||||
mod vmcs;
|
||||
mod vmxon;
|
||||
|
||||
@ -15,12 +16,30 @@ use crate::{
|
||||
};
|
||||
|
||||
pub struct IntelVCpu {
|
||||
activated: bool,
|
||||
vmxon: vmxon::Vmxon,
|
||||
vmcs: vmcs::Vmcs,
|
||||
}
|
||||
|
||||
impl IntelVCpu {
|
||||
fn activate(&mut self) -> Result<(), &'static str> {
|
||||
self.vmcs.reset();
|
||||
controls::setup_exec_controls()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl VCpu for IntelVCpu {
|
||||
fn run(&mut self) {
|
||||
fn run(&mut self) -> Result<(), &'static str> {
|
||||
info!("VCpu on Intel");
|
||||
|
||||
if !self.activated {
|
||||
self.activate()?;
|
||||
self.activated = true;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn new(frame_allocator: &mut impl FrameAllocator<Size4KiB>) -> Result<Self, &'static str>
|
||||
@ -43,7 +62,13 @@ impl VCpu for IntelVCpu {
|
||||
|
||||
vmxon.activate()?;
|
||||
|
||||
Ok(IntelVCpu { vmxon })
|
||||
let vmcs = vmcs::Vmcs::new(frame_allocator)?;
|
||||
|
||||
Ok(IntelVCpu {
|
||||
activated: false,
|
||||
vmxon,
|
||||
vmcs,
|
||||
})
|
||||
}
|
||||
|
||||
fn is_supported() -> bool
|
||||
|
Reference in New Issue
Block a user