thread_info.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * Thread support for the Hexagon architecture
  3. *
  4. * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 and
  8. * only version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  18. * 02110-1301, USA.
  19. */
  20. #ifndef _ASM_THREAD_INFO_H
  21. #define _ASM_THREAD_INFO_H
  22. #ifdef __KERNEL__
  23. #ifndef __ASSEMBLY__
  24. #include <asm/processor.h>
  25. #include <asm/registers.h>
  26. #include <asm/page.h>
  27. #endif
  28. #define THREAD_SHIFT 12
  29. #define THREAD_SIZE (1<<THREAD_SHIFT)
  30. #if THREAD_SHIFT >= PAGE_SHIFT
  31. #define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT)
  32. #else /* don't use standard allocator */
  33. #define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
  34. extern struct thread_info *alloc_thread_info_node(struct task_struct *tsk, int node);
  35. extern void free_thread_info(struct thread_info *ti);
  36. #endif
  37. #ifndef __ASSEMBLY__
  38. typedef struct {
  39. unsigned long seg;
  40. } mm_segment_t;
  41. /*
  42. * This is union'd with the "bottom" of the kernel stack.
  43. * It keeps track of thread info which is handy for routines
  44. * to access quickly.
  45. */
  46. struct thread_info {
  47. struct task_struct *task; /* main task structure */
  48. struct exec_domain *exec_domain; /* execution domain */
  49. unsigned long flags; /* low level flags */
  50. __u32 cpu; /* current cpu */
  51. int preempt_count; /* 0=>preemptible,<0=>BUG */
  52. mm_segment_t addr_limit; /* segmentation sux */
  53. /*
  54. * used for syscalls somehow;
  55. * seems to have a function pointer and four arguments
  56. */
  57. struct restart_block restart_block;
  58. /* Points to the current pt_regs frame */
  59. struct pt_regs *regs;
  60. /*
  61. * saved kernel sp at switch_to time;
  62. * not sure if this is used (it's not in the VM model it seems;
  63. * see thread_struct)
  64. */
  65. unsigned long sp;
  66. };
  67. #else /* !__ASSEMBLY__ */
  68. #include <asm/asm-offsets.h>
  69. #endif /* __ASSEMBLY__ */
  70. /* looks like "linux/hardirq.h" uses this. */
  71. #define PREEMPT_ACTIVE 0x10000000
  72. #ifndef __ASSEMBLY__
  73. #define INIT_THREAD_INFO(tsk) \
  74. { \
  75. .task = &tsk, \
  76. .exec_domain = &default_exec_domain, \
  77. .flags = 0, \
  78. .cpu = 0, \
  79. .preempt_count = 1, \
  80. .addr_limit = KERNEL_DS, \
  81. .restart_block = { \
  82. .fn = do_no_restart_syscall, \
  83. }, \
  84. .sp = 0, \
  85. .regs = NULL, \
  86. }
  87. #define init_thread_info (init_thread_union.thread_info)
  88. #define init_stack (init_thread_union.stack)
  89. /* Tacky preprocessor trickery */
  90. #define qqstr(s) qstr(s)
  91. #define qstr(s) #s
  92. #define QUOTED_THREADINFO_REG qqstr(THREADINFO_REG)
  93. register struct thread_info *__current_thread_info asm(QUOTED_THREADINFO_REG);
  94. #define current_thread_info() __current_thread_info
  95. #endif /* __ASSEMBLY__ */
  96. /*
  97. * thread information flags
  98. * - these are process state flags that various assembly files
  99. * 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 ss @ return to usr mode */
  108. #define TIF_IRET 5 /* return with iret */
  109. #define TIF_RESTORE_SIGMASK 6 /* restore sig mask in do_signal() */
  110. /* true if poll_idle() is polling TIF_NEED_RESCHED */
  111. #define TIF_POLLING_NRFLAG 16
  112. #define TIF_MEMDIE 17 /* OOM killer killed process */
  113. #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
  114. #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
  115. #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
  116. #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
  117. #define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
  118. #define _TIF_IRET (1 << TIF_IRET)
  119. #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
  120. #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
  121. /* work to do on interrupt/exception return - All but TIF_SYSCALL_TRACE */
  122. #define _TIF_WORK_MASK (0x0000FFFF & ~_TIF_SYSCALL_TRACE)
  123. /* work to do on any return to u-space */
  124. #define _TIF_ALLWORK_MASK 0x0000FFFF
  125. #endif /* __KERNEL__ */
  126. #endif