thread_info.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * include/asm-v850/thread_info.h -- v850 low-level thread information
  3. *
  4. * Copyright (C) 2002 NEC Corporation
  5. * Copyright (C) 2002 Miles Bader <miles@gnu.org>
  6. * Copyright (C) 2002 David Howells (dhowells@redhat.com)
  7. * - Incorporating suggestions made by Linus Torvalds and Dave Miller
  8. *
  9. * This file is subject to the terms and conditions of the GNU General
  10. * Public License. See the file COPYING in the main directory of this
  11. * archive for more details.
  12. *
  13. * This file was derived from the PPC version, include/asm-ppc/thread_info.h
  14. * which was adapted from the i386 version by Paul Mackerras
  15. */
  16. #ifndef __V850_THREAD_INFO_H__
  17. #define __V850_THREAD_INFO_H__
  18. #ifdef __KERNEL__
  19. #ifndef __ASSEMBLY__
  20. /*
  21. * low level task data.
  22. * If you change this, change the TI_* offsets below to match.
  23. */
  24. struct thread_info {
  25. struct task_struct *task; /* main task structure */
  26. struct exec_domain *exec_domain; /* execution domain */
  27. unsigned long flags; /* low level flags */
  28. int cpu; /* cpu we're on */
  29. int preempt_count;
  30. struct restart_block restart_block;
  31. };
  32. #define INIT_THREAD_INFO(tsk) \
  33. { \
  34. .task = &tsk, \
  35. .exec_domain = &default_exec_domain, \
  36. .flags = 0, \
  37. .cpu = 0, \
  38. .preempt_count = 1, \
  39. .restart_block = { \
  40. .fn = do_no_restart_syscall, \
  41. }, \
  42. }
  43. #define init_thread_info (init_thread_union.thread_info)
  44. #define init_stack (init_thread_union.stack)
  45. /*
  46. * macros/functions for gaining access to the thread information structure
  47. */
  48. /* thread information allocation */
  49. #define alloc_thread_info(tsk) ((struct thread_info *) \
  50. __get_free_pages(GFP_KERNEL, 1))
  51. #define free_thread_info(ti) free_pages((unsigned long) (ti), 1)
  52. #define get_thread_info(ti) get_task_struct((ti)->task)
  53. #define put_thread_info(ti) put_task_struct((ti)->task)
  54. #endif /* __ASSEMBLY__ */
  55. /*
  56. * Offsets in thread_info structure, used in assembly code
  57. */
  58. #define TI_TASK 0
  59. #define TI_EXECDOMAIN 4
  60. #define TI_FLAGS 8
  61. #define TI_CPU 12
  62. #define TI_PREEMPT 16
  63. #define PREEMPT_ACTIVE 0x4000000
  64. /*
  65. * thread information flag bit numbers
  66. */
  67. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  68. #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
  69. #define TIF_SIGPENDING 2 /* signal pending */
  70. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  71. #define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling
  72. TIF_NEED_RESCHED */
  73. #define TIF_MEMDIE 5
  74. /* as above, but as bit values */
  75. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  76. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  77. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  78. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  79. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  80. /* Size of kernel stack for each process. */
  81. #define THREAD_SIZE 0x2000
  82. /* The alignment of kernel threads, with thread_info structures at their
  83. base. Thus, a pointer for a task's task structure can be derived from
  84. its kernel stack pointer. */
  85. #define THREAD_ALIGNMENT THREAD_SIZE
  86. #define THREAD_MASK (-THREAD_ALIGNMENT)
  87. #ifdef __ASSEMBLY__
  88. /* Put a pointer to the current thread_info structure into REG. Note that
  89. this definition requires THREAD_MASK to be representable as a signed
  90. 16-bit value. */
  91. #define GET_CURRENT_THREAD(reg) \
  92. /* Use `addi' and then `and' instead of just `andi', because \
  93. `addi' sign-extends the immediate value, whereas `andi' \
  94. zero-extends it. */ \
  95. addi THREAD_MASK, r0, reg; \
  96. and sp, reg
  97. #else
  98. /* Return a pointer to the current thread_info structure. */
  99. static inline struct thread_info *current_thread_info (void)
  100. {
  101. register unsigned long sp __asm__ ("sp");
  102. return (struct thread_info *)(sp & THREAD_MASK);
  103. }
  104. #endif /* __ASSEMBLY__ */
  105. #endif /* __KERNEL__ */
  106. #endif /* __V850_THREAD_INFO_H__ */