entry_mm.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #ifndef __M68K_ENTRY_H
  2. #define __M68K_ENTRY_H
  3. #include <asm/setup.h>
  4. #include <asm/page.h>
  5. /*
  6. * Stack layout in 'ret_from_exception':
  7. *
  8. * This allows access to the syscall arguments in registers d1-d5
  9. *
  10. * 0(sp) - d1
  11. * 4(sp) - d2
  12. * 8(sp) - d3
  13. * C(sp) - d4
  14. * 10(sp) - d5
  15. * 14(sp) - a0
  16. * 18(sp) - a1
  17. * 1C(sp) - a2
  18. * 20(sp) - d0
  19. * 24(sp) - orig_d0
  20. * 28(sp) - stack adjustment
  21. * 2C(sp) - sr
  22. * 2E(sp) - pc
  23. * 32(sp) - format & vector
  24. */
  25. /*
  26. * 97/05/14 Andreas: Register %a2 is now set to the current task throughout
  27. * the whole kernel.
  28. */
  29. /* the following macro is used when enabling interrupts */
  30. #if defined(MACH_ATARI_ONLY)
  31. /* block out HSYNC on the atari */
  32. #define ALLOWINT (~0x400)
  33. #define MAX_NOINT_IPL 3
  34. #else
  35. /* portable version */
  36. #define ALLOWINT (~0x700)
  37. #define MAX_NOINT_IPL 0
  38. #endif /* machine compilation types */
  39. #ifdef __ASSEMBLY__
  40. #define curptr a2
  41. LFLUSH_I_AND_D = 0x00000808
  42. LSIGTRAP = 5
  43. /* process bits for task_struct.ptrace */
  44. PT_TRACESYS_OFF = 3
  45. PT_TRACESYS_BIT = 1
  46. PT_PTRACED_OFF = 3
  47. PT_PTRACED_BIT = 0
  48. PT_DTRACE_OFF = 3
  49. PT_DTRACE_BIT = 2
  50. #define SAVE_ALL_INT save_all_int
  51. #define SAVE_ALL_SYS save_all_sys
  52. #define RESTORE_ALL restore_all
  53. /*
  54. * This defines the normal kernel pt-regs layout.
  55. *
  56. * regs a3-a6 and d6-d7 are preserved by C code
  57. * the kernel doesn't mess with usp unless it needs to
  58. */
  59. /*
  60. * a -1 in the orig_d0 field signifies
  61. * that the stack frame is NOT for syscall
  62. */
  63. .macro save_all_int
  64. clrl %sp@- | stk_adj
  65. pea -1:w | orig d0
  66. movel %d0,%sp@- | d0
  67. moveml %d1-%d5/%a0-%a1/%curptr,%sp@-
  68. .endm
  69. .macro save_all_sys
  70. clrl %sp@- | stk_adj
  71. movel %d0,%sp@- | orig d0
  72. movel %d0,%sp@- | d0
  73. moveml %d1-%d5/%a0-%a1/%curptr,%sp@-
  74. .endm
  75. .macro restore_all
  76. moveml %sp@+,%a0-%a1/%curptr/%d1-%d5
  77. movel %sp@+,%d0
  78. addql #4,%sp | orig d0
  79. addl %sp@+,%sp | stk adj
  80. rte
  81. .endm
  82. #define SWITCH_STACK_SIZE (6*4+4) /* includes return address */
  83. #define SAVE_SWITCH_STACK save_switch_stack
  84. #define RESTORE_SWITCH_STACK restore_switch_stack
  85. #define GET_CURRENT(tmp) get_current tmp
  86. .macro save_switch_stack
  87. moveml %a3-%a6/%d6-%d7,%sp@-
  88. .endm
  89. .macro restore_switch_stack
  90. moveml %sp@+,%a3-%a6/%d6-%d7
  91. .endm
  92. .macro get_current reg=%d0
  93. movel %sp,\reg
  94. andw #-THREAD_SIZE,\reg
  95. movel \reg,%curptr
  96. movel %curptr@,%curptr
  97. .endm
  98. #else /* C source */
  99. #define STR(X) STR1(X)
  100. #define STR1(X) #X
  101. #define PT_OFF_ORIG_D0 0x24
  102. #define PT_OFF_FORMATVEC 0x32
  103. #define PT_OFF_SR 0x2C
  104. #define SAVE_ALL_INT \
  105. "clrl %%sp@-;" /* stk_adj */ \
  106. "pea -1:w;" /* orig d0 = -1 */ \
  107. "movel %%d0,%%sp@-;" /* d0 */ \
  108. "moveml %%d1-%%d5/%%a0-%%a2,%%sp@-"
  109. #define GET_CURRENT(tmp) \
  110. "movel %%sp,"#tmp"\n\t" \
  111. "andw #-"STR(THREAD_SIZE)","#tmp"\n\t" \
  112. "movel "#tmp",%%a2\n\t" \
  113. "movel %%a2@,%%a2"
  114. #endif
  115. #endif /* __M68K_ENTRY_H */