thread_info.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. unsigned long flags; /* low level flags */
  23. unsigned long status; /* thread-synchronous flags */
  24. __u32 cpu; /* current CPU */
  25. int preempt_count; /* 0 => preemptable, <0 => BUG */
  26. mm_segment_t addr_limit; /* thread address space:
  27. 0-0xBFFFFFFF for user-thread
  28. 0-0xFFFFFFFF for kernel-thread
  29. */
  30. __u8 supervisor_stack[0];
  31. };
  32. #endif /* !__ASSEMBLY__ */
  33. #define THREAD_SIZE (PAGE_SIZE << 1)
  34. #define THREAD_SIZE_ORDER 1
  35. /*
  36. * macros/functions for gaining access to the thread information structure
  37. */
  38. #ifndef __ASSEMBLY__
  39. #define INIT_THREAD_INFO(tsk) \
  40. { \
  41. .task = &tsk, \
  42. .flags = 0, \
  43. .cpu = 0, \
  44. .preempt_count = INIT_PREEMPT_COUNT, \
  45. .addr_limit = KERNEL_DS, \
  46. }
  47. #define init_thread_info (init_thread_union.thread_info)
  48. #define init_stack (init_thread_union.stack)
  49. /* how to get the thread information struct from C */
  50. static inline struct thread_info *current_thread_info(void)
  51. {
  52. struct thread_info *ti;
  53. __asm__ __volatile__ (
  54. "ldi %0, #%1 \n\t"
  55. "and %0, sp \n\t"
  56. : "=r" (ti) : "i" (~(THREAD_SIZE - 1))
  57. );
  58. return ti;
  59. }
  60. #define TI_FLAG_FAULT_CODE_SHIFT 28
  61. static inline void set_thread_fault_code(unsigned int val)
  62. {
  63. struct thread_info *ti = current_thread_info();
  64. ti->flags = (ti->flags & (~0 >> (32 - TI_FLAG_FAULT_CODE_SHIFT)))
  65. | (val << TI_FLAG_FAULT_CODE_SHIFT);
  66. }
  67. static inline unsigned int get_thread_fault_code(void)
  68. {
  69. struct thread_info *ti = current_thread_info();
  70. return ti->flags >> TI_FLAG_FAULT_CODE_SHIFT;
  71. }
  72. #endif
  73. /*
  74. * thread information flags
  75. * - these are process state flags that various assembly files may need to access
  76. * - pending work-to-be-done flags are in LSW
  77. * - other flags in MSW
  78. */
  79. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  80. #define TIF_SIGPENDING 1 /* signal pending */
  81. #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
  82. #define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */
  83. #define TIF_NOTIFY_RESUME 5 /* callback before returning to user */
  84. #define TIF_RESTORE_SIGMASK 8 /* restore signal mask in do_signal() */
  85. #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
  86. #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
  87. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  88. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  89. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  90. #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
  91. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  92. #define _TIF_USEDFPU (1<<TIF_USEDFPU)
  93. #define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
  94. #define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_SYSCALL_TRACE)
  95. /*
  96. * Thread-synchronous status.
  97. *
  98. * This is different from the flags in that nobody else
  99. * ever touches our thread-synchronous status, so we don't
  100. * have to worry about atomic accesses.
  101. */
  102. #define TS_USEDFPU 0x0001 /* FPU was used by this task this quantum (SMP) */
  103. #endif /* __KERNEL__ */
  104. #endif /* _ASM_M32R_THREAD_INFO_H */