Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
iommu-helper.h
Go to the documentation of this file.
1 #ifndef _LINUX_IOMMU_HELPER_H
2 #define _LINUX_IOMMU_HELPER_H
3 
4 #include <linux/kernel.h>
5 
6 static inline unsigned long iommu_device_max_index(unsigned long size,
7  unsigned long offset,
8  u64 dma_mask)
9 {
10  if (size + offset > dma_mask)
11  return dma_mask - offset + 1;
12  else
13  return size;
14 }
15 
16 extern int iommu_is_span_boundary(unsigned int index, unsigned int nr,
17  unsigned long shift,
18  unsigned long boundary_size);
19 extern unsigned long iommu_area_alloc(unsigned long *map, unsigned long size,
20  unsigned long start, unsigned int nr,
21  unsigned long shift,
22  unsigned long boundary_size,
23  unsigned long align_mask);
24 
25 static inline unsigned long iommu_num_pages(unsigned long addr,
26  unsigned long len,
27  unsigned long io_page_size)
28 {
29  unsigned long size = (addr & (io_page_size - 1)) + len;
30 
31  return DIV_ROUND_UP(size, io_page_size);
32 }
33 
34 #endif