thread_info.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * Copyright (C) 2006 Atmark Techno, Inc.
  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. #ifndef _ASM_MICROBLAZE_THREAD_INFO_H
  9. #define _ASM_MICROBLAZE_THREAD_INFO_H
  10. #ifdef __KERNEL__
  11. /* we have 8k stack */
  12. #define THREAD_SHIFT 13
  13. #define THREAD_SIZE (1 << THREAD_SHIFT)
  14. #define THREAD_SIZE_ORDER 1
  15. #ifndef __ASSEMBLY__
  16. # include <linux/types.h>
  17. # include <asm/processor.h>
  18. # include <asm/segment.h>
  19. /*
  20. * low level task data that entry.S needs immediate access to
  21. * - this struct should fit entirely inside of one cache line
  22. * - this struct shares the supervisor stack pages
  23. * - if the contents of this structure are changed, the assembly constants
  24. * must also be changed
  25. */
  26. struct cpu_context {
  27. __u32 r1; /* stack pointer */
  28. __u32 r2;
  29. /* dedicated registers */
  30. __u32 r13;
  31. __u32 r14;
  32. __u32 r15;
  33. __u32 r16;
  34. __u32 r17;
  35. __u32 r18;
  36. /* non-volatile registers */
  37. __u32 r19;
  38. __u32 r20;
  39. __u32 r21;
  40. __u32 r22;
  41. __u32 r23;
  42. __u32 r24;
  43. __u32 r25;
  44. __u32 r26;
  45. __u32 r27;
  46. __u32 r28;
  47. __u32 r29;
  48. __u32 r30;
  49. /* r31 is used as current task pointer */
  50. /* special purpose registers */
  51. __u32 msr;
  52. __u32 ear;
  53. __u32 esr;
  54. __u32 fsr;
  55. };
  56. struct thread_info {
  57. struct task_struct *task; /* main task structure */
  58. struct exec_domain *exec_domain; /* execution domain */
  59. unsigned long flags; /* low level flags */
  60. unsigned long status; /* thread-synchronous flags */
  61. __u32 cpu; /* current CPU */
  62. __s32 preempt_count; /* 0 => preemptable,< 0 => BUG*/
  63. mm_segment_t addr_limit; /* thread address space */
  64. struct restart_block restart_block;
  65. struct cpu_context cpu_context;
  66. };
  67. /*
  68. * macros/functions for gaining access to the thread information structure
  69. */
  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 = INIT_PREEMPT_COUNT, \
  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. register unsigned long sp asm("r1");
  88. return (struct thread_info *)(sp & ~(THREAD_SIZE-1));
  89. }
  90. /* thread information allocation */
  91. #endif /* __ASSEMBLY__ */
  92. #define PREEMPT_ACTIVE 0x10000000
  93. /*
  94. * thread information flags
  95. * - these are process state flags that various assembly files may
  96. * need to access
  97. * - pending work-to-be-done flags are in LSW
  98. * - other flags in MSW
  99. */
  100. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  101. #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
  102. #define TIF_SIGPENDING 2 /* signal pending */
  103. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  104. /* restore singlestep on return to user mode */
  105. #define TIF_SINGLESTEP 4
  106. #define TIF_IRET 5 /* return with iret */
  107. #define TIF_MEMDIE 6
  108. #define TIF_SYSCALL_AUDIT 9 /* syscall auditing active */
  109. #define TIF_SECCOMP 10 /* secure computing */
  110. #define TIF_FREEZE 14 /* Freezing for suspend */
  111. /* FIXME change in entry.S */
  112. #define TIF_KERNEL_TRACE 8 /* kernel trace active */
  113. /* true if poll_idle() is polling TIF_NEED_RESCHED */
  114. #define TIF_POLLING_NRFLAG 16
  115. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  116. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  117. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  118. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  119. #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
  120. #define _TIF_IRET (1<<TIF_IRET)
  121. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  122. #define _TIF_FREEZE (1<<TIF_FREEZE)
  123. #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
  124. #define _TIF_SECCOMP (1 << TIF_SECCOMP)
  125. #define _TIF_KERNEL_TRACE (1 << TIF_KERNEL_TRACE)
  126. /* work to do in syscall trace */
  127. #define _TIF_WORK_SYSCALL_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
  128. _TIF_SYSCALL_AUDIT | _TIF_SECCOMP)
  129. /* work to do on interrupt/exception return */
  130. #define _TIF_WORK_MASK 0x0000FFFE
  131. /* work to do on any return to u-space */
  132. #define _TIF_ALLWORK_MASK 0x0000FFFF
  133. /*
  134. * Thread-synchronous status.
  135. *
  136. * This is different from the flags in that nobody else
  137. * ever touches our thread-synchronous status, so we don't
  138. * have to worry about atomic accesses.
  139. */
  140. /* FPU was used by this task this quantum (SMP) */
  141. #define TS_USEDFPU 0x0001
  142. #define TS_RESTORE_SIGMASK 0x0002
  143. #ifndef __ASSEMBLY__
  144. #define HAVE_SET_RESTORE_SIGMASK 1
  145. static inline void set_restore_sigmask(void)
  146. {
  147. struct thread_info *ti = current_thread_info();
  148. ti->status |= TS_RESTORE_SIGMASK;
  149. set_bit(TIF_SIGPENDING, (unsigned long *)&ti->flags);
  150. }
  151. #endif
  152. #endif /* __KERNEL__ */
  153. #endif /* _ASM_MICROBLAZE_THREAD_INFO_H */