dvma.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * linux/arch/m68k/sun3/dvma.c
  3. *
  4. * Written by Sam Creasey
  5. *
  6. * Sun3 IOMMU routines used for dvma accesses.
  7. *
  8. */
  9. #include <linux/init.h>
  10. #include <linux/kernel.h>
  11. #include <linux/mm.h>
  12. #include <linux/bootmem.h>
  13. #include <linux/list.h>
  14. #include <asm/page.h>
  15. #include <asm/pgtable.h>
  16. #include <asm/sun3mmu.h>
  17. #include <asm/dvma.h>
  18. static unsigned long ptelist[120];
  19. static unsigned long dvma_page(unsigned long kaddr, unsigned long vaddr)
  20. {
  21. unsigned long pte;
  22. unsigned long j;
  23. pte_t ptep;
  24. j = *(volatile unsigned long *)kaddr;
  25. *(volatile unsigned long *)kaddr = j;
  26. ptep = pfn_pte(virt_to_pfn(kaddr), PAGE_KERNEL);
  27. pte = pte_val(ptep);
  28. // printk("dvma_remap: addr %lx -> %lx pte %08lx len %x\n",
  29. // kaddr, vaddr, pte, len);
  30. if(ptelist[(vaddr & 0xff000) >> PAGE_SHIFT] != pte) {
  31. sun3_put_pte(vaddr, pte);
  32. ptelist[(vaddr & 0xff000) >> PAGE_SHIFT] = pte;
  33. }
  34. return (vaddr + (kaddr & ~PAGE_MASK));
  35. }
  36. int dvma_map_iommu(unsigned long kaddr, unsigned long baddr,
  37. int len)
  38. {
  39. unsigned long end;
  40. unsigned long vaddr;
  41. vaddr = dvma_btov(baddr);
  42. end = vaddr + len;
  43. while(vaddr < end) {
  44. dvma_page(kaddr, vaddr);
  45. kaddr += PAGE_SIZE;
  46. vaddr += PAGE_SIZE;
  47. }
  48. return 0;
  49. }
  50. void __init sun3_dvma_init(void)
  51. {
  52. memset(ptelist, 0, sizeof(ptelist));
  53. }