thread_info.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * thread_info.h: LoongArch low-level thread information
  4. *
  5. * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
  6. */
  7. #ifndef _ASM_THREAD_INFO_H
  8. #define _ASM_THREAD_INFO_H
  9. #ifdef __KERNEL__
  10. #ifndef __ASSEMBLY__
  11. #include <asm/processor.h>
  12. /*
  13. * low level task data that entry.S needs immediate access to
  14. * - this struct should fit entirely inside of one cache line
  15. * - this struct shares the supervisor stack pages
  16. * - if the contents of this structure are changed, the assembly constants
  17. * must also be changed
  18. */
  19. struct thread_info {
  20. struct task_struct *task; /* main task structure */
  21. unsigned long flags; /* low level flags */
  22. unsigned long tp_value; /* thread pointer */
  23. __u32 cpu; /* current CPU */
  24. int preempt_count; /* 0 => preemptible, <0 => BUG */
  25. struct pt_regs *regs;
  26. unsigned long syscall; /* syscall number */
  27. unsigned long syscall_work; /* SYSCALL_WORK_ flags */
  28. };
  29. /*
  30. * macros/functions for gaining access to the thread information structure
  31. */
  32. #define INIT_THREAD_INFO(tsk) \
  33. { \
  34. .task = &tsk, \
  35. .flags = 0, \
  36. .cpu = 0, \
  37. .preempt_count = INIT_PREEMPT_COUNT, \
  38. }
  39. /* How to get the thread information struct from C. */
  40. register struct thread_info *__current_thread_info __asm__("$tp");
  41. static inline struct thread_info *current_thread_info(void)
  42. {
  43. return __current_thread_info;
  44. }
  45. register unsigned long current_stack_pointer __asm__("$sp");
  46. #endif /* !__ASSEMBLY__ */
  47. /* thread information allocation */
  48. #define THREAD_SIZE SZ_16K
  49. #define THREAD_MASK (THREAD_SIZE - 1UL)
  50. #define THREAD_SIZE_ORDER ilog2(THREAD_SIZE / PAGE_SIZE)
  51. /*
  52. * thread information flags
  53. * - these are process state flags that various assembly files may need to
  54. * access
  55. * - pending work-to-be-done flags are in LSW
  56. * - other flags in MSW
  57. */
  58. #define TIF_SIGPENDING 1 /* signal pending */
  59. #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
  60. #define TIF_NOTIFY_RESUME 3 /* callback before returning to user */
  61. #define TIF_NOTIFY_SIGNAL 4 /* signal notifications exist */
  62. #define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
  63. #define TIF_NOHZ 6 /* in adaptive nohz mode */
  64. #define TIF_UPROBE 7 /* breakpointed or singlestepping */
  65. #define TIF_USEDFPU 8 /* FPU was used by this task this quantum (SMP) */
  66. #define TIF_USEDSIMD 9 /* SIMD has been used this quantum */
  67. #define TIF_MEMDIE 10 /* is terminating due to OOM killer */
  68. #define TIF_FIXADE 11 /* Fix address errors in software */
  69. #define TIF_LOGADE 12 /* Log address errors to syslog */
  70. #define TIF_32BIT_REGS 13 /* 32-bit general purpose registers */
  71. #define TIF_32BIT_ADDR 14 /* 32-bit address space */
  72. #define TIF_LOAD_WATCH 15 /* If set, load watch registers */
  73. #define TIF_SINGLESTEP 16 /* Single Step */
  74. #define TIF_LSX_CTX_LIVE 17 /* LSX context must be preserved */
  75. #define TIF_LASX_CTX_LIVE 18 /* LASX context must be preserved */
  76. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  77. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  78. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  79. #define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL)
  80. #define _TIF_NOHZ (1<<TIF_NOHZ)
  81. #define _TIF_UPROBE (1<<TIF_UPROBE)
  82. #define _TIF_USEDFPU (1<<TIF_USEDFPU)
  83. #define _TIF_USEDSIMD (1<<TIF_USEDSIMD)
  84. #define _TIF_FIXADE (1<<TIF_FIXADE)
  85. #define _TIF_LOGADE (1<<TIF_LOGADE)
  86. #define _TIF_32BIT_REGS (1<<TIF_32BIT_REGS)
  87. #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
  88. #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
  89. #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
  90. #define _TIF_LSX_CTX_LIVE (1<<TIF_LSX_CTX_LIVE)
  91. #define _TIF_LASX_CTX_LIVE (1<<TIF_LASX_CTX_LIVE)
  92. #endif /* __KERNEL__ */
  93. #endif /* _ASM_THREAD_INFO_H */