thread_info.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /* thread_info.h: MIPS low-level thread information
  2. *
  3. * Copyright (C) 2002 David Howells (dhowells@redhat.com)
  4. * - Incorporating suggestions made by Linus Torvalds and Dave Miller
  5. */
  6. #ifndef _ASM_THREAD_INFO_H
  7. #define _ASM_THREAD_INFO_H
  8. #ifdef __KERNEL__
  9. #ifndef __ASSEMBLY__
  10. #include <asm/processor.h>
  11. /*
  12. * low level task data that entry.S needs immediate access to
  13. * - this struct should fit entirely inside of one cache line
  14. * - this struct shares the supervisor stack pages
  15. * - if the contents of this structure are changed, the assembly constants
  16. * must also be changed
  17. */
  18. struct thread_info {
  19. struct task_struct *task; /* main task structure */
  20. struct exec_domain *exec_domain; /* execution domain */
  21. unsigned long flags; /* low level flags */
  22. unsigned long tp_value; /* thread pointer */
  23. __u32 cpu; /* current CPU */
  24. int preempt_count; /* 0 => preemptable, <0 => BUG */
  25. mm_segment_t addr_limit; /* thread address space:
  26. 0-0xBFFFFFFF for user-thead
  27. 0-0xFFFFFFFF for kernel-thread
  28. */
  29. struct restart_block restart_block;
  30. struct pt_regs *regs;
  31. };
  32. /*
  33. * macros/functions for gaining access to the thread information structure
  34. */
  35. #define INIT_THREAD_INFO(tsk) \
  36. { \
  37. .task = &tsk, \
  38. .exec_domain = &default_exec_domain, \
  39. .flags = _TIF_FIXADE, \
  40. .cpu = 0, \
  41. .preempt_count = INIT_PREEMPT_COUNT, \
  42. .addr_limit = KERNEL_DS, \
  43. .restart_block = { \
  44. .fn = do_no_restart_syscall, \
  45. }, \
  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. register struct thread_info *__current_thread_info __asm__("$28");
  51. #define current_thread_info() __current_thread_info
  52. /* thread information allocation */
  53. #if defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_32BIT)
  54. #define THREAD_SIZE_ORDER (1)
  55. #endif
  56. #if defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_64BIT)
  57. #define THREAD_SIZE_ORDER (2)
  58. #endif
  59. #ifdef CONFIG_PAGE_SIZE_8KB
  60. #define THREAD_SIZE_ORDER (1)
  61. #endif
  62. #ifdef CONFIG_PAGE_SIZE_16KB
  63. #define THREAD_SIZE_ORDER (0)
  64. #endif
  65. #ifdef CONFIG_PAGE_SIZE_32KB
  66. #define THREAD_SIZE_ORDER (0)
  67. #endif
  68. #ifdef CONFIG_PAGE_SIZE_64KB
  69. #define THREAD_SIZE_ORDER (0)
  70. #endif
  71. #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
  72. #define THREAD_MASK (THREAD_SIZE - 1UL)
  73. #define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
  74. #ifdef CONFIG_DEBUG_STACK_USAGE
  75. #define alloc_thread_info(tsk) \
  76. ({ \
  77. struct thread_info *ret; \
  78. \
  79. ret = kzalloc(THREAD_SIZE, GFP_KERNEL); \
  80. \
  81. ret; \
  82. })
  83. #else
  84. #define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
  85. #endif
  86. #define free_thread_info(info) kfree(info)
  87. #endif /* !__ASSEMBLY__ */
  88. #define PREEMPT_ACTIVE 0x10000000
  89. /*
  90. * thread information flags
  91. * - these are process state flags that various assembly files may need to
  92. * access
  93. * - pending work-to-be-done flags are in LSW
  94. * - other flags in MSW
  95. */
  96. #define TIF_SIGPENDING 1 /* signal pending */
  97. #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
  98. #define TIF_SYSCALL_AUDIT 3 /* syscall auditing active */
  99. #define TIF_SECCOMP 4 /* secure computing */
  100. #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */
  101. #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
  102. #define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */
  103. #define TIF_MEMDIE 18
  104. #define TIF_FREEZE 19
  105. #define TIF_FIXADE 20 /* Fix address errors in software */
  106. #define TIF_LOGADE 21 /* Log address errors to syslog */
  107. #define TIF_32BIT_REGS 22 /* also implies 16/32 fprs */
  108. #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
  109. #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
  110. #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
  111. #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
  112. #ifdef CONFIG_MIPS32_O32
  113. #define TIF_32BIT TIF_32BIT_REGS
  114. #elif defined(CONFIG_MIPS32_N32)
  115. #define TIF_32BIT _TIF_32BIT_ADDR
  116. #endif /* CONFIG_MIPS32_O32 */
  117. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  118. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  119. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  120. #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
  121. #define _TIF_SECCOMP (1<<TIF_SECCOMP)
  122. #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
  123. #define _TIF_USEDFPU (1<<TIF_USEDFPU)
  124. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  125. #define _TIF_FREEZE (1<<TIF_FREEZE)
  126. #define _TIF_FIXADE (1<<TIF_FIXADE)
  127. #define _TIF_LOGADE (1<<TIF_LOGADE)
  128. #define _TIF_32BIT_REGS (1<<TIF_32BIT_REGS)
  129. #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
  130. #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
  131. #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
  132. /* work to do on interrupt/exception return */
  133. #define _TIF_WORK_MASK (0x0000ffef & ~_TIF_SECCOMP)
  134. /* work to do on any return to u-space */
  135. #define _TIF_ALLWORK_MASK (0x8000ffff & ~_TIF_SECCOMP)
  136. #endif /* __KERNEL__ */
  137. #endif /* _ASM_THREAD_INFO_H */