*参照元 [#x2551374] #backlinks *説明 [#u0460a30] -パス: 複数あり --CONFIG_IOMMU_API 有効: [[linux-4.4.1/drivers/iommu/iommu.c]] --CONFIG_IOMMU_API 無効: [[linux-4.4.1/include/linux/iommu.h]] -FIXME: これは何? --iommu_ops の map を呼ぶ。 **引数 [#ydb82ba0] -struct iommu_domain *domain -- --[[linux-4.4.1/iommu_domain]] -unsigned long iova -- -phys_addr_t paddr -- --[[linux-4.4.1/phys_addr_t]] -size_t size -- -int prot -- **返り値 [#rf4e072d] -int **参考 [#yf5f97df] unmap -[[linux-4.4.1/iommu_unmap()]] *実装 [#yb9447e6] **CONFIG_IOMMU_API 有効: drivers/iommu/iommu.c [#wa942784] int iommu_map(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size, int prot) { unsigned long orig_iova = iova; unsigned int min_pagesz; size_t orig_size = size; int ret = 0; if (unlikely(domain->ops->map == NULL || domain->ops->pgsize_bitmap == 0UL)) return -ENODEV; if (unlikely(!(domain->type & __IOMMU_DOMAIN_PAGING))) return -EINVAL; - --domain->ops は const struct iommu_ops * 型 --[[linux-4.4.1/iommu_ops]] --[[linux-4.4.1/unlikely()]] /* find out the minimum page size supported */ min_pagesz = 1 << __ffs(domain->ops->pgsize_bitmap); - --[[linux-4.4.1/__ffs()]] /* * both the virtual address and the physical one, as well as * the size of the mapping, must be aligned (at least) to the * size of the smallest page supported by the hardware */ if (!IS_ALIGNED(iova | paddr | size, min_pagesz)) { pr_err("unaligned: iova 0x%lx pa %pa size 0x%zx min_pagesz 0x%x\n", iova, &paddr, size, min_pagesz); return -EINVAL; } - --[[linux-4.4.1/IS_ALIGNED()]] --[[linux-4.4.1/pr_err()]] pr_debug("map: iova 0x%lx pa %pa size 0x%zx\n", iova, &paddr, size); - --[[linux-4.4.1/pr_debug()]] while (size) { size_t pgsize = iommu_pgsize(domain, iova | paddr, size); pr_debug("mapping: iova 0x%lx pa %pa pgsize 0x%zx\n", iova, &paddr, pgsize); - --[[linux-4.4.1/iommu_pgsize()]] ret = domain->ops->map(domain, iova, paddr, pgsize, prot); if (ret) break; - --domain->ops は const struct iommu_ops * 型 --[[linux-4.4.1/iommu_ops]] iova += pgsize; paddr += pgsize; size -= pgsize; } /* unroll mapping in case something went wrong */ if (ret) iommu_unmap(domain, orig_iova, orig_size - size); else trace_map(orig_iova, paddr, orig_size); - --[[linux-4.4.1/iommu_unmap()]] --[[linux-4.4.1/trace_map()]] return ret; } EXPORT_SYMBOL_GPL(iommu_map); - --[[linux-4.4.1/EXPORT_SYMBOL_GPL()]] **CONFIG_IOMMU_API 無効: include/linux/iommu.h [#s2fba07f] static inline int iommu_map(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, int gfp_order, int prot) { return -ENODEV; } *コメント [#u0deed09]