thread_info.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. struct restart_block restart_block;
  24. __u8 supervisor_stack[0];
  25. };
  26. #define INIT_THREAD_INFO(tsk) \
  27. { \
  28. .task = &tsk, \
  29. .exec_domain = &default_exec_domain, \
  30. .flags = 0, \
  31. .cpu = 0, \
  32. .preempt_count = 1, \
  33. .restart_block = { \
  34. .fn = do_no_restart_syscall \
  35. } \
  36. }
  37. #define init_thread_info (init_thread_union.thread_info)
  38. #define init_stack (init_thread_union.stack)
  39. /*
  40. * Get the thread information struct from C.
  41. * We do the usual trick and use the lower end of the stack for this
  42. */
  43. static inline struct thread_info *current_thread_info(void)
  44. {
  45. unsigned long addr = ~(THREAD_SIZE - 1);
  46. asm("and %0, sp" : "=r"(addr) : "0"(addr));
  47. return (struct thread_info *)addr;
  48. }
  49. /* thread information allocation */
  50. #define alloc_thread_info(ti) \
  51. ((struct thread_info *) __get_free_pages(GFP_KERNEL, THREAD_SIZE_ORDER))
  52. #define free_thread_info(ti) free_pages((unsigned long)(ti), 1)
  53. #define get_thread_info(ti) get_task_struct((ti)->task)
  54. #define put_thread_info(ti) put_task_struct((ti)->task)
  55. #endif /* !__ASSEMBLY__ */
  56. #define PREEMPT_ACTIVE 0x40000000
  57. /*
  58. * Thread information flags
  59. * - these are process state flags that various assembly files may need to access
  60. * - pending work-to-be-done flags are in LSW
  61. * - other flags in MSW
  62. */
  63. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  64. #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
  65. #define TIF_SIGPENDING 2 /* signal pending */
  66. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  67. #define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling
  68. TIF_NEED_RESCHED */
  69. #define TIF_BREAKPOINT 5 /* true if we should break after return */
  70. #define TIF_SINGLE_STEP 6 /* single step after next break */
  71. #define TIF_MEMDIE 7
  72. #define TIF_RESTORE_SIGMASK 8 /* restore signal mask in do_signal */
  73. #define TIF_USERSPACE 31 /* true if FS sets userspace */
  74. #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
  75. #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
  76. #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
  77. #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
  78. #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
  79. #define _TIF_BREAKPOINT (1 << TIF_BREAKPOINT)
  80. #define _TIF_SINGLE_STEP (1 << TIF_SINGLE_STEP)
  81. #define _TIF_MEMDIE (1 << TIF_MEMDIE)
  82. #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
  83. /* XXX: These two masks must never span more than 16 bits! */
  84. /* work to do on interrupt/exception return */
  85. #define _TIF_WORK_MASK 0x0000013e
  86. /* work to do on any return to userspace */
  87. #define _TIF_ALLWORK_MASK 0x0000013f
  88. /* work to do on return from debug mode */
  89. #define _TIF_DBGWORK_MASK 0x0000017e
  90. #endif /* __ASM_AVR32_THREAD_INFO_H */