pg-sh7705.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * arch/sh/mm/pg-sh7705.c
  3. *
  4. * Copyright (C) 1999, 2000 Niibe Yutaka
  5. * Copyright (C) 2004 Alex Song
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file "COPYING" in the main directory of this archive
  9. * for more details.
  10. *
  11. */
  12. #include <linux/init.h>
  13. #include <linux/mman.h>
  14. #include <linux/mm.h>
  15. #include <linux/threads.h>
  16. #include <linux/fs.h>
  17. #include <asm/addrspace.h>
  18. #include <asm/page.h>
  19. #include <asm/pgtable.h>
  20. #include <asm/processor.h>
  21. #include <asm/cache.h>
  22. #include <asm/io.h>
  23. #include <asm/uaccess.h>
  24. #include <asm/pgalloc.h>
  25. #include <asm/mmu_context.h>
  26. #include <asm/cacheflush.h>
  27. static void __flush_purge_virtual_region(void *p1, void *virt, int size)
  28. {
  29. unsigned long v;
  30. unsigned long begin, end;
  31. unsigned long p1_begin;
  32. begin = L1_CACHE_ALIGN((unsigned long)virt);
  33. end = L1_CACHE_ALIGN((unsigned long)virt + size);
  34. p1_begin = (unsigned long)p1 & ~(L1_CACHE_BYTES - 1);
  35. /* do this the slow way as we may not have TLB entries
  36. * for virt yet. */
  37. for (v = begin; v < end; v += L1_CACHE_BYTES) {
  38. unsigned long p;
  39. unsigned long ways, addr;
  40. p = __pa(p1_begin);
  41. ways = current_cpu_data.dcache.ways;
  42. addr = CACHE_OC_ADDRESS_ARRAY;
  43. do {
  44. unsigned long data;
  45. addr |= (v & current_cpu_data.dcache.entry_mask);
  46. data = ctrl_inl(addr);
  47. if ((data & CACHE_PHYSADDR_MASK) ==
  48. (p & CACHE_PHYSADDR_MASK)) {
  49. data &= ~(SH_CACHE_UPDATED|SH_CACHE_VALID);
  50. ctrl_outl(data, addr);
  51. }
  52. addr += current_cpu_data.dcache.way_incr;
  53. } while (--ways);
  54. p1_begin += L1_CACHE_BYTES;
  55. }
  56. }
  57. /*
  58. * clear_user_page
  59. * @to: P1 address
  60. * @address: U0 address to be mapped
  61. */
  62. void clear_user_page(void *to, unsigned long address, struct page *pg)
  63. {
  64. if (pages_do_alias(address, (unsigned long)to))
  65. __flush_purge_virtual_region(to,
  66. (void *)(address & 0xfffff000),
  67. PAGE_SIZE);
  68. clear_page(to);
  69. __flush_wback_region(to, PAGE_SIZE);
  70. }
  71. /*
  72. * copy_user_page
  73. * @to: P1 address
  74. * @from: P1 address
  75. * @address: U0 address to be mapped
  76. */
  77. void copy_user_page(void *to, void *from, unsigned long address, struct page *pg)
  78. {
  79. if (pages_do_alias(address, (unsigned long)to))
  80. __flush_purge_virtual_region(to,
  81. (void *)(address & 0xfffff000),
  82. PAGE_SIZE);
  83. copy_page(to, from);
  84. __flush_wback_region(to, PAGE_SIZE);
  85. }