copypage-v4wt.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * linux/arch/arm/mm/copypage-v4wt.S
  3. *
  4. * Copyright (C) 1995-1999 Russell King
  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 is for CPUs with a writethrough cache and 'flush ID cache' is
  11. * the only supported cache operation.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/highmem.h>
  15. /*
  16. * ARMv4 optimised copy_user_highpage
  17. *
  18. * Since we have writethrough caches, we don't have to worry about
  19. * dirty data in the cache. However, we do have to ensure that
  20. * subsequent reads are up to date.
  21. */
  22. static void __naked
  23. v4wt_copy_user_page(void *kto, const void *kfrom)
  24. {
  25. asm("\
  26. stmfd sp!, {r4, lr} @ 2\n\
  27. mov r2, %2 @ 1\n\
  28. ldmia r1!, {r3, r4, ip, lr} @ 4\n\
  29. 1: stmia r0!, {r3, r4, ip, lr} @ 4\n\
  30. ldmia r1!, {r3, r4, ip, lr} @ 4+1\n\
  31. stmia r0!, {r3, r4, ip, lr} @ 4\n\
  32. ldmia r1!, {r3, r4, ip, lr} @ 4\n\
  33. stmia r0!, {r3, r4, ip, lr} @ 4\n\
  34. ldmia r1!, {r3, r4, ip, lr} @ 4\n\
  35. subs r2, r2, #1 @ 1\n\
  36. stmia r0!, {r3, r4, ip, lr} @ 4\n\
  37. ldmneia r1!, {r3, r4, ip, lr} @ 4\n\
  38. bne 1b @ 1\n\
  39. mcr p15, 0, r2, c7, c7, 0 @ flush ID cache\n\
  40. ldmfd sp!, {r4, pc} @ 3"
  41. :
  42. : "r" (kto), "r" (kfrom), "I" (PAGE_SIZE / 64));
  43. }
  44. void v4wt_copy_user_highpage(struct page *to, struct page *from,
  45. unsigned long vaddr, struct vm_area_struct *vma)
  46. {
  47. void *kto, *kfrom;
  48. kto = kmap_atomic(to);
  49. kfrom = kmap_atomic(from);
  50. v4wt_copy_user_page(kto, kfrom);
  51. kunmap_atomic(kfrom);
  52. kunmap_atomic(kto);
  53. }
  54. /*
  55. * ARMv4 optimised clear_user_page
  56. *
  57. * Same story as above.
  58. */
  59. void v4wt_clear_user_highpage(struct page *page, unsigned long vaddr)
  60. {
  61. void *ptr, *kaddr = kmap_atomic(page);
  62. asm volatile("\
  63. mov r1, %2 @ 1\n\
  64. mov r2, #0 @ 1\n\
  65. mov r3, #0 @ 1\n\
  66. mov ip, #0 @ 1\n\
  67. mov lr, #0 @ 1\n\
  68. 1: stmia %0!, {r2, r3, ip, lr} @ 4\n\
  69. stmia %0!, {r2, r3, ip, lr} @ 4\n\
  70. stmia %0!, {r2, r3, ip, lr} @ 4\n\
  71. stmia %0!, {r2, r3, ip, lr} @ 4\n\
  72. subs r1, r1, #1 @ 1\n\
  73. bne 1b @ 1\n\
  74. mcr p15, 0, r2, c7, c7, 0 @ flush ID cache"
  75. : "=r" (ptr)
  76. : "0" (kaddr), "I" (PAGE_SIZE / 64)
  77. : "r1", "r2", "r3", "ip", "lr");
  78. kunmap_atomic(kaddr);
  79. }
  80. struct cpu_user_fns v4wt_user_fns __initdata = {
  81. .cpu_clear_user_highpage = v4wt_clear_user_highpage,
  82. .cpu_copy_user_highpage = v4wt_copy_user_highpage,
  83. };