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 = INIT_PREEMPT_COUNT, \
  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_ORDER 1
  44. #define THREAD_SIZE 8192 /* 2 pages */
  45. /* how to get the thread information struct from C */
  46. static inline struct thread_info *current_thread_info(void)
  47. {
  48. struct thread_info *ti;
  49. __asm__(
  50. "mov.l sp, %0 \n\t"
  51. "and.l %1, %0"
  52. : "=&r"(ti)
  53. : "i" (~(THREAD_SIZE-1))
  54. );
  55. return ti;
  56. }
  57. #endif /* __ASSEMBLY__ */
  58. /*
  59. * Offsets in thread_info structure, used in assembly code
  60. */
  61. #define TI_TASK 0
  62. #define TI_EXECDOMAIN 4
  63. #define TI_FLAGS 8
  64. #define TI_CPU 12
  65. #define TI_PRE_COUNT 16
  66. #define PREEMPT_ACTIVE 0x4000000
  67. /*
  68. * thread information flag bit numbers
  69. */
  70. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  71. #define TIF_SIGPENDING 1 /* signal pending */
  72. #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
  73. #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
  74. TIF_NEED_RESCHED */
  75. #define TIF_MEMDIE 4 /* is terminating due to OOM killer */
  76. #define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
  77. #define TIF_NOTIFY_RESUME 6 /* callback before returning to user */
  78. /* as above, but as bit values */
  79. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  80. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  81. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  82. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  83. #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
  84. #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
  85. #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
  86. #endif /* __KERNEL__ */
  87. #endif /* _ASM_THREAD_INFO_H */