- Timestamp:
- Mar 31, 2020 11:10:04 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevIommuAmd.cpp
r83462 r83495 63 63 64 64 /** 65 * @name Capability Header.65 * @name IOMMU Capability Header. 66 66 * In accordance with the AMD spec. 67 67 * @{ … … 102 102 103 103 /** 104 * @name Base Address Low Register.104 * @name IOMMU Base Address Low Register. 105 105 * In accordance with the AMD spec. 106 106 * @{ … … 112 112 #define IOMMU_BF_BASEADDR_LO_RSVD_1_13_SHIFT 1 113 113 #define IOMMU_BF_BASEADDR_LO_RSVD_1_13_MASK UINT32_C(0x00003ffe) 114 /** Base Address[18:14]: Low Base address (Lo) of IOMMU control registers. */ 115 #define IOMMU_BF_BASEADDR_LO_ADDR_LO_SHIFT 14 116 #define IOMMU_BF_BASEADDR_LO_ADDR_LO_MASK UINT32_C(0x0007c000) 117 /** Base Address[31:19]: Low Base address (Hi) of IOMMU control registers. */ 118 #define IOMMU_BF_BASEADDR_LO_ADDR_HI_SHIFT 19 119 #define IOMMU_BF_BASEADDR_LO_ADDR_HI_MASK UINT32_C(0xfff80000) 114 /** Base Address[31:14]: Low Base address of IOMMU MMIO control registers. */ 115 #define IOMMU_BF_BASEADDR_LO_ADDR_SHIFT 14 116 #define IOMMU_BF_BASEADDR_LO_ADDR_MASK UINT32_C(0xffffc000) 120 117 RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_BASEADDR_LO_, UINT32_C(0), UINT32_MAX, 121 (ENABLE, RSVD_1_13, ADDR _LO, ADDR_HI));118 (ENABLE, RSVD_1_13, ADDR)); 122 119 /** @} */ 123 120 124 121 /** 125 * @name Range Register.122 * @name IOMMU Range Register. 126 123 * In accordance with the AMD spec. 127 124 * @{ … … 150 147 151 148 /** 152 * @name Miscellaneous Information Register 0.149 * @name IOMMU Miscellaneous Information Register 0. 153 150 * In accordance with the AMD spec. 154 151 * @{ … … 180 177 181 178 /** 182 * @name Miscellaneous Information Register 1.179 * @name IOMMU Miscellaneous Information Register 1. 183 180 * In accordance with the AMD spec. 184 181 * @{ … … 254 251 * @{ */ 255 252 #define IOMMU_LOG_PFX "AMD_IOMMU" /**< Log prefix string. */ 253 #define IOMMU_SAVED_STATE_VERSION 1 /**< The current saved state version. */ 256 254 #define IOMMU_PCI_VENDOR_ID 0x1022 /**< AMD's vendor ID. */ 257 255 #define IOMMU_PCI_DEVICE_ID 0xc0de /**< VirtualBox IOMMU Device ID. */ 258 256 #define IOMMU_PCI_REVISION_ID 0x01 /**< VirtualBox IOMMU Device Revision ID. */ 257 #define IOMMU_MMIO_SIZE _16K /**< Size of the MMIO region in bytes. */ 259 258 /** @} */ 260 259 … … 833 832 AssertCompileSize(EVT_EVENT_COUNTER_ZERO, 16); 834 833 834 /* Not needed as we can initialize from bitfields and set/get using PCI config PDM helpers. */ 835 #if 0 836 /** 837 * IOMMU Capability Header (PCI). 838 * In accordance with the AMD spec. 839 */ 840 typedef union 841 { 842 struct 843 { 844 uint32_t u8CapId : 8; /**< Bits 7:0 - CapId: Capability ID. */ 845 uint32_t u8CapPtr : 8; /**< Bits 15:8 - CapPtr: Pointer (PCI config offset) to the next capability. */ 846 uint32_t u3CapType : 3; /**< Bits 18:16 - CapType: Capability Type. */ 847 uint32_t u5CapRev : 5; /**< Bits 23:19 - CapRev: Capability revision. */ 848 uint32_t u1IoTlbSup : 1; /**< Bit 24 - IotlbSup: IOTLB Support. */ 849 uint32_t u1HtTunnel : 1; /**< Bit 25 - HtTunnel: HyperTransport Tunnel translation support. */ 850 uint32_t u1NpCache : 1; /**< Bit 26 - NpCache: Not Present table entries are cached. */ 851 uint32_t u1EfrSup : 1; /**< Bit 27 - EFRSup: Extended Feature Register Support. */ 852 uint32_t u1CapExt : 1; /**< Bit 28 - CapExt: Misc. Information Register 1 Support. */ 853 uint32_t u4Rsvd0 : 4; /**< Bits 31:29 - Reserved. */ 854 } n; 855 /** The 32-bit unsigned integer view. */ 856 uint32_t u32; 857 } IOMMU_CAP_HDR_T; 858 AssertCompileSize(IOMMU_CAP_HDR_T, 4); 859 #endif 860 835 861 /** 836 862 * Device Table Base Address Register (MMIO). … … 1607 1633 /** Alignment padding. */ 1608 1634 bool afPadding[3]; 1635 /** The MMIO handle. */ 1636 IOMMMIOHANDLE hMmio; 1609 1637 1610 1638 /** @name MMIO: Control and status registers. … … 1771 1799 #ifndef VBOX_DEVICE_STRUCT_TESTCASE 1772 1800 1801 /** 1802 * @callback_method_impl{FNIOMMMIONEWWRITE} 1803 */ 1804 static DECLCALLBACK(VBOXSTRICTRC) iommuAmdMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb) 1805 { 1806 /** @todo IOMMU: MMIO write. */ 1807 RT_NOREF5(pDevIns, pvUser, off, pv, cb); 1808 return VERR_NOT_IMPLEMENTED; 1809 } 1810 1811 1812 /** 1813 * @callback_method_impl{FNIOMMMIONEWREAD} 1814 */ 1815 static DECLCALLBACK(VBOXSTRICTRC) iommuAmdMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb) 1816 { 1817 /** @todo IOMMU: MMIO read. */ 1818 RT_NOREF5(pDevIns, pvUser, off, pv, cb); 1819 return VERR_NOT_IMPLEMENTED; 1820 } 1821 1822 1773 1823 # ifdef IN_RING3 1824 /** 1825 * @callback_method_impl{FNSSMDEVSAVEEXEC} 1826 */ 1827 static DECLCALLBACK(int) iommuAmdR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 1828 { 1829 /** @todo IOMMU: Save state. */ 1830 RT_NOREF2(pDevIns, pSSM); 1831 return VERR_NOT_IMPLEMENTED; 1832 } 1833 1834 /** 1835 * @callback_method_impl{FNSSMDEVLOADEXEC} 1836 */ 1837 static DECLCALLBACK(int) iommuAmdR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 1838 { 1839 /** @todo IOMMU: Load state. */ 1840 RT_NOREF4(pDevIns, pSSM, uVersion, uPass); 1841 return VERR_NOT_IMPLEMENTED; 1842 } 1843 1844 1774 1845 /** 1775 1846 * @interface_method_impl{PDMDEVREG,pfnReset} … … 1797 1868 { 1798 1869 NOREF(iInstance); 1799 NOREF(pCfg);1800 1870 1801 1871 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); … … 1811 1881 * Validate and read the configuration. 1812 1882 */ 1813 PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "RootComplex ", "");1883 PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "RootComplex|MmioBase", ""); 1814 1884 1815 1885 rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "RootComplex", &pThis->fRootComplex, true); 1816 AssertLogRelRCReturn(rc, rc); 1886 if (RT_FAILURE(rc)) 1887 return PDMDEV_SET_ERROR(pDevIns, rc, N_("IOMMU: Failed to query \"RootComplex\"")); 1888 1889 uint64_t u64MmioBase; 1890 rc = pHlp->pfnCFGMQueryU64Def(pCfg, "MmioBase", &u64MmioBase, 0); 1891 if (RT_FAILURE(rc)) 1892 return PDMDEV_SET_ERROR(pDevIns, rc, N_("IOMMU: Failed to query \"MmioBase\"")); 1893 /* Must be 16KB aligned when we don't support IOMMU performance counters. */ 1894 if (u64MmioBase & 0x3fff) 1895 return PDMDEV_SET_ERROR(pDevIns, rc, N_("IOMMU: \"MmioBase\" must be 16 KB aligned")); 1817 1896 1818 1897 /* … … 1864 1943 /* Base Address Low Register. */ 1865 1944 PDMPciDevSetDWord(pPciDev, offBaseAddrLo, 1866 RT_BF_MAKE(IOMMU_BF_BASEADDR_LO_ENABLE, 0x0) /* RW - Enable */ 1867 | RT_BF_MAKE(IOMMU_BF_BASEADDR_LO_ADDR_LO, 0x0) /* RW - Base address low (lo) */ 1868 | RT_BF_MAKE(IOMMU_BF_BASEADDR_LO_ADDR_HI, 0x0)); /* RW - Base address low (hi) */ 1945 RT_BF_MAKE(IOMMU_BF_BASEADDR_LO_ENABLE, 0x1) /* RW1S - Enable */ 1946 | RT_BF_MAKE(IOMMU_BF_BASEADDR_LO_ADDR, (u64MmioBase >> 14))); /* RO - Base address (Lo) */ 1869 1947 1870 1948 /* Base Address High Register. */ 1871 PDMPciDevSetDWord(pPciDev, offBaseAddrHi, 0); /* RW - Base address high*/1949 PDMPciDevSetDWord(pPciDev, offBaseAddrHi, RT_HI_U32(u64MmioBase)); /* RO - Base address (Hi) */ 1872 1950 1873 1951 /* IOMMU Range Register. */ 1874 PDMPciDevSetDWord(pPciDev, offRange, 1875 RT_BF_MAKE(IOMMU_BF_RANGE_UNIT_ID, 0x0) /* RO - HyperTransport Unit ID */ 1876 | RT_BF_MAKE(IOMMU_BF_RANGE_VALID, 0x0) /* RW - Range Valid */ 1877 | RT_BF_MAKE(IOMMU_BF_RANGE_BUS_NUMBER, 0x0) /* RO - Bus number */ 1878 | RT_BF_MAKE(IOMMU_BF_RANGE_FIRST_DEVICE, 0x0) /* RO - First device */ 1879 | RT_BF_MAKE(IOMMU_BF_RANGE_LAST_DEVICE, 0x0)); /* RO - Last device */ 1952 PDMPciDevSetDWord(pPciDev, offRange, 0x0); /* RO - Range register. */ 1880 1953 1881 1954 /* Misc. Information Register 0. */ … … 1916 1989 | RT_BF_MAKE(IOMMU_BF_MSI_MAP_CAPHDR_FIXED, 0x1) /* RO - MSI mapping range is fixed */ 1917 1990 | RT_BF_MAKE(IOMMU_BF_MSI_MAP_CAPHDR_CAP_TYPE, 0x15)); /* RO - MSI mapping capability */ 1991 1992 /* 1993 * Register the PCI device with PDM. 1994 */ 1995 rc = PDMDevHlpPCIRegister(pDevIns, pDevIns->apPciDevs[0]); 1996 AssertRCReturn(rc, rc); 1997 1998 /* 1999 * Map MMIO registers. 2000 */ 2001 rc = PDMDevHlpMmioCreateAndMap(pDevIns, u64MmioBase, _16K, iommuAmdMmioWrite, iommuAmdMmioRead, 2002 IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU, 2003 "IOMMU-AMD", &pThis->hMmio); 2004 AssertRCReturn(rc, rc); 2005 2006 /* 2007 * Register saved state. 2008 */ 2009 rc = PDMDevHlpSSMRegisterEx(pDevIns, IOMMU_SAVED_STATE_VERSION, sizeof(IOMMU), NULL, 2010 NULL, NULL, NULL, 2011 NULL, iommuAmdR3SaveExec, NULL, 2012 NULL, iommuAmdR3LoadExec, NULL); 2013 AssertRCReturn(rc, rc); 1918 2014 1919 2015 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.