thread_info.h 3.8 KB

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