• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use super::common::Hypervisor;
2 use super::DeviceAssigningHypervisor;
3 use crate::{Error, Result};
4 use thiserror::Error;
5 use uuid::{uuid, Uuid};
6 
7 const SIZE_4KB: usize = 4 << 10;
8 
9 pub(super) struct GunyahHypervisor;
10 
11 /// Error from a Gunyah HVC call.
12 #[derive(Copy, Clone, Debug, Eq, Error, PartialEq)]
13 pub enum GunyahError {
14     /// The call is not supported by the implementation.
15     #[error("Gunyah call not supported")]
16     NotSupported,
17 }
18 
19 impl GunyahHypervisor {
20     pub const UUID: Uuid = uuid!("c1d58fcd-a453-5fdb-9265-ce36673d5f14");
21 }
22 
23 impl Hypervisor for GunyahHypervisor {
as_device_assigner(&self) -> Option<&dyn DeviceAssigningHypervisor>24     fn as_device_assigner(&self) -> Option<&dyn DeviceAssigningHypervisor> {
25         Some(self)
26     }
27 
get_granule_size(&self) -> Option<usize>28     fn get_granule_size(&self) -> Option<usize> {
29         Some(SIZE_4KB)
30     }
31 }
32 
33 impl DeviceAssigningHypervisor for GunyahHypervisor {
get_phys_mmio_token(&self, base_ipa: u64) -> Result<u64>34     fn get_phys_mmio_token(&self, base_ipa: u64) -> Result<u64> {
35         // PA = IPA for now.
36         Ok(base_ipa)
37     }
38 
get_phys_iommu_token(&self, _pviommu_id: u64, _vsid: u64) -> Result<(u64, u64)>39     fn get_phys_iommu_token(&self, _pviommu_id: u64, _vsid: u64) -> Result<(u64, u64)> {
40         Err(Error::GunyahError(GunyahError::NotSupported))
41     }
42 }
43