thread_info.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * Vineetg: Oct 2009
  9. * No need for ARC specific thread_info allocator (kmalloc/free). This is
  10. * anyways one page allocation, thus slab alloc can be short-circuited and
  11. * the generic version (get_free_page) would be loads better.
  12. *
  13. * Sameer Dhavale: Codito Technologies 2004
  14. */
  15. #ifndef _ASM_THREAD_INFO_H
  16. #define _ASM_THREAD_INFO_H
  17. #include <asm/page.h>
  18. #ifdef CONFIG_16KSTACKS
  19. #define THREAD_SIZE_ORDER 1
  20. #else
  21. #define THREAD_SIZE_ORDER 0
  22. #endif
  23. #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
  24. #ifndef __ASSEMBLY__
  25. #include <linux/thread_info.h>
  26. #include <asm/segment.h>
  27. /*
  28. * low level task data that entry.S needs immediate access to
  29. * - this struct should fit entirely inside of one cache line
  30. * - this struct shares the supervisor stack pages
  31. * - if the contents of this structure are changed, the assembly constants
  32. * must also be changed
  33. */
  34. struct thread_info {
  35. unsigned long flags; /* low level flags */
  36. int preempt_count; /* 0 => preemptable, <0 => BUG */
  37. struct task_struct *task; /* main task structure */
  38. mm_segment_t addr_limit; /* thread address space */
  39. struct exec_domain *exec_domain;/* execution domain */
  40. __u32 cpu; /* current CPU */
  41. unsigned long thr_ptr; /* TLS ptr */
  42. struct restart_block restart_block;
  43. };
  44. /*
  45. * macros/functions for gaining access to the thread information structure
  46. *
  47. * preempt_count needs to be 1 initially, until the scheduler is functional.
  48. */
  49. #define INIT_THREAD_INFO(tsk) \
  50. { \
  51. .task = &tsk, \
  52. .exec_domain = &default_exec_domain, \
  53. .flags = 0, \
  54. .cpu = 0, \
  55. .preempt_count = INIT_PREEMPT_COUNT, \
  56. .addr_limit = KERNEL_DS, \
  57. .restart_block = { \
  58. .fn = do_no_restart_syscall, \
  59. }, \
  60. }
  61. #define init_thread_info (init_thread_union.thread_info)
  62. #define init_stack (init_thread_union.stack)
  63. static inline __attribute_const__ struct thread_info *current_thread_info(void)
  64. {
  65. register unsigned long sp asm("sp");
  66. return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
  67. }
  68. #endif /* !__ASSEMBLY__ */
  69. /*
  70. * thread information flags
  71. * - these are process state flags that various assembly files may need to
  72. * access
  73. * - pending work-to-be-done flags are in LSW
  74. * - other flags in MSW
  75. */
  76. #define TIF_RESTORE_SIGMASK 0 /* restore sig mask in do_signal() */
  77. #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
  78. #define TIF_SIGPENDING 2 /* signal pending */
  79. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  80. #define TIF_SYSCALL_AUDIT 4 /* syscall auditing active */
  81. #define TIF_SYSCALL_TRACE 15 /* syscall trace active */
  82. /* true if poll_idle() is polling TIF_NEED_RESCHED */
  83. #define TIF_MEMDIE 16
  84. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  85. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  86. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  87. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  88. #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
  89. #define _TIF_MEMDIE (1<<TIF_MEMDIE)
  90. /* work to do on interrupt/exception return */
  91. #define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
  92. _TIF_NOTIFY_RESUME)
  93. /*
  94. * _TIF_ALLWORK_MASK includes SYSCALL_TRACE, but we don't need it.
  95. * SYSCALL_TRACE is anways seperately/unconditionally tested right after a
  96. * syscall, so all that reamins to be tested is _TIF_WORK_MASK
  97. */
  98. #endif /* _ASM_THREAD_INFO_H */