13 #include <linux/kernel.h>
15 #include <linux/bitops.h>
24 #include <asm/pgtable.h>
25 #include <asm/pgalloc.h>
29 #define IOMMU_ADDR_MASK 0x03ffe000
30 #define IOMMU_CACHE_INHIBIT 0x00000040
31 #define IOMMU_FULL_BLOCK 0x00000020
32 #define IOMMU_MODIFIED 0x00000010
33 #define IOMMU_USED 0x00000008
34 #define IOMMU_WRITE_PROTECT 0x00000004
35 #define IOMMU_DT_MASK 0x00000003
36 #define IOMMU_DT_INVALID 0x00000000
37 #define IOMMU_DT_VALID 0x00000001
38 #define IOMMU_DT_BAD 0x00000002
41 static volatile unsigned long *iommu_pte = (
unsigned long *)
SUN3X_IOMMU;
44 #define dvma_entry_paddr(index) (iommu_pte[index] & IOMMU_ADDR_MASK)
45 #define dvma_entry_vaddr(index,paddr) ((index << DVMA_PAGE_SHIFT) | \
46 (paddr & (DVMA_PAGE_SIZE-1)))
48 #define dvma_entry_set(index,addr) (iommu_pte[index] = \
49 (addr & IOMMU_ADDR_MASK) | \
50 IOMMU_DT_VALID | IOMMU_CACHE_INHIBIT)
52 #define dvma_entry_set(index,addr) (iommu_pte[index] = \
53 (addr & IOMMU_ADDR_MASK) | \
56 #define dvma_entry_clr(index) (iommu_pte[index] = IOMMU_DT_INVALID)
57 #define dvma_entry_hash(addr) ((addr >> DVMA_PAGE_SHIFT) ^ \
58 ((addr & 0x03c00000) >> \
65 void dvma_print (
unsigned long dvma_addr)
72 printk(
"idx %lx dvma_addr %08lx paddr %08lx\n", index, dvma_addr,
83 unsigned long vaddr,
int len)
95 printk(
"dvma: mapping kern %08lx to virt %08lx\n",
118 if((pte = pte_alloc_kernel(pmd, vaddr)) ==
NULL) {
130 printk(
"mapping %08lx phys to %08lx\n",
138 }
while(vaddr < end3);
140 }
while(vaddr < end2);
142 }
while(vaddr < end);
157 end = ((baddr+len) >> DVMA_PAGE_SHIFT);
162 for(; index <
end ; index++) {
176 for(index = (baddr >> DVMA_PAGE_SHIFT); index <
end; index++)
177 dvma_print(index << DVMA_PAGE_SHIFT);
192 for(; index <
end ; index++) {
194 printk(
"freeing bus mapping %08x\n", index << DVMA_PAGE_SHIFT);
198 printk(
"dvma_unmap freeing unused entry %04x\n",
201 dvma_entry_dec(index);