ia64/xen-unstable

view xen/include/xen/iommu.h @ 17540:8bced3d8a907

MSI 1/6: Move PCI functions and headers to a common location.

Signed-off-by: Shan Haitao <haitao.shan@intel.com>
Signed-off-by: Jiang Yunhong <yunhong.jiang@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu May 01 10:26:58 2008 +0100 (2008-05-01)
parents 8d20c24238ad
children 86c0353f19d0
line source
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, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307 USA.
16 *
17 * Copyright (C) Allen Kay <allen.m.kay@intel.com>
18 */
20 #ifndef _IOMMU_H_
21 #define _IOMMU_H_
23 #include <xen/init.h>
24 #include <xen/pci.h>
25 #include <xen/spinlock.h>
26 #include <public/hvm/ioreq.h>
27 #include <public/domctl.h>
29 extern int vtd_enabled;
30 extern int iommu_enabled;
32 #define domain_hvm_iommu(d) (&d->arch.hvm_domain.hvm_iommu)
33 #define domain_vmx_iommu(d) (&d->arch.hvm_domain.hvm_iommu.vmx_iommu)
35 #define MAX_IOMMUS 32
37 #define PAGE_SHIFT_4K (12)
38 #define PAGE_SIZE_4K (1UL << PAGE_SHIFT_4K)
39 #define PAGE_MASK_4K (((u64)-1) << PAGE_SHIFT_4K)
40 #define PAGE_ALIGN_4K(addr) (((addr) + PAGE_SIZE_4K - 1) & PAGE_MASK_4K)
42 struct iommu {
43 struct list_head list;
44 void __iomem *reg; /* Pointer to hardware regs, virtual addr */
45 u32 gcmd; /* Holds TE, EAFL. Don't need SRTP, SFL, WBF */
46 u64 cap;
47 u64 ecap;
48 spinlock_t lock; /* protect context, domain ids */
49 spinlock_t register_lock; /* protect iommu register handling */
50 u64 root_maddr; /* root entry machine address */
51 unsigned int vector;
52 struct intel_iommu *intel;
53 };
55 int iommu_domain_init(struct domain *d);
56 void iommu_domain_destroy(struct domain *d);
57 int device_assigned(u8 bus, u8 devfn);
58 int assign_device(struct domain *d, u8 bus, u8 devfn);
59 void deassign_device(struct domain *d, u8 bus, u8 devfn);
60 void reassign_device_ownership(struct domain *source,
61 struct domain *target,
62 u8 bus, u8 devfn);
63 int iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn);
64 int iommu_unmap_page(struct domain *d, unsigned long gfn);
65 void iommu_flush(struct domain *d, unsigned long gfn, u64 *p2m_entry);
66 void iommu_set_pgd(struct domain *d);
67 void iommu_free_pgd(struct domain *d);
68 void iommu_domain_teardown(struct domain *d);
69 int hvm_do_IRQ_dpci(struct domain *d, unsigned int irq);
70 int dpci_ioport_intercept(ioreq_t *p);
71 int pt_irq_create_bind_vtd(struct domain *d,
72 xen_domctl_bind_pt_irq_t *pt_irq_bind);
73 int pt_irq_destroy_bind_vtd(struct domain *d,
74 xen_domctl_bind_pt_irq_t *pt_irq_bind);
75 unsigned int io_apic_read_remap_rte(unsigned int apic, unsigned int reg);
76 void io_apic_write_remap_rte(unsigned int apic,
77 unsigned int reg, unsigned int value);
78 struct qi_ctrl *iommu_qi_ctrl(struct iommu *iommu);
79 struct ir_ctrl *iommu_ir_ctrl(struct iommu *iommu);
80 struct iommu_flush *iommu_get_flush(struct iommu *iommu);
81 void hvm_dpci_isairq_eoi(struct domain *d, unsigned int isairq);
82 struct hvm_irq_dpci *domain_get_irq_dpci(struct domain *domain);
83 int domain_set_irq_dpci(struct domain *domain, struct hvm_irq_dpci *dpci);
85 #define PT_IRQ_TIME_OUT MILLISECS(8)
86 #define VTDPREFIX "[VT-D]"
88 struct iommu_ops {
89 int (*init)(struct domain *d);
90 int (*assign_device)(struct domain *d, u8 bus, u8 devfn);
91 void (*teardown)(struct domain *d);
92 int (*map_page)(struct domain *d, unsigned long gfn, unsigned long mfn);
93 int (*unmap_page)(struct domain *d, unsigned long gfn);
94 void (*reassign_device)(struct domain *s, struct domain *t,
95 u8 bus, u8 devfn);
96 };
98 #endif /* _IOMMU_H_ */