Thomas Gleixner | 1e19b16 | 2008-10-06 14:15:24 +0200 | [diff] [blame] | 1 | #ifndef _LINUX_IOMMU_HELPER_H |
| 2 | #define _LINUX_IOMMU_HELPER_H |
| 3 | |
Anton Blanchard | e269b08 | 2010-08-09 17:20:23 -0700 | [diff] [blame] | 4 | #include <linux/kernel.h> |
| 5 | |
FUJITA Tomonori | eecfffc | 2008-09-12 19:42:33 +0900 | [diff] [blame] | 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 | |
FUJITA Tomonori | 3715863 | 2008-03-04 14:29:27 -0800 | [diff] [blame] | 16 | extern int iommu_is_span_boundary(unsigned int index, unsigned int nr, |
| 17 | unsigned long shift, |
| 18 | unsigned long boundary_size); |
FUJITA Tomonori | 0291df8 | 2008-02-04 22:28:07 -0800 | [diff] [blame] | 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); |
Thomas Gleixner | 1e19b16 | 2008-10-06 14:15:24 +0200 | [diff] [blame] | 24 | |
Anton Blanchard | e269b08 | 2010-08-09 17:20:23 -0700 | [diff] [blame] | 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 | } |
Joerg Roedel | 56d9366 | 2008-10-15 22:02:10 -0700 | [diff] [blame] | 33 | |
Thomas Gleixner | 1e19b16 | 2008-10-06 14:15:24 +0200 | [diff] [blame] | 34 | #endif |