copypage-fa.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * linux/arch/arm/lib/copypage-fa.S
  3. *
  4. * Copyright (C) 2005 Faraday Corp.
  5. * Copyright (C) 2008-2009 Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
  6. *
  7. * Based on copypage-v4wb.S:
  8. * Copyright (C) 1995-1999 Russell King
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/highmem.h>
  16. /*
  17. * Faraday optimised copy_user_page
  18. */
  19. static void __naked
  20. fa_copy_user_page(void *kto, const void *kfrom)
  21. {
  22. asm("\
  23. stmfd sp!, {r4, lr} @ 2\n\
  24. mov r2, %0 @ 1\n\
  25. 1: ldmia r1!, {r3, r4, ip, lr} @ 4\n\
  26. stmia r0, {r3, r4, ip, lr} @ 4\n\
  27. mcr p15, 0, r0, c7, c14, 1 @ 1 clean and invalidate D line\n\
  28. add r0, r0, #16 @ 1\n\
  29. ldmia r1!, {r3, r4, ip, lr} @ 4\n\
  30. stmia r0, {r3, r4, ip, lr} @ 4\n\
  31. mcr p15, 0, r0, c7, c14, 1 @ 1 clean and invalidate D line\n\
  32. add r0, r0, #16 @ 1\n\
  33. subs r2, r2, #1 @ 1\n\
  34. bne 1b @ 1\n\
  35. mcr p15, 0, r2, c7, c10, 4 @ 1 drain WB\n\
  36. ldmfd sp!, {r4, pc} @ 3"
  37. :
  38. : "I" (PAGE_SIZE / 32));
  39. }
  40. void fa_copy_user_highpage(struct page *to, struct page *from,
  41. unsigned long vaddr, struct vm_area_struct *vma)
  42. {
  43. void *kto, *kfrom;
  44. kto = kmap_atomic(to);
  45. kfrom = kmap_atomic(from);
  46. fa_copy_user_page(kto, kfrom);
  47. kunmap_atomic(kfrom);
  48. kunmap_atomic(kto);
  49. }
  50. /*
  51. * Faraday optimised clear_user_page
  52. *
  53. * Same story as above.
  54. */
  55. void fa_clear_user_highpage(struct page *page, unsigned long vaddr)
  56. {
  57. void *ptr, *kaddr = kmap_atomic(page);
  58. asm volatile("\
  59. mov r1, %2 @ 1\n\
  60. mov r2, #0 @ 1\n\
  61. mov r3, #0 @ 1\n\
  62. mov ip, #0 @ 1\n\
  63. mov lr, #0 @ 1\n\
  64. 1: stmia %0, {r2, r3, ip, lr} @ 4\n\
  65. mcr p15, 0, %0, c7, c14, 1 @ 1 clean and invalidate D line\n\
  66. add %0, %0, #16 @ 1\n\
  67. stmia %0, {r2, r3, ip, lr} @ 4\n\
  68. mcr p15, 0, %0, c7, c14, 1 @ 1 clean and invalidate D line\n\
  69. add %0, %0, #16 @ 1\n\
  70. subs r1, r1, #1 @ 1\n\
  71. bne 1b @ 1\n\
  72. mcr p15, 0, r1, c7, c10, 4 @ 1 drain WB"
  73. : "=r" (ptr)
  74. : "0" (kaddr), "I" (PAGE_SIZE / 32)
  75. : "r1", "r2", "r3", "ip", "lr");
  76. kunmap_atomic(kaddr);
  77. }
  78. struct cpu_user_fns fa_user_fns __initdata = {
  79. .cpu_clear_user_highpage = fa_clear_user_highpage,
  80. .cpu_copy_user_highpage = fa_copy_user_highpage,
  81. };