thread_info.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Copyright (C) 2004-2006 Atmel Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef __ASM_AVR32_THREAD_INFO_H
  9. #define __ASM_AVR32_THREAD_INFO_H
  10. #include <asm/page.h>
  11. #define THREAD_SIZE_ORDER 1
  12. #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
  13. #ifndef __ASSEMBLY__
  14. #include <asm/types.h>
  15. struct task_struct;
  16. struct exec_domain;
  17. struct thread_info {
  18. struct task_struct *task; /* main task structure */
  19. struct exec_domain *exec_domain; /* execution domain */
  20. unsigned long flags; /* low level flags */
  21. __u32 cpu;
  22. __s32 preempt_count; /* 0 => preemptable, <0 => BUG */
  23. __u32 rar_saved; /* return address... */
  24. __u32 rsr_saved; /* ...and status register
  25. saved by debug handler
  26. when setting up
  27. trampoline */
  28. struct restart_block restart_block;
  29. __u8 supervisor_stack[0];
  30. };
  31. #define INIT_THREAD_INFO(tsk) \
  32. { \
  33. .task = &tsk, \
  34. .exec_domain = &default_exec_domain, \
  35. .flags = 0, \
  36. .cpu = 0, \
  37. .preempt_count = INIT_PREEMPT_COUNT, \
  38. .restart_block = { \
  39. .fn = do_no_restart_syscall \
  40. } \
  41. }
  42. #define init_thread_info (init_thread_union.thread_info)
  43. #define init_stack (init_thread_union.stack)
  44. /*
  45. * Get the thread information struct from C.
  46. * We do the usual trick and use the lower end of the stack for this
  47. */
  48. static inline struct thread_info *current_thread_info(void)
  49. {
  50. unsigned long addr = ~(THREAD_SIZE - 1);
  51. asm("and %0, sp" : "=r"(addr) : "0"(addr));
  52. return (struct thread_info *)addr;
  53. }
  54. #define get_thread_info(ti) get_task_struct((ti)->task)
  55. #define put_thread_info(ti) put_task_struct((ti)->task)
  56. #endif /* !__ASSEMBLY__ */
  57. #define PREEMPT_ACTIVE 0x40000000
  58. /*
  59. * Thread information flags
  60. * - these are process state flags that various assembly files may need to access
  61. * - pending work-to-be-done flags are in LSW
  62. * - other flags in MSW
  63. */
  64. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  65. #define TIF_SIGPENDING 1 /* signal pending */
  66. #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
  67. #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
  68. TIF_NEED_RESCHED */
  69. #define TIF_BREAKPOINT 4 /* enter monitor mode on return */
  70. #define TIF_SINGLE_STEP 5 /* single step in progress */
  71. #define TIF_MEMDIE 6 /* is terminating due to OOM killer */
  72. #define TIF_RESTORE_SIGMASK 7 /* restore signal mask in do_signal */
  73. #define TIF_CPU_GOING_TO_SLEEP 8 /* CPU is entering sleep 0 mode */
  74. #define TIF_NOTIFY_RESUME 9 /* callback before returning to user */
  75. #define TIF_DEBUG 30 /* debugging enabled */
  76. #define TIF_USERSPACE 31 /* true if FS sets userspace */
  77. #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
  78. #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
  79. #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
  80. #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
  81. #define _TIF_SINGLE_STEP (1 << TIF_SINGLE_STEP)
  82. #define _TIF_MEMDIE (1 << TIF_MEMDIE)
  83. #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
  84. #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
  85. #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
  86. /* Note: The masks below must never span more than 16 bits! */
  87. /* work to do on interrupt/exception return */
  88. #define _TIF_WORK_MASK \
  89. ((1 << TIF_SIGPENDING) \
  90. | _TIF_NOTIFY_RESUME \
  91. | (1 << TIF_NEED_RESCHED) \
  92. | (1 << TIF_POLLING_NRFLAG) \
  93. | (1 << TIF_BREAKPOINT) \
  94. | (1 << TIF_RESTORE_SIGMASK))
  95. /* work to do on any return to userspace */
  96. #define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | (1 << TIF_SYSCALL_TRACE) | \
  97. _TIF_NOTIFY_RESUME)
  98. /* work to do on return from debug mode */
  99. #define _TIF_DBGWORK_MASK (_TIF_WORK_MASK & ~(1 << TIF_BREAKPOINT))
  100. #endif /* __ASM_AVR32_THREAD_INFO_H */