fn read_common_config(
        &self,
        device: &Arc<Mutex<dyn VirtioDevice>>,
        offset: u64,
    ) -> PciResult<u32> {
        let value = match offset {
            COMMON_DFSELECT_REG => self.features_select,
            COMMON_DF_REG => device
                .lock()
                .unwrap()
                .get_device_features(self.features_select),
            COMMON_GFSELECT_REG => self.acked_features_select,
            COMMON_MSIX_REG => self.msix_config.load(Ordering::SeqCst) as u32,
            COMMON_NUMQ_REG => self.queues_config.len() as u32,
            COMMON_STATUS_REG => self.device_status,
            COMMON_CFGGENERATION_REG => self.config_generation,
            COMMON_Q_SELECT_REG => self.queue_select as u32,
            COMMON_Q_SIZE_REG => self
                .get_queue_config()
                .map(|config| u32::from(config.max_size))?,
            COMMON_Q_MSIX_REG => self
                .get_queue_config()
                .map(|config| u32::from(config.vector))?,
            COMMON_Q_ENABLE_REG => self
                .get_queue_config()
                .map(|config| u32::from(config.ready))?,
            COMMON_Q_NOFF_REG => self.queue_select as u32,
            COMMON_Q_DESCLO_REG => self
                .get_queue_config()
                .map(|config| config.desc_table.0 as u32)?,
            COMMON_Q_DESCHI_REG => self
                .get_queue_config()
                .map(|config| (config.desc_table.0 >> 32) as u32)?,
            COMMON_Q_AVAILLO_REG => self
                .get_queue_config()
                .map(|config| config.avail_ring.0 as u32)?,
            COMMON_Q_AVAILHI_REG => self
                .get_queue_config()
                .map(|config| (config.avail_ring.0 >> 32) as u32)?,
            COMMON_Q_USEDLO_REG => self
                .get_queue_config()
                .map(|config| config.used_ring.0 as u32)?,
            COMMON_Q_USEDHI_REG => self
                .get_queue_config()
                .map(|config| (config.used_ring.0 >> 32) as u32)?,
            _ => {
                return Err(ErrorKind::PciRegister(offset).into());
            }
        };

        Ok(value)
    }
/// Read data from the common config of virtio device.
/// Return the config value in u32.
///
/// # Arguments
///
/// * `device` - Virtio device entity.
/// * `offset` - The offset of common config.
Read data from the common config of virtio device.
Return the config value in u32.
Read data from the common config of virtio device . Return the config value in u32 .
fn read_common_config(
        &self,
        device: &Arc<Mutex<dyn VirtioDevice>>,
        offset: u64,
    ) -> PciResult<u32> {
        let value = match offset {
            COMMON_DFSELECT_REG => self.features_select,
            COMMON_DF_REG => device
                .lock()
                .unwrap()
                .get_device_features(self.features_select),
            COMMON_GFSELECT_REG => self.acked_features_select,
            COMMON_MSIX_REG => self.msix_config.load(Ordering::SeqCst) as u32,
            COMMON_NUMQ_REG => self.queues_config.len() as u32,
            COMMON_STATUS_REG => self.device_status,
            COMMON_CFGGENERATION_REG => self.config_generation,
            COMMON_Q_SELECT_REG => self.queue_select as u32,
            COMMON_Q_SIZE_REG => self
                .get_queue_config()
                .map(|config| u32::from(config.max_size))?,
            COMMON_Q_MSIX_REG => self
                .get_queue_config()
                .map(|config| u32::from(config.vector))?,
            COMMON_Q_ENABLE_REG => self
                .get_queue_config()
                .map(|config| u32::from(config.ready))?,
            COMMON_Q_NOFF_REG => self.queue_select as u32,
            COMMON_Q_DESCLO_REG => self
                .get_queue_config()
                .map(|config| config.desc_table.0 as u32)?,
            COMMON_Q_DESCHI_REG => self
                .get_queue_config()
                .map(|config| (config.desc_table.0 >> 32) as u32)?,
            COMMON_Q_AVAILLO_REG => self
                .get_queue_config()
                .map(|config| config.avail_ring.0 as u32)?,
            COMMON_Q_AVAILHI_REG => self
                .get_queue_config()
                .map(|config| (config.avail_ring.0 >> 32) as u32)?,
            COMMON_Q_USEDLO_REG => self
                .get_queue_config()
                .map(|config| config.used_ring.0 as u32)?,
            COMMON_Q_USEDHI_REG => self
                .get_queue_config()
                .map(|config| (config.used_ring.0 >> 32) as u32)?,
            _ => {
                return Err(ErrorKind::PciRegister(offset).into());
            }
        };
        Ok(value)
    }
fn read_common_config ( & self , device : & Arc < Mutex < dyn VirtioDevice > > , offset : u64 , ) -> PciResult < u32 > { let value = match offset { COMMON_DFSELECT_REG => self . features_select , COMMON_DF_REG => device . lock ( ) . unwrap ( ) . get_device_features ( self . features_select ) , COMMON_GFSELECT_REG => self . acked_features_select , COMMON_MSIX_REG => self . msix_config . load ( Ordering :: SeqCst ) as u32 , COMMON_NUMQ_REG => self . queues_config . len ( ) as u32 , COMMON_STATUS_REG => self . device_status , COMMON_CFGGENERATION_REG => self . config_generation , COMMON_Q_SELECT_REG => self . queue_select as u32 , COMMON_Q_SIZE_REG => self . get_queue_config ( ) . map ( | config | u32 :: from ( config . max_size ) ) ? , COMMON_Q_MSIX_REG => self . get_queue_config ( ) . map ( | config | u32 :: from ( config . vector ) ) ? , COMMON_Q_ENABLE_REG => self . get_queue_config ( ) . map ( | config | u32 :: from ( config . ready ) ) ? , COMMON_Q_NOFF_REG => self . queue_select as u32 , COMMON_Q_DESCLO_REG => self . get_queue_config ( ) . map ( | config | config . desc_table . 0 as u32 ) ? , COMMON_Q_DESCHI_REG => self . get_queue_config ( ) . map ( | config | ( config . desc_table . 0 >> 32 ) as u32 ) ? , COMMON_Q_AVAILLO_REG => self . get_queue_config ( ) . map ( | config | config . avail_ring . 0 as u32 ) ? , COMMON_Q_AVAILHI_REG => self . get_queue_config ( ) . map ( | config | ( config . avail_ring . 0 >> 32 ) as u32 ) ? , COMMON_Q_USEDLO_REG => self . get_queue_config ( ) . map ( | config | config . used_ring . 0 as u32 ) ? , COMMON_Q_USEDHI_REG => self . get_queue_config ( ) . map ( | config | ( config . used_ring . 0 >> 32 ) as u32 ) ? , _ => { return Err ( ErrorKind :: PciRegister ( offset ) . into ( ) ) ; } } ; Ok ( value ) }
Read data from the common config of virtio device.
Read data from the common config of virtio device .
&self
device
&Arc<Mutex<dyn VirtioDevice>>
offset
u64
&self
device
&Arc<Mutex<dyn VirtioDevice>>
offset
u64