blob: 544c30785ad4b81ced562cc7624430c22d99403b [file] [log] [blame]
Yoshinori Satod2a5f492015-05-11 02:20:06 +09001/* thread_info.h: h8300 low-level thread information
2 * adapted from the i386 and PPC versions by Yoshinori Sato <ysato@users.sourceforge.jp>
3 *
4 * Copyright (C) 2002 David Howells (dhowells@redhat.com)
5 * - Incorporating suggestions made by Linus Torvalds and Dave Miller
6 */
7
8#ifndef _ASM_THREAD_INFO_H
9#define _ASM_THREAD_INFO_H
10
11#include <asm/page.h>
12#include <asm/segment.h>
13
14#ifdef __KERNEL__
15
16#ifndef __ASSEMBLY__
17
18/*
19 * low level task data.
20 * If you change this, change the TI_* offsets below to match.
21 */
22struct thread_info {
23 struct task_struct *task; /* main task structure */
24 unsigned long flags; /* low level flags */
25 int cpu; /* cpu we're on */
26 int preempt_count; /* 0 => preemptable, <0 => BUG */
27 mm_segment_t addr_limit;
28 struct restart_block restart_block;
29};
30
31/*
32 * macros/functions for gaining access to the thread information structure
33 */
34#define INIT_THREAD_INFO(tsk) \
35{ \
36 .task = &tsk, \
37 .flags = 0, \
38 .cpu = 0, \
39 .preempt_count = INIT_PREEMPT_COUNT, \
40 .addr_limit = KERNEL_DS, \
41 .restart_block = { \
42 .fn = do_no_restart_syscall, \
43 }, \
44}
45
46#define init_thread_info (init_thread_union.thread_info)
47#define init_stack (init_thread_union.stack)
48
49
50/*
51 * Size of kernel stack for each process. This must be a power of 2...
52 */
53#define THREAD_SIZE_ORDER 1
54#define THREAD_SIZE 8192 /* 2 pages */
55
56
57/* how to get the thread information struct from C */
58static inline struct thread_info *current_thread_info(void)
59{
60 struct thread_info *ti;
61
62 __asm__("mov.l sp, %0\n\t"
63 "and.w %1, %T0"
64 : "=&r"(ti)
65 : "i" (~(THREAD_SIZE-1) & 0xffff));
66 return ti;
67}
68
69#endif /* __ASSEMBLY__ */
70
71/*
72 * thread information flag bit numbers
73 */
74#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
75#define TIF_SIGPENDING 1 /* signal pending */
76#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
77#define TIF_SINGLESTEP 3 /* singlestepping active */
78#define TIF_MEMDIE 4 /* is terminating due to OOM killer */
79#define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
80#define TIF_NOTIFY_RESUME 6 /* callback before returning to user */
81#define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
82#define TIF_SYSCALL_TRACEPOINT 8 /* for ftrace syscall instrumentation */
83#define TIF_POLLING_NRFLAG 9 /* true if poll_idle() is polling TIF_NEED_RESCHED */
84
85/* as above, but as bit values */
86#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
87#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
88#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
89#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
90#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
91#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
92#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
93#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
94
95/* work to do in syscall trace */
96#define _TIF_WORK_SYSCALL_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
97 _TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT)
98
99/* work to do on any return to u-space */
100#define _TIF_ALLWORK_MASK (_TIF_SYSCALL_TRACE | _TIF_SIGPENDING | \
101 _TIF_NEED_RESCHED | _TIF_SYSCALL_AUDIT | \
102 _TIF_SINGLESTEP | _TIF_NOTIFY_RESUME | \
103 _TIF_SYSCALL_TRACEPOINT)
104
105/* work to do on interrupt/exception return */
106#define _TIF_WORK_MASK (_TIF_ALLWORK_MASK & ~(_TIF_SYSCALL_TRACE | \
107 _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP))
108
109#endif /* __KERNEL__ */
110
111#endif /* _ASM_THREAD_INFO_H */