mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-11 04:26:38 +00:00
devices: irqchip: IrqChipX86_64 trait
This trait handles the x86-specific features of an irqchip, including getting and setting the state of the pic, ioapic, lapics, and pit. Also includes an empty implementation of this trait for the KvmKernelIrqChip. BUG=chromium:1077058 TEST=cargo test -p devices Change-Id: I36034661f4a2baedc7ac2b8f311cab6327afefba Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2197717 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Colin Downs-Razouk <colindr@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
This commit is contained in:
parent
814a8da0ed
commit
ba76624370
4 changed files with 105 additions and 0 deletions
|
@ -8,6 +8,11 @@ use std::sync::Arc;
|
|||
use sync::Mutex;
|
||||
use sys_util::{EventFd, Result};
|
||||
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
mod x86_64;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
pub use x86_64::*;
|
||||
|
||||
use crate::IrqChip;
|
||||
|
||||
/// IrqChip implementation where the entire IrqChip is emulated by KVM.
|
||||
|
|
57
devices/src/irqchip/kvm/x86_64.rs
Normal file
57
devices/src/irqchip/kvm/x86_64.rs
Normal file
|
@ -0,0 +1,57 @@
|
|||
// Copyright 2020 The Chromium OS Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
use hypervisor::kvm::KvmVcpu;
|
||||
use hypervisor::{IoapicState, LapicState, PicSelect, PicState, PitState};
|
||||
|
||||
use sys_util::Result;
|
||||
|
||||
use crate::{Bus, IrqChipX86_64, KvmKernelIrqChip};
|
||||
|
||||
impl IrqChipX86_64<KvmVcpu> for KvmKernelIrqChip {
|
||||
/// Get the current state of the PIC
|
||||
fn get_pic_state(&self, _select: PicSelect) -> Result<PicState> {
|
||||
unimplemented!("get_pic_state for KvmKernelIrqChip is not yet implemented");
|
||||
}
|
||||
|
||||
/// Set the current state of the PIC
|
||||
fn set_pic_state(&mut self, _select: PicSelect, _state: &PicState) -> Result<()> {
|
||||
unimplemented!("set_pic_state for KvmKernelIrqChip is not yet implemented");
|
||||
}
|
||||
|
||||
/// Get the current state of the IOAPIC
|
||||
fn get_ioapic_state(&self) -> Result<IoapicState> {
|
||||
unimplemented!("get_ioapic_state for KvmKernelIrqChip is not yet implemented");
|
||||
}
|
||||
|
||||
/// Set the current state of the IOAPIC
|
||||
fn set_ioapic_state(&mut self, _state: &IoapicState) -> Result<()> {
|
||||
unimplemented!("set_ioapic_state for KvmKernelIrqChip is not yet implemented");
|
||||
}
|
||||
|
||||
/// Get the current state of the specified VCPU's local APIC
|
||||
fn get_lapic_state(&self, _vcpu_id: usize) -> Result<LapicState> {
|
||||
unimplemented!("get_lapic_state for KvmKernelIrqChip is not yet implemented");
|
||||
}
|
||||
|
||||
/// Set the current state of the specified VCPU's local APIC
|
||||
fn set_lapic_state(&mut self, _vcpu_id: usize, _state: &LapicState) -> Result<()> {
|
||||
unimplemented!("set_lapic_state for KvmKernelIrqChip is not yet implemented");
|
||||
}
|
||||
|
||||
/// Create a PIT (Programmable Interval Timer) for this VM.
|
||||
fn create_pit(&mut self, _io_bus: &mut Bus) -> Result<()> {
|
||||
unimplemented!("create_pit for KvmKernelIrqChip is not yet implemented");
|
||||
}
|
||||
|
||||
/// Retrieves the state of the PIT.
|
||||
fn get_pit(&self) -> Result<PitState> {
|
||||
unimplemented!("get_pit for KvmKernelIrqChip is not yet implemented");
|
||||
}
|
||||
|
||||
/// Sets the state of the PIT.
|
||||
fn set_pit(&mut self, _state: &PitState) -> Result<()> {
|
||||
unimplemented!("set_pit for KvmKernelIrqChip is not yet implemented");
|
||||
}
|
||||
}
|
|
@ -10,6 +10,11 @@ use std::marker::{Send, Sized};
|
|||
use hypervisor::{IrqRoute, Vcpu};
|
||||
use sys_util::{EventFd, Result};
|
||||
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
mod x86_64;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
pub use x86_64::*;
|
||||
|
||||
/// Trait that abstracts interactions with interrupt controllers.
|
||||
///
|
||||
/// Each VM will have one IrqChip instance which is responsible for routing IRQ lines and
|
||||
|
|
38
devices/src/irqchip/x86_64.rs
Normal file
38
devices/src/irqchip/x86_64.rs
Normal file
|
@ -0,0 +1,38 @@
|
|||
// Copyright 2020 The Chromium OS Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
use crate::Bus;
|
||||
use hypervisor::{IoapicState, LapicState, PicSelect, PicState, PitState, VcpuX86_64};
|
||||
use sys_util::Result;
|
||||
|
||||
use crate::IrqChip;
|
||||
|
||||
pub trait IrqChipX86_64<V: VcpuX86_64>: IrqChip<V> {
|
||||
/// Get the current state of the PIC
|
||||
fn get_pic_state(&self, select: PicSelect) -> Result<PicState>;
|
||||
|
||||
/// Set the current state of the PIC
|
||||
fn set_pic_state(&mut self, select: PicSelect, state: &PicState) -> Result<()>;
|
||||
|
||||
/// Get the current state of the IOAPIC
|
||||
fn get_ioapic_state(&self) -> Result<IoapicState>;
|
||||
|
||||
/// Set the current state of the IOAPIC
|
||||
fn set_ioapic_state(&mut self, state: &IoapicState) -> Result<()>;
|
||||
|
||||
/// Get the current state of the specified VCPU's local APIC
|
||||
fn get_lapic_state(&self, vcpu_id: usize) -> Result<LapicState>;
|
||||
|
||||
/// Set the current state of the specified VCPU's local APIC
|
||||
fn set_lapic_state(&mut self, vcpu_id: usize, state: &LapicState) -> Result<()>;
|
||||
|
||||
/// Create a PIT (Programmable Interval Timer) for this VM.
|
||||
fn create_pit(&mut self, io_bus: &mut Bus) -> Result<()>;
|
||||
|
||||
/// Retrieves the state of the PIT.
|
||||
fn get_pit(&self) -> Result<PitState>;
|
||||
|
||||
/// Sets the state of the PIT.
|
||||
fn set_pit(&mut self, state: &PitState) -> Result<()>;
|
||||
}
|
Loading…
Reference in a new issue