1 /* 2 * Common IOMMU interface for X86 platform 3 * 4 * Copyright (C) 2016 Peter Xu, Red Hat <peterx@redhat.com> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 16 * You should have received a copy of the GNU General Public License along 17 * with this program; if not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef IOMMU_COMMON_H 21 #define IOMMU_COMMON_H 22 23 #include "hw/sysbus.h" 24 25 #define TYPE_X86_IOMMU_DEVICE ("x86-iommu") 26 #define X86_IOMMU_DEVICE(obj) \ 27 OBJECT_CHECK(X86IOMMUState, (obj), TYPE_X86_IOMMU_DEVICE) 28 #define X86_IOMMU_CLASS(klass) \ 29 OBJECT_CLASS_CHECK(X86IOMMUClass, (klass), TYPE_X86_IOMMU_DEVICE) 30 #define X86_IOMMU_GET_CLASS(obj) \ 31 OBJECT_GET_CLASS(X86IOMMUClass, obj, TYPE_X86_IOMMU_DEVICE) 32 33 #define X86_IOMMU_PCI_DEVFN_MAX 256 34 35 typedef struct X86IOMMUState X86IOMMUState; 36 typedef struct X86IOMMUClass X86IOMMUClass; 37 38 struct X86IOMMUClass { 39 SysBusDeviceClass parent; 40 /* Intel/AMD specific realize() hook */ 41 DeviceRealize realize; 42 }; 43 44 struct X86IOMMUState { 45 SysBusDevice busdev; 46 bool intr_supported; /* Whether vIOMMU supports IR */ 47 }; 48 49 /** 50 * x86_iommu_get_default - get default IOMMU device 51 * @return: pointer to default IOMMU device 52 */ 53 X86IOMMUState *x86_iommu_get_default(void); 54 55 #endif 56