thread_info.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. struct exec_domain *exec_domain; /* execution domain */
  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. struct restart_block restart_block;
  45. unsigned long cpenable;
  46. /* Allocate storage for extra user states and coprocessor states. */
  47. #if XTENSA_HAVE_COPROCESSORS
  48. xtregs_coprocessor_t xtregs_cp;
  49. #endif
  50. xtregs_user_t xtregs_user;
  51. };
  52. #else /* !__ASSEMBLY__ */
  53. /* offsets into the thread_info struct for assembly code access */
  54. #define TI_TASK 0x00000000
  55. #define TI_EXEC_DOMAIN 0x00000004
  56. #define TI_FLAGS 0x00000008
  57. #define TI_STATUS 0x0000000C
  58. #define TI_CPU 0x00000010
  59. #define TI_PRE_COUNT 0x00000014
  60. #define TI_ADDR_LIMIT 0x00000018
  61. #define TI_RESTART_BLOCK 0x000001C
  62. #endif
  63. #define PREEMPT_ACTIVE 0x10000000
  64. /*
  65. * macros/functions for gaining access to the thread information structure
  66. */
  67. #ifndef __ASSEMBLY__
  68. #define INIT_THREAD_INFO(tsk) \
  69. { \
  70. .task = &tsk, \
  71. .exec_domain = &default_exec_domain, \
  72. .flags = 0, \
  73. .cpu = 0, \
  74. .preempt_count = INIT_PREEMPT_COUNT, \
  75. .addr_limit = KERNEL_DS, \
  76. .restart_block = { \
  77. .fn = do_no_restart_syscall, \
  78. }, \
  79. }
  80. #define init_thread_info (init_thread_union.thread_info)
  81. #define init_stack (init_thread_union.stack)
  82. /* how to get the thread information struct from C */
  83. static inline struct thread_info *current_thread_info(void)
  84. {
  85. struct thread_info *ti;
  86. __asm__("extui %0,a1,0,13\n\t"
  87. "xor %0, a1, %0" : "=&r" (ti) : );
  88. return ti;
  89. }
  90. #else /* !__ASSEMBLY__ */
  91. /* how to get the thread information struct from ASM */
  92. #define GET_THREAD_INFO(reg,sp) \
  93. extui reg, sp, 0, 13; \
  94. xor reg, sp, reg
  95. #endif
  96. /*
  97. * thread information flags
  98. * - these are process state flags that various assembly files may need to access
  99. * - pending work-to-be-done flags are in LSW
  100. * - other flags in MSW
  101. */
  102. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  103. #define TIF_SIGPENDING 1 /* signal pending */
  104. #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
  105. #define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */
  106. #define TIF_IRET 4 /* return with iret */
  107. #define TIF_MEMDIE 5 /* is terminating due to OOM killer */
  108. #define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */
  109. #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
  110. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  111. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  112. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  113. #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
  114. #define _TIF_IRET (1<<TIF_IRET)
  115. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  116. #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
  117. #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
  118. #define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */
  119. /*
  120. * Thread-synchronous status.
  121. *
  122. * This is different from the flags in that nobody else
  123. * ever touches our thread-synchronous status, so we don't
  124. * have to worry about atomic accesses.
  125. */
  126. #define TS_USEDFPU 0x0001 /* FPU was used by this task this quantum (SMP) */
  127. #define THREAD_SIZE 8192 //(2*PAGE_SIZE)
  128. #define THREAD_SIZE_ORDER 1
  129. #endif /* __KERNEL__ */
  130. #endif /* _XTENSA_THREAD_INFO */