thread_info.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #ifndef _ALPHA_THREAD_INFO_H
  2. #define _ALPHA_THREAD_INFO_H
  3. #ifdef __KERNEL__
  4. #ifndef __ASSEMBLY__
  5. #include <asm/processor.h>
  6. #include <asm/types.h>
  7. #include <asm/hwrpb.h>
  8. #include <asm/sysinfo.h>
  9. #endif
  10. #ifndef __ASSEMBLY__
  11. struct thread_info {
  12. struct pcb_struct pcb; /* palcode state */
  13. struct task_struct *task; /* main task structure */
  14. unsigned int flags; /* low level flags */
  15. unsigned int ieee_state; /* see fpu.h */
  16. struct exec_domain *exec_domain; /* execution domain */
  17. mm_segment_t addr_limit; /* thread address space */
  18. unsigned cpu; /* current CPU */
  19. int preempt_count; /* 0 => preemptable, <0 => BUG */
  20. unsigned int status; /* thread-synchronous flags */
  21. int bpt_nsaved;
  22. unsigned long bpt_addr[2]; /* breakpoint handling */
  23. unsigned int bpt_insn[2];
  24. struct restart_block restart_block;
  25. };
  26. /*
  27. * Macros/functions for gaining access to the thread information structure.
  28. */
  29. #define INIT_THREAD_INFO(tsk) \
  30. { \
  31. .task = &tsk, \
  32. .exec_domain = &default_exec_domain, \
  33. .addr_limit = KERNEL_DS, \
  34. .preempt_count = INIT_PREEMPT_COUNT, \
  35. .restart_block = { \
  36. .fn = do_no_restart_syscall, \
  37. }, \
  38. }
  39. #define init_thread_info (init_thread_union.thread_info)
  40. #define init_stack (init_thread_union.stack)
  41. /* How to get the thread information struct from C. */
  42. register struct thread_info *__current_thread_info __asm__("$8");
  43. #define current_thread_info() __current_thread_info
  44. #endif /* __ASSEMBLY__ */
  45. /* Thread information allocation. */
  46. #define THREAD_SIZE_ORDER 1
  47. #define THREAD_SIZE (2*PAGE_SIZE)
  48. #define PREEMPT_ACTIVE 0x40000000
  49. /*
  50. * Thread information flags:
  51. * - these are process state flags and used from assembly
  52. * - pending work-to-be-done flags come first and must be assigned to be
  53. * within bits 0 to 7 to fit in and immediate operand.
  54. *
  55. * TIF_SYSCALL_TRACE is known to be 0 via blbs.
  56. */
  57. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  58. #define TIF_NOTIFY_RESUME 1 /* callback before returning to user */
  59. #define TIF_SIGPENDING 2 /* signal pending */
  60. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  61. #define TIF_DIE_IF_KERNEL 9 /* dik recursion lock */
  62. #define TIF_MEMDIE 13 /* is terminating due to OOM killer */
  63. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  64. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  65. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  66. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  67. /* Work to do on interrupt/exception return. */
  68. #define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
  69. _TIF_NOTIFY_RESUME)
  70. /* Work to do on any return to userspace. */
  71. #define _TIF_ALLWORK_MASK (_TIF_WORK_MASK \
  72. | _TIF_SYSCALL_TRACE)
  73. #define TS_UAC_NOPRINT 0x0001 /* ! Preserve the following three */
  74. #define TS_UAC_NOFIX 0x0002 /* ! flags as they match */
  75. #define TS_UAC_SIGBUS 0x0004 /* ! userspace part of 'osf_sysinfo' */
  76. #define TS_RESTORE_SIGMASK 0x0008 /* restore signal mask in do_signal() */
  77. #define TS_POLLING 0x0010 /* idle task polling need_resched,
  78. skip sending interrupt */
  79. #define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING)
  80. #ifndef __ASSEMBLY__
  81. #define HAVE_SET_RESTORE_SIGMASK 1
  82. static inline void set_restore_sigmask(void)
  83. {
  84. struct thread_info *ti = current_thread_info();
  85. ti->status |= TS_RESTORE_SIGMASK;
  86. WARN_ON(!test_bit(TIF_SIGPENDING, (unsigned long *)&ti->flags));
  87. }
  88. static inline void clear_restore_sigmask(void)
  89. {
  90. current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
  91. }
  92. static inline bool test_restore_sigmask(void)
  93. {
  94. return current_thread_info()->status & TS_RESTORE_SIGMASK;
  95. }
  96. static inline bool test_and_clear_restore_sigmask(void)
  97. {
  98. struct thread_info *ti = current_thread_info();
  99. if (!(ti->status & TS_RESTORE_SIGMASK))
  100. return false;
  101. ti->status &= ~TS_RESTORE_SIGMASK;
  102. return true;
  103. }
  104. #endif
  105. #define SET_UNALIGN_CTL(task,value) ({ \
  106. __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \
  107. if (value & PR_UNALIGN_NOPRINT) \
  108. status |= TS_UAC_NOPRINT; \
  109. if (value & PR_UNALIGN_SIGBUS) \
  110. status |= TS_UAC_SIGBUS; \
  111. if (value & 4) /* alpha-specific */ \
  112. status |= TS_UAC_NOFIX; \
  113. task_thread_info(task)->status = status; \
  114. 0; })
  115. #define GET_UNALIGN_CTL(task,value) ({ \
  116. __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \
  117. __u32 res = 0; \
  118. if (status & TS_UAC_NOPRINT) \
  119. res |= PR_UNALIGN_NOPRINT; \
  120. if (status & TS_UAC_SIGBUS) \
  121. res |= PR_UNALIGN_SIGBUS; \
  122. if (status & TS_UAC_NOFIX) \
  123. res |= 4; \
  124. put_user(res, (int __user *)(value)); \
  125. })
  126. #endif /* __KERNEL__ */
  127. #endif /* _ALPHA_THREAD_INFO_H */