thread_info.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. * preempt_count needs to be 1 initially, until the scheduler is functional.
  68. */
  69. #ifndef __ASSEMBLY__
  70. #define INIT_THREAD_INFO(tsk) \
  71. { \
  72. .task = &tsk, \
  73. .exec_domain = &default_exec_domain, \
  74. .flags = 0, \
  75. .cpu = 0, \
  76. .preempt_count = 1, \
  77. .addr_limit = KERNEL_DS, \
  78. .restart_block = { \
  79. .fn = do_no_restart_syscall, \
  80. }, \
  81. }
  82. #define init_thread_info (init_thread_union.thread_info)
  83. #define init_stack (init_thread_union.stack)
  84. /* how to get the thread information struct from C */
  85. static inline struct thread_info *current_thread_info(void)
  86. {
  87. struct thread_info *ti;
  88. __asm__("extui %0,a1,0,13\n\t"
  89. "xor %0, a1, %0" : "=&r" (ti) : );
  90. return ti;
  91. }
  92. #else /* !__ASSEMBLY__ */
  93. /* how to get the thread information struct from ASM */
  94. #define GET_THREAD_INFO(reg,sp) \
  95. extui reg, sp, 0, 13; \
  96. xor reg, sp, reg
  97. #endif
  98. /*
  99. * thread information flags
  100. * - these are process state flags that various assembly files may need to access
  101. * - pending work-to-be-done flags are in LSW
  102. * - other flags in MSW
  103. */
  104. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  105. #define TIF_SIGPENDING 1 /* signal pending */
  106. #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
  107. #define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */
  108. #define TIF_IRET 4 /* return with iret */
  109. #define TIF_MEMDIE 5
  110. #define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */
  111. #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
  112. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  113. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  114. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  115. #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
  116. #define _TIF_IRET (1<<TIF_IRET)
  117. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  118. #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
  119. #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
  120. #define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */
  121. /*
  122. * Thread-synchronous status.
  123. *
  124. * This is different from the flags in that nobody else
  125. * ever touches our thread-synchronous status, so we don't
  126. * have to worry about atomic accesses.
  127. */
  128. #define TS_USEDFPU 0x0001 /* FPU was used by this task this quantum (SMP) */
  129. #define THREAD_SIZE 8192 //(2*PAGE_SIZE)
  130. #define THREAD_SIZE_ORDER 1
  131. #endif /* __KERNEL__ */
  132. #endif /* _XTENSA_THREAD_INFO */