thread_info.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. __u8 supervisor_stack[0];
  51. /* saved context data */
  52. unsigned long ksp;
  53. };
  54. #endif
  55. /*
  56. * macros/functions for gaining access to the thread information structure
  57. *
  58. * preempt_count needs to be 1 initially, until the scheduler is functional.
  59. */
  60. #ifndef __ASSEMBLY__
  61. #define INIT_THREAD_INFO(tsk) \
  62. { \
  63. .task = &tsk, \
  64. .exec_domain = &default_exec_domain, \
  65. .flags = 0, \
  66. .cpu = 0, \
  67. .preempt_count = 1, \
  68. .addr_limit = KERNEL_DS, \
  69. .ksp = 0, \
  70. }
  71. #define init_thread_info (init_thread_union.thread_info)
  72. /* how to get the thread information struct from C */
  73. register struct thread_info *current_thread_info_reg asm("r10");
  74. #define current_thread_info() (current_thread_info_reg)
  75. #define get_thread_info(ti) get_task_struct((ti)->task)
  76. #define put_thread_info(ti) put_task_struct((ti)->task)
  77. #endif /* !__ASSEMBLY__ */
  78. /*
  79. * thread information flags
  80. * these are process state flags that various assembly files may need to
  81. * access
  82. * - pending work-to-be-done flags are in LSW
  83. * - other flags in MSW
  84. */
  85. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  86. #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
  87. #define TIF_SIGPENDING 2 /* signal pending */
  88. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  89. #define TIF_SINGLESTEP 4 /* restore singlestep on return to user
  90. * mode
  91. */
  92. #define TIF_SYSCALL_TRACEPOINT 8 /* for ftrace syscall instrumentation */
  93. #define TIF_RESTORE_SIGMASK 9
  94. #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling * TIF_NEED_RESCHED
  95. */
  96. #define TIF_MEMDIE 17
  97. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  98. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  99. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  100. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  101. #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
  102. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  103. /* Work to do when returning from interrupt/exception */
  104. /* For OpenRISC, this is anything in the LSW other than syscall trace */
  105. #define _TIF_WORK_MASK (0xff & ~(_TIF_SYSCALL_TRACE|_TIF_SINGLESTEP))
  106. #endif /* __KERNEL__ */
  107. #endif /* _ASM_THREAD_INFO_H */