entry.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. #ifndef __M68K_ENTRY_H
  2. #define __M68K_ENTRY_H
  3. #include <asm/setup.h>
  4. #include <asm/page.h>
  5. #ifdef __ASSEMBLY__
  6. #include <asm/thread_info.h>
  7. #endif
  8. /*
  9. * Stack layout in 'ret_from_exception':
  10. *
  11. * This allows access to the syscall arguments in registers d1-d5
  12. *
  13. * 0(sp) - d1
  14. * 4(sp) - d2
  15. * 8(sp) - d3
  16. * C(sp) - d4
  17. * 10(sp) - d5
  18. * 14(sp) - a0
  19. * 18(sp) - a1
  20. * 1C(sp) - a2
  21. * 20(sp) - d0
  22. * 24(sp) - orig_d0
  23. * 28(sp) - stack adjustment
  24. * 2C(sp) - [ sr ] [ format & vector ]
  25. * 2E(sp) - [ pc-hiword ] [ sr ]
  26. * 30(sp) - [ pc-loword ] [ pc-hiword ]
  27. * 32(sp) - [ format & vector ] [ pc-loword ]
  28. * ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^
  29. * M68K COLDFIRE
  30. */
  31. /* the following macro is used when enabling interrupts */
  32. #if defined(MACH_ATARI_ONLY)
  33. /* block out HSYNC on the atari */
  34. #define ALLOWINT (~0x400)
  35. #define MAX_NOINT_IPL 3
  36. #else
  37. /* portable version */
  38. #define ALLOWINT (~0x700)
  39. #define MAX_NOINT_IPL 0
  40. #endif /* machine compilation types */
  41. #ifdef __ASSEMBLY__
  42. /*
  43. * This defines the normal kernel pt-regs layout.
  44. *
  45. * regs a3-a6 and d6-d7 are preserved by C code
  46. * the kernel doesn't mess with usp unless it needs to
  47. */
  48. #define SWITCH_STACK_SIZE (6*4+4) /* includes return address */
  49. #ifdef CONFIG_COLDFIRE
  50. #ifdef CONFIG_COLDFIRE_SW_A7
  51. /*
  52. * This is made a little more tricky on older ColdFires. There is no
  53. * separate supervisor and user stack pointers. Need to artificially
  54. * construct a usp in software... When doing this we need to disable
  55. * interrupts, otherwise bad things will happen.
  56. */
  57. .globl sw_usp
  58. .globl sw_ksp
  59. .macro SAVE_ALL_SYS
  60. move #0x2700,%sr /* disable intrs */
  61. btst #5,%sp@(2) /* from user? */
  62. bnes 6f /* no, skip */
  63. movel %sp,sw_usp /* save user sp */
  64. addql #8,sw_usp /* remove exception */
  65. movel sw_ksp,%sp /* kernel sp */
  66. subql #8,%sp /* room for exception */
  67. clrl %sp@- /* stkadj */
  68. movel %d0,%sp@- /* orig d0 */
  69. movel %d0,%sp@- /* d0 */
  70. lea %sp@(-32),%sp /* space for 8 regs */
  71. moveml %d1-%d5/%a0-%a2,%sp@
  72. movel sw_usp,%a0 /* get usp */
  73. movel %a0@-,%sp@(PT_OFF_PC) /* copy exception program counter */
  74. movel %a0@-,%sp@(PT_OFF_FORMATVEC)/*copy exception format/vector/sr */
  75. bra 7f
  76. 6:
  77. clrl %sp@- /* stkadj */
  78. movel %d0,%sp@- /* orig d0 */
  79. movel %d0,%sp@- /* d0 */
  80. lea %sp@(-32),%sp /* space for 8 regs */
  81. moveml %d1-%d5/%a0-%a2,%sp@
  82. 7:
  83. .endm
  84. .macro SAVE_ALL_INT
  85. SAVE_ALL_SYS
  86. moveq #-1,%d0 /* not system call entry */
  87. movel %d0,%sp@(PT_OFF_ORIG_D0)
  88. .endm
  89. .macro RESTORE_USER
  90. move #0x2700,%sr /* disable intrs */
  91. movel sw_usp,%a0 /* get usp */
  92. movel %sp@(PT_OFF_PC),%a0@- /* copy exception program counter */
  93. movel %sp@(PT_OFF_FORMATVEC),%a0@-/*copy exception format/vector/sr */
  94. moveml %sp@,%d1-%d5/%a0-%a2
  95. lea %sp@(32),%sp /* space for 8 regs */
  96. movel %sp@+,%d0
  97. addql #4,%sp /* orig d0 */
  98. addl %sp@+,%sp /* stkadj */
  99. addql #8,%sp /* remove exception */
  100. movel %sp,sw_ksp /* save ksp */
  101. subql #8,sw_usp /* set exception */
  102. movel sw_usp,%sp /* restore usp */
  103. rte
  104. .endm
  105. .macro RDUSP
  106. movel sw_usp,%a3
  107. .endm
  108. .macro WRUSP
  109. movel %a3,sw_usp
  110. .endm
  111. #else /* !CONFIG_COLDFIRE_SW_A7 */
  112. /*
  113. * Modern ColdFire parts have separate supervisor and user stack
  114. * pointers. Simple load and restore macros for this case.
  115. */
  116. .macro SAVE_ALL_SYS
  117. move #0x2700,%sr /* disable intrs */
  118. clrl %sp@- /* stkadj */
  119. movel %d0,%sp@- /* orig d0 */
  120. movel %d0,%sp@- /* d0 */
  121. lea %sp@(-32),%sp /* space for 8 regs */
  122. moveml %d1-%d5/%a0-%a2,%sp@
  123. .endm
  124. .macro SAVE_ALL_INT
  125. move #0x2700,%sr /* disable intrs */
  126. clrl %sp@- /* stkadj */
  127. pea -1:w /* orig d0 */
  128. movel %d0,%sp@- /* d0 */
  129. lea %sp@(-32),%sp /* space for 8 regs */
  130. moveml %d1-%d5/%a0-%a2,%sp@
  131. .endm
  132. .macro RESTORE_USER
  133. moveml %sp@,%d1-%d5/%a0-%a2
  134. lea %sp@(32),%sp /* space for 8 regs */
  135. movel %sp@+,%d0
  136. addql #4,%sp /* orig d0 */
  137. addl %sp@+,%sp /* stkadj */
  138. rte
  139. .endm
  140. .macro RDUSP
  141. /*move %usp,%a3*/
  142. .word 0x4e6b
  143. .endm
  144. .macro WRUSP
  145. /*move %a3,%usp*/
  146. .word 0x4e63
  147. .endm
  148. #endif /* !CONFIG_COLDFIRE_SW_A7 */
  149. .macro SAVE_SWITCH_STACK
  150. lea %sp@(-24),%sp /* 6 regs */
  151. moveml %a3-%a6/%d6-%d7,%sp@
  152. .endm
  153. .macro RESTORE_SWITCH_STACK
  154. moveml %sp@,%a3-%a6/%d6-%d7
  155. lea %sp@(24),%sp /* 6 regs */
  156. .endm
  157. #else /* !CONFIG_COLDFIRE */
  158. /*
  159. * All other types of m68k parts (68000, 680x0, CPU32) have the same
  160. * entry and exit code.
  161. */
  162. /*
  163. * a -1 in the orig_d0 field signifies
  164. * that the stack frame is NOT for syscall
  165. */
  166. .macro SAVE_ALL_INT
  167. clrl %sp@- /* stk_adj */
  168. pea -1:w /* orig d0 */
  169. movel %d0,%sp@- /* d0 */
  170. moveml %d1-%d5/%a0-%a2,%sp@-
  171. .endm
  172. .macro SAVE_ALL_SYS
  173. clrl %sp@- /* stk_adj */
  174. movel %d0,%sp@- /* orig d0 */
  175. movel %d0,%sp@- /* d0 */
  176. moveml %d1-%d5/%a0-%a2,%sp@-
  177. .endm
  178. .macro RESTORE_ALL
  179. moveml %sp@+,%a0-%a2/%d1-%d5
  180. movel %sp@+,%d0
  181. addql #4,%sp /* orig d0 */
  182. addl %sp@+,%sp /* stk adj */
  183. rte
  184. .endm
  185. .macro SAVE_SWITCH_STACK
  186. moveml %a3-%a6/%d6-%d7,%sp@-
  187. .endm
  188. .macro RESTORE_SWITCH_STACK
  189. moveml %sp@+,%a3-%a6/%d6-%d7
  190. .endm
  191. #endif /* !CONFIG_COLDFIRE */
  192. /*
  193. * Register %a2 is reserved and set to current task on MMU enabled systems.
  194. * Non-MMU systems do not reserve %a2 in this way, and this definition is
  195. * not used for them.
  196. */
  197. #define curptr a2
  198. #define GET_CURRENT(tmp) get_current tmp
  199. .macro get_current reg=%d0
  200. movel %sp,\reg
  201. andw #-THREAD_SIZE,\reg
  202. movel \reg,%curptr
  203. movel %curptr@,%curptr
  204. .endm
  205. #else /* C source */
  206. #define STR(X) STR1(X)
  207. #define STR1(X) #X
  208. #define SAVE_ALL_INT \
  209. "clrl %%sp@-;" /* stk_adj */ \
  210. "pea -1:w;" /* orig d0 = -1 */ \
  211. "movel %%d0,%%sp@-;" /* d0 */ \
  212. "moveml %%d1-%%d5/%%a0-%%a2,%%sp@-"
  213. #define GET_CURRENT(tmp) \
  214. "movel %%sp,"#tmp"\n\t" \
  215. "andw #-"STR(THREAD_SIZE)","#tmp"\n\t" \
  216. "movel "#tmp",%%a2\n\t" \
  217. "movel %%a2@,%%a2"
  218. #endif
  219. #endif /* __M68K_ENTRY_H */