iommu-common.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef _LINUX_IOMMU_COMMON_H
  2. #define _LINUX_IOMMU_COMMON_H
  3. #include <linux/spinlock_types.h>
  4. #include <linux/device.h>
  5. #include <asm/page.h>
  6. #define IOMMU_POOL_HASHBITS 4
  7. #define IOMMU_NR_POOLS (1 << IOMMU_POOL_HASHBITS)
  8. #define IOMMU_ERROR_CODE (~(unsigned long) 0)
  9. struct iommu_pool {
  10. unsigned long start;
  11. unsigned long end;
  12. unsigned long hint;
  13. spinlock_t lock;
  14. };
  15. struct iommu_map_table {
  16. unsigned long table_map_base;
  17. unsigned long table_shift;
  18. unsigned long nr_pools;
  19. void (*lazy_flush)(struct iommu_map_table *);
  20. unsigned long poolsize;
  21. struct iommu_pool pools[IOMMU_NR_POOLS];
  22. u32 flags;
  23. #define IOMMU_HAS_LARGE_POOL 0x00000001
  24. #define IOMMU_NO_SPAN_BOUND 0x00000002
  25. #define IOMMU_NEED_FLUSH 0x00000004
  26. struct iommu_pool large_pool;
  27. unsigned long *map;
  28. };
  29. extern void iommu_tbl_pool_init(struct iommu_map_table *iommu,
  30. unsigned long num_entries,
  31. u32 table_shift,
  32. void (*lazy_flush)(struct iommu_map_table *),
  33. bool large_pool, u32 npools,
  34. bool skip_span_boundary_check);
  35. extern unsigned long iommu_tbl_range_alloc(struct device *dev,
  36. struct iommu_map_table *iommu,
  37. unsigned long npages,
  38. unsigned long *handle,
  39. unsigned long mask,
  40. unsigned int align_order);
  41. extern void iommu_tbl_range_free(struct iommu_map_table *iommu,
  42. u64 dma_addr, unsigned long npages,
  43. unsigned long entry);
  44. #endif