16e6d8ac6SEric Auger #ifndef SYSEMU_IOMMUFD_H 26e6d8ac6SEric Auger #define SYSEMU_IOMMUFD_H 36e6d8ac6SEric Auger 46e6d8ac6SEric Auger #include "qom/object.h" 56e6d8ac6SEric Auger #include "exec/hwaddr.h" 66e6d8ac6SEric Auger #include "exec/cpu-common.h" 76e6d8ac6SEric Auger 86e6d8ac6SEric Auger #define TYPE_IOMMUFD_BACKEND "iommufd" 96e6d8ac6SEric Auger OBJECT_DECLARE_TYPE(IOMMUFDBackend, IOMMUFDBackendClass, IOMMUFD_BACKEND) 106e6d8ac6SEric Auger 116e6d8ac6SEric Auger struct IOMMUFDBackendClass { 126e6d8ac6SEric Auger ObjectClass parent_class; 136e6d8ac6SEric Auger }; 146e6d8ac6SEric Auger 156e6d8ac6SEric Auger struct IOMMUFDBackend { 166e6d8ac6SEric Auger Object parent; 176e6d8ac6SEric Auger 186e6d8ac6SEric Auger /*< protected >*/ 196e6d8ac6SEric Auger int fd; /* /dev/iommu file descriptor */ 206e6d8ac6SEric Auger bool owned; /* is the /dev/iommu opened internally */ 216e6d8ac6SEric Auger uint32_t users; 226e6d8ac6SEric Auger 236e6d8ac6SEric Auger /*< public >*/ 246e6d8ac6SEric Auger }; 256e6d8ac6SEric Auger 26*9067d50dSZhenzhong Duan bool iommufd_backend_connect(IOMMUFDBackend *be, Error **errp); 276e6d8ac6SEric Auger void iommufd_backend_disconnect(IOMMUFDBackend *be); 286e6d8ac6SEric Auger 29*9067d50dSZhenzhong Duan bool iommufd_backend_alloc_ioas(IOMMUFDBackend *be, uint32_t *ioas_id, 306e6d8ac6SEric Auger Error **errp); 316e6d8ac6SEric Auger void iommufd_backend_free_id(IOMMUFDBackend *be, uint32_t id); 326e6d8ac6SEric Auger int iommufd_backend_map_dma(IOMMUFDBackend *be, uint32_t ioas_id, hwaddr iova, 336e6d8ac6SEric Auger ram_addr_t size, void *vaddr, bool readonly); 346e6d8ac6SEric Auger int iommufd_backend_unmap_dma(IOMMUFDBackend *be, uint32_t ioas_id, 356e6d8ac6SEric Auger hwaddr iova, ram_addr_t size); 366e6d8ac6SEric Auger #endif 37