Merge branch 'clockevents/fixes' of git://git.linaro.org/people/daniel.lezcano/linux...
[linux-drm-fsl-dcu.git] / arch / mn10300 / include / asm / thread_info.h
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
12 #ifndef _ASM_THREAD_INFO_H
13 #define _ASM_THREAD_INFO_H
14
15 #ifdef __KERNEL__
16
17 #include <asm/page.h>
18
19 #ifdef CONFIG_4KSTACKS
20 #define THREAD_SIZE             (4096)
21 #define THREAD_SIZE_ORDER       (0)
22 #else
23 #define THREAD_SIZE             (8192)
24 #define THREAD_SIZE_ORDER       (1)
25 #endif
26
27 #define STACK_WARN              (THREAD_SIZE / 8)
28
29 /*
30  * low level task data that entry.S needs immediate access to
31  * - this struct should fit entirely inside of one cache line
32  * - this struct shares the supervisor stack pages
33  * - if the contents of this structure are changed, the assembly constants
34  *   must also be changed
35  */
36 #ifndef __ASSEMBLY__
37 typedef struct {
38         unsigned long   seg;
39 } mm_segment_t;
40
41 struct thread_info {
42         struct task_struct      *task;          /* main task structure */
43         struct exec_domain      *exec_domain;   /* execution domain */
44         struct pt_regs          *frame;         /* current exception frame */
45         unsigned long           flags;          /* low level flags */
46         __u32                   cpu;            /* current CPU */
47         __s32                   preempt_count;  /* 0 => preemptable, <0 => BUG */
48
49         mm_segment_t            addr_limit;     /* thread address space:
50                                                    0-0xBFFFFFFF for user-thead
51                                                    0-0xFFFFFFFF for kernel-thread
52                                                 */
53         struct restart_block    restart_block;
54
55         __u8                    supervisor_stack[0];
56 };
57
58 #define thread_info_to_uregs(ti)                                        \
59         ((struct pt_regs *)                                             \
60          ((unsigned long)ti + THREAD_SIZE - sizeof(struct pt_regs)))
61
62 #else /* !__ASSEMBLY__ */
63
64 #ifndef __ASM_OFFSETS_H__
65 #include <asm/asm-offsets.h>
66 #endif
67
68 #endif
69
70 /*
71  * macros/functions for gaining access to the thread information structure
72  */
73 #ifndef __ASSEMBLY__
74
75 #define INIT_THREAD_INFO(tsk)                   \
76 {                                               \
77         .task           = &tsk,                 \
78         .exec_domain    = &default_exec_domain, \
79         .flags          = 0,                    \
80         .cpu            = 0,                    \
81         .preempt_count  = INIT_PREEMPT_COUNT,   \
82         .addr_limit     = KERNEL_DS,            \
83         .restart_block = {                      \
84                 .fn = do_no_restart_syscall,    \
85         },                                      \
86 }
87
88 #define init_thread_info        (init_thread_union.thread_info)
89 #define init_stack              (init_thread_union.stack)
90 #define init_uregs                                                      \
91         ((struct pt_regs *)                                             \
92          ((unsigned long) init_stack + THREAD_SIZE - sizeof(struct pt_regs)))
93
94 extern struct thread_info *__current_ti;
95
96 /* how to get the thread information struct from C */
97 static inline __attribute__((const))
98 struct thread_info *current_thread_info(void)
99 {
100         struct thread_info *ti;
101         asm("mov sp,%0\n"
102             "and %1,%0\n"
103             : "=d" (ti)
104             : "i" (~(THREAD_SIZE - 1))
105             : "cc");
106         return ti;
107 }
108
109 static inline __attribute__((const))
110 struct pt_regs *current_frame(void)
111 {
112         return current_thread_info()->frame;
113 }
114
115 /* how to get the current stack pointer from C */
116 static inline unsigned long current_stack_pointer(void)
117 {
118         unsigned long sp;
119         asm("mov sp,%0; ":"=r" (sp));
120         return sp;
121 }
122
123 #ifndef CONFIG_KGDB
124 void arch_release_thread_info(struct thread_info *ti);
125 #endif
126 #define get_thread_info(ti)     get_task_struct((ti)->task)
127 #define put_thread_info(ti)     put_task_struct((ti)->task)
128
129 #else /* !__ASSEMBLY__ */
130
131 #ifndef __VMLINUX_LDS__
132 /* how to get the thread information struct from ASM */
133 .macro GET_THREAD_INFO reg
134         mov     sp,\reg
135         and     -THREAD_SIZE,\reg
136 .endm
137 #endif
138 #endif
139
140 /*
141  * thread information flags
142  * - these are process state flags that various assembly files may need to
143  *   access
144  * - pending work-to-be-done flags are in LSW
145  * - other flags in MSW
146  */
147 #define TIF_SYSCALL_TRACE       0       /* syscall trace active */
148 #define TIF_NOTIFY_RESUME       1       /* resumption notification requested */
149 #define TIF_SIGPENDING          2       /* signal pending */
150 #define TIF_NEED_RESCHED        3       /* rescheduling necessary */
151 #define TIF_SINGLESTEP          4       /* restore singlestep on return to user mode */
152 #define TIF_RESTORE_SIGMASK     5       /* restore signal mask in do_signal() */
153 #define TIF_POLLING_NRFLAG      16      /* true if poll_idle() is polling TIF_NEED_RESCHED */
154 #define TIF_MEMDIE              17      /* is terminating due to OOM killer */
155
156 #define _TIF_SYSCALL_TRACE      +(1 << TIF_SYSCALL_TRACE)
157 #define _TIF_NOTIFY_RESUME      +(1 << TIF_NOTIFY_RESUME)
158 #define _TIF_SIGPENDING         +(1 << TIF_SIGPENDING)
159 #define _TIF_NEED_RESCHED       +(1 << TIF_NEED_RESCHED)
160 #define _TIF_SINGLESTEP         +(1 << TIF_SINGLESTEP)
161 #define _TIF_POLLING_NRFLAG     +(1 << TIF_POLLING_NRFLAG)
162
163 #define _TIF_WORK_MASK          0x0000FFFE      /* work to do on interrupt/exception return */
164 #define _TIF_ALLWORK_MASK       0x0000FFFF      /* work to do on any return to u-space */
165
166 #endif /* __KERNEL__ */
167
168 #endif /* _ASM_THREAD_INFO_H */