pg-r3k.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:2k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * Copyright (C) 2001 Ralf Baechle (ralf@gnu.org)
  3.  */
  4. #include <linux/sched.h>
  5. #include <linux/mm.h>
  6. /* page functions */
  7. void r3k_clear_page(void * page)
  8. {
  9. __asm__ __volatile__(
  10. ".settnoreordernt"
  11. ".settnoatnt"
  12. "addiut$1,%0,%2n"
  13. "1:tswt$0,(%0)nt"
  14. "swt$0,4(%0)nt"
  15. "swt$0,8(%0)nt"
  16. "swt$0,12(%0)nt"
  17. "addiut%0,32nt"
  18. "swt$0,-16(%0)nt"
  19. "swt$0,-12(%0)nt"
  20. "swt$0,-8(%0)nt"
  21. "bnet$1,%0,1bnt"
  22. "swt$0,-4(%0)nt"
  23. ".settatnt"
  24. ".settreorder"
  25. : "=r" (page)
  26. : "0" (page), "I" (PAGE_SIZE)
  27. : "memory");
  28. }
  29. void r3k_copy_page(void * to, void * from)
  30. {
  31. unsigned long dummy1, dummy2;
  32. unsigned long reg1, reg2, reg3, reg4;
  33. __asm__ __volatile__(
  34. ".settnoreordernt"
  35. ".settnoatnt"
  36. "addiut$1,%0,%8n"
  37. "1:tlwt%2,(%1)nt"
  38. "lwt%3,4(%1)nt"
  39. "lwt%4,8(%1)nt"
  40. "lwt%5,12(%1)nt"
  41. "swt%2,(%0)nt"
  42. "swt%3,4(%0)nt"
  43. "swt%4,8(%0)nt"
  44. "swt%5,12(%0)nt"
  45. "lwt%2,16(%1)nt"
  46. "lwt%3,20(%1)nt"
  47. "lwt%4,24(%1)nt"
  48. "lwt%5,28(%1)nt"
  49. "swt%2,16(%0)nt"
  50. "swt%3,20(%0)nt"
  51. "swt%4,24(%0)nt"
  52. "swt%5,28(%0)nt"
  53. "addiut%0,64nt"
  54. "addiut%1,64nt"
  55. "lwt%2,-32(%1)nt"
  56. "lwt%3,-28(%1)nt"
  57. "lwt%4,-24(%1)nt"
  58. "lwt%5,-20(%1)nt"
  59. "swt%2,-32(%0)nt"
  60. "swt%3,-28(%0)nt"
  61. "swt%4,-24(%0)nt"
  62. "swt%5,-20(%0)nt"
  63. "lwt%2,-16(%1)nt"
  64. "lwt%3,-12(%1)nt"
  65. "lwt%4,-8(%1)nt"
  66. "lwt%5,-4(%1)nt"
  67. "swt%2,-16(%0)nt"
  68. "swt%3,-12(%0)nt"
  69. "swt%4,-8(%0)nt"
  70. "bnet$1,%0,1bnt"
  71. "swt%5,-4(%0)nt"
  72. ".settatnt"
  73. ".settreorder"
  74. : "=r" (dummy1), "=r" (dummy2),
  75.   "=&r" (reg1), "=&r" (reg2), "=&r" (reg3), "=&r" (reg4)
  76. : "0" (to), "1" (from),
  77.   "I" (PAGE_SIZE));
  78. }
  79. /*
  80.  * Initialize new page directory with pointers to invalid ptes
  81.  */
  82. void pgd_init(unsigned long page)
  83. {
  84. unsigned long dummy1, dummy2;
  85. /*
  86.  * The plain and boring version for the R3000.  No cache flushing
  87.  * stuff is implemented since the R3000 has physical caches.
  88.  */
  89. __asm__ __volatile__(
  90. ".settnoreordern"
  91. "1:tswt%2, (%0)nt"
  92. "swt%2, 4(%0)nt"
  93. "swt%2, 8(%0)nt"
  94. "swt%2, 12(%0)nt"
  95. "swt%2, 16(%0)nt"
  96. "swt%2, 20(%0)nt"
  97. "swt%2, 24(%0)nt"
  98. "swt%2, 28(%0)nt"
  99. "subut%1, 1nt"
  100. "bnezt%1, 1bnt"
  101. "addiut%0, 32nt"
  102. ".settreorder"
  103. :"=r" (dummy1), "=r" (dummy2)
  104. :"r" ((unsigned long) invalid_pte_table), "0" (page),
  105.  "1" (USER_PTRS_PER_PGD / 8));
  106. }