]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/metag/include/asm/thread_info.h
afb3ca4776d1df43271cbbe1514ad5e8478186bf
[karo-tx-linux.git] / arch / metag / include / asm / thread_info.h
1 /* thread_info.h: Meta low-level thread information
2  *
3  * Copyright (C) 2002  David Howells (dhowells@redhat.com)
4  * - Incorporating suggestions made by Linus Torvalds and Dave Miller
5  *
6  * Meta port by Imagination Technologies
7  */
8
9 #ifndef _ASM_THREAD_INFO_H
10 #define _ASM_THREAD_INFO_H
11
12 #include <linux/compiler.h>
13 #include <asm/page.h>
14
15 #ifndef __ASSEMBLY__
16 #include <asm/processor.h>
17 #endif
18
19 /*
20  * low level task data that entry.S needs immediate access to
21  * - this struct should fit entirely inside of one cache line
22  * - this struct shares the supervisor stack pages
23  * - if the contents of this structure are changed, the assembly constants must
24  *   also be changed
25  */
26 #ifndef __ASSEMBLY__
27
28 /* This must be 8 byte aligned so we can ensure stack alignment. */
29 struct thread_info {
30         struct task_struct *task;       /* main task structure */
31         struct exec_domain *exec_domain;        /* execution domain */
32         unsigned long flags;    /* low level flags */
33         unsigned long status;   /* thread-synchronous flags */
34         u32 cpu;                /* current CPU */
35         int preempt_count;      /* 0 => preemptable, <0 => BUG */
36
37         mm_segment_t addr_limit;        /* thread address space */
38
39         u8 supervisor_stack[0] __aligned(8);
40 };
41
42 #else /* !__ASSEMBLY__ */
43
44 #include <generated/asm-offsets.h>
45
46 #endif
47
48 #ifdef CONFIG_4KSTACKS
49 #define THREAD_SHIFT            12
50 #else
51 #define THREAD_SHIFT            13
52 #endif
53
54 #if THREAD_SHIFT >= PAGE_SHIFT
55 #define THREAD_SIZE_ORDER       (THREAD_SHIFT - PAGE_SHIFT)
56 #else
57 #define THREAD_SIZE_ORDER       0
58 #endif
59
60 #define THREAD_SIZE             (PAGE_SIZE << THREAD_SIZE_ORDER)
61
62 #define STACK_WARN              (THREAD_SIZE/8)
63 /*
64  * macros/functions for gaining access to the thread information structure
65  */
66 #ifndef __ASSEMBLY__
67
68 #define INIT_THREAD_INFO(tsk)                   \
69 {                                               \
70         .task           = &tsk,                 \
71         .exec_domain    = &default_exec_domain, \
72         .flags          = 0,                    \
73         .cpu            = 0,                    \
74         .preempt_count  = INIT_PREEMPT_COUNT,   \
75         .addr_limit     = KERNEL_DS,            \
76 }
77
78 #define init_thread_info        (init_thread_union.thread_info)
79 #define init_stack              (init_thread_union.stack)
80
81 /* how to get the current stack pointer from C */
82 register unsigned long current_stack_pointer asm("A0StP") __used;
83
84 /* how to get the thread information struct from C */
85 static inline struct thread_info *current_thread_info(void)
86 {
87         return (struct thread_info *)(current_stack_pointer &
88                                       ~(THREAD_SIZE - 1));
89 }
90
91 #define __HAVE_ARCH_KSTACK_END
92 static inline int kstack_end(void *addr)
93 {
94         return addr == (void *) (((unsigned long) addr & ~(THREAD_SIZE - 1))
95                                  + sizeof(struct thread_info));
96 }
97
98 #endif
99
100 /*
101  * thread information flags
102  * - these are process state flags that various assembly files may need to
103  *   access
104  * - pending work-to-be-done flags are in LSW
105  * - other flags in MSW
106  */
107 #define TIF_SYSCALL_TRACE       0       /* syscall trace active */
108 #define TIF_SIGPENDING          1       /* signal pending */
109 #define TIF_NEED_RESCHED        2       /* rescheduling necessary */
110 #define TIF_SINGLESTEP          3       /* restore singlestep on return to user
111                                            mode */
112 #define TIF_SYSCALL_AUDIT       4       /* syscall auditing active */
113 #define TIF_SECCOMP             5       /* secure computing */
114 #define TIF_RESTORE_SIGMASK     6       /* restore signal mask in do_signal() */
115 #define TIF_NOTIFY_RESUME       7       /* callback before returning to user */
116 #define TIF_MEMDIE              8       /* is terminating due to OOM killer */
117 #define TIF_SYSCALL_TRACEPOINT  9       /* syscall tracepoint instrumentation */
118
119
120 #define _TIF_SYSCALL_TRACE      (1<<TIF_SYSCALL_TRACE)
121 #define _TIF_SIGPENDING         (1<<TIF_SIGPENDING)
122 #define _TIF_NEED_RESCHED       (1<<TIF_NEED_RESCHED)
123 #define _TIF_SINGLESTEP         (1<<TIF_SINGLESTEP)
124 #define _TIF_SYSCALL_AUDIT      (1<<TIF_SYSCALL_AUDIT)
125 #define _TIF_SECCOMP            (1<<TIF_SECCOMP)
126 #define _TIF_NOTIFY_RESUME      (1<<TIF_NOTIFY_RESUME)
127 #define _TIF_RESTORE_SIGMASK    (1<<TIF_RESTORE_SIGMASK)
128 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
129
130 /* work to do in syscall trace */
131 #define _TIF_WORK_SYSCALL_MASK  (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
132                                  _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \
133                                  _TIF_SYSCALL_TRACEPOINT)
134
135 /* work to do on any return to u-space */
136 #define _TIF_ALLWORK_MASK       (_TIF_SYSCALL_TRACE | _TIF_SIGPENDING      | \
137                                  _TIF_NEED_RESCHED  | _TIF_SYSCALL_AUDIT   | \
138                                  _TIF_SINGLESTEP    | _TIF_RESTORE_SIGMASK | \
139                                  _TIF_NOTIFY_RESUME)
140
141 /* work to do on interrupt/exception return */
142 #define _TIF_WORK_MASK          (_TIF_ALLWORK_MASK & ~(_TIF_SYSCALL_TRACE | \
143                                  _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP))
144
145 #endif /* _ASM_THREAD_INFO_H */