thread_info.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. /*
  19. * low level task data that entry.S needs immediate access to
  20. * - this struct should fit entirely inside of one cache line
  21. * - this struct shares the supervisor stack pages
  22. * - if the contents of this structure are changed, the assembly constants must also be changed
  23. */
  24. #ifndef __ASSEMBLY__
  25. struct thread_info {
  26. struct task_struct *task; /* main task structure */
  27. struct exec_domain *exec_domain; /* execution domain */
  28. unsigned long flags; /* low level flags */
  29. unsigned long status; /* thread-synchronous flags */
  30. __u32 cpu; /* current CPU */
  31. int preempt_count; /* 0 => preemptable, <0 => BUG */
  32. mm_segment_t addr_limit; /* thread address space:
  33. 0-0xBFFFFFFF for user-thead
  34. 0-0xFFFFFFFF for kernel-thread
  35. */
  36. struct restart_block restart_block;
  37. __u8 supervisor_stack[0];
  38. };
  39. #else /* !__ASSEMBLY__ */
  40. /* offsets into the thread_info struct for assembly code access */
  41. #define TI_TASK 0x00000000
  42. #define TI_EXEC_DOMAIN 0x00000004
  43. #define TI_FLAGS 0x00000008
  44. #define TI_STATUS 0x0000000C
  45. #define TI_CPU 0x00000010
  46. #define TI_PRE_COUNT 0x00000014
  47. #define TI_ADDR_LIMIT 0x00000018
  48. #define TI_RESTART_BLOCK 0x0000001C
  49. #endif
  50. #define PREEMPT_ACTIVE 0x10000000
  51. /*
  52. * macros/functions for gaining access to the thread information structure
  53. *
  54. * preempt_count needs to be 1 initially, until the scheduler is functional.
  55. */
  56. #ifndef __ASSEMBLY__
  57. #define INIT_THREAD_INFO(tsk) \
  58. { \
  59. .task = &tsk, \
  60. .exec_domain = &default_exec_domain, \
  61. .flags = 0, \
  62. .cpu = 0, \
  63. .preempt_count = 1, \
  64. .addr_limit = KERNEL_DS, \
  65. .restart_block = { \
  66. .fn = do_no_restart_syscall, \
  67. }, \
  68. }
  69. #define init_thread_info (init_thread_union.thread_info)
  70. #define init_stack (init_thread_union.stack)
  71. #ifdef CONFIG_SMALL_TASKS
  72. #define THREAD_SIZE 4096
  73. #else
  74. #define THREAD_SIZE 8192
  75. #endif
  76. /* how to get the thread information struct from C */
  77. register struct thread_info *__current_thread_info asm("gr15");
  78. #define current_thread_info() ({ __current_thread_info; })
  79. /* thread information allocation */
  80. #ifdef CONFIG_DEBUG_STACK_USAGE
  81. #define alloc_thread_info(tsk) \
  82. ({ \
  83. struct thread_info *ret; \
  84. \
  85. ret = kmalloc(THREAD_SIZE, GFP_KERNEL); \
  86. if (ret) \
  87. memset(ret, 0, THREAD_SIZE); \
  88. ret; \
  89. })
  90. #else
  91. #define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
  92. #endif
  93. #define free_thread_info(info) kfree(info)
  94. #else /* !__ASSEMBLY__ */
  95. #define THREAD_SIZE 8192
  96. #endif
  97. /*
  98. * thread information flags
  99. * - these are process state flags that various assembly files may need to access
  100. * - pending work-to-be-done flags are in LSW
  101. * - other flags in MSW
  102. */
  103. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  104. #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
  105. #define TIF_SIGPENDING 2 /* signal pending */
  106. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  107. #define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */
  108. #define TIF_IRET 5 /* return with iret */
  109. #define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */
  110. #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
  111. #define TIF_MEMDIE 17 /* OOM killer killed process */
  112. #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
  113. #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
  114. #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
  115. #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
  116. #define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
  117. #define _TIF_IRET (1 << TIF_IRET)
  118. #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
  119. #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
  120. #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
  121. #define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */
  122. /*
  123. * Thread-synchronous status.
  124. *
  125. * This is different from the flags in that nobody else
  126. * ever touches our thread-synchronous status, so we don't
  127. * have to worry about atomic accesses.
  128. */
  129. #define TS_USEDFPM 0x0001 /* FPU/Media was used by this task this quantum (SMP) */
  130. #endif /* __KERNEL__ */
  131. #endif /* _ASM_THREAD_INFO_H */