thread_info.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_M32R_THREAD_INFO_H
  3. #define _ASM_M32R_THREAD_INFO_H
  4. /* thread_info.h: m32r low-level thread information
  5. *
  6. * Copyright (C) 2002 David Howells (dhowells@redhat.com)
  7. * - Incorporating suggestions made by Linus Torvalds and Dave Miller
  8. * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org>
  9. */
  10. #ifdef __KERNEL__
  11. #ifndef __ASSEMBLY__
  12. #include <asm/processor.h>
  13. #endif
  14. /*
  15. * low level task data that entry.S needs immediate access to
  16. * - this struct should fit entirely inside of one cache line
  17. * - this struct shares the supervisor stack pages
  18. * - if the contents of this structure are changed, the assembly constants must also be changed
  19. */
  20. #ifndef __ASSEMBLY__
  21. struct thread_info {
  22. struct task_struct *task; /* main task structure */
  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. __u8 supervisor_stack[0];
  32. };
  33. #endif /* !__ASSEMBLY__ */
  34. #define THREAD_SIZE (PAGE_SIZE << 1)
  35. #define THREAD_SIZE_ORDER 1
  36. /*
  37. * macros/functions for gaining access to the thread information structure
  38. */
  39. #ifndef __ASSEMBLY__
  40. #define INIT_THREAD_INFO(tsk) \
  41. { \
  42. .task = &tsk, \
  43. .flags = 0, \
  44. .cpu = 0, \
  45. .preempt_count = INIT_PREEMPT_COUNT, \
  46. .addr_limit = KERNEL_DS, \
  47. }
  48. /* how to get the thread information struct from C */
  49. static inline struct thread_info *current_thread_info(void)
  50. {
  51. struct thread_info *ti;
  52. __asm__ __volatile__ (
  53. "ldi %0, #%1 \n\t"
  54. "and %0, sp \n\t"
  55. : "=r" (ti) : "i" (~(THREAD_SIZE - 1))
  56. );
  57. return ti;
  58. }
  59. #define TI_FLAG_FAULT_CODE_SHIFT 28
  60. static inline void set_thread_fault_code(unsigned int val)
  61. {
  62. struct thread_info *ti = current_thread_info();
  63. ti->flags = (ti->flags & (~0 >> (32 - TI_FLAG_FAULT_CODE_SHIFT)))
  64. | (val << TI_FLAG_FAULT_CODE_SHIFT);
  65. }
  66. static inline unsigned int get_thread_fault_code(void)
  67. {
  68. struct thread_info *ti = current_thread_info();
  69. return ti->flags >> TI_FLAG_FAULT_CODE_SHIFT;
  70. }
  71. #endif
  72. /*
  73. * thread information flags
  74. * - these are process state flags that various assembly files may need to access
  75. * - pending work-to-be-done flags are in LSW
  76. * - other flags in MSW
  77. */
  78. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  79. #define TIF_SIGPENDING 1 /* signal pending */
  80. #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
  81. #define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */
  82. #define TIF_NOTIFY_RESUME 5 /* callback before returning to user */
  83. #define TIF_RESTORE_SIGMASK 8 /* restore signal mask in do_signal() */
  84. #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
  85. #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
  86. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  87. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  88. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  89. #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
  90. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  91. #define _TIF_USEDFPU (1<<TIF_USEDFPU)
  92. #define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
  93. #define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_SYSCALL_TRACE)
  94. /*
  95. * Thread-synchronous status.
  96. *
  97. * This is different from the flags in that nobody else
  98. * ever touches our thread-synchronous status, so we don't
  99. * have to worry about atomic accesses.
  100. */
  101. #define TS_USEDFPU 0x0001 /* FPU was used by this task this quantum (SMP) */
  102. #endif /* __KERNEL__ */
  103. #endif /* _ASM_M32R_THREAD_INFO_H */