thread_info.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. * preempt_count needs to be 1 initially, until the scheduler is functional.
  36. */
  37. #define INIT_THREAD_INFO(tsk) \
  38. { \
  39. .task = &tsk, \
  40. .exec_domain = &default_exec_domain, \
  41. .flags = _TIF_FIXADE, \
  42. .cpu = 0, \
  43. .preempt_count = 1, \
  44. .addr_limit = KERNEL_DS, \
  45. .restart_block = { \
  46. .fn = do_no_restart_syscall, \
  47. }, \
  48. }
  49. #define init_thread_info (init_thread_union.thread_info)
  50. #define init_stack (init_thread_union.stack)
  51. /* How to get the thread information struct from C. */
  52. register struct thread_info *__current_thread_info __asm__("$28");
  53. #define current_thread_info() __current_thread_info
  54. /* thread information allocation */
  55. #if defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_32BIT)
  56. #define THREAD_SIZE_ORDER (1)
  57. #endif
  58. #if defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_64BIT)
  59. #define THREAD_SIZE_ORDER (2)
  60. #endif
  61. #ifdef CONFIG_PAGE_SIZE_8KB
  62. #define THREAD_SIZE_ORDER (1)
  63. #endif
  64. #ifdef CONFIG_PAGE_SIZE_16KB
  65. #define THREAD_SIZE_ORDER (0)
  66. #endif
  67. #ifdef CONFIG_PAGE_SIZE_32KB
  68. #define THREAD_SIZE_ORDER (0)
  69. #endif
  70. #ifdef CONFIG_PAGE_SIZE_64KB
  71. #define THREAD_SIZE_ORDER (0)
  72. #endif
  73. #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
  74. #define THREAD_MASK (THREAD_SIZE - 1UL)
  75. #define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
  76. #ifdef CONFIG_DEBUG_STACK_USAGE
  77. #define alloc_thread_info(tsk) \
  78. ({ \
  79. struct thread_info *ret; \
  80. \
  81. ret = kzalloc(THREAD_SIZE, GFP_KERNEL); \
  82. \
  83. ret; \
  84. })
  85. #else
  86. #define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
  87. #endif
  88. #define free_thread_info(info) kfree(info)
  89. #endif /* !__ASSEMBLY__ */
  90. #define PREEMPT_ACTIVE 0x10000000
  91. /*
  92. * thread information flags
  93. * - these are process state flags that various assembly files may need to
  94. * access
  95. * - pending work-to-be-done flags are in LSW
  96. * - other flags in MSW
  97. */
  98. #define TIF_SIGPENDING 1 /* signal pending */
  99. #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
  100. #define TIF_SYSCALL_AUDIT 3 /* syscall auditing active */
  101. #define TIF_SECCOMP 4 /* secure computing */
  102. #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */
  103. #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
  104. #define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */
  105. #define TIF_MEMDIE 18
  106. #define TIF_FREEZE 19
  107. #define TIF_FIXADE 20 /* Fix address errors in software */
  108. #define TIF_LOGADE 21 /* Log address errors to syslog */
  109. #define TIF_32BIT_REGS 22 /* also implies 16/32 fprs */
  110. #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
  111. #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
  112. #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
  113. #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
  114. #ifdef CONFIG_MIPS32_O32
  115. #define TIF_32BIT TIF_32BIT_REGS
  116. #elif defined(CONFIG_MIPS32_N32)
  117. #define TIF_32BIT _TIF_32BIT_ADDR
  118. #endif /* CONFIG_MIPS32_O32 */
  119. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  120. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  121. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  122. #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
  123. #define _TIF_SECCOMP (1<<TIF_SECCOMP)
  124. #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
  125. #define _TIF_USEDFPU (1<<TIF_USEDFPU)
  126. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  127. #define _TIF_FREEZE (1<<TIF_FREEZE)
  128. #define _TIF_FIXADE (1<<TIF_FIXADE)
  129. #define _TIF_LOGADE (1<<TIF_LOGADE)
  130. #define _TIF_32BIT_REGS (1<<TIF_32BIT_REGS)
  131. #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
  132. #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
  133. #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
  134. /* work to do on interrupt/exception return */
  135. #define _TIF_WORK_MASK (0x0000ffef & ~_TIF_SECCOMP)
  136. /* work to do on any return to u-space */
  137. #define _TIF_ALLWORK_MASK (0x8000ffff & ~_TIF_SECCOMP)
  138. #endif /* __KERNEL__ */
  139. #endif /* _ASM_THREAD_INFO_H */