thread_info.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * include/asm-xtensa/thread_info.h
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * Copyright (C) 2001 - 2005 Tensilica Inc.
  9. */
  10. #ifndef _XTENSA_THREAD_INFO_H
  11. #define _XTENSA_THREAD_INFO_H
  12. #include <asm/kmem_layout.h>
  13. #define CURRENT_SHIFT KERNEL_STACK_SHIFT
  14. #ifndef __ASSEMBLY__
  15. # include <asm/processor.h>
  16. #endif
  17. /*
  18. * low level task data that entry.S needs immediate access to
  19. * - this struct should fit entirely inside of one cache line
  20. * - this struct shares the supervisor stack pages
  21. * - if the contents of this structure are changed, the assembly constants
  22. * must also be changed
  23. */
  24. #ifndef __ASSEMBLY__
  25. #if XTENSA_HAVE_COPROCESSORS
  26. typedef struct xtregs_coprocessor {
  27. xtregs_cp0_t cp0;
  28. xtregs_cp1_t cp1;
  29. xtregs_cp2_t cp2;
  30. xtregs_cp3_t cp3;
  31. xtregs_cp4_t cp4;
  32. xtregs_cp5_t cp5;
  33. xtregs_cp6_t cp6;
  34. xtregs_cp7_t cp7;
  35. } xtregs_coprocessor_t;
  36. #endif
  37. struct thread_info {
  38. struct task_struct *task; /* main task structure */
  39. unsigned long flags; /* low level flags */
  40. unsigned long status; /* thread-synchronous flags */
  41. __u32 cpu; /* current CPU */
  42. __s32 preempt_count; /* 0 => preemptable,< 0 => BUG*/
  43. mm_segment_t addr_limit; /* thread address space */
  44. unsigned long cpenable;
  45. /* Allocate storage for extra user states and coprocessor states. */
  46. #if XTENSA_HAVE_COPROCESSORS
  47. xtregs_coprocessor_t xtregs_cp;
  48. #endif
  49. xtregs_user_t xtregs_user;
  50. };
  51. #endif
  52. /*
  53. * macros/functions for gaining access to the thread information structure
  54. */
  55. #ifndef __ASSEMBLY__
  56. #define INIT_THREAD_INFO(tsk) \
  57. { \
  58. .task = &tsk, \
  59. .flags = 0, \
  60. .cpu = 0, \
  61. .preempt_count = INIT_PREEMPT_COUNT, \
  62. .addr_limit = KERNEL_DS, \
  63. }
  64. /* how to get the thread information struct from C */
  65. static inline struct thread_info *current_thread_info(void)
  66. {
  67. struct thread_info *ti;
  68. __asm__("extui %0, a1, 0, "__stringify(CURRENT_SHIFT)"\n\t"
  69. "xor %0, a1, %0" : "=&r" (ti) : );
  70. return ti;
  71. }
  72. #else /* !__ASSEMBLY__ */
  73. /* how to get the thread information struct from ASM */
  74. #define GET_THREAD_INFO(reg,sp) \
  75. extui reg, sp, 0, CURRENT_SHIFT; \
  76. xor reg, sp, reg
  77. #endif
  78. /*
  79. * thread information flags
  80. * - these are process state flags that various assembly files may need to access
  81. * - pending work-to-be-done flags are in LSW
  82. * - other flags in MSW
  83. */
  84. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  85. #define TIF_SIGPENDING 1 /* signal pending */
  86. #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
  87. #define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */
  88. #define TIF_MEMDIE 5 /* is terminating due to OOM killer */
  89. #define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */
  90. #define TIF_NOTIFY_RESUME 7 /* callback before returning to user */
  91. #define TIF_DB_DISABLED 8 /* debug trap disabled for syscall */
  92. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  93. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  94. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  95. #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
  96. #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
  97. #define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */
  98. /*
  99. * Thread-synchronous status.
  100. *
  101. * This is different from the flags in that nobody else
  102. * ever touches our thread-synchronous status, so we don't
  103. * have to worry about atomic accesses.
  104. */
  105. #define TS_USEDFPU 0x0001 /* FPU was used by this task this quantum (SMP) */
  106. #define THREAD_SIZE KERNEL_STACK_SIZE
  107. #define THREAD_SIZE_ORDER (KERNEL_STACK_SHIFT - PAGE_SHIFT)
  108. #endif /* _XTENSA_THREAD_INFO */