thread_info.h 3.6 KB

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