thread_info.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ALPHA_THREAD_INFO_H
  3. #define _ALPHA_THREAD_INFO_H
  4. #ifdef __KERNEL__
  5. #ifndef __ASSEMBLY__
  6. #include <asm/processor.h>
  7. #include <asm/types.h>
  8. #include <asm/hwrpb.h>
  9. #include <asm/sysinfo.h>
  10. #endif
  11. #ifndef __ASSEMBLY__
  12. struct thread_info {
  13. struct pcb_struct pcb; /* palcode state */
  14. struct task_struct *task; /* main task structure */
  15. unsigned int flags; /* low level flags */
  16. unsigned int ieee_state; /* see fpu.h */
  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. .preempt_count = INIT_PREEMPT_COUNT, \
  31. }
  32. /* How to get the thread information struct from C. */
  33. register struct thread_info *__current_thread_info __asm__("$8");
  34. #define current_thread_info() __current_thread_info
  35. #endif /* __ASSEMBLY__ */
  36. /* Thread information allocation. */
  37. #define THREAD_SIZE_ORDER 1
  38. #define THREAD_SIZE (2*PAGE_SIZE)
  39. /*
  40. * Thread information flags:
  41. * - these are process state flags and used from assembly
  42. * - pending work-to-be-done flags come first and must be assigned to be
  43. * within bits 0 to 7 to fit in and immediate operand.
  44. *
  45. * TIF_SYSCALL_TRACE is known to be 0 via blbs.
  46. */
  47. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  48. #define TIF_NOTIFY_RESUME 1 /* callback before returning to user */
  49. #define TIF_SIGPENDING 2 /* signal pending */
  50. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  51. #define TIF_SYSCALL_AUDIT 4 /* syscall audit active */
  52. #define TIF_NOTIFY_SIGNAL 5 /* signal notifications exist */
  53. #define TIF_DIE_IF_KERNEL 9 /* dik recursion lock */
  54. #define TIF_MEMDIE 13 /* is terminating due to OOM killer */
  55. #define TIF_POLLING_NRFLAG 14 /* idle is polling for TIF_NEED_RESCHED */
  56. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  57. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  58. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  59. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  60. #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
  61. #define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL)
  62. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  63. /* Work to do on interrupt/exception return. */
  64. #define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
  65. _TIF_NOTIFY_RESUME | _TIF_NOTIFY_SIGNAL)
  66. /* Work to do on any return to userspace. */
  67. #define _TIF_ALLWORK_MASK (_TIF_WORK_MASK \
  68. | _TIF_SYSCALL_TRACE)
  69. #define TS_UAC_NOPRINT 0x0001 /* ! Preserve the following three */
  70. #define TS_UAC_NOFIX 0x0002 /* ! flags as they match */
  71. #define TS_UAC_SIGBUS 0x0004 /* ! userspace part of 'osf_sysinfo' */
  72. #define SET_UNALIGN_CTL(task,value) ({ \
  73. __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \
  74. if (value & PR_UNALIGN_NOPRINT) \
  75. status |= TS_UAC_NOPRINT; \
  76. if (value & PR_UNALIGN_SIGBUS) \
  77. status |= TS_UAC_SIGBUS; \
  78. if (value & 4) /* alpha-specific */ \
  79. status |= TS_UAC_NOFIX; \
  80. task_thread_info(task)->status = status; \
  81. 0; })
  82. #define GET_UNALIGN_CTL(task,value) ({ \
  83. __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \
  84. __u32 res = 0; \
  85. if (status & TS_UAC_NOPRINT) \
  86. res |= PR_UNALIGN_NOPRINT; \
  87. if (status & TS_UAC_SIGBUS) \
  88. res |= PR_UNALIGN_SIGBUS; \
  89. if (status & TS_UAC_NOFIX) \
  90. res |= 4; \
  91. put_user(res, (int __user *)(value)); \
  92. })
  93. #endif /* __KERNEL__ */
  94. #endif /* _ALPHA_THREAD_INFO_H */