thread_info.h 4.1 KB

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