thread_info.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * linux/arch/unicore32/include/asm/thread_info.h
  3. *
  4. * Code specific to PKUnity SoC and UniCore ISA
  5. *
  6. * Copyright (C) 2001-2010 GUAN Xue-tao
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #ifndef __UNICORE_THREAD_INFO_H__
  13. #define __UNICORE_THREAD_INFO_H__
  14. #ifdef __KERNEL__
  15. #include <linux/compiler.h>
  16. #include <asm/fpstate.h>
  17. #define THREAD_SIZE_ORDER 1
  18. #define THREAD_SIZE 8192
  19. #define THREAD_START_SP (THREAD_SIZE - 8)
  20. #ifndef __ASSEMBLY__
  21. struct task_struct;
  22. struct exec_domain;
  23. #include <asm/types.h>
  24. typedef struct {
  25. unsigned long seg;
  26. } mm_segment_t;
  27. struct cpu_context_save {
  28. __u32 r4;
  29. __u32 r5;
  30. __u32 r6;
  31. __u32 r7;
  32. __u32 r8;
  33. __u32 r9;
  34. __u32 r10;
  35. __u32 r11;
  36. __u32 r12;
  37. __u32 r13;
  38. __u32 r14;
  39. __u32 r15;
  40. __u32 r16;
  41. __u32 r17;
  42. __u32 r18;
  43. __u32 r19;
  44. __u32 r20;
  45. __u32 r21;
  46. __u32 r22;
  47. __u32 r23;
  48. __u32 r24;
  49. __u32 r25;
  50. __u32 r26;
  51. __u32 fp;
  52. __u32 sp;
  53. __u32 pc;
  54. };
  55. /*
  56. * low level task data that entry.S needs immediate access to.
  57. * __switch_to() assumes cpu_context follows immediately after cpu_domain.
  58. */
  59. struct thread_info {
  60. unsigned long flags; /* low level flags */
  61. int preempt_count; /* 0 => preemptable */
  62. /* <0 => bug */
  63. mm_segment_t addr_limit; /* address limit */
  64. struct task_struct *task; /* main task structure */
  65. struct exec_domain *exec_domain; /* execution domain */
  66. __u32 cpu; /* cpu */
  67. struct cpu_context_save cpu_context; /* cpu context */
  68. __u32 syscall; /* syscall number */
  69. __u8 used_cp[16]; /* thread used copro */
  70. #ifdef CONFIG_UNICORE_FPU_F64
  71. struct fp_state fpstate __attribute__((aligned(8)));
  72. #endif
  73. struct restart_block restart_block;
  74. };
  75. #define INIT_THREAD_INFO(tsk) \
  76. { \
  77. .task = &tsk, \
  78. .exec_domain = &default_exec_domain, \
  79. .flags = 0, \
  80. .preempt_count = INIT_PREEMPT_COUNT, \
  81. .addr_limit = KERNEL_DS, \
  82. .restart_block = { \
  83. .fn = do_no_restart_syscall, \
  84. }, \
  85. }
  86. #define init_thread_info (init_thread_union.thread_info)
  87. #define init_stack (init_thread_union.stack)
  88. /*
  89. * how to get the thread information struct from C
  90. */
  91. static inline struct thread_info *current_thread_info(void) __attribute_const__;
  92. static inline struct thread_info *current_thread_info(void)
  93. {
  94. register unsigned long sp asm ("sp");
  95. return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
  96. }
  97. #define thread_saved_pc(tsk) \
  98. ((unsigned long)(task_thread_info(tsk)->cpu_context.pc))
  99. #define thread_saved_sp(tsk) \
  100. ((unsigned long)(task_thread_info(tsk)->cpu_context.sp))
  101. #define thread_saved_fp(tsk) \
  102. ((unsigned long)(task_thread_info(tsk)->cpu_context.fp))
  103. #endif
  104. /*
  105. * We use bit 30 of the preempt_count to indicate that kernel
  106. * preemption is occurring. See <asm/hardirq.h>.
  107. */
  108. #define PREEMPT_ACTIVE 0x40000000
  109. /*
  110. * thread information flags:
  111. * TIF_SYSCALL_TRACE - syscall trace active
  112. * TIF_SIGPENDING - signal pending
  113. * TIF_NEED_RESCHED - rescheduling necessary
  114. * TIF_NOTIFY_RESUME - callback before returning to user
  115. */
  116. #define TIF_SIGPENDING 0
  117. #define TIF_NEED_RESCHED 1
  118. #define TIF_NOTIFY_RESUME 2 /* callback before returning to user */
  119. #define TIF_SYSCALL_TRACE 8
  120. #define TIF_MEMDIE 18
  121. #define TIF_FREEZE 19
  122. #define TIF_RESTORE_SIGMASK 20
  123. #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
  124. #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
  125. #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
  126. #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
  127. #define _TIF_FREEZE (1 << TIF_FREEZE)
  128. #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
  129. /*
  130. * Change these and you break ASM code in entry-common.S
  131. */
  132. #define _TIF_WORK_MASK 0x000000ff
  133. #endif /* __KERNEL__ */
  134. #endif /* __UNICORE_THREAD_INFO_H__ */