thread_info.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 thread_info {
  17. struct task_struct *task; /* main task structure */
  18. unsigned long flags; /* low level flags */
  19. __u32 cpu;
  20. __s32 preempt_count; /* 0 => preemptable, <0 => BUG */
  21. __u32 rar_saved; /* return address... */
  22. __u32 rsr_saved; /* ...and status register
  23. saved by debug handler
  24. when setting up
  25. trampoline */
  26. __u8 supervisor_stack[0];
  27. };
  28. #define INIT_THREAD_INFO(tsk) \
  29. { \
  30. .task = &tsk, \
  31. .flags = 0, \
  32. .cpu = 0, \
  33. .preempt_count = INIT_PREEMPT_COUNT, \
  34. }
  35. #define init_thread_info (init_thread_union.thread_info)
  36. #define init_stack (init_thread_union.stack)
  37. /*
  38. * Get the thread information struct from C.
  39. * We do the usual trick and use the lower end of the stack for this
  40. */
  41. static inline struct thread_info *current_thread_info(void)
  42. {
  43. unsigned long addr = ~(THREAD_SIZE - 1);
  44. asm("and %0, sp" : "=r"(addr) : "0"(addr));
  45. return (struct thread_info *)addr;
  46. }
  47. #define get_thread_info(ti) get_task_struct((ti)->task)
  48. #define put_thread_info(ti) put_task_struct((ti)->task)
  49. #endif /* !__ASSEMBLY__ */
  50. /*
  51. * Thread information flags
  52. * - these are process state flags that various assembly files may need to access
  53. * - pending work-to-be-done flags are in LSW
  54. * - other flags in MSW
  55. */
  56. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  57. #define TIF_SIGPENDING 1 /* signal pending */
  58. #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
  59. #define TIF_BREAKPOINT 4 /* enter monitor mode on return */
  60. #define TIF_SINGLE_STEP 5 /* single step in progress */
  61. #define TIF_MEMDIE 6 /* is terminating due to OOM killer */
  62. #define TIF_RESTORE_SIGMASK 7 /* restore signal mask in do_signal */
  63. #define TIF_CPU_GOING_TO_SLEEP 8 /* CPU is entering sleep 0 mode */
  64. #define TIF_NOTIFY_RESUME 9 /* callback before returning to user */
  65. #define TIF_DEBUG 30 /* debugging enabled */
  66. #define TIF_USERSPACE 31 /* true if FS sets userspace */
  67. #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
  68. #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
  69. #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
  70. #define _TIF_BREAKPOINT (1 << TIF_BREAKPOINT)
  71. #define _TIF_SINGLE_STEP (1 << TIF_SINGLE_STEP)
  72. #define _TIF_MEMDIE (1 << TIF_MEMDIE)
  73. #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
  74. #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
  75. /* Note: The masks below must never span more than 16 bits! */
  76. /* work to do on interrupt/exception return */
  77. #define _TIF_WORK_MASK \
  78. (_TIF_SIGPENDING \
  79. | _TIF_NOTIFY_RESUME \
  80. | _TIF_NEED_RESCHED \
  81. | _TIF_BREAKPOINT)
  82. /* work to do on any return to userspace */
  83. #define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_SYSCALL_TRACE)
  84. /* work to do on return from debug mode */
  85. #define _TIF_DBGWORK_MASK (_TIF_WORK_MASK & ~_TIF_BREAKPOINT)
  86. #endif /* __ASM_AVR32_THREAD_INFO_H */