assembler.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Based on arch/arm/include/asm/assembler.h
  3. *
  4. * Copyright (C) 1996-2000 Russell King
  5. * Copyright (C) 2012 ARM Ltd.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef __ASSEMBLY__
  20. #error "Only include this from assembly code"
  21. #endif
  22. #include <asm/ptrace.h>
  23. /*
  24. * Stack pushing/popping (register pairs only). Equivalent to store decrement
  25. * before, load increment after.
  26. */
  27. .macro push, xreg1, xreg2
  28. stp \xreg1, \xreg2, [sp, #-16]!
  29. .endm
  30. .macro pop, xreg1, xreg2
  31. ldp \xreg1, \xreg2, [sp], #16
  32. .endm
  33. /*
  34. * Enable and disable interrupts.
  35. */
  36. .macro disable_irq
  37. msr daifset, #2
  38. .endm
  39. .macro enable_irq
  40. msr daifclr, #2
  41. .endm
  42. /*
  43. * Save/disable and restore interrupts.
  44. */
  45. .macro save_and_disable_irqs, olddaif
  46. mrs \olddaif, daif
  47. disable_irq
  48. .endm
  49. .macro restore_irqs, olddaif
  50. msr daif, \olddaif
  51. .endm
  52. /*
  53. * Enable and disable debug exceptions.
  54. */
  55. .macro disable_dbg
  56. msr daifset, #8
  57. .endm
  58. .macro enable_dbg
  59. msr daifclr, #8
  60. .endm
  61. .macro disable_step, tmp
  62. mrs \tmp, mdscr_el1
  63. bic \tmp, \tmp, #1
  64. msr mdscr_el1, \tmp
  65. .endm
  66. .macro enable_step, tmp
  67. mrs \tmp, mdscr_el1
  68. orr \tmp, \tmp, #1
  69. msr mdscr_el1, \tmp
  70. .endm
  71. .macro enable_dbg_if_not_stepping, tmp
  72. mrs \tmp, mdscr_el1
  73. tbnz \tmp, #0, 9990f
  74. enable_dbg
  75. 9990:
  76. .endm
  77. /*
  78. * SMP data memory barrier
  79. */
  80. .macro smp_dmb, opt
  81. #ifdef CONFIG_SMP
  82. dmb \opt
  83. #endif
  84. .endm
  85. #define USER(l, x...) \
  86. 9999: x; \
  87. .section __ex_table,"a"; \
  88. .align 3; \
  89. .quad 9999b,l; \
  90. .previous
  91. /*
  92. * Register aliases.
  93. */
  94. lr .req x30 // link register
  95. /*
  96. * Vector entry
  97. */
  98. .macro ventry label
  99. .align 7
  100. b \label
  101. .endm