proc-macros.S 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * linux/arch/unicore32/mm/proc-macros.S
  3. *
  4. * Code specific to PKUnity SoC and UniCore ISA
  5. *
  6. * Copyright (C) 2001-2010 GUAN Xue-tao
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * We need constants.h for:
  13. * VMA_VM_MM
  14. * VMA_VM_FLAGS
  15. * VM_EXEC
  16. */
  17. #include <generated/asm-offsets.h>
  18. #include <asm/thread_info.h>
  19. #include <asm/memory.h>
  20. /*
  21. * the cache line sizes of the I and D cache are the same
  22. */
  23. #define CACHE_LINESIZE 32
  24. /*
  25. * This is the maximum size of an area which will be invalidated
  26. * using the single invalidate entry instructions. Anything larger
  27. * than this, and we go for the whole cache.
  28. *
  29. * This value should be chosen such that we choose the cheapest
  30. * alternative.
  31. */
  32. #ifdef CONFIG_CPU_UCV2
  33. #define MAX_AREA_SIZE 0x800 /* 64 cache line */
  34. #endif
  35. /*
  36. * vma_vm_mm - get mm pointer from vma pointer (vma->vm_mm)
  37. */
  38. .macro vma_vm_mm, rd, rn
  39. ldw \rd, [\rn+], #VMA_VM_MM
  40. .endm
  41. /*
  42. * vma_vm_flags - get vma->vm_flags
  43. */
  44. .macro vma_vm_flags, rd, rn
  45. ldw \rd, [\rn+], #VMA_VM_FLAGS
  46. .endm
  47. .macro tsk_mm, rd, rn
  48. ldw \rd, [\rn+], #TI_TASK
  49. ldw \rd, [\rd+], #TSK_ACTIVE_MM
  50. .endm
  51. /*
  52. * act_mm - get current->active_mm
  53. */
  54. .macro act_mm, rd
  55. andn \rd, sp, #8128
  56. andn \rd, \rd, #63
  57. ldw \rd, [\rd+], #TI_TASK
  58. ldw \rd, [\rd+], #TSK_ACTIVE_MM
  59. .endm
  60. /*
  61. * mmid - get context id from mm pointer (mm->context.id)
  62. */
  63. .macro mmid, rd, rn
  64. ldw \rd, [\rn+], #MM_CONTEXT_ID
  65. .endm
  66. /*
  67. * mask_asid - mask the ASID from the context ID
  68. */
  69. .macro asid, rd, rn
  70. and \rd, \rn, #255
  71. .endm
  72. .macro crval, clear, mmuset, ucset
  73. .word \clear
  74. .word \mmuset
  75. .endm
  76. #ifndef CONFIG_CPU_DCACHE_LINE_DISABLE
  77. /*
  78. * va2pa va, pa, tbl, msk, off, err
  79. * This macro is used to translate virtual address to its physical address.
  80. *
  81. * va: virtual address
  82. * pa: physical address, result is stored in this register
  83. * tbl, msk, off: temp registers, will be destroyed
  84. * err: jump to error label if the physical address not exist
  85. * NOTE: all regs must be different
  86. */
  87. .macro va2pa, va, pa, tbl, msk, off, err=990f
  88. movc \pa, p0.c2, #0
  89. mov \off, \va >> #22 @ off <- index of 1st page table
  90. adr \tbl, 910f @ tbl <- table of 1st page table
  91. 900: @ ---- handle 1, 2 page table
  92. add \pa, \pa, #PAGE_OFFSET @ pa <- virt addr of page table
  93. ldw \pa, [\pa+], \off << #2 @ pa <- the content of pt
  94. cand.a \pa, #4 @ test exist bit
  95. beq \err @ if not exist
  96. and \off, \pa, #3 @ off <- the last 2 bits
  97. add \tbl, \tbl, \off << #3 @ cmove table pointer
  98. ldw \msk, [\tbl+], #0 @ get the mask
  99. ldw pc, [\tbl+], #4
  100. 930: @ ---- handle 2nd page table
  101. and \pa, \pa, \msk @ pa <- phys addr of 2nd pt
  102. mov \off, \va << #10
  103. cntlo \tbl, \msk @ use tbl as temp reg
  104. mov \off, \off >> \tbl
  105. mov \off, \off >> #2 @ off <- index of 2nd pt
  106. adr \tbl, 920f @ tbl <- table of 2nd pt
  107. b 900b
  108. 910: @ 1st level page table
  109. .word 0xfffff000, 930b @ second level page table
  110. .word 0xfffffc00, 930b @ second level large page table
  111. .word 0x00000000, \err @ invalid
  112. .word 0xffc00000, 980f @ super page
  113. 920: @ 2nd level page table
  114. .word 0xfffff000, 980f @ page
  115. .word 0xffffc000, 980f @ middle page
  116. .word 0xffff0000, 980f @ large page
  117. .word 0x00000000, \err @ invalid
  118. 980:
  119. andn \tbl, \va, \msk
  120. and \pa, \pa, \msk
  121. or \pa, \pa, \tbl
  122. 990:
  123. .endm
  124. #endif
  125. .macro dcacheline_flush, addr, t1, t2
  126. mov \t1, \addr << #20
  127. ldw \t2, =_stext @ _stext must ALIGN(4096)
  128. add \t2, \t2, \t1 >> #20
  129. ldw \t1, [\t2+], #0x0000
  130. ldw \t1, [\t2+], #0x1000
  131. ldw \t1, [\t2+], #0x2000
  132. ldw \t1, [\t2+], #0x3000
  133. .endm