dma_remapping.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef _DMA_REMAPPING_H
  2. #define _DMA_REMAPPING_H
  3. /*
  4. * VT-d hardware uses 4KiB page size regardless of host page size.
  5. */
  6. #define VTD_PAGE_SHIFT (12)
  7. #define VTD_PAGE_SIZE (1UL << VTD_PAGE_SHIFT)
  8. #define VTD_PAGE_MASK (((u64)-1) << VTD_PAGE_SHIFT)
  9. #define VTD_PAGE_ALIGN(addr) (((addr) + VTD_PAGE_SIZE - 1) & VTD_PAGE_MASK)
  10. #define VTD_STRIDE_SHIFT (9)
  11. #define VTD_STRIDE_MASK (((u64)-1) << VTD_STRIDE_SHIFT)
  12. #define DMA_PTE_READ (1)
  13. #define DMA_PTE_WRITE (2)
  14. #define DMA_PTE_LARGE_PAGE (1 << 7)
  15. #define DMA_PTE_SNP (1 << 11)
  16. #define CONTEXT_TT_MULTI_LEVEL 0
  17. #define CONTEXT_TT_DEV_IOTLB 1
  18. #define CONTEXT_TT_PASS_THROUGH 2
  19. struct intel_iommu;
  20. struct dmar_domain;
  21. struct root_entry;
  22. #ifdef CONFIG_INTEL_IOMMU
  23. extern void free_dmar_iommu(struct intel_iommu *iommu);
  24. extern int iommu_calculate_agaw(struct intel_iommu *iommu);
  25. extern int iommu_calculate_max_sagaw(struct intel_iommu *iommu);
  26. extern int dmar_disabled;
  27. extern int intel_iommu_enabled;
  28. #else
  29. static inline int iommu_calculate_agaw(struct intel_iommu *iommu)
  30. {
  31. return 0;
  32. }
  33. static inline int iommu_calculate_max_sagaw(struct intel_iommu *iommu)
  34. {
  35. return 0;
  36. }
  37. static inline void free_dmar_iommu(struct intel_iommu *iommu)
  38. {
  39. }
  40. #define dmar_disabled (1)
  41. #define intel_iommu_enabled (0)
  42. #endif
  43. #endif