thread_info.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. #ifndef _ASM_M32R_THREAD_INFO_H
  2. #define _ASM_M32R_THREAD_INFO_H
  3. /* thread_info.h: m32r low-level thread information
  4. *
  5. * Copyright (C) 2002 David Howells (dhowells@redhat.com)
  6. * - Incorporating suggestions made by Linus Torvalds and Dave Miller
  7. * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org>
  8. */
  9. #ifdef __KERNEL__
  10. #ifndef __ASSEMBLY__
  11. #include <asm/processor.h>
  12. #endif
  13. /*
  14. * low level task data that entry.S needs immediate access to
  15. * - this struct should fit entirely inside of one cache line
  16. * - this struct shares the supervisor stack pages
  17. * - if the contents of this structure are changed, the assembly constants must also be changed
  18. */
  19. #ifndef __ASSEMBLY__
  20. struct thread_info {
  21. struct task_struct *task; /* main task structure */
  22. struct exec_domain *exec_domain; /* execution domain */
  23. unsigned long flags; /* low level flags */
  24. unsigned long status; /* thread-synchronous flags */
  25. __u32 cpu; /* current CPU */
  26. int preempt_count; /* 0 => preemptable, <0 => BUG */
  27. mm_segment_t addr_limit; /* thread address space:
  28. 0-0xBFFFFFFF for user-thread
  29. 0-0xFFFFFFFF for kernel-thread
  30. */
  31. struct restart_block restart_block;
  32. __u8 supervisor_stack[0];
  33. };
  34. #else /* !__ASSEMBLY__ */
  35. /* offsets into the thread_info struct for assembly code access */
  36. #define TI_TASK 0x00000000
  37. #define TI_EXEC_DOMAIN 0x00000004
  38. #define TI_FLAGS 0x00000008
  39. #define TI_STATUS 0x0000000C
  40. #define TI_CPU 0x00000010
  41. #define TI_PRE_COUNT 0x00000014
  42. #define TI_ADDR_LIMIT 0x00000018
  43. #define TI_RESTART_BLOCK 0x000001C
  44. #endif
  45. #define PREEMPT_ACTIVE 0x10000000
  46. /*
  47. * macros/functions for gaining access to the thread information structure
  48. */
  49. #ifndef __ASSEMBLY__
  50. #define INIT_THREAD_INFO(tsk) \
  51. { \
  52. .task = &tsk, \
  53. .exec_domain = &default_exec_domain, \
  54. .flags = 0, \
  55. .cpu = 0, \
  56. .preempt_count = INIT_PREEMPT_COUNT, \
  57. .addr_limit = KERNEL_DS, \
  58. .restart_block = { \
  59. .fn = do_no_restart_syscall, \
  60. }, \
  61. }
  62. #define init_thread_info (init_thread_union.thread_info)
  63. #define init_stack (init_thread_union.stack)
  64. #define THREAD_SIZE (2*PAGE_SIZE)
  65. /* how to get the thread information struct from C */
  66. static inline struct thread_info *current_thread_info(void)
  67. {
  68. struct thread_info *ti;
  69. __asm__ __volatile__ (
  70. "ldi %0, #%1 \n\t"
  71. "and %0, sp \n\t"
  72. : "=r" (ti) : "i" (~(THREAD_SIZE - 1))
  73. );
  74. return ti;
  75. }
  76. #define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
  77. /* thread information allocation */
  78. #ifdef CONFIG_DEBUG_STACK_USAGE
  79. #define alloc_thread_info(tsk) \
  80. ({ \
  81. struct thread_info *ret; \
  82. \
  83. ret = kzalloc(THREAD_SIZE, GFP_KERNEL); \
  84. \
  85. ret; \
  86. })
  87. #else
  88. #define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
  89. #endif
  90. #define free_thread_info(info) kfree(info)
  91. #define TI_FLAG_FAULT_CODE_SHIFT 28
  92. static inline void set_thread_fault_code(unsigned int val)
  93. {
  94. struct thread_info *ti = current_thread_info();
  95. ti->flags = (ti->flags & (~0 >> (32 - TI_FLAG_FAULT_CODE_SHIFT)))
  96. | (val << TI_FLAG_FAULT_CODE_SHIFT);
  97. }
  98. static inline unsigned int get_thread_fault_code(void)
  99. {
  100. struct thread_info *ti = current_thread_info();
  101. return ti->flags >> TI_FLAG_FAULT_CODE_SHIFT;
  102. }
  103. #else /* !__ASSEMBLY__ */
  104. #define THREAD_SIZE 8192
  105. /* how to get the thread information struct from ASM */
  106. #define GET_THREAD_INFO(reg) GET_THREAD_INFO reg
  107. .macro GET_THREAD_INFO reg
  108. ldi \reg, #-THREAD_SIZE
  109. and \reg, sp
  110. .endm
  111. #endif
  112. /*
  113. * thread information flags
  114. * - these are process state flags that various assembly files may need to access
  115. * - pending work-to-be-done flags are in LSW
  116. * - other flags in MSW
  117. */
  118. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  119. #define TIF_SIGPENDING 1 /* signal pending */
  120. #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
  121. #define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */
  122. #define TIF_IRET 4 /* return with iret */
  123. #define TIF_RESTORE_SIGMASK 8 /* restore signal mask in do_signal() */
  124. #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
  125. #define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */
  126. #define TIF_MEMDIE 18 /* OOM killer killed process */
  127. #define TIF_FREEZE 19 /* is freezing for suspend */
  128. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  129. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  130. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  131. #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
  132. #define _TIF_IRET (1<<TIF_IRET)
  133. #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
  134. #define _TIF_USEDFPU (1<<TIF_USEDFPU)
  135. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  136. #define _TIF_FREEZE (1<<TIF_FREEZE)
  137. #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
  138. #define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */
  139. /*
  140. * Thread-synchronous status.
  141. *
  142. * This is different from the flags in that nobody else
  143. * ever touches our thread-synchronous status, so we don't
  144. * have to worry about atomic accesses.
  145. */
  146. #define TS_USEDFPU 0x0001 /* FPU was used by this task this quantum (SMP) */
  147. #endif /* __KERNEL__ */
  148. #endif /* _ASM_M32R_THREAD_INFO_H */