PageRenderTime 56ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/arch/mn10300/include/asm/thread_info.h

https://gitlab.com/jhalayashraj/nkernel
C Header | 182 lines | 117 code | 31 blank | 34 comment | 0 complexity | f386b5e8477f128b0b1988044bfd9d81 MD5 | raw file
  1. /* MN10300 Low-level thread information
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #ifndef _ASM_THREAD_INFO_H
  12. #define _ASM_THREAD_INFO_H
  13. #ifdef __KERNEL__
  14. #include <asm/page.h>
  15. #define PREEMPT_ACTIVE 0x10000000
  16. #ifdef CONFIG_4KSTACKS
  17. #define THREAD_SIZE (4096)
  18. #else
  19. #define THREAD_SIZE (8192)
  20. #endif
  21. #define STACK_WARN (THREAD_SIZE / 8)
  22. /*
  23. * low level task data that entry.S needs immediate access to
  24. * - this struct should fit entirely inside of one cache line
  25. * - this struct shares the supervisor stack pages
  26. * - if the contents of this structure are changed, the assembly constants
  27. * must also be changed
  28. */
  29. #ifndef __ASSEMBLY__
  30. typedef struct {
  31. unsigned long seg;
  32. } mm_segment_t;
  33. struct thread_info {
  34. struct task_struct *task; /* main task structure */
  35. struct exec_domain *exec_domain; /* execution domain */
  36. struct pt_regs *frame; /* current exception frame */
  37. unsigned long flags; /* low level flags */
  38. __u32 cpu; /* current CPU */
  39. __s32 preempt_count; /* 0 => preemptable, <0 => BUG */
  40. mm_segment_t addr_limit; /* thread address space:
  41. 0-0xBFFFFFFF for user-thead
  42. 0-0xFFFFFFFF for kernel-thread
  43. */
  44. struct restart_block restart_block;
  45. __u8 supervisor_stack[0];
  46. };
  47. #define thread_info_to_uregs(ti) \
  48. ((struct pt_regs *) \
  49. ((unsigned long)ti + THREAD_SIZE - sizeof(struct pt_regs)))
  50. #else /* !__ASSEMBLY__ */
  51. #ifndef __ASM_OFFSETS_H__
  52. #include <asm/asm-offsets.h>
  53. #endif
  54. #endif
  55. /*
  56. * macros/functions for gaining access to the thread information structure
  57. */
  58. #ifndef __ASSEMBLY__
  59. #define INIT_THREAD_INFO(tsk) \
  60. { \
  61. .task = &tsk, \
  62. .exec_domain = &default_exec_domain, \
  63. .flags = 0, \
  64. .cpu = 0, \
  65. .preempt_count = INIT_PREEMPT_COUNT, \
  66. .addr_limit = KERNEL_DS, \
  67. .restart_block = { \
  68. .fn = do_no_restart_syscall, \
  69. }, \
  70. }
  71. #define init_thread_info (init_thread_union.thread_info)
  72. #define init_stack (init_thread_union.stack)
  73. #define init_uregs \
  74. ((struct pt_regs *) \
  75. ((unsigned long) init_stack + THREAD_SIZE - sizeof(struct pt_regs)))
  76. extern struct thread_info *__current_ti;
  77. /* how to get the thread information struct from C */
  78. static inline __attribute__((const))
  79. struct thread_info *current_thread_info(void)
  80. {
  81. struct thread_info *ti;
  82. asm("mov sp,%0\n"
  83. "and %1,%0\n"
  84. : "=d" (ti)
  85. : "i" (~(THREAD_SIZE - 1))
  86. : "cc");
  87. return ti;
  88. }
  89. static inline __attribute__((const))
  90. struct pt_regs *current_frame(void)
  91. {
  92. return current_thread_info()->frame;
  93. }
  94. /* how to get the current stack pointer from C */
  95. static inline unsigned long current_stack_pointer(void)
  96. {
  97. unsigned long sp;
  98. asm("mov sp,%0; ":"=r" (sp));
  99. return sp;
  100. }
  101. #define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
  102. /* thread information allocation */
  103. #ifdef CONFIG_DEBUG_STACK_USAGE
  104. #define alloc_thread_info_node(tsk, node) \
  105. kzalloc_node(THREAD_SIZE, GFP_KERNEL, node)
  106. #else
  107. #define alloc_thread_info_node(tsk, node) \
  108. kmalloc_node(THREAD_SIZE, GFP_KERNEL, node)
  109. #endif
  110. #ifndef CONFIG_KGDB
  111. #define free_thread_info(ti) kfree((ti))
  112. #else
  113. extern void free_thread_info(struct thread_info *);
  114. #endif
  115. #define get_thread_info(ti) get_task_struct((ti)->task)
  116. #define put_thread_info(ti) put_task_struct((ti)->task)
  117. #else /* !__ASSEMBLY__ */
  118. #ifndef __VMLINUX_LDS__
  119. /* how to get the thread information struct from ASM */
  120. .macro GET_THREAD_INFO reg
  121. mov sp,\reg
  122. and -THREAD_SIZE,\reg
  123. .endm
  124. #endif
  125. #endif
  126. /*
  127. * thread information flags
  128. * - these are process state flags that various assembly files may need to
  129. * access
  130. * - pending work-to-be-done flags are in LSW
  131. * - other flags in MSW
  132. */
  133. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  134. #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
  135. #define TIF_SIGPENDING 2 /* signal pending */
  136. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  137. #define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */
  138. #define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
  139. #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
  140. #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
  141. #define _TIF_SYSCALL_TRACE +(1 << TIF_SYSCALL_TRACE)
  142. #define _TIF_NOTIFY_RESUME +(1 << TIF_NOTIFY_RESUME)
  143. #define _TIF_SIGPENDING +(1 << TIF_SIGPENDING)
  144. #define _TIF_NEED_RESCHED +(1 << TIF_NEED_RESCHED)
  145. #define _TIF_SINGLESTEP +(1 << TIF_SINGLESTEP)
  146. #define _TIF_RESTORE_SIGMASK +(1 << TIF_RESTORE_SIGMASK)
  147. #define _TIF_POLLING_NRFLAG +(1 << TIF_POLLING_NRFLAG)
  148. #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
  149. #define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */
  150. #endif /* __KERNEL__ */
  151. #endif /* _ASM_THREAD_INFO_H */