mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-21 19:02:30 +00:00
arch: Code cleanup after refactoring aarch64
Signed-off-by: Michael Zhao <michael.zhao@arm.com>
This commit is contained in:
parent
ddf1b76906
commit
f57d970451
@ -47,11 +47,11 @@ pub trait GICDevice {
|
||||
}
|
||||
|
||||
pub mod kvm {
|
||||
use super::super::gicv2::kvm::KvmGICv2;
|
||||
use super::super::gicv3::kvm::KvmGICv3;
|
||||
use super::super::gicv3_its::kvm::KvmGICv3ITS;
|
||||
use super::GICDevice;
|
||||
use super::Result;
|
||||
use crate::aarch64::gicv2::kvm::KvmGICv2;
|
||||
use crate::aarch64::gicv3::kvm::KvmGICv3;
|
||||
use crate::aarch64::gicv3_its::kvm::KvmGICv3ITS;
|
||||
use crate::layout;
|
||||
use hypervisor::kvm::kvm_bindings;
|
||||
use std::boxed::Box;
|
||||
@ -60,31 +60,22 @@ pub mod kvm {
|
||||
/// Trait for GIC devices.
|
||||
pub trait KvmGICDevice: Send + Sync + GICDevice {
|
||||
/// Returns the GIC version of the device
|
||||
fn version() -> u32
|
||||
where
|
||||
Self: Sized;
|
||||
fn version() -> u32;
|
||||
|
||||
/// Create the GIC device object
|
||||
fn create_device(
|
||||
device: Arc<dyn hypervisor::Device>,
|
||||
vcpu_count: u64,
|
||||
) -> Box<dyn GICDevice>
|
||||
where
|
||||
Self: Sized;
|
||||
) -> Box<dyn GICDevice>;
|
||||
|
||||
/// Setup the device-specific attributes
|
||||
fn init_device_attributes(
|
||||
vm: &Arc<dyn hypervisor::Vm>,
|
||||
gic_device: &Box<dyn GICDevice>,
|
||||
) -> Result<()>
|
||||
where
|
||||
Self: Sized;
|
||||
) -> Result<()>;
|
||||
|
||||
/// Initialize a GIC device
|
||||
fn init_device(vm: &Arc<dyn hypervisor::Vm>) -> Result<Arc<dyn hypervisor::Device>>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
fn init_device(vm: &Arc<dyn hypervisor::Vm>) -> Result<Arc<dyn hypervisor::Device>> {
|
||||
let mut gic_device = kvm_bindings::kvm_create_device {
|
||||
type_: Self::version(),
|
||||
fd: 0,
|
||||
@ -102,10 +93,7 @@ pub mod kvm {
|
||||
attr: u64,
|
||||
addr: u64,
|
||||
flags: u32,
|
||||
) -> Result<()>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
) -> Result<()> {
|
||||
let attr = kvm_bindings::kvm_device_attr {
|
||||
group: group,
|
||||
attr: attr,
|
||||
@ -120,10 +108,7 @@ pub mod kvm {
|
||||
}
|
||||
|
||||
/// Finalize the setup of a GIC device
|
||||
fn finalize_device(gic_device: &Box<dyn GICDevice>) -> Result<()>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
fn finalize_device(gic_device: &Box<dyn GICDevice>) -> Result<()> {
|
||||
/* We need to tell the kernel how many irqs to support with this vgic.
|
||||
* See the `layout` module for details.
|
||||
*/
|
||||
@ -152,10 +137,7 @@ pub mod kvm {
|
||||
}
|
||||
|
||||
/// Method to initialize the GIC device
|
||||
fn new(vm: &Arc<dyn hypervisor::Vm>, vcpu_count: u64) -> Result<Box<dyn GICDevice>>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
fn new(vm: &Arc<dyn hypervisor::Vm>, vcpu_count: u64) -> Result<Box<dyn GICDevice>> {
|
||||
let vgic_fd = Self::init_device(vm)?;
|
||||
|
||||
let device = Self::create_device(vgic_fd, vcpu_count);
|
||||
|
@ -2,8 +2,8 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
pub mod kvm {
|
||||
use super::super::gic::kvm::KvmGICDevice;
|
||||
use super::super::gic::{Error, GICDevice};
|
||||
use crate::aarch64::gic::kvm::KvmGICDevice;
|
||||
use crate::aarch64::gic::{Error, GICDevice};
|
||||
use std::{boxed::Box, result};
|
||||
type Result<T> = result::Result<T, Error>;
|
||||
use crate::layout;
|
||||
@ -12,7 +12,7 @@ pub mod kvm {
|
||||
|
||||
/// Represent a GIC v2 device
|
||||
pub struct KvmGICv2 {
|
||||
/// The file descriptor for the KVM device
|
||||
/// The hypervisor agnostic device
|
||||
device: Arc<dyn hypervisor::Device>,
|
||||
|
||||
/// GIC device properties, to be used for setting up the fdt entry
|
||||
|
@ -2,8 +2,8 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
pub mod kvm {
|
||||
use super::super::gic::kvm::KvmGICDevice;
|
||||
use super::super::gic::{Error, GICDevice};
|
||||
use crate::aarch64::gic::kvm::KvmGICDevice;
|
||||
use crate::aarch64::gic::{Error, GICDevice};
|
||||
use crate::layout;
|
||||
use hypervisor::kvm::kvm_bindings;
|
||||
use std::sync::Arc;
|
||||
@ -11,7 +11,7 @@ pub mod kvm {
|
||||
type Result<T> = result::Result<T, Error>;
|
||||
|
||||
pub struct KvmGICv3 {
|
||||
/// The file descriptor for the KVM device
|
||||
/// The hypervisor agnostic device
|
||||
device: Arc<dyn hypervisor::Device>,
|
||||
|
||||
/// GIC device properties, to be used for setting up the fdt entry
|
||||
|
@ -5,13 +5,13 @@ pub mod kvm {
|
||||
use std::sync::Arc;
|
||||
use std::{boxed::Box, result};
|
||||
type Result<T> = result::Result<T, Error>;
|
||||
use super::super::gic::kvm::KvmGICDevice;
|
||||
use super::super::gic::{Error, GICDevice};
|
||||
use super::super::gicv3::kvm::KvmGICv3;
|
||||
use crate::aarch64::gic::kvm::KvmGICDevice;
|
||||
use crate::aarch64::gic::{Error, GICDevice};
|
||||
use crate::aarch64::gicv3::kvm::KvmGICv3;
|
||||
use hypervisor::kvm::kvm_bindings;
|
||||
|
||||
pub struct KvmGICv3ITS {
|
||||
/// The file descriptor for the KVM device
|
||||
/// The hypervisor agnostic device
|
||||
device: Arc<dyn hypervisor::Device>,
|
||||
|
||||
/// GIC device properties, to be used for setting up the fdt entry
|
||||
|
Loading…
x
Reference in New Issue
Block a user