thread_info.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. #include <asm/types.h>
  23. typedef struct {
  24. unsigned long seg;
  25. } mm_segment_t;
  26. struct cpu_context_save {
  27. __u32 r4;
  28. __u32 r5;
  29. __u32 r6;
  30. __u32 r7;
  31. __u32 r8;
  32. __u32 r9;
  33. __u32 r10;
  34. __u32 r11;
  35. __u32 r12;
  36. __u32 r13;
  37. __u32 r14;
  38. __u32 r15;
  39. __u32 r16;
  40. __u32 r17;
  41. __u32 r18;
  42. __u32 r19;
  43. __u32 r20;
  44. __u32 r21;
  45. __u32 r22;
  46. __u32 r23;
  47. __u32 r24;
  48. __u32 r25;
  49. __u32 r26;
  50. __u32 fp;
  51. __u32 sp;
  52. __u32 pc;
  53. };
  54. /*
  55. * low level task data that entry.S needs immediate access to.
  56. * __switch_to() assumes cpu_context follows immediately after cpu_domain.
  57. */
  58. struct thread_info {
  59. unsigned long flags; /* low level flags */
  60. int preempt_count; /* 0 => preemptable */
  61. /* <0 => bug */
  62. mm_segment_t addr_limit; /* address limit */
  63. struct task_struct *task; /* main task structure */
  64. __u32 cpu; /* cpu */
  65. struct cpu_context_save cpu_context; /* cpu context */
  66. __u32 syscall; /* syscall number */
  67. __u8 used_cp[16]; /* thread used copro */
  68. #ifdef CONFIG_UNICORE_FPU_F64
  69. struct fp_state fpstate __attribute__((aligned(8)));
  70. #endif
  71. };
  72. #define INIT_THREAD_INFO(tsk) \
  73. { \
  74. .task = &tsk, \
  75. .flags = 0, \
  76. .preempt_count = INIT_PREEMPT_COUNT, \
  77. .addr_limit = KERNEL_DS, \
  78. }
  79. #define init_thread_info (init_thread_union.thread_info)
  80. #define init_stack (init_thread_union.stack)
  81. /*
  82. * how to get the thread information struct from C
  83. */
  84. static inline struct thread_info *current_thread_info(void) __attribute_const__;
  85. static inline struct thread_info *current_thread_info(void)
  86. {
  87. register unsigned long sp asm ("sp");
  88. return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
  89. }
  90. #define thread_saved_pc(tsk) \
  91. ((unsigned long)(task_thread_info(tsk)->cpu_context.pc))
  92. #define thread_saved_sp(tsk) \
  93. ((unsigned long)(task_thread_info(tsk)->cpu_context.sp))
  94. #define thread_saved_fp(tsk) \
  95. ((unsigned long)(task_thread_info(tsk)->cpu_context.fp))
  96. #endif
  97. /*
  98. * thread information flags:
  99. * TIF_SYSCALL_TRACE - syscall trace active
  100. * TIF_SIGPENDING - signal pending
  101. * TIF_NEED_RESCHED - rescheduling necessary
  102. * TIF_NOTIFY_RESUME - callback before returning to user
  103. */
  104. #define TIF_SIGPENDING 0
  105. #define TIF_NEED_RESCHED 1
  106. #define TIF_NOTIFY_RESUME 2 /* callback before returning to user */
  107. #define TIF_SYSCALL_TRACE 8
  108. #define TIF_MEMDIE 18
  109. #define TIF_RESTORE_SIGMASK 20
  110. #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
  111. #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
  112. #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
  113. #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
  114. /*
  115. * Change these and you break ASM code in entry-common.S
  116. */
  117. #define _TIF_WORK_MASK \
  118. (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
  119. #endif /* __KERNEL__ */
  120. #endif /* __UNICORE_THREAD_INFO_H__ */