thread_info.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. struct thread_info {
  25. struct task_struct *task; /* main task structure */
  26. struct exec_domain *exec_domain; /* execution domain */
  27. unsigned long flags; /* low level flags */
  28. unsigned long status; /* thread-synchronous flags */
  29. __u32 cpu; /* current CPU */
  30. __s32 preempt_count; /* 0 => preemptable,< 0 => BUG*/
  31. mm_segment_t addr_limit; /* thread address space */
  32. struct restart_block restart_block;
  33. };
  34. #else /* !__ASSEMBLY__ */
  35. /* offsets into the thread_info struct for assembly code access */
  36. #define TI_TASK 0x00000000
  37. #define TI_EXEC_DOMAIN 0x00000004
  38. #define TI_FLAGS 0x00000008
  39. #define TI_STATUS 0x0000000C
  40. #define TI_CPU 0x00000010
  41. #define TI_PRE_COUNT 0x00000014
  42. #define TI_ADDR_LIMIT 0x00000018
  43. #define TI_RESTART_BLOCK 0x000001C
  44. #endif
  45. #define PREEMPT_ACTIVE 0x10000000
  46. /*
  47. * macros/functions for gaining access to the thread information structure
  48. *
  49. * preempt_count needs to be 1 initially, until the scheduler is functional.
  50. */
  51. #ifndef __ASSEMBLY__
  52. #define INIT_THREAD_INFO(tsk) \
  53. { \
  54. .task = &tsk, \
  55. .exec_domain = &default_exec_domain, \
  56. .flags = 0, \
  57. .cpu = 0, \
  58. .preempt_count = 1, \
  59. .addr_limit = KERNEL_DS, \
  60. .restart_block = { \
  61. .fn = do_no_restart_syscall, \
  62. }, \
  63. }
  64. #define init_thread_info (init_thread_union.thread_info)
  65. #define init_stack (init_thread_union.stack)
  66. /* how to get the thread information struct from C */
  67. static inline struct thread_info *current_thread_info(void)
  68. {
  69. struct thread_info *ti;
  70. __asm__("extui %0,a1,0,13\n\t"
  71. "xor %0, a1, %0" : "=&r" (ti) : );
  72. return ti;
  73. }
  74. /* thread information allocation */
  75. #define alloc_thread_info(tsk) ((struct thread_info *) __get_free_pages(GFP_KERNEL,1))
  76. #define free_thread_info(ti) free_pages((unsigned long) (ti), 1)
  77. #else /* !__ASSEMBLY__ */
  78. /* how to get the thread information struct from ASM */
  79. #define GET_THREAD_INFO(reg,sp) \
  80. extui reg, sp, 0, 13; \
  81. xor reg, sp, reg
  82. #endif
  83. /*
  84. * thread information flags
  85. * - these are process state flags that various assembly files may need to access
  86. * - pending work-to-be-done flags are in LSW
  87. * - other flags in MSW
  88. */
  89. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  90. #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
  91. #define TIF_SIGPENDING 2 /* signal pending */
  92. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  93. #define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */
  94. #define TIF_IRET 5 /* return with iret */
  95. #define TIF_MEMDIE 6
  96. #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
  97. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  98. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  99. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  100. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  101. #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
  102. #define _TIF_IRET (1<<TIF_IRET)
  103. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  104. #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
  105. #define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */
  106. /*
  107. * Thread-synchronous status.
  108. *
  109. * This is different from the flags in that nobody else
  110. * ever touches our thread-synchronous status, so we don't
  111. * have to worry about atomic accesses.
  112. */
  113. #define TS_USEDFPU 0x0001 /* FPU was used by this task this quantum (SMP) */
  114. #define THREAD_SIZE 8192 //(2*PAGE_SIZE)
  115. #endif /* __KERNEL__ */
  116. #endif /* _XTENSA_THREAD_INFO */