xref: /aosp_15_r20/external/crosvm/devices/src/irqchip/aarch64.rs (revision bb4ee6a4ae7042d18b07a98463b9c8b875e44b39)
1*bb4ee6a4SAndroid Build Coastguard Worker // Copyright 2020 The ChromiumOS Authors
2*bb4ee6a4SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
3*bb4ee6a4SAndroid Build Coastguard Worker // found in the LICENSE file.
4*bb4ee6a4SAndroid Build Coastguard Worker 
5*bb4ee6a4SAndroid Build Coastguard Worker use anyhow::anyhow;
6*bb4ee6a4SAndroid Build Coastguard Worker use base::Result;
7*bb4ee6a4SAndroid Build Coastguard Worker use hypervisor::DeviceKind;
8*bb4ee6a4SAndroid Build Coastguard Worker 
9*bb4ee6a4SAndroid Build Coastguard Worker use crate::IrqChip;
10*bb4ee6a4SAndroid Build Coastguard Worker 
11*bb4ee6a4SAndroid Build Coastguard Worker pub trait IrqChipAArch64: IrqChip {
12*bb4ee6a4SAndroid Build Coastguard Worker     // Clones this trait as a `Box` version of itself.
try_box_clone(&self) -> Result<Box<dyn IrqChipAArch64>>13*bb4ee6a4SAndroid Build Coastguard Worker     fn try_box_clone(&self) -> Result<Box<dyn IrqChipAArch64>>;
14*bb4ee6a4SAndroid Build Coastguard Worker 
15*bb4ee6a4SAndroid Build Coastguard Worker     // Get this as the super-trait IrqChip.
as_irq_chip(&self) -> &dyn IrqChip16*bb4ee6a4SAndroid Build Coastguard Worker     fn as_irq_chip(&self) -> &dyn IrqChip;
17*bb4ee6a4SAndroid Build Coastguard Worker 
18*bb4ee6a4SAndroid Build Coastguard Worker     // Get this as the mutable super-trait IrqChip.
as_irq_chip_mut(&mut self) -> &mut dyn IrqChip19*bb4ee6a4SAndroid Build Coastguard Worker     fn as_irq_chip_mut(&mut self) -> &mut dyn IrqChip;
20*bb4ee6a4SAndroid Build Coastguard Worker 
21*bb4ee6a4SAndroid Build Coastguard Worker     /// Get the version of VGIC that this chip is emulating. Currently KVM may either implement
22*bb4ee6a4SAndroid Build Coastguard Worker     /// VGIC version 2 or 3.
get_vgic_version(&self) -> DeviceKind23*bb4ee6a4SAndroid Build Coastguard Worker     fn get_vgic_version(&self) -> DeviceKind;
24*bb4ee6a4SAndroid Build Coastguard Worker 
25*bb4ee6a4SAndroid Build Coastguard Worker     /// Once all the VCPUs have been enabled, finalize the irq chip.
finalize(&self) -> Result<()>26*bb4ee6a4SAndroid Build Coastguard Worker     fn finalize(&self) -> Result<()>;
27*bb4ee6a4SAndroid Build Coastguard Worker 
28*bb4ee6a4SAndroid Build Coastguard Worker     // Snapshot irqchip.
snapshot(&self, _cpus_num: usize) -> anyhow::Result<serde_json::Value>29*bb4ee6a4SAndroid Build Coastguard Worker     fn snapshot(&self, _cpus_num: usize) -> anyhow::Result<serde_json::Value> {
30*bb4ee6a4SAndroid Build Coastguard Worker         Err(anyhow!("Snapshot not yet implemented for AArch64"))
31*bb4ee6a4SAndroid Build Coastguard Worker     }
32*bb4ee6a4SAndroid Build Coastguard Worker 
restore(&mut self, _data: serde_json::Value, _vcpus_num: usize) -> anyhow::Result<()>33*bb4ee6a4SAndroid Build Coastguard Worker     fn restore(&mut self, _data: serde_json::Value, _vcpus_num: usize) -> anyhow::Result<()> {
34*bb4ee6a4SAndroid Build Coastguard Worker         Err(anyhow!("Restore not yet implemented for AArch64"))
35*bb4ee6a4SAndroid Build Coastguard Worker     }
36*bb4ee6a4SAndroid Build Coastguard Worker }
37