thread_info.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * OpenRISC Linux
  4. *
  5. * Linux architectural port borrowing liberally from similar works of
  6. * others. All original copyrights apply as per the original source
  7. * declaration.
  8. *
  9. * OpenRISC implementation:
  10. * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
  11. * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
  12. * et al.
  13. */
  14. #ifndef _ASM_THREAD_INFO_H
  15. #define _ASM_THREAD_INFO_H
  16. #ifdef __KERNEL__
  17. #ifndef __ASSEMBLY__
  18. #include <asm/types.h>
  19. #include <asm/processor.h>
  20. #endif
  21. /* THREAD_SIZE is the size of the task_struct/kernel_stack combo.
  22. * normally, the stack is found by doing something like p + THREAD_SIZE
  23. * in or1k, a page is 8192 bytes, which seems like a sane size
  24. */
  25. #define THREAD_SIZE_ORDER 0
  26. #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
  27. /*
  28. * low level task data that entry.S needs immediate access to
  29. * - this struct should fit entirely inside of one cache line
  30. * - this struct shares the supervisor stack pages
  31. * - if the contents of this structure are changed, the assembly constants
  32. * must also be changed
  33. */
  34. #ifndef __ASSEMBLY__
  35. struct thread_info {
  36. struct task_struct *task; /* main task structure */
  37. unsigned long flags; /* low level flags */
  38. __u32 cpu; /* current CPU */
  39. __s32 preempt_count; /* 0 => preemptable, <0 => BUG */
  40. __u8 supervisor_stack[0];
  41. /* saved context data */
  42. unsigned long ksp;
  43. };
  44. #endif
  45. /*
  46. * macros/functions for gaining access to the thread information structure
  47. *
  48. * preempt_count needs to be 1 initially, until the scheduler is functional.
  49. */
  50. #ifndef __ASSEMBLY__
  51. #define INIT_THREAD_INFO(tsk) \
  52. { \
  53. .task = &tsk, \
  54. .flags = 0, \
  55. .cpu = 0, \
  56. .preempt_count = INIT_PREEMPT_COUNT, \
  57. .ksp = 0, \
  58. }
  59. /* how to get the thread information struct from C */
  60. register struct thread_info *current_thread_info_reg asm("r10");
  61. #define current_thread_info() (current_thread_info_reg)
  62. #define get_thread_info(ti) get_task_struct((ti)->task)
  63. #define put_thread_info(ti) put_task_struct((ti)->task)
  64. #endif /* !__ASSEMBLY__ */
  65. /*
  66. * thread information flags
  67. * these are process state flags that various assembly files may need to
  68. * access
  69. * - pending work-to-be-done flags are in LSW
  70. * - other flags in MSW
  71. */
  72. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  73. #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
  74. #define TIF_SIGPENDING 2 /* signal pending */
  75. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  76. #define TIF_SINGLESTEP 4 /* restore singlestep on return to user
  77. * mode
  78. */
  79. #define TIF_NOTIFY_SIGNAL 5 /* signal notifications exist */
  80. #define TIF_SYSCALL_TRACEPOINT 8 /* for ftrace syscall instrumentation */
  81. #define TIF_RESTORE_SIGMASK 9
  82. #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling * TIF_NEED_RESCHED
  83. */
  84. #define TIF_MEMDIE 17
  85. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  86. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  87. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  88. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  89. #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
  90. #define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL)
  91. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  92. /* Work to do when returning from interrupt/exception */
  93. /* For OpenRISC, this is anything in the LSW other than syscall trace */
  94. #define _TIF_WORK_MASK (0xff & ~(_TIF_SYSCALL_TRACE|_TIF_SINGLESTEP))
  95. #endif /* __KERNEL__ */
  96. #endif /* _ASM_THREAD_INFO_H */