thread_info.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* thread_info.h: PPC low-level thread information
  2. * adapted from the i386 version by Paul Mackerras
  3. *
  4. * Copyright (C) 2002 David Howells (dhowells@redhat.com)
  5. * - Incorporating suggestions made by Linus Torvalds and Dave Miller
  6. */
  7. #ifndef _ASM_THREAD_INFO_H
  8. #define _ASM_THREAD_INFO_H
  9. #ifdef __KERNEL__
  10. #ifndef __ASSEMBLY__
  11. #include <linux/config.h>
  12. #include <linux/cache.h>
  13. #include <asm/processor.h>
  14. #include <asm/page.h>
  15. #include <linux/stringify.h>
  16. /*
  17. * low level task data.
  18. */
  19. struct thread_info {
  20. struct task_struct *task; /* main task structure */
  21. struct exec_domain *exec_domain; /* execution domain */
  22. int cpu; /* cpu we're on */
  23. int preempt_count; /* 0 => preemptable, <0 => BUG */
  24. struct restart_block restart_block;
  25. /* set by force_successful_syscall_return */
  26. unsigned char syscall_noerror;
  27. /* low level flags - has atomic operations done on it */
  28. unsigned long flags ____cacheline_aligned_in_smp;
  29. };
  30. /*
  31. * macros/functions for gaining access to the thread information structure
  32. *
  33. * preempt_count needs to be 1 initially, until the scheduler is functional.
  34. */
  35. #define INIT_THREAD_INFO(tsk) \
  36. { \
  37. .task = &tsk, \
  38. .exec_domain = &default_exec_domain, \
  39. .cpu = 0, \
  40. .preempt_count = 1, \
  41. .restart_block = { \
  42. .fn = do_no_restart_syscall, \
  43. }, \
  44. .flags = 0, \
  45. }
  46. #define init_thread_info (init_thread_union.thread_info)
  47. #define init_stack (init_thread_union.stack)
  48. /* thread information allocation */
  49. #define THREAD_ORDER 2
  50. #define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER)
  51. #define THREAD_SHIFT (PAGE_SHIFT + THREAD_ORDER)
  52. #ifdef CONFIG_DEBUG_STACK_USAGE
  53. #define alloc_thread_info(tsk) \
  54. ({ \
  55. struct thread_info *ret; \
  56. \
  57. ret = kmalloc(THREAD_SIZE, GFP_KERNEL); \
  58. if (ret) \
  59. memset(ret, 0, THREAD_SIZE); \
  60. ret; \
  61. })
  62. #else
  63. #define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
  64. #endif
  65. #define free_thread_info(ti) kfree(ti)
  66. #define get_thread_info(ti) get_task_struct((ti)->task)
  67. #define put_thread_info(ti) put_task_struct((ti)->task)
  68. /* how to get the thread information struct from C */
  69. static inline struct thread_info *current_thread_info(void)
  70. {
  71. struct thread_info *ti;
  72. __asm__("clrrdi %0,1,%1" : "=r"(ti) : "i" (THREAD_SHIFT));
  73. return ti;
  74. }
  75. #endif /* __ASSEMBLY__ */
  76. #define PREEMPT_ACTIVE 0x10000000
  77. /*
  78. * thread information flag bit numbers
  79. */
  80. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  81. #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
  82. #define TIF_SIGPENDING 2 /* signal pending */
  83. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  84. #define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling
  85. TIF_NEED_RESCHED */
  86. #define TIF_32BIT 5 /* 32 bit binary */
  87. /* #define SPARE 6 */
  88. #define TIF_ABI_PENDING 7 /* 32/64 bit switch needed */
  89. #define TIF_SYSCALL_AUDIT 8 /* syscall auditing active */
  90. #define TIF_SINGLESTEP 9 /* singlestepping active */
  91. #define TIF_MEMDIE 10
  92. #define TIF_SECCOMP 11 /* secure computing */
  93. /* as above, but as bit values */
  94. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  95. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  96. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  97. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  98. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  99. #define _TIF_32BIT (1<<TIF_32BIT)
  100. /* #define _SPARE (1<<SPARE) */
  101. #define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
  102. #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
  103. #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
  104. #define _TIF_SECCOMP (1<<TIF_SECCOMP)
  105. #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP)
  106. #define _TIF_USER_WORK_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | \
  107. _TIF_NEED_RESCHED)
  108. #endif /* __KERNEL__ */
  109. #endif /* _ASM_THREAD_INFO_H */