crosvm/devices/src/irqchip/aarch64.rs
Zach Reizner dc74848b7c arch: Simplify build_vm by removing closure parameters
These parameters multiplied the number of type arguments to build_vm
unnecessarily and complicated the thread of execution in the programmers
head. Closures also complicate the borrow rules, making things much
harder to change.

This change uses the results of the closures (e.g. PCI devices, IRQ
chips) as parameters instead. The rest of this change follows naturally
from pulling on that thread until tests pass.

As a result of the removal of several type arguments, the code size was
reduced by ~100KiB on a 5MiB build.

BUG=b:185170486
TEST=./test_all

Change-Id: I6bcc5eb1b1f3031d4328bb4a81ddef618d04767b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2829136
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-05-06 16:31:49 +00:00

26 lines
870 B
Rust

// 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 base::Result;
use hypervisor::DeviceKind;
use crate::IrqChip;
pub trait IrqChipAArch64: IrqChip {
// Clones this trait as a `Box` version of itself.
fn try_box_clone(&self) -> Result<Box<dyn IrqChipAArch64>>;
// Get this as the super-trait IrqChip.
fn as_irq_chip(&self) -> &dyn IrqChip;
// Get this as the mutable super-trait IrqChip.
fn as_irq_chip_mut(&mut self) -> &mut dyn IrqChip;
/// Get the version of VGIC that this chip is emulating. Currently KVM may either implement
/// VGIC version 2 or 3.
fn get_vgic_version(&self) -> DeviceKind;
/// Once all the VCPUs have been enabled, finalize the irq chip.
fn finalize(&self) -> Result<()>;
}