thread_info.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright 2004-2010 Analog Devices Inc.
  3. *
  4. * Licensed under the GPL-2 or later.
  5. */
  6. #ifndef _ASM_THREAD_INFO_H
  7. #define _ASM_THREAD_INFO_H
  8. #include <asm/page.h>
  9. #include <asm/entry.h>
  10. #include <asm/l1layout.h>
  11. #include <linux/compiler.h>
  12. #ifdef __KERNEL__
  13. /* Thread Align Mask to reach to the top of the stack
  14. * for any process
  15. */
  16. #define ALIGN_PAGE_MASK 0xffffe000
  17. /*
  18. * Size of kernel stack for each process. This must be a power of 2...
  19. */
  20. #define THREAD_SIZE_ORDER 1
  21. #define THREAD_SIZE 8192 /* 2 pages */
  22. #define STACK_WARN (THREAD_SIZE/8)
  23. #ifndef __ASSEMBLY__
  24. typedef unsigned long mm_segment_t;
  25. /*
  26. * low level task data.
  27. * If you change this, change the TI_* offsets below to match.
  28. */
  29. struct thread_info {
  30. struct task_struct *task; /* main task structure */
  31. struct exec_domain *exec_domain; /* execution domain */
  32. unsigned long flags; /* low level flags */
  33. int cpu; /* cpu we're on */
  34. int preempt_count; /* 0 => preemptable, <0 => BUG */
  35. mm_segment_t addr_limit; /* address limit */
  36. struct restart_block restart_block;
  37. #ifndef CONFIG_SMP
  38. struct l1_scratch_task_info l1_task_info;
  39. #endif
  40. };
  41. /*
  42. * macros/functions for gaining access to the thread information structure
  43. */
  44. #define INIT_THREAD_INFO(tsk) \
  45. { \
  46. .task = &tsk, \
  47. .exec_domain = &default_exec_domain, \
  48. .flags = 0, \
  49. .cpu = 0, \
  50. .preempt_count = INIT_PREEMPT_COUNT, \
  51. .restart_block = { \
  52. .fn = do_no_restart_syscall, \
  53. }, \
  54. }
  55. #define init_thread_info (init_thread_union.thread_info)
  56. #define init_stack (init_thread_union.stack)
  57. /* Given a task stack pointer, you can find its corresponding
  58. * thread_info structure just by masking it to the THREAD_SIZE
  59. * boundary (currently 8K as you can see above).
  60. */
  61. __attribute_const__
  62. static inline struct thread_info *current_thread_info(void)
  63. {
  64. struct thread_info *ti;
  65. __asm__("%0 = sp;" : "=da"(ti));
  66. return (struct thread_info *)((long)ti & ~((long)THREAD_SIZE-1));
  67. }
  68. #endif /* __ASSEMBLY__ */
  69. /*
  70. * Offsets in thread_info structure, used in assembly code
  71. */
  72. #define TI_TASK 0
  73. #define TI_EXECDOMAIN 4
  74. #define TI_FLAGS 8
  75. #define TI_CPU 12
  76. #define TI_PREEMPT 16
  77. #define PREEMPT_ACTIVE 0x4000000
  78. /*
  79. * thread information flag bit numbers
  80. */
  81. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  82. #define TIF_SIGPENDING 1 /* signal pending */
  83. #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
  84. #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
  85. TIF_NEED_RESCHED */
  86. #define TIF_MEMDIE 4 /* is terminating due to OOM killer */
  87. #define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
  88. #define TIF_FREEZE 6 /* is freezing for suspend */
  89. #define TIF_IRQ_SYNC 7 /* sync pipeline stage */
  90. #define TIF_NOTIFY_RESUME 8 /* callback before returning to user */
  91. #define TIF_SINGLESTEP 9
  92. /* as above, but as bit values */
  93. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  94. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  95. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  96. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  97. #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
  98. #define _TIF_FREEZE (1<<TIF_FREEZE)
  99. #define _TIF_IRQ_SYNC (1<<TIF_IRQ_SYNC)
  100. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  101. #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
  102. #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
  103. #endif /* __KERNEL__ */
  104. #endif /* _ASM_THREAD_INFO_H */