thread_info.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * Copyright (C) 2002 David Howells (dhowells@redhat.com)
  3. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation, version 2.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  12. * NON INFRINGEMENT. See the GNU General Public License for
  13. * more details.
  14. */
  15. #ifndef _ASM_TILE_THREAD_INFO_H
  16. #define _ASM_TILE_THREAD_INFO_H
  17. #include <asm/processor.h>
  18. #include <asm/page.h>
  19. #ifndef __ASSEMBLY__
  20. /*
  21. * Low level task data that assembly code needs immediate access to.
  22. * The structure is placed at the bottom of the supervisor stack.
  23. */
  24. struct thread_info {
  25. struct task_struct *task; /* main task structure */
  26. struct exec_domain *exec_domain; /* execution domain */
  27. unsigned long flags; /* low level flags */
  28. unsigned long status; /* thread-synchronous flags */
  29. __u32 homecache_cpu; /* CPU we are homecached on */
  30. __u32 cpu; /* current CPU */
  31. int preempt_count; /* 0 => preemptable,
  32. <0 => BUG */
  33. mm_segment_t addr_limit; /* thread address space
  34. (KERNEL_DS or USER_DS) */
  35. struct restart_block restart_block;
  36. struct single_step_state *step_state; /* single step state
  37. (if non-zero) */
  38. };
  39. /*
  40. * macros/functions for gaining access to the thread information structure.
  41. */
  42. #define INIT_THREAD_INFO(tsk) \
  43. { \
  44. .task = &tsk, \
  45. .exec_domain = &default_exec_domain, \
  46. .flags = 0, \
  47. .cpu = 0, \
  48. .preempt_count = INIT_PREEMPT_COUNT, \
  49. .addr_limit = KERNEL_DS, \
  50. .restart_block = { \
  51. .fn = do_no_restart_syscall, \
  52. }, \
  53. .step_state = NULL, \
  54. }
  55. #define init_thread_info (init_thread_union.thread_info)
  56. #define init_stack (init_thread_union.stack)
  57. #endif /* !__ASSEMBLY__ */
  58. #if PAGE_SIZE < 8192
  59. #define THREAD_SIZE_ORDER (13 - PAGE_SHIFT)
  60. #else
  61. #define THREAD_SIZE_ORDER (0)
  62. #endif
  63. #define THREAD_SIZE_PAGES (1 << THREAD_SIZE_ORDER)
  64. #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
  65. #define LOG2_THREAD_SIZE (PAGE_SHIFT + THREAD_SIZE_ORDER)
  66. #define STACK_WARN (THREAD_SIZE/8)
  67. #ifndef __ASSEMBLY__
  68. /* How to get the thread information struct from C. */
  69. register unsigned long stack_pointer __asm__("sp");
  70. #define current_thread_info() \
  71. ((struct thread_info *)(stack_pointer & -THREAD_SIZE))
  72. #define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
  73. extern struct thread_info *alloc_thread_info_node(struct task_struct *task, int node);
  74. extern void free_thread_info(struct thread_info *info);
  75. /* Sit on a nap instruction until interrupted. */
  76. extern void smp_nap(void);
  77. /* Enable interrupts racelessly and nap forever: helper for cpu_idle(). */
  78. extern void _cpu_idle(void);
  79. /* Switch boot idle thread to a freshly-allocated stack and free old stack. */
  80. extern void cpu_idle_on_new_stack(struct thread_info *old_ti,
  81. unsigned long new_sp,
  82. unsigned long new_ss10);
  83. #else /* __ASSEMBLY__ */
  84. /* how to get the thread information struct from ASM */
  85. #ifdef __tilegx__
  86. #define GET_THREAD_INFO(reg) move reg, sp; mm reg, zero, LOG2_THREAD_SIZE, 63
  87. #else
  88. #define GET_THREAD_INFO(reg) mm reg, sp, zero, LOG2_THREAD_SIZE, 31
  89. #endif
  90. #endif /* !__ASSEMBLY__ */
  91. #define PREEMPT_ACTIVE 0x10000000
  92. /*
  93. * Thread information flags that various assembly files may need to access.
  94. * Keep flags accessed frequently in low bits, particular since it makes
  95. * it easier to build constants in assembly.
  96. */
  97. #define TIF_SIGPENDING 0 /* signal pending */
  98. #define TIF_NEED_RESCHED 1 /* rescheduling necessary */
  99. #define TIF_SINGLESTEP 2 /* restore singlestep on return to
  100. user mode */
  101. #define TIF_ASYNC_TLB 3 /* got an async TLB fault in kernel */
  102. #define TIF_SYSCALL_TRACE 4 /* syscall trace active */
  103. #define TIF_SYSCALL_AUDIT 5 /* syscall auditing active */
  104. #define TIF_SECCOMP 6 /* secure computing */
  105. #define TIF_MEMDIE 7 /* OOM killer at work */
  106. #define TIF_NOTIFY_RESUME 8 /* callback before returning to user */
  107. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  108. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  109. #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
  110. #define _TIF_ASYNC_TLB (1<<TIF_ASYNC_TLB)
  111. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  112. #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
  113. #define _TIF_SECCOMP (1<<TIF_SECCOMP)
  114. #define _TIF_MEMDIE (1<<TIF_MEMDIE)
  115. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  116. /* Work to do on any return to user space. */
  117. #define _TIF_ALLWORK_MASK \
  118. (_TIF_SIGPENDING|_TIF_NEED_RESCHED|_TIF_SINGLESTEP|\
  119. _TIF_ASYNC_TLB|_TIF_NOTIFY_RESUME)
  120. /*
  121. * Thread-synchronous status.
  122. *
  123. * This is different from the flags in that nobody else
  124. * ever touches our thread-synchronous status, so we don't
  125. * have to worry about atomic accesses.
  126. */
  127. #ifdef __tilegx__
  128. #define TS_COMPAT 0x0001 /* 32-bit compatibility mode */
  129. #endif
  130. #define TS_POLLING 0x0004 /* in idle loop but not sleeping */
  131. #define TS_RESTORE_SIGMASK 0x0008 /* restore signal mask in do_signal */
  132. #define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING)
  133. #ifndef __ASSEMBLY__
  134. #define HAVE_SET_RESTORE_SIGMASK 1
  135. static inline void set_restore_sigmask(void)
  136. {
  137. struct thread_info *ti = current_thread_info();
  138. ti->status |= TS_RESTORE_SIGMASK;
  139. set_bit(TIF_SIGPENDING, &ti->flags);
  140. }
  141. #endif /* !__ASSEMBLY__ */
  142. #endif /* _ASM_TILE_THREAD_INFO_H */