assembler.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. ldi r13, #0
  100. push r13 ; dummy push acc1h
  101. push r13 ; dummy push acc1l
  102. #else
  103. #error unknown isa configuration
  104. #endif
  105. ldi r13, #-1
  106. push r13 ; syscall_nr (default: -1)
  107. push r12
  108. push r11
  109. push r10
  110. push r9
  111. push r8
  112. push r7
  113. push r3
  114. push r2
  115. push r1
  116. push r0
  117. addi sp, #-4 ; room for implicit pt_regs parameter
  118. push r6
  119. push r5
  120. push r4
  121. .endm
  122. .macro RESTORE_ALL
  123. pop r4
  124. pop r5
  125. pop r6
  126. addi sp, #4
  127. pop r0
  128. pop r1
  129. pop r2
  130. pop r3
  131. pop r7
  132. pop r8
  133. pop r9
  134. pop r10
  135. pop r11
  136. pop r12
  137. addi r15, #4 ; Skip syscall number
  138. #if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
  139. pop r13
  140. mvtachi r13, a0
  141. pop r13
  142. mvtaclo r13, a0
  143. pop r13
  144. mvtachi r13, a1
  145. pop r13
  146. mvtaclo r13, a1
  147. #elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
  148. pop r13 ; dummy pop acc1h
  149. pop r13 ; dummy pop acc1l
  150. pop r13
  151. mvtachi r13
  152. pop r13
  153. mvtaclo r13
  154. #else
  155. #error unknown isa configuration
  156. #endif
  157. pop r14
  158. mvtc r14, psw
  159. pop r14
  160. mvtc r14, bpc
  161. addi sp, #8 ; Skip bbpsw, bbpc
  162. pop r14
  163. mvtc r14, cr3 ; spu
  164. pop r13
  165. pop lr ; r14
  166. pop sp ; spi (r15)
  167. addi sp, #4 ; Skip orig_r0
  168. .fillinsn
  169. 1: rte
  170. .section .fixup,"ax"
  171. 2: bl do_exit
  172. .previous
  173. .section __ex_table,"a"
  174. ALIGN
  175. .long 1b, 2b
  176. .previous
  177. .endm
  178. #define GET_CURRENT(reg) get_current reg
  179. .macro get_current reg
  180. ldi \reg, #-8192
  181. and \reg, sp
  182. .endm
  183. #if !(defined(CONFIG_CHIP_M32102) || defined(CONFIG_CHIP_M32104))
  184. .macro SWITCH_TO_KERNEL_STACK
  185. ; switch to kernel stack (spi)
  186. clrpsw #0x80 -> nop
  187. .endm
  188. #else /* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */
  189. .macro SWITCH_TO_KERNEL_STACK
  190. push r0 ; save r0 for working
  191. mvfc r0, psw
  192. and3 r0, r0, #0x00ff7f
  193. mvtc r0, psw
  194. slli r0, #16
  195. bltz r0, 1f ; check BSM-bit
  196. ;
  197. ;; called from kernel context: previous stack = spi
  198. pop r0 ; retrieve r0
  199. bra 2f
  200. .fillinsn
  201. 1:
  202. ;; called from user context: previous stack = spu
  203. mvfc r0, cr3 ; spu
  204. addi r0, #4
  205. mvtc r0, cr3 ; spu
  206. ld r0, @(-4,r0) ; retrieve r0
  207. .fillinsn
  208. 2:
  209. .endm
  210. #endif /* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */
  211. #endif /* __ASSEMBLY__ */
  212. #endif /* _ASM_M32R_ASSEMBLER_H */