thread_info.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* thread_info.h: h8300 low-level thread information
  2. * adapted from the i386 and PPC versions by Yoshinori Sato <ysato@users.sourceforge.jp>
  3. *
  4. * Copyright (C) 2002 David Howells (dhowells@redhat.com)
  5. * - Incorporating suggestions made by Linus Torvalds and Dave Miller
  6. */
  7. #ifndef _ASM_THREAD_INFO_H
  8. #define _ASM_THREAD_INFO_H
  9. #include <asm/page.h>
  10. #ifdef __KERNEL__
  11. #ifndef __ASSEMBLY__
  12. /*
  13. * low level task data.
  14. * If you change this, change the TI_* offsets below to match.
  15. */
  16. struct thread_info {
  17. struct task_struct *task; /* main task structure */
  18. struct exec_domain *exec_domain; /* execution domain */
  19. unsigned long flags; /* low level flags */
  20. int cpu; /* cpu we're on */
  21. int preempt_count; /* 0 => preemptable, <0 => BUG */
  22. struct restart_block restart_block;
  23. };
  24. /*
  25. * macros/functions for gaining access to the thread information structure
  26. */
  27. #define INIT_THREAD_INFO(tsk) \
  28. { \
  29. .task = &tsk, \
  30. .exec_domain = &default_exec_domain, \
  31. .flags = 0, \
  32. .cpu = 0, \
  33. .preempt_count = 1, \
  34. .restart_block = { \
  35. .fn = do_no_restart_syscall, \
  36. }, \
  37. }
  38. #define init_thread_info (init_thread_union.thread_info)
  39. #define init_stack (init_thread_union.stack)
  40. /*
  41. * Size of kernel stack for each process. This must be a power of 2...
  42. */
  43. #define THREAD_SIZE 8192 /* 2 pages */
  44. /* how to get the thread information struct from C */
  45. static inline struct thread_info *current_thread_info(void)
  46. {
  47. struct thread_info *ti;
  48. __asm__(
  49. "mov.l sp, %0 \n\t"
  50. "and.l %1, %0"
  51. : "=&r"(ti)
  52. : "i" (~(THREAD_SIZE-1))
  53. );
  54. return ti;
  55. }
  56. /* thread information allocation */
  57. #define alloc_thread_info(tsk) ((struct thread_info *) \
  58. __get_free_pages(GFP_KERNEL, 1))
  59. #define free_thread_info(ti) free_pages((unsigned long) (ti), 1)
  60. #endif /* __ASSEMBLY__ */
  61. /*
  62. * Offsets in thread_info structure, used in assembly code
  63. */
  64. #define TI_TASK 0
  65. #define TI_EXECDOMAIN 4
  66. #define TI_FLAGS 8
  67. #define TI_CPU 12
  68. #define TI_PRE_COUNT 16
  69. #define PREEMPT_ACTIVE 0x4000000
  70. /*
  71. * thread information flag bit numbers
  72. */
  73. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  74. #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
  75. #define TIF_SIGPENDING 2 /* signal pending */
  76. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  77. #define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling
  78. TIF_NEED_RESCHED */
  79. #define TIF_MEMDIE 5
  80. /* as above, but as bit values */
  81. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  82. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  83. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  84. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  85. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  86. #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
  87. #endif /* __KERNEL__ */
  88. #endif /* _ASM_THREAD_INFO_H */