Path: blob/master/arch/sparc/kernel/iommu_common.h
10817 views
/* iommu_common.h: UltraSparc SBUS/PCI common iommu declarations.1*2* Copyright (C) 1999, 2008 David S. Miller ([email protected])3*/45#ifndef _IOMMU_COMMON_H6#define _IOMMU_COMMON_H78#include <linux/kernel.h>9#include <linux/types.h>10#include <linux/sched.h>11#include <linux/mm.h>12#include <linux/scatterlist.h>13#include <linux/device.h>14#include <linux/iommu-helper.h>1516#include <asm/iommu.h>17#include <asm/scatterlist.h>1819/*20* These give mapping size of each iommu pte/tlb.21*/22#define IO_PAGE_SHIFT 1323#define IO_PAGE_SIZE (1UL << IO_PAGE_SHIFT)24#define IO_PAGE_MASK (~(IO_PAGE_SIZE-1))25#define IO_PAGE_ALIGN(addr) ALIGN(addr, IO_PAGE_SIZE)2627#define IO_TSB_ENTRIES (128*1024)28#define IO_TSB_SIZE (IO_TSB_ENTRIES * 8)2930/*31* This is the hardwired shift in the iotlb tag/data parts.32*/33#define IOMMU_PAGE_SHIFT 133435#define SG_ENT_PHYS_ADDRESS(SG) (__pa(sg_virt((SG))))3637static inline int is_span_boundary(unsigned long entry,38unsigned long shift,39unsigned long boundary_size,40struct scatterlist *outs,41struct scatterlist *sg)42{43unsigned long paddr = SG_ENT_PHYS_ADDRESS(outs);44int nr = iommu_num_pages(paddr, outs->dma_length + sg->length,45IO_PAGE_SIZE);4647return iommu_is_span_boundary(entry, nr, shift, boundary_size);48}4950extern unsigned long iommu_range_alloc(struct device *dev,51struct iommu *iommu,52unsigned long npages,53unsigned long *handle);54extern void iommu_range_free(struct iommu *iommu,55dma_addr_t dma_addr,56unsigned long npages);5758#endif /* _IOMMU_COMMON_H */596061