thread_info.h 4.3 KB

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