copypage-feroceon.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * linux/arch/arm/mm/copypage-feroceon.S
  3. *
  4. * Copyright (C) 2008 Marvell Semiconductors
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * This handles copy_user_highpage and clear_user_page on Feroceon
  11. * more optimally than the generic implementations.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/highmem.h>
  15. static void __naked
  16. feroceon_copy_user_page(void *kto, const void *kfrom)
  17. {
  18. asm("\
  19. stmfd sp!, {r4-r9, lr} \n\
  20. mov ip, %2 \n\
  21. 1: mov lr, r1 \n\
  22. ldmia r1!, {r2 - r9} \n\
  23. pld [lr, #32] \n\
  24. pld [lr, #64] \n\
  25. pld [lr, #96] \n\
  26. pld [lr, #128] \n\
  27. pld [lr, #160] \n\
  28. pld [lr, #192] \n\
  29. pld [lr, #224] \n\
  30. stmia r0, {r2 - r9} \n\
  31. ldmia r1!, {r2 - r9} \n\
  32. mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line\n\
  33. add r0, r0, #32 \n\
  34. stmia r0, {r2 - r9} \n\
  35. ldmia r1!, {r2 - r9} \n\
  36. mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line\n\
  37. add r0, r0, #32 \n\
  38. stmia r0, {r2 - r9} \n\
  39. ldmia r1!, {r2 - r9} \n\
  40. mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line\n\
  41. add r0, r0, #32 \n\
  42. stmia r0, {r2 - r9} \n\
  43. ldmia r1!, {r2 - r9} \n\
  44. mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line\n\
  45. add r0, r0, #32 \n\
  46. stmia r0, {r2 - r9} \n\
  47. ldmia r1!, {r2 - r9} \n\
  48. mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line\n\
  49. add r0, r0, #32 \n\
  50. stmia r0, {r2 - r9} \n\
  51. ldmia r1!, {r2 - r9} \n\
  52. mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line\n\
  53. add r0, r0, #32 \n\
  54. stmia r0, {r2 - r9} \n\
  55. ldmia r1!, {r2 - r9} \n\
  56. mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line\n\
  57. add r0, r0, #32 \n\
  58. stmia r0, {r2 - r9} \n\
  59. subs ip, ip, #(32 * 8) \n\
  60. mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line\n\
  61. add r0, r0, #32 \n\
  62. bne 1b \n\
  63. mcr p15, 0, ip, c7, c10, 4 @ drain WB\n\
  64. ldmfd sp!, {r4-r9, pc}"
  65. :
  66. : "r" (kto), "r" (kfrom), "I" (PAGE_SIZE));
  67. }
  68. void feroceon_copy_user_highpage(struct page *to, struct page *from,
  69. unsigned long vaddr, struct vm_area_struct *vma)
  70. {
  71. void *kto, *kfrom;
  72. kto = kmap_atomic(to);
  73. kfrom = kmap_atomic(from);
  74. flush_cache_page(vma, vaddr, page_to_pfn(from));
  75. feroceon_copy_user_page(kto, kfrom);
  76. kunmap_atomic(kfrom);
  77. kunmap_atomic(kto);
  78. }
  79. void feroceon_clear_user_highpage(struct page *page, unsigned long vaddr)
  80. {
  81. void *ptr, *kaddr = kmap_atomic(page);
  82. asm volatile ("\
  83. mov r1, %2 \n\
  84. mov r2, #0 \n\
  85. mov r3, #0 \n\
  86. mov r4, #0 \n\
  87. mov r5, #0 \n\
  88. mov r6, #0 \n\
  89. mov r7, #0 \n\
  90. mov ip, #0 \n\
  91. mov lr, #0 \n\
  92. 1: stmia %0, {r2-r7, ip, lr} \n\
  93. subs r1, r1, #1 \n\
  94. mcr p15, 0, %0, c7, c14, 1 @ clean and invalidate D line\n\
  95. add %0, %0, #32 \n\
  96. bne 1b \n\
  97. mcr p15, 0, r1, c7, c10, 4 @ drain WB"
  98. : "=r" (ptr)
  99. : "0" (kaddr), "I" (PAGE_SIZE / 32)
  100. : "r1", "r2", "r3", "r4", "r5", "r6", "r7", "ip", "lr");
  101. kunmap_atomic(kaddr);
  102. }
  103. struct cpu_user_fns feroceon_user_fns __initdata = {
  104. .cpu_clear_user_highpage = feroceon_clear_user_highpage,
  105. .cpu_copy_user_highpage = feroceon_copy_user_highpage,
  106. };