assembler.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. #ifndef _ASM_M32R_ASSEMBLER_H
  2. #define _ASM_M32R_ASSEMBLER_H
  3. /*
  4. * linux/asm-m32r/assembler.h
  5. *
  6. * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org>
  7. *
  8. * This file contains M32R architecture specific macro definitions.
  9. */
  10. #include <linux/config.h>
  11. #ifndef __STR
  12. #ifdef __ASSEMBLY__
  13. #define __STR(x) x
  14. #else
  15. #define __STR(x) #x
  16. #endif
  17. #endif /* __STR */
  18. #ifdef CONFIG_SMP
  19. #define M32R_LOCK __STR(lock)
  20. #define M32R_UNLOCK __STR(unlock)
  21. #else
  22. #define M32R_LOCK __STR(ld)
  23. #define M32R_UNLOCK __STR(st)
  24. #endif
  25. #ifdef __ASSEMBLY__
  26. #undef ENTRY
  27. #define ENTRY(name) ENTRY_M name
  28. .macro ENTRY_M name
  29. .global \name
  30. ALIGN
  31. \name:
  32. .endm
  33. #endif
  34. /**
  35. * LDIMM - load immediate value
  36. * STI - enable interruption
  37. * CLI - disable interruption
  38. */
  39. #ifdef __ASSEMBLY__
  40. #define LDIMM(reg,x) LDIMM reg x
  41. .macro LDIMM reg x
  42. seth \reg, #high(\x)
  43. or3 \reg, \reg, #low(\x)
  44. .endm
  45. #if !(defined(CONFIG_CHIP_M32102) || defined(CONFIG_CHIP_M32104))
  46. #define STI(reg) STI_M reg
  47. .macro STI_M reg
  48. setpsw #0x40 -> nop
  49. ; WORKAROUND: "-> nop" is a workaround for the M32700(TS1).
  50. .endm
  51. #define CLI(reg) CLI_M reg
  52. .macro CLI_M reg
  53. clrpsw #0x40 -> nop
  54. ; WORKAROUND: "-> nop" is a workaround for the M32700(TS1).
  55. .endm
  56. #else /* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */
  57. #define STI(reg) STI_M reg
  58. .macro STI_M reg
  59. mvfc \reg, psw
  60. or3 \reg, \reg, #0x0040
  61. mvtc \reg, psw
  62. .endm
  63. #define CLI(reg) CLI_M reg
  64. .macro CLI_M reg
  65. mvfc \reg, psw
  66. and3 \reg, \reg, #0xffbf
  67. mvtc \reg, psw
  68. .endm
  69. #endif /* CONFIG_CHIP_M32102 */
  70. .macro SAVE_ALL
  71. push r0 ; orig_r0
  72. push sp ; spi (r15)
  73. push lr ; r14
  74. push r13
  75. mvfc r13, cr3 ; spu
  76. push r13
  77. mvfc r13, bbpc
  78. push r13
  79. mvfc r13, bbpsw
  80. push r13
  81. mvfc r13, bpc
  82. push r13
  83. mvfc r13, psw
  84. push r13
  85. #if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
  86. mvfaclo r13, a1
  87. push r13
  88. mvfachi r13, a1
  89. push r13
  90. mvfaclo r13, a0
  91. push r13
  92. mvfachi r13, a0
  93. push r13
  94. #elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
  95. mvfaclo r13
  96. push r13
  97. mvfachi r13
  98. push r13
  99. #else
  100. #error unknown isa configuration
  101. #endif
  102. ldi r13, #-1
  103. push r13 ; syscall_nr (default: -1)
  104. push r12
  105. push r11
  106. push r10
  107. push r9
  108. push r8
  109. push r7
  110. push r3
  111. push r2
  112. push r1
  113. push r0
  114. addi sp, #-4 ; room for implicit pt_regs parameter
  115. push r6
  116. push r5
  117. push r4
  118. .endm
  119. .macro RESTORE_ALL
  120. pop r4
  121. pop r5
  122. pop r6
  123. addi sp, #4
  124. pop r0
  125. pop r1
  126. pop r2
  127. pop r3
  128. pop r7
  129. pop r8
  130. pop r9
  131. pop r10
  132. pop r11
  133. pop r12
  134. addi r15, #4 ; Skip syscall number
  135. #if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
  136. pop r13
  137. mvtachi r13, a0
  138. pop r13
  139. mvtaclo r13, a0
  140. pop r13
  141. mvtachi r13, a1
  142. pop r13
  143. mvtaclo r13, a1
  144. #elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
  145. pop r13
  146. mvtachi r13
  147. pop r13
  148. mvtaclo r13
  149. #else
  150. #error unknown isa configuration
  151. #endif
  152. pop r14
  153. mvtc r14, psw
  154. pop r14
  155. mvtc r14, bpc
  156. addi sp, #8 ; Skip bbpsw, bbpc
  157. pop r14
  158. mvtc r14, cr3 ; spu
  159. pop r13
  160. pop lr ; r14
  161. pop sp ; spi (r15)
  162. addi sp, #4 ; Skip orig_r0
  163. .fillinsn
  164. 1: rte
  165. .section .fixup,"ax"
  166. 2: bl do_exit
  167. .previous
  168. .section __ex_table,"a"
  169. ALIGN
  170. .long 1b, 2b
  171. .previous
  172. .endm
  173. #define GET_CURRENT(reg) get_current reg
  174. .macro get_current reg
  175. ldi \reg, #-8192
  176. and \reg, sp
  177. .endm
  178. #if !(defined(CONFIG_CHIP_M32102) || defined(CONFIG_CHIP_M32104))
  179. .macro SWITCH_TO_KERNEL_STACK
  180. ; switch to kernel stack (spi)
  181. clrpsw #0x80 -> nop
  182. .endm
  183. #else /* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */
  184. .macro SWITCH_TO_KERNEL_STACK
  185. push r0 ; save r0 for working
  186. mvfc r0, psw
  187. and3 r0, r0, #0x00ff7f
  188. mvtc r0, psw
  189. slli r0, #16
  190. bltz r0, 1f ; check BSM-bit
  191. ;
  192. ;; called from kernel context: previous stack = spi
  193. pop r0 ; retrieve r0
  194. bra 2f
  195. .fillinsn
  196. 1:
  197. ;; called from user context: previous stack = spu
  198. mvfc r0, cr3 ; spu
  199. addi r0, #4
  200. mvtc r0, cr3 ; spu
  201. ld r0, @(-4,r0) ; retrieve r0
  202. .fillinsn
  203. 2:
  204. .endm
  205. #endif /* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */
  206. #endif /* __ASSEMBLY__ */
  207. #endif /* _ASM_M32R_ASSEMBLER_H */