hw/i386: Activate IOMMUFD for q35 machines
[qemu/kevin.git] / include / sysemu / iommufd.h
blob9c5524b0ed15ef5f81be159415bc216572a283d8
1 #ifndef SYSEMU_IOMMUFD_H
2 #define SYSEMU_IOMMUFD_H
4 #include "qom/object.h"
5 #include "qemu/thread.h"
6 #include "exec/hwaddr.h"
7 #include "exec/cpu-common.h"
9 #define TYPE_IOMMUFD_BACKEND "iommufd"
10 OBJECT_DECLARE_TYPE(IOMMUFDBackend, IOMMUFDBackendClass, IOMMUFD_BACKEND)
12 struct IOMMUFDBackendClass {
13 ObjectClass parent_class;
16 struct IOMMUFDBackend {
17 Object parent;
19 /*< protected >*/
20 int fd; /* /dev/iommu file descriptor */
21 bool owned; /* is the /dev/iommu opened internally */
22 QemuMutex lock;
23 uint32_t users;
25 /*< public >*/
28 int iommufd_backend_connect(IOMMUFDBackend *be, Error **errp);
29 void iommufd_backend_disconnect(IOMMUFDBackend *be);
31 int iommufd_backend_alloc_ioas(IOMMUFDBackend *be, uint32_t *ioas_id,
32 Error **errp);
33 void iommufd_backend_free_id(IOMMUFDBackend *be, uint32_t id);
34 int iommufd_backend_map_dma(IOMMUFDBackend *be, uint32_t ioas_id, hwaddr iova,
35 ram_addr_t size, void *vaddr, bool readonly);
36 int iommufd_backend_unmap_dma(IOMMUFDBackend *be, uint32_t ioas_id,
37 hwaddr iova, ram_addr_t size);
38 #endif