MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / Vfio

Interface Vfio

pci/src/vfio.rs:368–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

366}
367
368pub(crate) trait Vfio: Send + Sync {
369 fn read_config_byte(&self, offset: u32) -> u8 {
370 let mut data: [u8; 1] = [0];
371 self.read_config(offset, &mut data);
372 data[0]
373 }
374
375 fn read_config_word(&self, offset: u32) -> u16 {
376 let mut data: [u8; 2] = [0, 0];
377 self.read_config(offset, &mut data);
378 u16::from_le_bytes(data)
379 }
380
381 fn read_config_dword(&self, offset: u32) -> u32 {
382 let mut data: [u8; 4] = [0, 0, 0, 0];
383 self.read_config(offset, &mut data);
384 u32::from_le_bytes(data)
385 }
386
387 fn write_config_dword(&self, offset: u32, buf: u32) {
388 let data: [u8; 4] = buf.to_le_bytes();
389 self.write_config(offset, &data);
390 }
391
392 fn read_config(&self, offset: u32, data: &mut [u8]) {
393 self.region_read(VFIO_PCI_CONFIG_REGION_INDEX, offset.into(), data.as_mut());
394 }
395
396 fn write_config(&self, offset: u32, data: &[u8]) {
397 self.region_write(VFIO_PCI_CONFIG_REGION_INDEX, offset.into(), data);
398 }
399
400 fn enable_msi(&self, fds: Vec<&EventFd>) -> Result<(), VfioError> {
401 self.enable_irq(VFIO_PCI_MSI_IRQ_INDEX, fds)
402 }
403
404 fn disable_msi(&self) -> Result<(), VfioError> {
405 self.disable_irq(VFIO_PCI_MSI_IRQ_INDEX)
406 }
407
408 fn enable_msix(&self, fds: Vec<&EventFd>) -> Result<(), VfioError> {
409 self.enable_irq(VFIO_PCI_MSIX_IRQ_INDEX, fds)
410 }
411
412 fn disable_msix(&self) -> Result<(), VfioError> {
413 self.disable_irq(VFIO_PCI_MSIX_IRQ_INDEX)
414 }
415
416 fn region_read(&self, _index: u32, _offset: u64, _data: &mut [u8]) {
417 unimplemented!()
418 }
419
420 fn region_write(&self, _index: u32, _offset: u64, _data: &[u8]) {
421 unimplemented!()
422 }
423
424 fn get_irq_info(&self, _irq_index: u32) -> Option<VfioIrq> {
425 unimplemented!()

Callers 1

add_vfio_deviceMethod · 0.85

Implementers 2

vfio.rspci/src/vfio.rs
vfio_user.rspci/src/vfio_user.rs

Calls

no outgoing calls

Tested by

no test coverage detected