proc-macros.S 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Based on arch/arm/mm/proc-macros.S
  3. *
  4. * Copyright (C) 2012 ARM Ltd.
  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 program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <asm/asm-offsets.h>
  19. #include <asm/thread_info.h>
  20. /*
  21. * vma_vm_mm - get mm pointer from vma pointer (vma->vm_mm)
  22. */
  23. .macro vma_vm_mm, rd, rn
  24. ldr \rd, [\rn, #VMA_VM_MM]
  25. .endm
  26. /*
  27. * mmid - get context id from mm pointer (mm->context.id)
  28. */
  29. .macro mmid, rd, rn
  30. ldr \rd, [\rn, #MM_CONTEXT_ID]
  31. .endm
  32. /*
  33. * dcache_line_size - get the minimum D-cache line size from the CTR register.
  34. */
  35. .macro dcache_line_size, reg, tmp
  36. mrs \tmp, ctr_el0 // read CTR
  37. lsr \tmp, \tmp, #16
  38. and \tmp, \tmp, #0xf // cache line size encoding
  39. mov \reg, #4 // bytes per word
  40. lsl \reg, \reg, \tmp // actual cache line size
  41. .endm
  42. /*
  43. * icache_line_size - get the minimum I-cache line size from the CTR register.
  44. */
  45. .macro icache_line_size, reg, tmp
  46. mrs \tmp, ctr_el0 // read CTR
  47. and \tmp, \tmp, #0xf // cache line size encoding
  48. mov \reg, #4 // bytes per word
  49. lsl \reg, \reg, \tmp // actual cache line size
  50. .endm