thread_info.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * NiosII low-level thread information
  3. *
  4. * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
  5. * Copyright (C) 2004 Microtronix Datacom Ltd.
  6. *
  7. * Based on asm/thread_info_no.h from m68k which is:
  8. *
  9. * Copyright (C) 2002 David Howells <dhowells@redhat.com>
  10. *
  11. * This file is subject to the terms and conditions of the GNU General Public
  12. * License. See the file "COPYING" in the main directory of this archive
  13. * for more details.
  14. */
  15. #ifndef _ASM_NIOS2_THREAD_INFO_H
  16. #define _ASM_NIOS2_THREAD_INFO_H
  17. #ifdef __KERNEL__
  18. /*
  19. * Size of the kernel stack for each process.
  20. */
  21. #define THREAD_SIZE_ORDER 1
  22. #define THREAD_SIZE 8192 /* 2 * PAGE_SIZE */
  23. #ifndef __ASSEMBLY__
  24. typedef struct {
  25. unsigned long seg;
  26. } mm_segment_t;
  27. /*
  28. * low level task data that entry.S needs immediate access to
  29. * - this struct should fit entirely inside of one cache line
  30. * - this struct shares the supervisor stack pages
  31. * - if the contents of this structure are changed, the assembly constants
  32. * must also be changed
  33. */
  34. struct thread_info {
  35. struct task_struct *task; /* main task structure */
  36. struct exec_domain *exec_domain; /* execution domain */
  37. unsigned long flags; /* low level flags */
  38. __u32 cpu; /* current CPU */
  39. int preempt_count; /* 0 => preemptable,<0 => BUG */
  40. mm_segment_t addr_limit; /* thread address space:
  41. 0-0x7FFFFFFF for user-thead
  42. 0-0xFFFFFFFF for kernel-thread
  43. */
  44. struct restart_block restart_block;
  45. struct pt_regs *regs;
  46. };
  47. /*
  48. * macros/functions for gaining access to the thread information structure
  49. *
  50. * preempt_count needs to be 1 initially, until the scheduler is functional.
  51. */
  52. #define INIT_THREAD_INFO(tsk) \
  53. { \
  54. .task = &tsk, \
  55. .exec_domain = &default_exec_domain, \
  56. .flags = 0, \
  57. .cpu = 0, \
  58. .preempt_count = INIT_PREEMPT_COUNT, \
  59. .addr_limit = KERNEL_DS, \
  60. .restart_block = { \
  61. .fn = do_no_restart_syscall, \
  62. }, \
  63. }
  64. #define init_thread_info (init_thread_union.thread_info)
  65. #define init_stack (init_thread_union.stack)
  66. /* how to get the thread information struct from C */
  67. static inline struct thread_info *current_thread_info(void)
  68. {
  69. register unsigned long sp asm("sp");
  70. return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
  71. }
  72. #endif /* !__ASSEMBLY__ */
  73. /*
  74. * thread information flags
  75. * - these are process state flags that various assembly files may need to
  76. * access
  77. * - pending work-to-be-done flags are in LSW
  78. * - other flags in MSW
  79. */
  80. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  81. #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
  82. #define TIF_SIGPENDING 2 /* signal pending */
  83. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  84. #define TIF_MEMDIE 4 /* is terminating due to OOM killer */
  85. #define TIF_SECCOMP 5 /* secure computing */
  86. #define TIF_SYSCALL_AUDIT 6 /* syscall auditing active */
  87. #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */
  88. #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling
  89. TIF_NEED_RESCHED */
  90. #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
  91. #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
  92. #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
  93. #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
  94. #define _TIF_SECCOMP (1 << TIF_SECCOMP)
  95. #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
  96. #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
  97. #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
  98. /* work to do on interrupt/exception return */
  99. #define _TIF_WORK_MASK 0x0000FFFE
  100. /* work to do on any return to u-space */
  101. # define _TIF_ALLWORK_MASK 0x0000FFFF
  102. #endif /* __KERNEL__ */
  103. #endif /* _ASM_NIOS2_THREAD_INFO_H */