Some modifications to files needed to succesfully compile ;)
[wrt350n-kernel.git] / arch / sparc64 / kernel / iommu_common.h
blob0713bd58499c1de49d2650877c60f59437b66fd3
1 /* iommu_common.h: UltraSparc SBUS/PCI common iommu declarations.
3 * Copyright (C) 1999, 2008 David S. Miller (davem@davemloft.net)
4 */
6 #ifndef _IOMMU_COMMON_H
7 #define _IOMMU_COMMON_H
9 #include <linux/kernel.h>
10 #include <linux/types.h>
11 #include <linux/sched.h>
12 #include <linux/mm.h>
13 #include <linux/scatterlist.h>
14 #include <linux/device.h>
16 #include <asm/iommu.h>
17 #include <asm/scatterlist.h>
20 * These give mapping size of each iommu pte/tlb.
22 #define IO_PAGE_SHIFT 13
23 #define IO_PAGE_SIZE (1UL << IO_PAGE_SHIFT)
24 #define IO_PAGE_MASK (~(IO_PAGE_SIZE-1))
25 #define IO_PAGE_ALIGN(addr) (((addr)+IO_PAGE_SIZE-1)&IO_PAGE_MASK)
27 #define IO_TSB_ENTRIES (128*1024)
28 #define IO_TSB_SIZE (IO_TSB_ENTRIES * 8)
31 * This is the hardwired shift in the iotlb tag/data parts.
33 #define IOMMU_PAGE_SHIFT 13
35 #define SG_ENT_PHYS_ADDRESS(SG) (__pa(sg_virt((SG))))
37 static inline unsigned long iommu_num_pages(unsigned long vaddr,
38 unsigned long slen)
40 unsigned long npages;
42 npages = IO_PAGE_ALIGN(vaddr + slen) - (vaddr & IO_PAGE_MASK);
43 npages >>= IO_PAGE_SHIFT;
45 return npages;
48 static inline unsigned long calc_npages(struct scatterlist *sglist, int nelems)
50 unsigned long i, npages = 0;
51 struct scatterlist *sg;
53 for_each_sg(sglist, sg, nelems, i) {
54 unsigned long paddr = SG_ENT_PHYS_ADDRESS(sg);
55 npages += iommu_num_pages(paddr, sg->length);
58 return npages;
61 extern unsigned long iommu_range_alloc(struct device *dev,
62 struct iommu *iommu,
63 unsigned long npages,
64 unsigned long *handle);
65 extern void iommu_range_free(struct iommu *iommu,
66 dma_addr_t dma_addr,
67 unsigned long npages);
69 #endif /* _IOMMU_COMMON_H */