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