thread_info.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /* MN10300 Low-level thread information
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #ifndef _ASM_THREAD_INFO_H
  12. #define _ASM_THREAD_INFO_H
  13. #ifdef __KERNEL__
  14. #include <asm/page.h>
  15. #ifndef __ASSEMBLY__
  16. #include <asm/processor.h>
  17. #endif
  18. #define PREEMPT_ACTIVE 0x10000000
  19. #ifdef CONFIG_4KSTACKS
  20. #define THREAD_SIZE (4096)
  21. #else
  22. #define THREAD_SIZE (8192)
  23. #endif
  24. #define STACK_WARN (THREAD_SIZE / 8)
  25. /*
  26. * low level task data that entry.S needs immediate access to
  27. * - this struct should fit entirely inside of one cache line
  28. * - this struct shares the supervisor stack pages
  29. * - if the contents of this structure are changed, the assembly constants
  30. * must also be changed
  31. */
  32. #ifndef __ASSEMBLY__
  33. struct thread_info {
  34. struct task_struct *task; /* main task structure */
  35. struct exec_domain *exec_domain; /* execution domain */
  36. unsigned long flags; /* low level flags */
  37. __u32 cpu; /* current CPU */
  38. __s32 preempt_count; /* 0 => preemptable, <0 => BUG */
  39. mm_segment_t addr_limit; /* thread address space:
  40. 0-0xBFFFFFFF for user-thead
  41. 0-0xFFFFFFFF for kernel-thread
  42. */
  43. struct restart_block restart_block;
  44. __u8 supervisor_stack[0];
  45. };
  46. #else /* !__ASSEMBLY__ */
  47. #ifndef __ASM_OFFSETS_H__
  48. #include <asm/asm-offsets.h>
  49. #endif
  50. #endif
  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. #define init_uregs \
  72. ((struct pt_regs *) \
  73. ((unsigned long) init_stack + THREAD_SIZE - sizeof(struct pt_regs)))
  74. extern struct thread_info *__current_ti;
  75. /* how to get the thread information struct from C */
  76. static inline __attribute__((const))
  77. struct thread_info *current_thread_info(void)
  78. {
  79. struct thread_info *ti;
  80. asm("mov sp,%0\n"
  81. "and %1,%0\n"
  82. : "=d" (ti)
  83. : "i" (~(THREAD_SIZE - 1))
  84. : "cc");
  85. return ti;
  86. }
  87. /* how to get the current stack pointer from C */
  88. static inline unsigned long current_stack_pointer(void)
  89. {
  90. unsigned long sp;
  91. asm("mov sp,%0; ":"=r" (sp));
  92. return sp;
  93. }
  94. #define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
  95. /* thread information allocation */
  96. #ifdef CONFIG_DEBUG_STACK_USAGE
  97. #define alloc_thread_info(tsk) kzalloc(THREAD_SIZE, GFP_KERNEL)
  98. #else
  99. #define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
  100. #endif
  101. #define free_thread_info(ti) kfree((ti))
  102. #define get_thread_info(ti) get_task_struct((ti)->task)
  103. #define put_thread_info(ti) put_task_struct((ti)->task)
  104. #else /* !__ASSEMBLY__ */
  105. #ifndef __VMLINUX_LDS__
  106. /* how to get the thread information struct from ASM */
  107. .macro GET_THREAD_INFO reg
  108. mov sp,\reg
  109. and -THREAD_SIZE,\reg
  110. .endm
  111. #endif
  112. #endif
  113. /*
  114. * thread information flags
  115. * - these are process state flags that various assembly files may need to
  116. * access
  117. * - pending work-to-be-done flags are in LSW
  118. * - other flags in MSW
  119. */
  120. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  121. #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
  122. #define TIF_SIGPENDING 2 /* signal pending */
  123. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  124. #define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */
  125. #define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
  126. #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
  127. #define TIF_MEMDIE 17 /* OOM killer killed process */
  128. #define TIF_FREEZE 18 /* freezing for suspend */
  129. #define _TIF_SYSCALL_TRACE +(1 << TIF_SYSCALL_TRACE)
  130. #define _TIF_NOTIFY_RESUME +(1 << TIF_NOTIFY_RESUME)
  131. #define _TIF_SIGPENDING +(1 << TIF_SIGPENDING)
  132. #define _TIF_NEED_RESCHED +(1 << TIF_NEED_RESCHED)
  133. #define _TIF_SINGLESTEP +(1 << TIF_SINGLESTEP)
  134. #define _TIF_RESTORE_SIGMASK +(1 << TIF_RESTORE_SIGMASK)
  135. #define _TIF_POLLING_NRFLAG +(1 << TIF_POLLING_NRFLAG)
  136. #define _TIF_FREEZE +(1 << TIF_FREEZE)
  137. #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
  138. #define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */
  139. #endif /* __KERNEL__ */
  140. #endif /* _ASM_THREAD_INFO_H */