1 /* 2 * Copyright (c) 2006, Intel Corporation. 3 * 4 * This program is free software; you can redistribute it and/or modify it 5 * under the terms and conditions of the GNU General Public License, 6 * version 2, as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope it will be useful, but WITHOUT 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 * more details. 12 * 13 * You should have received a copy of the GNU General Public License along with 14 * this program; If not, see <http://www.gnu.org/licenses/>. 15 * 16 * Copyright (C) Allen Kay <allen.m.kay@intel.com> 17 * Copyright (C) Weidong Han <weidong.han@intel.com> 18 */ 19 20 #ifndef _VTD_EXTERN_H_ 21 #define _VTD_EXTERN_H_ 22 23 #include "dmar.h" 24 #include <xen/keyhandler.h> 25 26 #define VTDPREFIX "[VT-D]" 27 28 struct pci_ats_dev; 29 extern bool_t rwbf_quirk; 30 extern const struct iommu_init_ops intel_iommu_init_ops; 31 extern const struct iommu_ops intel_iommu_ops; 32 33 void print_iommu_regs(struct acpi_drhd_unit *drhd); 34 void print_vtd_entries(struct vtd_iommu *iommu, int bus, int devfn, u64 gmfn); 35 keyhandler_fn_t vtd_dump_iommu_info; 36 37 bool intel_iommu_supports_eim(void); 38 int intel_iommu_enable_eim(void); 39 void intel_iommu_disable_eim(void); 40 41 int enable_qinval(struct vtd_iommu *iommu); 42 void disable_qinval(struct vtd_iommu *iommu); 43 int enable_intremap(struct vtd_iommu *iommu, int eim); 44 void disable_intremap(struct vtd_iommu *iommu); 45 46 int iommu_alloc(struct acpi_drhd_unit *drhd); 47 void iommu_free(struct acpi_drhd_unit *drhd); 48 49 int iommu_flush_iec_global(struct vtd_iommu *iommu); 50 int iommu_flush_iec_index(struct vtd_iommu *iommu, u8 im, u16 iidx); 51 void clear_fault_bits(struct vtd_iommu *iommu); 52 53 struct vtd_iommu *ioapic_to_iommu(unsigned int apic_id); 54 struct vtd_iommu *hpet_to_iommu(unsigned int hpet_id); 55 struct acpi_drhd_unit *ioapic_to_drhd(unsigned int apic_id); 56 struct acpi_drhd_unit *hpet_to_drhd(unsigned int hpet_id); 57 struct acpi_rhsa_unit *drhd_to_rhsa(const struct acpi_drhd_unit *drhd); 58 59 struct acpi_drhd_unit *find_ats_dev_drhd(struct vtd_iommu *iommu); 60 61 int ats_device(const struct pci_dev *, const struct acpi_drhd_unit *); 62 63 int dev_invalidate_iotlb(struct vtd_iommu *iommu, u16 did, 64 u64 addr, unsigned int size_order, u64 type); 65 66 int __must_check qinval_device_iotlb_sync(struct vtd_iommu *iommu, 67 struct pci_dev *pdev, 68 u16 did, u16 size, u64 addr); 69 70 unsigned int get_cache_line_size(void); 71 void flush_all_cache(void); 72 73 uint64_t alloc_pgtable_maddr(unsigned long npages, nodeid_t node); 74 void free_pgtable_maddr(u64 maddr); 75 void *map_vtd_domain_page(u64 maddr); 76 void unmap_vtd_domain_page(void *va); 77 int domain_context_mapping_one(struct domain *domain, struct vtd_iommu *iommu, 78 u8 bus, u8 devfn, const struct pci_dev *); 79 int domain_context_unmap_one(struct domain *domain, struct vtd_iommu *iommu, 80 u8 bus, u8 devfn); 81 int intel_iommu_get_reserved_device_memory(iommu_grdm_t *func, void *ctxt); 82 83 unsigned int io_apic_read_remap_rte(unsigned int apic, unsigned int reg); 84 void io_apic_write_remap_rte(unsigned int apic, 85 unsigned int reg, unsigned int value); 86 87 struct msi_desc; 88 struct msi_msg; 89 void msi_msg_read_remap_rte(struct msi_desc *, struct msi_msg *); 90 int msi_msg_write_remap_rte(struct msi_desc *, struct msi_msg *); 91 92 int intel_setup_hpet_msi(struct msi_desc *); 93 94 int is_igd_vt_enabled_quirk(void); 95 void platform_quirks_init(void); 96 void vtd_ops_preamble_quirk(struct vtd_iommu *iommu); 97 void vtd_ops_postamble_quirk(struct vtd_iommu *iommu); 98 int __must_check me_wifi_quirk(struct domain *domain, 99 u8 bus, u8 devfn, int map); 100 void pci_vtd_quirk(const struct pci_dev *); 101 void quirk_iommu_caps(struct vtd_iommu *iommu); 102 103 bool_t platform_supports_intremap(void); 104 bool_t platform_supports_x2apic(void); 105 106 #endif // _VTD_EXTERN_H_ 107