thread_info.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. #include <linux/config.h>
  10. #ifndef __ASSEMBLY__
  11. #include <asm/processor.h>
  12. /*
  13. * low level task data that entry.S needs immediate access to
  14. * - this struct should fit entirely inside of one cache line
  15. * - this struct shares the supervisor stack pages
  16. * - if the contents of this structure are changed, the assembly constants
  17. * must also be changed
  18. */
  19. struct thread_info {
  20. struct task_struct *task; /* main task structure */
  21. struct exec_domain *exec_domain; /* execution domain */
  22. unsigned long flags; /* low level flags */
  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. };
  31. /*
  32. * macros/functions for gaining access to the thread information structure
  33. *
  34. * preempt_count needs to be 1 initially, until the scheduler is functional.
  35. */
  36. #define INIT_THREAD_INFO(tsk) \
  37. { \
  38. .task = &tsk, \
  39. .exec_domain = &default_exec_domain, \
  40. .flags = 0, \
  41. .cpu = 0, \
  42. .preempt_count = 1, \
  43. .addr_limit = KERNEL_DS, \
  44. .restart_block = { \
  45. .fn = do_no_restart_syscall, \
  46. }, \
  47. }
  48. #define init_thread_info (init_thread_union.thread_info)
  49. #define init_stack (init_thread_union.stack)
  50. /* How to get the thread information struct from C. */
  51. register struct thread_info *__current_thread_info __asm__("$28");
  52. #define current_thread_info() __current_thread_info
  53. /* thread information allocation */
  54. #if defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_MIPS32)
  55. #define THREAD_SIZE_ORDER (1)
  56. #endif
  57. #if defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_MIPS64)
  58. #define THREAD_SIZE_ORDER (2)
  59. #endif
  60. #ifdef CONFIG_PAGE_SIZE_8KB
  61. #define THREAD_SIZE_ORDER (1)
  62. #endif
  63. #ifdef CONFIG_PAGE_SIZE_16KB
  64. #define THREAD_SIZE_ORDER (0)
  65. #endif
  66. #ifdef CONFIG_PAGE_SIZE_64KB
  67. #define THREAD_SIZE_ORDER (0)
  68. #endif
  69. #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
  70. #define THREAD_MASK (THREAD_SIZE - 1UL)
  71. #ifdef CONFIG_DEBUG_STACK_USAGE
  72. #define alloc_thread_info(tsk) \
  73. ({ \
  74. struct thread_info *ret; \
  75. \
  76. ret = kmalloc(THREAD_SIZE, GFP_KERNEL); \
  77. if (ret) \
  78. memset(ret, 0, THREAD_SIZE); \
  79. ret; \
  80. })
  81. #else
  82. #define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
  83. #endif
  84. #define free_thread_info(info) kfree(info)
  85. #define get_thread_info(ti) get_task_struct((ti)->task)
  86. #define put_thread_info(ti) put_task_struct((ti)->task)
  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_NOTIFY_RESUME 1 /* resumption notification requested */
  97. #define TIF_SIGPENDING 2 /* signal pending */
  98. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  99. #define TIF_SYSCALL_AUDIT 4 /* syscall auditing active */
  100. #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
  101. #define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */
  102. #define TIF_MEMDIE 18
  103. #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
  104. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  105. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  106. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  107. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  108. #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
  109. #define _TIF_USEDFPU (1<<TIF_USEDFPU)
  110. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  111. #define _TIF_WORK_MASK 0x0000ffef /* work to do on
  112. interrupt/exception return */
  113. #define _TIF_ALLWORK_MASK 0x8000ffff /* work to do on any return to
  114. u-space */
  115. #endif /* __KERNEL__ */
  116. #endif /* _ASM_THREAD_INFO_H */