Merge tag 'trace-seq-buf-3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/roste...
[cascardo/linux.git] / arch / nios2 / include / asm / thread_info.h
1 /*
2  * NiosII low-level thread information
3  *
4  * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
5  * Copyright (C) 2004 Microtronix Datacom Ltd.
6  *
7  * Based on asm/thread_info_no.h from m68k which is:
8  *
9  * Copyright (C) 2002 David Howells <dhowells@redhat.com>
10  *
11  * This file is subject to the terms and conditions of the GNU General Public
12  * License.  See the file "COPYING" in the main directory of this archive
13  * for more details.
14  */
15
16 #ifndef _ASM_NIOS2_THREAD_INFO_H
17 #define _ASM_NIOS2_THREAD_INFO_H
18
19 #ifdef __KERNEL__
20
21 /*
22  * Size of the kernel stack for each process.
23  */
24 #define THREAD_SIZE_ORDER       1
25 #define THREAD_SIZE             8192 /* 2 * PAGE_SIZE */
26
27 #ifndef __ASSEMBLY__
28
29 typedef struct {
30         unsigned long seg;
31 } mm_segment_t;
32
33 /*
34  * low level task data that entry.S needs immediate access to
35  * - this struct should fit entirely inside of one cache line
36  * - this struct shares the supervisor stack pages
37  * - if the contents of this structure are changed, the assembly constants
38  *   must also be changed
39  */
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         int                     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         struct restart_block    restart_block;
51         struct pt_regs          *regs;
52 };
53
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 #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
72 #define init_thread_info        (init_thread_union.thread_info)
73 #define init_stack              (init_thread_union.stack)
74
75 /* how to get the thread information struct from C */
76 static inline struct thread_info *current_thread_info(void)
77 {
78         register unsigned long sp asm("sp");
79
80         return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
81 }
82 #endif /* !__ASSEMBLY__ */
83
84 /*
85  * thread information flags
86  * - these are process state flags that various assembly files may need to
87  *   access
88  * - pending work-to-be-done flags are in LSW
89  * - other flags in MSW
90  */
91 #define TIF_SYSCALL_TRACE       0       /* syscall trace active */
92 #define TIF_NOTIFY_RESUME       1       /* resumption notification requested */
93 #define TIF_SIGPENDING          2       /* signal pending */
94 #define TIF_NEED_RESCHED        3       /* rescheduling necessary */
95 #define TIF_MEMDIE              4       /* is terminating due to OOM killer */
96 #define TIF_SECCOMP             5       /* secure computing */
97 #define TIF_SYSCALL_AUDIT       6       /* syscall auditing active */
98 #define TIF_RESTORE_SIGMASK     9       /* restore signal mask in do_signal() */
99
100 #define TIF_POLLING_NRFLAG      16      /* true if poll_idle() is polling
101                                            TIF_NEED_RESCHED */
102
103 #define _TIF_SYSCALL_TRACE      (1 << TIF_SYSCALL_TRACE)
104 #define _TIF_NOTIFY_RESUME      (1 << TIF_NOTIFY_RESUME)
105 #define _TIF_SIGPENDING         (1 << TIF_SIGPENDING)
106 #define _TIF_NEED_RESCHED       (1 << TIF_NEED_RESCHED)
107 #define _TIF_SECCOMP            (1 << TIF_SECCOMP)
108 #define _TIF_SYSCALL_AUDIT      (1 << TIF_SYSCALL_AUDIT)
109 #define _TIF_RESTORE_SIGMASK    (1 << TIF_RESTORE_SIGMASK)
110 #define _TIF_POLLING_NRFLAG     (1 << TIF_POLLING_NRFLAG)
111
112 /* work to do on interrupt/exception return */
113 #define _TIF_WORK_MASK          0x0000FFFE
114
115 /* work to do on any return to u-space */
116 # define _TIF_ALLWORK_MASK      0x0000FFFF
117
118 #endif /* __KERNEL__ */
119
120 #endif /* _ASM_NIOS2_THREAD_INFO_H */