thread_info.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* thread_info.h: description
  2. *
  3. * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. * Derived from include/asm-i386/thread_info.h
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. */
  12. #ifndef _ASM_THREAD_INFO_H
  13. #define _ASM_THREAD_INFO_H
  14. #ifdef __KERNEL__
  15. #ifndef __ASSEMBLY__
  16. #include <asm/processor.h>
  17. #endif
  18. #define THREAD_SIZE 8192
  19. #define __HAVE_ARCH_TASK_STRUCT_ALLOCATOR
  20. /*
  21. * low level task data that entry.S needs immediate access to
  22. * - this struct should fit entirely inside of one cache line
  23. * - this struct shares the supervisor stack pages
  24. * - if the contents of this structure are changed, the assembly constants must also be changed
  25. */
  26. #ifndef __ASSEMBLY__
  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. unsigned long status; /* thread-synchronous flags */
  32. __u32 cpu; /* current CPU */
  33. int preempt_count; /* 0 => preemptable, <0 => BUG */
  34. mm_segment_t addr_limit; /* thread address space:
  35. * 0-0xBFFFFFFF for user-thead
  36. * 0-0xFFFFFFFF for kernel-thread
  37. */
  38. struct restart_block restart_block;
  39. __u8 supervisor_stack[0];
  40. };
  41. #else /* !__ASSEMBLY__ */
  42. #include <asm/asm-offsets.h>
  43. #endif
  44. #define PREEMPT_ACTIVE 0x10000000
  45. /*
  46. * macros/functions for gaining access to the thread information structure
  47. */
  48. #ifndef __ASSEMBLY__
  49. #define INIT_THREAD_INFO(tsk) \
  50. { \
  51. .task = &tsk, \
  52. .exec_domain = &default_exec_domain, \
  53. .flags = 0, \
  54. .cpu = 0, \
  55. .preempt_count = INIT_PREEMPT_COUNT, \
  56. .addr_limit = KERNEL_DS, \
  57. .restart_block = { \
  58. .fn = do_no_restart_syscall, \
  59. }, \
  60. }
  61. #define init_thread_info (init_thread_union.thread_info)
  62. #define init_stack (init_thread_union.stack)
  63. /* how to get the thread information struct from C */
  64. register struct thread_info *__current_thread_info asm("gr15");
  65. #define current_thread_info() ({ __current_thread_info; })
  66. #define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
  67. /* thread information allocation */
  68. #ifdef CONFIG_DEBUG_STACK_USAGE
  69. #define alloc_thread_info_node(tsk, node) \
  70. kzalloc_node(THREAD_SIZE, GFP_KERNEL, node)
  71. #else
  72. #define alloc_thread_info_node(tsk, node) \
  73. kmalloc_node(THREAD_SIZE, GFP_KERNEL, node)
  74. #endif
  75. #define free_thread_info(info) kfree(info)
  76. #endif /* __ASSEMBLY__ */
  77. /*
  78. * thread information flags
  79. * - these are process state flags that various assembly files may need to access
  80. * - pending work-to-be-done flags are in LSW
  81. * - other flags in MSW
  82. */
  83. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  84. #define TIF_NOTIFY_RESUME 1 /* callback before returning to user */
  85. #define TIF_SIGPENDING 2 /* signal pending */
  86. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  87. #define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */
  88. #define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
  89. #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
  90. #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
  91. #define TIF_FREEZE 18 /* freezing for suspend */
  92. #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
  93. #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
  94. #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
  95. #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
  96. #define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
  97. #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
  98. #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
  99. #define _TIF_FREEZE (1 << TIF_FREEZE)
  100. #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
  101. #define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */
  102. /*
  103. * Thread-synchronous status.
  104. *
  105. * This is different from the flags in that nobody else
  106. * ever touches our thread-synchronous status, so we don't
  107. * have to worry about atomic accesses.
  108. */
  109. #define TS_USEDFPM 0x0001 /* FPU/Media was used by this task this quantum (SMP) */
  110. #endif /* __KERNEL__ */
  111. #endif /* _ASM_THREAD_INFO_H */