thread_info.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. #ifndef __ASSEMBLY__
  80. #define HAVE_SET_RESTORE_SIGMASK 1
  81. static inline void set_restore_sigmask(void)
  82. {
  83. struct thread_info *ti = current_thread_info();
  84. ti->status |= TS_RESTORE_SIGMASK;
  85. WARN_ON(!test_bit(TIF_SIGPENDING, (unsigned long *)&ti->flags));
  86. }
  87. static inline void clear_restore_sigmask(void)
  88. {
  89. current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
  90. }
  91. static inline bool test_restore_sigmask(void)
  92. {
  93. return current_thread_info()->status & TS_RESTORE_SIGMASK;
  94. }
  95. static inline bool test_and_clear_restore_sigmask(void)
  96. {
  97. struct thread_info *ti = current_thread_info();
  98. if (!(ti->status & TS_RESTORE_SIGMASK))
  99. return false;
  100. ti->status &= ~TS_RESTORE_SIGMASK;
  101. return true;
  102. }
  103. #endif
  104. #define SET_UNALIGN_CTL(task,value) ({ \
  105. __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \
  106. if (value & PR_UNALIGN_NOPRINT) \
  107. status |= TS_UAC_NOPRINT; \
  108. if (value & PR_UNALIGN_SIGBUS) \
  109. status |= TS_UAC_SIGBUS; \
  110. if (value & 4) /* alpha-specific */ \
  111. status |= TS_UAC_NOFIX; \
  112. task_thread_info(task)->status = status; \
  113. 0; })
  114. #define GET_UNALIGN_CTL(task,value) ({ \
  115. __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \
  116. __u32 res = 0; \
  117. if (status & TS_UAC_NOPRINT) \
  118. res |= PR_UNALIGN_NOPRINT; \
  119. if (status & TS_UAC_SIGBUS) \
  120. res |= PR_UNALIGN_SIGBUS; \
  121. if (status & TS_UAC_NOFIX) \
  122. res |= 4; \
  123. put_user(res, (int __user *)(value)); \
  124. })
  125. #endif /* __KERNEL__ */
  126. #endif /* _ALPHA_THREAD_INFO_H */