assembler.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * linux/arch/unicore32/include/asm/assembler.h
  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. * Do not include any C declarations in this file - it is included by
  13. * assembler source.
  14. */
  15. #ifndef __ASSEMBLY__
  16. #error "Only include this from assembly code"
  17. #endif
  18. #include <asm/ptrace.h>
  19. /*
  20. * Little Endian independent macros for shifting bytes within registers.
  21. */
  22. #define pull >>
  23. #define push <<
  24. #define get_byte_0 << #0
  25. #define get_byte_1 >> #8
  26. #define get_byte_2 >> #16
  27. #define get_byte_3 >> #24
  28. #define put_byte_0 << #0
  29. #define put_byte_1 << #8
  30. #define put_byte_2 << #16
  31. #define put_byte_3 << #24
  32. #define cadd cmpadd
  33. #define cand cmpand
  34. #define csub cmpsub
  35. #define cxor cmpxor
  36. /*
  37. * Enable and disable interrupts
  38. */
  39. .macro disable_irq, temp
  40. mov \temp, asr
  41. andn \temp, \temp, #0xFF
  42. or \temp, \temp, #PSR_I_BIT | PRIV_MODE
  43. mov.a asr, \temp
  44. .endm
  45. .macro enable_irq, temp
  46. mov \temp, asr
  47. andn \temp, \temp, #0xFF
  48. or \temp, \temp, #PRIV_MODE
  49. mov.a asr, \temp
  50. .endm
  51. #define USER(x...) \
  52. 9999: x; \
  53. .pushsection __ex_table, "a"; \
  54. .align 3; \
  55. .long 9999b, 9001f; \
  56. .popsection
  57. .macro notcond, cond, nexti = .+8
  58. .ifc \cond, eq
  59. bne \nexti
  60. .else; .ifc \cond, ne
  61. beq \nexti
  62. .else; .ifc \cond, ea
  63. bub \nexti
  64. .else; .ifc \cond, ub
  65. bea \nexti
  66. .else; .ifc \cond, fs
  67. bns \nexti
  68. .else; .ifc \cond, ns
  69. bfs \nexti
  70. .else; .ifc \cond, fv
  71. bnv \nexti
  72. .else; .ifc \cond, nv
  73. bfv \nexti
  74. .else; .ifc \cond, ua
  75. beb \nexti
  76. .else; .ifc \cond, eb
  77. bua \nexti
  78. .else; .ifc \cond, eg
  79. bsl \nexti
  80. .else; .ifc \cond, sl
  81. beg \nexti
  82. .else; .ifc \cond, sg
  83. bel \nexti
  84. .else; .ifc \cond, el
  85. bsg \nexti
  86. .else; .ifnc \cond, al
  87. .error "Unknown cond in notcond macro argument"
  88. .endif; .endif; .endif; .endif; .endif; .endif; .endif
  89. .endif; .endif; .endif; .endif; .endif; .endif; .endif
  90. .endif
  91. .endm
  92. .macro usracc, instr, reg, ptr, inc, cond, rept, abort
  93. .rept \rept
  94. notcond \cond, .+8
  95. 9999 :
  96. .if \inc == 1
  97. \instr\()b.u \reg, [\ptr], #\inc
  98. .elseif \inc == 4
  99. \instr\()w.u \reg, [\ptr], #\inc
  100. .else
  101. .error "Unsupported inc macro argument"
  102. .endif
  103. .pushsection __ex_table, "a"
  104. .align 3
  105. .long 9999b, \abort
  106. .popsection
  107. .endr
  108. .endm
  109. .macro strusr, reg, ptr, inc, cond = al, rept = 1, abort = 9001f
  110. usracc st, \reg, \ptr, \inc, \cond, \rept, \abort
  111. .endm
  112. .macro ldrusr, reg, ptr, inc, cond = al, rept = 1, abort = 9001f
  113. usracc ld, \reg, \ptr, \inc, \cond, \rept, \abort
  114. .endm
  115. .macro nop8
  116. .rept 8
  117. nop
  118. .endr
  119. .endm