thread_info.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
  3. * Licensed under the GPL
  4. */
  5. #ifndef __UM_THREAD_INFO_H
  6. #define __UM_THREAD_INFO_H
  7. #ifndef __ASSEMBLY__
  8. #include <asm/processor.h>
  9. #include <asm/types.h>
  10. struct thread_info {
  11. struct task_struct *task; /* main task structure */
  12. struct exec_domain *exec_domain; /* execution domain */
  13. unsigned long flags; /* low level flags */
  14. __u32 cpu; /* current CPU */
  15. int preempt_count; /* 0 => preemptable,
  16. <0 => BUG */
  17. mm_segment_t addr_limit; /* thread address space:
  18. 0-0xBFFFFFFF for user
  19. 0-0xFFFFFFFF for kernel */
  20. struct restart_block restart_block;
  21. struct thread_info *real_thread; /* Points to non-IRQ stack */
  22. };
  23. #define INIT_THREAD_INFO(tsk) \
  24. { \
  25. .task = &tsk, \
  26. .exec_domain = &default_exec_domain, \
  27. .flags = 0, \
  28. .cpu = 0, \
  29. .preempt_count = 1, \
  30. .addr_limit = KERNEL_DS, \
  31. .restart_block = { \
  32. .fn = do_no_restart_syscall, \
  33. }, \
  34. .real_thread = NULL, \
  35. }
  36. #define init_thread_info (init_thread_union.thread_info)
  37. #define init_stack (init_thread_union.stack)
  38. #define THREAD_SIZE ((1 << CONFIG_KERNEL_STACK_ORDER) * PAGE_SIZE)
  39. /* how to get the thread information struct from C */
  40. static inline struct thread_info *current_thread_info(void)
  41. {
  42. struct thread_info *ti;
  43. unsigned long mask = THREAD_SIZE - 1;
  44. ti = (struct thread_info *) (((unsigned long) &ti) & ~mask);
  45. return ti;
  46. }
  47. #ifdef CONFIG_DEBUG_STACK_USAGE
  48. #define alloc_thread_info(tsk) \
  49. ((struct thread_info *) __get_free_pages(GFP_KERNEL | __GFP_ZERO, \
  50. CONFIG_KERNEL_STACK_ORDER))
  51. #else
  52. /* thread information allocation */
  53. #define alloc_thread_info(tsk) \
  54. ((struct thread_info *) __get_free_pages(GFP_KERNEL, \
  55. CONFIG_KERNEL_STACK_ORDER))
  56. #endif
  57. #define free_thread_info(ti) \
  58. free_pages((unsigned long)(ti),CONFIG_KERNEL_STACK_ORDER)
  59. #endif
  60. #define PREEMPT_ACTIVE 0x10000000
  61. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  62. #define TIF_SIGPENDING 1 /* signal pending */
  63. #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
  64. #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
  65. * TIF_NEED_RESCHED
  66. */
  67. #define TIF_RESTART_BLOCK 4
  68. #define TIF_MEMDIE 5
  69. #define TIF_SYSCALL_AUDIT 6
  70. #define TIF_RESTORE_SIGMASK 7
  71. #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
  72. #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
  73. #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
  74. #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
  75. #define _TIF_MEMDIE (1 << TIF_MEMDIE)
  76. #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
  77. #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
  78. #endif