thread_info.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Port on Texas Instruments TMS320C6x architecture
  3. *
  4. * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
  5. * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
  6. *
  7. * Updated for 2.6.3x: Mark Salter <msalter@redhat.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #ifndef _ASM_C6X_THREAD_INFO_H
  14. #define _ASM_C6X_THREAD_INFO_H
  15. #ifdef __KERNEL__
  16. #include <asm/page.h>
  17. #ifdef CONFIG_4KSTACKS
  18. #define THREAD_SIZE 4096
  19. #define THREAD_SHIFT 12
  20. #define THREAD_ORDER 0
  21. #else
  22. #define THREAD_SIZE 8192
  23. #define THREAD_SHIFT 13
  24. #define THREAD_ORDER 1
  25. #endif
  26. #define THREAD_START_SP (THREAD_SIZE - 8)
  27. #ifndef __ASSEMBLY__
  28. typedef struct {
  29. unsigned long seg;
  30. } mm_segment_t;
  31. /*
  32. * low level task data.
  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. int cpu; /* cpu we're on */
  39. int preempt_count; /* 0 = preemptable, <0 = BUG */
  40. mm_segment_t addr_limit; /* thread address space */
  41. struct restart_block restart_block;
  42. };
  43. /*
  44. * macros/functions for gaining access to the thread information structure
  45. *
  46. * preempt_count needs to be 1 initially, until the scheduler is functional.
  47. */
  48. #define INIT_THREAD_INFO(tsk) \
  49. { \
  50. .task = &tsk, \
  51. .exec_domain = &default_exec_domain, \
  52. .flags = 0, \
  53. .cpu = 0, \
  54. .preempt_count = INIT_PREEMPT_COUNT, \
  55. .addr_limit = KERNEL_DS, \
  56. .restart_block = { \
  57. .fn = do_no_restart_syscall, \
  58. }, \
  59. }
  60. #define init_thread_info (init_thread_union.thread_info)
  61. #define init_stack (init_thread_union.stack)
  62. /* get the thread information struct of current task */
  63. static inline __attribute__((const))
  64. struct thread_info *current_thread_info(void)
  65. {
  66. struct thread_info *ti;
  67. asm volatile (" clr .s2 B15,0,%1,%0\n"
  68. : "=b" (ti)
  69. : "Iu5" (THREAD_SHIFT - 1));
  70. return ti;
  71. }
  72. #define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
  73. /* thread information allocation */
  74. #ifdef CONFIG_DEBUG_STACK_USAGE
  75. #define THREAD_FLAGS (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO)
  76. #else
  77. #define THREAD_FLAGS (GFP_KERNEL | __GFP_NOTRACK)
  78. #endif
  79. #define alloc_thread_info_node(tsk, node) \
  80. ((struct thread_info *)__get_free_pages(THREAD_FLAGS, THREAD_ORDER))
  81. #define free_thread_info(ti) free_pages((unsigned long) (ti), THREAD_ORDER)
  82. #define get_thread_info(ti) get_task_struct((ti)->task)
  83. #define put_thread_info(ti) put_task_struct((ti)->task)
  84. #endif /* __ASSEMBLY__ */
  85. #define PREEMPT_ACTIVE 0x10000000
  86. /*
  87. * thread information flag bit numbers
  88. * - pending work-to-be-done flags are in LSW
  89. * - other flags in MSW
  90. */
  91. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  92. #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
  93. #define TIF_SIGPENDING 2 /* signal pending */
  94. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  95. #define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */
  96. #define TIF_POLLING_NRFLAG 16 /* true if polling TIF_NEED_RESCHED */
  97. #define TIF_MEMDIE 17 /* OOM killer killed process */
  98. #define TIF_WORK_MASK 0x00007FFE /* work on irq/exception return */
  99. #define TIF_ALLWORK_MASK 0x00007FFF /* work on any return to u-space */
  100. #endif /* __KERNEL__ */
  101. #endif /* _ASM_C6X_THREAD_INFO_H */