thread_info.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright (C) 2009 Chen Liqin <liqin.chen@sunplusct.com>
  3. * Copyright (C) 2012 Regents of the University of California
  4. * Copyright (C) 2017 SiFive
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation, version 2.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #ifndef _ASM_RISCV_THREAD_INFO_H
  16. #define _ASM_RISCV_THREAD_INFO_H
  17. #include <asm/page.h>
  18. #include <linux/const.h>
  19. /* thread information allocation */
  20. #ifdef CONFIG_64BIT
  21. #define THREAD_SIZE_ORDER (2)
  22. #else
  23. #define THREAD_SIZE_ORDER (1)
  24. #endif
  25. #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
  26. #ifndef __ASSEMBLY__
  27. #include <asm/processor.h>
  28. #include <asm/csr.h>
  29. typedef unsigned long mm_segment_t;
  30. /*
  31. * low level task data that entry.S needs immediate access to
  32. * - this struct should fit entirely inside of one cache line
  33. * - if the members of this struct changes, the assembly constants
  34. * in asm-offsets.c must be updated accordingly
  35. * - thread_info is included in task_struct at an offset of 0. This means that
  36. * tp points to both thread_info and task_struct.
  37. */
  38. struct thread_info {
  39. unsigned long flags; /* low level flags */
  40. int preempt_count; /* 0=>preemptible, <0=>BUG */
  41. mm_segment_t addr_limit;
  42. /*
  43. * These stack pointers are overwritten on every system call or
  44. * exception. SP is also saved to the stack it can be recovered when
  45. * overwritten.
  46. */
  47. long kernel_sp; /* Kernel stack pointer */
  48. long user_sp; /* User stack pointer */
  49. int cpu;
  50. };
  51. /*
  52. * macros/functions for gaining access to the thread information structure
  53. *
  54. * preempt_count needs to be 1 initially, until the scheduler is functional.
  55. */
  56. #define INIT_THREAD_INFO(tsk) \
  57. { \
  58. .flags = 0, \
  59. .preempt_count = INIT_PREEMPT_COUNT, \
  60. .addr_limit = KERNEL_DS, \
  61. }
  62. #endif /* !__ASSEMBLY__ */
  63. /*
  64. * thread information flags
  65. * - these are process state flags that various assembly files may need to
  66. * access
  67. * - pending work-to-be-done flags are in lowest half-word
  68. * - other flags in upper half-word(s)
  69. */
  70. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  71. #define TIF_NOTIFY_RESUME 1 /* callback before returning to user */
  72. #define TIF_SIGPENDING 2 /* signal pending */
  73. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  74. #define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */
  75. #define TIF_MEMDIE 5 /* is terminating due to OOM killer */
  76. #define TIF_SYSCALL_TRACEPOINT 6 /* syscall tracepoint instrumentation */
  77. #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
  78. #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
  79. #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
  80. #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
  81. #define _TIF_WORK_MASK \
  82. (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | _TIF_NEED_RESCHED)
  83. #endif /* _ASM_RISCV_THREAD_INFO_H */