thread_info.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* thread_info.h: m68knommu low-level thread information
  2. * adapted from the i386 and PPC versions by Greg Ungerer (gerg@snapgear.com)
  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. * Size of kernel stack for each process. This must be a power of 2...
  14. */
  15. #ifdef CONFIG_4KSTACKS
  16. #define THREAD_SIZE_ORDER (0)
  17. #else
  18. #define THREAD_SIZE_ORDER (1)
  19. #endif
  20. /*
  21. * for asm files, THREAD_SIZE is now generated by asm-offsets.c
  22. */
  23. #define THREAD_SIZE (PAGE_SIZE<<THREAD_SIZE_ORDER)
  24. /*
  25. * low level task data.
  26. */
  27. struct thread_info {
  28. struct task_struct *task; /* main task structure */
  29. struct exec_domain *exec_domain; /* execution domain */
  30. unsigned long flags; /* low level flags */
  31. int cpu; /* cpu we're on */
  32. int preempt_count; /* 0 => preemptable, <0 => BUG */
  33. struct restart_block restart_block;
  34. };
  35. /*
  36. * macros/functions for gaining access to the thread information structure
  37. */
  38. #define INIT_THREAD_INFO(tsk) \
  39. { \
  40. .task = &tsk, \
  41. .exec_domain = &default_exec_domain, \
  42. .flags = 0, \
  43. .cpu = 0, \
  44. .restart_block = { \
  45. .fn = do_no_restart_syscall, \
  46. }, \
  47. }
  48. #define init_thread_info (init_thread_union.thread_info)
  49. #define init_stack (init_thread_union.stack)
  50. /* how to get the thread information struct from C */
  51. static inline struct thread_info *current_thread_info(void)
  52. {
  53. struct thread_info *ti;
  54. __asm__(
  55. "move.l %%sp, %0 \n\t"
  56. "and.l %1, %0"
  57. : "=&d"(ti)
  58. : "di" (~(THREAD_SIZE-1))
  59. );
  60. return ti;
  61. }
  62. /* thread information allocation */
  63. #define alloc_thread_info(tsk) ((struct thread_info *) \
  64. __get_free_pages(GFP_KERNEL, THREAD_SIZE_ORDER))
  65. #define free_thread_info(ti) free_pages((unsigned long) (ti), THREAD_SIZE_ORDER)
  66. #endif /* __ASSEMBLY__ */
  67. #define PREEMPT_ACTIVE 0x4000000
  68. /*
  69. * thread information flag bit numbers
  70. */
  71. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  72. #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
  73. #define TIF_SIGPENDING 2 /* signal pending */
  74. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  75. #define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling
  76. TIF_NEED_RESCHED */
  77. #define TIF_MEMDIE 5
  78. /* as above, but as bit values */
  79. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  80. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  81. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  82. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  83. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  84. #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
  85. #endif /* __KERNEL__ */
  86. #endif /* _ASM_THREAD_INFO_H */