iommu-common.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. struct iommu_pool {
  9. unsigned long start;
  10. unsigned long end;
  11. unsigned long hint;
  12. spinlock_t lock;
  13. };
  14. struct iommu_map_table {
  15. unsigned long table_map_base;
  16. unsigned long table_shift;
  17. unsigned long nr_pools;
  18. void (*lazy_flush)(struct iommu_map_table *);
  19. unsigned long poolsize;
  20. struct iommu_pool pools[IOMMU_NR_POOLS];
  21. u32 flags;
  22. #define IOMMU_HAS_LARGE_POOL 0x00000001
  23. #define IOMMU_NO_SPAN_BOUND 0x00000002
  24. #define IOMMU_NEED_FLUSH 0x00000004
  25. struct iommu_pool large_pool;
  26. unsigned long *map;
  27. };
  28. extern void iommu_tbl_pool_init(struct iommu_map_table *iommu,
  29. unsigned long num_entries,
  30. u32 table_shift,
  31. void (*lazy_flush)(struct iommu_map_table *),
  32. bool large_pool, u32 npools,
  33. bool skip_span_boundary_check);
  34. extern unsigned long iommu_tbl_range_alloc(struct device *dev,
  35. struct iommu_map_table *iommu,
  36. unsigned long npages,
  37. unsigned long *handle,
  38. unsigned long mask,
  39. unsigned int align_order);
  40. extern void iommu_tbl_range_free(struct iommu_map_table *iommu,
  41. u64 dma_addr, unsigned long npages,
  42. unsigned long entry);
  43. #endif