thread_info.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #ifndef __ASM_SH_THREAD_INFO_H
  2. #define __ASM_SH_THREAD_INFO_H
  3. /* SuperH version
  4. * Copyright (C) 2002 Niibe Yutaka
  5. *
  6. * The copyright of original i386 version is:
  7. *
  8. * Copyright (C) 2002 David Howells (dhowells@redhat.com)
  9. * - Incorporating suggestions made by Linus Torvalds and Dave Miller
  10. */
  11. #ifdef __KERNEL__
  12. #ifndef __ASSEMBLY__
  13. #include <asm/processor.h>
  14. struct thread_info {
  15. struct task_struct *task; /* main task structure */
  16. struct exec_domain *exec_domain; /* execution domain */
  17. unsigned long flags; /* low level flags */
  18. __u32 cpu;
  19. int preempt_count; /* 0 => preemptable, <0 => BUG */
  20. struct restart_block restart_block;
  21. __u8 supervisor_stack[0];
  22. };
  23. #endif
  24. #define PREEMPT_ACTIVE 0x10000000
  25. /*
  26. * macros/functions for gaining access to the thread information structure
  27. */
  28. #ifndef __ASSEMBLY__
  29. #define INIT_THREAD_INFO(tsk) \
  30. { \
  31. .task = &tsk, \
  32. .exec_domain = &default_exec_domain, \
  33. .flags = 0, \
  34. .cpu = 0, \
  35. .preempt_count = 1, \
  36. .restart_block = { \
  37. .fn = do_no_restart_syscall, \
  38. }, \
  39. }
  40. #define init_thread_info (init_thread_union.thread_info)
  41. #define init_stack (init_thread_union.stack)
  42. #define THREAD_SIZE (2*PAGE_SIZE)
  43. /* how to get the thread information struct from C */
  44. static inline struct thread_info *current_thread_info(void)
  45. {
  46. struct thread_info *ti;
  47. #ifdef CONFIG_CPU_HAS_SR_RB
  48. __asm__("stc r7_bank, %0" : "=r" (ti));
  49. #else
  50. unsigned long __dummy;
  51. __asm__ __volatile__ (
  52. "mov r15, %0\n\t"
  53. "and %1, %0\n\t"
  54. : "=&r" (ti), "=r" (__dummy)
  55. : "1" (~(THREAD_SIZE - 1))
  56. : "memory");
  57. #endif
  58. return ti;
  59. }
  60. /* thread information allocation */
  61. #define alloc_thread_info(ti) ((struct thread_info *) __get_free_pages(GFP_KERNEL,1))
  62. #define free_thread_info(ti) free_pages((unsigned long) (ti), 1)
  63. #else /* !__ASSEMBLY__ */
  64. /* how to get the thread information struct from ASM */
  65. #define GET_THREAD_INFO(reg) \
  66. stc r7_bank, reg
  67. #endif
  68. /*
  69. * thread information flags
  70. * - these are process state flags that various assembly files may need to access
  71. * - pending work-to-be-done flags are in LSW
  72. * - other flags in MSW
  73. */
  74. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  75. #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
  76. #define TIF_SIGPENDING 2 /* signal pending */
  77. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  78. #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
  79. #define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */
  80. #define TIF_MEMDIE 18
  81. #define TIF_USERSPACE 31 /* true if FS sets userspace */
  82. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  83. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  84. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  85. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  86. #define _TIF_USEDFPU (1<<TIF_USEDFPU)
  87. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  88. #define _TIF_USERSPACE (1<<TIF_USERSPACE)
  89. #define _TIF_WORK_MASK 0x000000FE /* work to do on interrupt/exception return */
  90. #define _TIF_ALLWORK_MASK 0x000000FF /* work to do on any return to u-space */
  91. #endif /* __KERNEL__ */
  92. #endif /* __ASM_SH_THREAD_INFO_H */