thread_info.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* thread_info.h: h8300 low-level thread information
  3. * adapted from the i386 and PPC versions by Yoshinori Sato <ysato@users.sourceforge.jp>
  4. *
  5. * Copyright (C) 2002 David Howells (dhowells@redhat.com)
  6. * - Incorporating suggestions made by Linus Torvalds and Dave Miller
  7. */
  8. #ifndef _ASM_THREAD_INFO_H
  9. #define _ASM_THREAD_INFO_H
  10. #include <asm/page.h>
  11. #include <asm/segment.h>
  12. #ifdef __KERNEL__
  13. /*
  14. * Size of kernel stack for each process. This must be a power of 2...
  15. */
  16. #define THREAD_SIZE_ORDER 1
  17. #define THREAD_SIZE 8192 /* 2 pages */
  18. #ifndef __ASSEMBLY__
  19. /*
  20. * low level task data.
  21. * If you change this, change the TI_* offsets below to match.
  22. */
  23. struct thread_info {
  24. struct task_struct *task; /* main task structure */
  25. unsigned long flags; /* low level flags */
  26. int cpu; /* cpu we're on */
  27. int preempt_count; /* 0 => preemptable, <0 => BUG */
  28. mm_segment_t addr_limit;
  29. };
  30. /*
  31. * macros/functions for gaining access to the thread information structure
  32. */
  33. #define INIT_THREAD_INFO(tsk) \
  34. { \
  35. .task = &tsk, \
  36. .flags = 0, \
  37. .cpu = 0, \
  38. .preempt_count = INIT_PREEMPT_COUNT, \
  39. .addr_limit = KERNEL_DS, \
  40. }
  41. /* how to get the thread information struct from C */
  42. static inline struct thread_info *current_thread_info(void)
  43. {
  44. struct thread_info *ti;
  45. __asm__("mov.l sp, %0\n\t"
  46. "and.w %1, %T0"
  47. : "=&r"(ti)
  48. : "i" (~(THREAD_SIZE-1) & 0xffff));
  49. return ti;
  50. }
  51. #endif /* __ASSEMBLY__ */
  52. /*
  53. * thread information flag bit numbers
  54. */
  55. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  56. #define TIF_SIGPENDING 1 /* signal pending */
  57. #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
  58. #define TIF_SINGLESTEP 3 /* singlestepping active */
  59. #define TIF_MEMDIE 4 /* is terminating due to OOM killer */
  60. #define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
  61. #define TIF_NOTIFY_RESUME 6 /* callback before returning to user */
  62. #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
  63. #define TIF_SYSCALL_TRACEPOINT 8 /* for ftrace syscall instrumentation */
  64. #define TIF_POLLING_NRFLAG 9 /* true if poll_idle() is polling TIF_NEED_RESCHED */
  65. /* as above, but as bit values */
  66. #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
  67. #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
  68. #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
  69. #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
  70. #define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
  71. #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
  72. #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
  73. #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
  74. /* work to do in syscall trace */
  75. #define _TIF_WORK_SYSCALL_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
  76. _TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT)
  77. /* work to do on any return to u-space */
  78. #define _TIF_ALLWORK_MASK (_TIF_SYSCALL_TRACE | _TIF_SIGPENDING | \
  79. _TIF_NEED_RESCHED | _TIF_SYSCALL_AUDIT | \
  80. _TIF_SINGLESTEP | _TIF_NOTIFY_RESUME | \
  81. _TIF_SYSCALL_TRACEPOINT)
  82. /* work to do on interrupt/exception return */
  83. #define _TIF_WORK_MASK (_TIF_ALLWORK_MASK & ~(_TIF_SYSCALL_TRACE | \
  84. _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP))
  85. #endif /* __KERNEL__ */
  86. #endif /* _ASM_THREAD_INFO_H */