thread_info.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. /*
  19. * low level task data that entry.S needs immediate access to
  20. * - this struct should fit entirely inside of one cache line
  21. * - this struct shares the supervisor stack pages
  22. * - if the contents of this structure are changed, the assembly constants
  23. * must also be changed
  24. */
  25. struct cpu_context {
  26. __u32 r1; /* stack pointer */
  27. __u32 r2;
  28. /* dedicated registers */
  29. __u32 r13;
  30. __u32 r14;
  31. __u32 r15;
  32. __u32 r16;
  33. __u32 r17;
  34. __u32 r18;
  35. /* non-volatile registers */
  36. __u32 r19;
  37. __u32 r20;
  38. __u32 r21;
  39. __u32 r22;
  40. __u32 r23;
  41. __u32 r24;
  42. __u32 r25;
  43. __u32 r26;
  44. __u32 r27;
  45. __u32 r28;
  46. __u32 r29;
  47. __u32 r30;
  48. /* r31 is used as current task pointer */
  49. /* special purpose registers */
  50. __u32 msr;
  51. __u32 ear;
  52. __u32 esr;
  53. __u32 fsr;
  54. };
  55. typedef struct {
  56. unsigned long seg;
  57. } mm_segment_t;
  58. struct thread_info {
  59. struct task_struct *task; /* main task structure */
  60. struct exec_domain *exec_domain; /* execution domain */
  61. unsigned long flags; /* low level flags */
  62. unsigned long status; /* thread-synchronous flags */
  63. __u32 cpu; /* current CPU */
  64. __s32 preempt_count; /* 0 => preemptable,< 0 => BUG*/
  65. mm_segment_t addr_limit; /* thread address space */
  66. struct restart_block restart_block;
  67. struct cpu_context cpu_context;
  68. };
  69. /*
  70. * macros/functions for gaining access to the thread information structure
  71. */
  72. #define INIT_THREAD_INFO(tsk) \
  73. { \
  74. .task = &tsk, \
  75. .exec_domain = &default_exec_domain, \
  76. .flags = 0, \
  77. .cpu = 0, \
  78. .preempt_count = INIT_PREEMPT_COUNT, \
  79. .addr_limit = KERNEL_DS, \
  80. .restart_block = { \
  81. .fn = do_no_restart_syscall, \
  82. }, \
  83. }
  84. #define init_thread_info (init_thread_union.thread_info)
  85. #define init_stack (init_thread_union.stack)
  86. /* how to get the thread information struct from C */
  87. static inline struct thread_info *current_thread_info(void)
  88. {
  89. register unsigned long sp asm("r1");
  90. return (struct thread_info *)(sp & ~(THREAD_SIZE-1));
  91. }
  92. /* thread information allocation */
  93. #endif /* __ASSEMBLY__ */
  94. #define PREEMPT_ACTIVE 0x10000000
  95. /*
  96. * thread information flags
  97. * - these are process state flags that various assembly files may
  98. * 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_NOTIFY_RESUME 1 /* resumption notification requested */
  104. #define TIF_SIGPENDING 2 /* signal pending */
  105. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  106. /* restore singlestep on return to user mode */
  107. #define TIF_SINGLESTEP 4
  108. #define TIF_IRET 5 /* return with iret */
  109. #define TIF_MEMDIE 6 /* is terminating due to OOM killer */
  110. #define TIF_SYSCALL_AUDIT 9 /* syscall auditing active */
  111. #define TIF_SECCOMP 10 /* secure computing */
  112. #define TIF_FREEZE 14 /* Freezing for suspend */
  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. /* work to do in syscall trace */
  126. #define _TIF_WORK_SYSCALL_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
  127. _TIF_SYSCALL_AUDIT | _TIF_SECCOMP)
  128. /* work to do on interrupt/exception return */
  129. #define _TIF_WORK_MASK 0x0000FFFE
  130. /* work to do on any return to u-space */
  131. #define _TIF_ALLWORK_MASK 0x0000FFFF
  132. /*
  133. * Thread-synchronous status.
  134. *
  135. * This is different from the flags in that nobody else
  136. * ever touches our thread-synchronous status, so we don't
  137. * have to worry about atomic accesses.
  138. */
  139. /* FPU was used by this task this quantum (SMP) */
  140. #define TS_USEDFPU 0x0001
  141. #define TS_RESTORE_SIGMASK 0x0002
  142. #ifndef __ASSEMBLY__
  143. #define HAVE_SET_RESTORE_SIGMASK 1
  144. static inline void set_restore_sigmask(void)
  145. {
  146. struct thread_info *ti = current_thread_info();
  147. ti->status |= TS_RESTORE_SIGMASK;
  148. set_bit(TIF_SIGPENDING, (unsigned long *)&ti->flags);
  149. }
  150. #endif
  151. #endif /* __KERNEL__ */
  152. #endif /* _ASM_MICROBLAZE_THREAD_INFO_H */