thread_info.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. #define THREAD_SIZE_ORDER (1)
  21. #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
  22. #ifndef __ASSEMBLY__
  23. #include <asm/processor.h>
  24. #include <asm/csr.h>
  25. typedef unsigned long mm_segment_t;
  26. /*
  27. * low level task data that entry.S needs immediate access to
  28. * - this struct should fit entirely inside of one cache line
  29. * - if the members of this struct changes, the assembly constants
  30. * in asm-offsets.c must be updated accordingly
  31. * - thread_info is included in task_struct at an offset of 0. This means that
  32. * tp points to both thread_info and task_struct.
  33. */
  34. struct thread_info {
  35. unsigned long flags; /* low level flags */
  36. int preempt_count; /* 0=>preemptible, <0=>BUG */
  37. mm_segment_t addr_limit;
  38. /*
  39. * These stack pointers are overwritten on every system call or
  40. * exception. SP is also saved to the stack it can be recovered when
  41. * overwritten.
  42. */
  43. long kernel_sp; /* Kernel stack pointer */
  44. long user_sp; /* User stack pointer */
  45. int cpu;
  46. };
  47. /*
  48. * macros/functions for gaining access to the thread information structure
  49. *
  50. * preempt_count needs to be 1 initially, until the scheduler is functional.
  51. */
  52. #define INIT_THREAD_INFO(tsk) \
  53. { \
  54. .flags = 0, \
  55. .preempt_count = INIT_PREEMPT_COUNT, \
  56. .addr_limit = KERNEL_DS, \
  57. }
  58. #endif /* !__ASSEMBLY__ */
  59. /*
  60. * thread information flags
  61. * - these are process state flags that various assembly files may need to
  62. * access
  63. * - pending work-to-be-done flags are in lowest half-word
  64. * - other flags in upper half-word(s)
  65. */
  66. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  67. #define TIF_NOTIFY_RESUME 1 /* callback before returning to user */
  68. #define TIF_SIGPENDING 2 /* signal pending */
  69. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  70. #define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */
  71. #define TIF_MEMDIE 5 /* is terminating due to OOM killer */
  72. #define TIF_SYSCALL_TRACEPOINT 6 /* syscall tracepoint instrumentation */
  73. #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
  74. #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
  75. #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
  76. #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
  77. #define _TIF_WORK_MASK \
  78. (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | _TIF_NEED_RESCHED)
  79. #endif /* _ASM_RISCV_THREAD_INFO_H */