@@ -1839,131 +1839,6 @@ virtio_pci_write(struct vmctx *ctx, int vcpu, struct pci_vdev *dev,
1839
1839
base -> vops -> name , baridx );
1840
1840
}
1841
1841
1842
- /**
1843
- * @brief Handle PCI configuration space reads.
1844
- *
1845
- * Handle virtio PCI configuration space reads. Only the specific registers
1846
- * that need speical operation are handled in this callback. For others just
1847
- * fallback to pci core. This interface is only valid for virtio modern.
1848
- *
1849
- * @param ctx Pointer to struct vmctx representing VM context.
1850
- * @param vcpu VCPU ID.
1851
- * @param dev Pointer to struct pci_vdev which emulates a PCI device.
1852
- * @param coff Register offset in bytes within PCI configuration space.
1853
- * @param bytes Access range in bytes.
1854
- * @param rv The value returned as read.
1855
- *
1856
- * @return 0 on handled and non-zero on non-handled.
1857
- */
1858
- int
1859
- virtio_pci_modern_cfgread (struct vmctx * ctx , int vcpu , struct pci_vdev * dev ,
1860
- int coff , int bytes , uint32_t * rv )
1861
- {
1862
- struct virtio_base * base = dev -> arg ;
1863
- struct virtio_pci_cfg_cap * cfg ;
1864
- uint32_t value ;
1865
- int cfg_coff = base -> cfg_coff ;
1866
- size_t cfg_data_offset ;
1867
-
1868
- cfg_data_offset = offsetof(struct virtio_pci_cfg_cap , pci_cfg_data );
1869
-
1870
- /* we only need to handle the read to
1871
- * virtio_pci_cfg_cap.pci_cfg_data[]
1872
- * fallback for anything else by return -1
1873
- */
1874
- if ((cfg_coff > 0 ) && (coff >= cfg_coff + cfg_data_offset ) &&
1875
- (coff + bytes <= cfg_coff + sizeof (* cfg ))) {
1876
- cfg = (struct virtio_pci_cfg_cap * )& dev -> cfgdata [cfg_coff ];
1877
- if (cfg -> cap .bar == base -> modern_pio_bar_idx )
1878
- value = virtio_pci_modern_pio_read (ctx , vcpu , dev ,
1879
- cfg -> cap .bar , cfg -> cap .offset , cfg -> cap .length );
1880
- else if (cfg -> cap .bar == base -> modern_mmio_bar_idx )
1881
- value = virtio_pci_modern_mmio_read (ctx , vcpu , dev ,
1882
- cfg -> cap .bar , cfg -> cap .offset , cfg -> cap .length );
1883
- else {
1884
- fprintf (stderr , "%s: cfgread unexpected baridx %d\r\n" ,
1885
- base -> vops -> name , cfg -> cap .bar );
1886
- value = 0 ;
1887
- }
1888
-
1889
- /* update pci_cfg_data */
1890
- if (cfg -> cap .length == 1 )
1891
- pci_set_cfgdata8 (dev , cfg_coff + cfg_data_offset ,
1892
- value );
1893
- else if (cfg -> cap .length == 2 )
1894
- pci_set_cfgdata16 (dev , cfg_coff + cfg_data_offset ,
1895
- value );
1896
- else
1897
- pci_set_cfgdata32 (dev , cfg_coff + cfg_data_offset ,
1898
- value );
1899
-
1900
- * rv = value ;
1901
- return 0 ;
1902
- }
1903
-
1904
- return -1 ;
1905
- }
1906
-
1907
- /**
1908
- * @brief Handle PCI configuration space writes.
1909
- *
1910
- * Handle virtio PCI configuration space writes. Only the specific registers
1911
- * that need speical operation are handled in this callback. For others just
1912
- * fallback to pci core. This interface is only valid for virtio modern.
1913
- *
1914
- * @param ctx Pointer to struct vmctx representing VM context.
1915
- * @param vcpu VCPU ID.
1916
- * @param dev Pointer to struct pci_vdev which emulates a PCI device.
1917
- * @param coff Register offset in bytes within PCI configuration space.
1918
- * @param bytes Access range in bytes.
1919
- * @param val The value to write.
1920
- *
1921
- * @return 0 on handled and non-zero on non-handled.
1922
- */
1923
- int
1924
- virtio_pci_modern_cfgwrite (struct vmctx * ctx , int vcpu , struct pci_vdev * dev ,
1925
- int coff , int bytes , uint32_t val )
1926
- {
1927
- struct virtio_base * base = dev -> arg ;
1928
- struct virtio_pci_cfg_cap * cfg ;
1929
- int cfg_coff = base -> cfg_coff ;
1930
- size_t cfg_data_offset ;
1931
-
1932
- cfg_data_offset = offsetof(struct virtio_pci_cfg_cap , pci_cfg_data );
1933
-
1934
- /* we only need to handle the write to
1935
- * virtio_pci_cfg_cap.pci_cfg_data[]
1936
- * fallback for anything else by return -1
1937
- */
1938
- if ((cfg_coff > 0 ) && (coff >= cfg_coff + cfg_data_offset ) &&
1939
- (coff + bytes <= cfg_coff + sizeof (* cfg ))) {
1940
- /* default cfg write */
1941
- if (bytes == 1 )
1942
- pci_set_cfgdata8 (dev , coff , val );
1943
- else if (bytes == 2 )
1944
- pci_set_cfgdata16 (dev , coff , val );
1945
- else
1946
- pci_set_cfgdata32 (dev , coff , val );
1947
-
1948
- cfg = (struct virtio_pci_cfg_cap * )& dev -> cfgdata [cfg_coff ];
1949
- if (cfg -> cap .bar == base -> modern_pio_bar_idx )
1950
- virtio_pci_modern_pio_write (ctx , vcpu , dev ,
1951
- cfg -> cap .bar , cfg -> cap .offset ,
1952
- cfg -> cap .length , val );
1953
- else if (cfg -> cap .bar == base -> modern_mmio_bar_idx )
1954
- virtio_pci_modern_mmio_write (ctx , vcpu , dev ,
1955
- cfg -> cap .bar , cfg -> cap .offset ,
1956
- cfg -> cap .length , val );
1957
- else
1958
- fprintf (stderr , "%s: cfgwrite unexpected baridx %d\r\n" ,
1959
- base -> vops -> name , cfg -> cap .bar );
1960
-
1961
- return 0 ;
1962
- }
1963
-
1964
- return -1 ;
1965
- }
1966
-
1967
1842
/**
1968
1843
* @brief Get the virtio poll parameters
1969
1844
*
0 commit comments