MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / include / asm-nios2nommu / thread_info.h
blob6d51e0cbc21f080610c132e117a4a75caff1680c
1 /* thread_info.h: niosnommu low-level thread information
2 * adapted from the m68knommu
4 * Copyright (C) 2004 Microtronix Datacom Ltd.
5 * Copyright (C) 2002 Microtronix Datacom
7 * - Incorporating suggestions made by Linus Torvalds and Dave Miller
9 * All rights reserved.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
19 * NON INFRINGEMENT. See the GNU General Public License for more
20 * details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #ifndef _ASM_THREAD_INFO_H
29 #define _ASM_THREAD_INFO_H
31 #include <asm/page.h>
33 #ifdef __KERNEL__
35 #ifndef __ASSEMBLY__
38 * low level task data.
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 int cpu; /* cpu we're on */
45 int preempt_count; /* 0 => preemptable, <0 => BUG*/
46 struct restart_block restart_block;
50 * macros/functions for gaining access to the thread information structure
52 #define INIT_THREAD_INFO(tsk) \
53 { \
54 .task = &tsk, \
55 .exec_domain = &default_exec_domain, \
56 .flags = 0, \
57 .cpu = 0, \
58 .preempt_count = 1, \
59 .restart_block = { \
60 .fn = do_no_restart_syscall, \
61 }, \
64 #define init_thread_info (init_thread_union.thread_info)
65 #define init_stack (init_thread_union.stack)
68 /* how to get the thread information struct from C
69 usable only in supervisor mode */
70 static inline struct thread_info *current_thread_info(void)
72 struct thread_info *ti;
73 __asm__ __volatile__(
74 "mov %0, sp\n"
75 "and %0, %0, %1\n"
76 : "=&r"(ti)
77 : "r" (~(THREAD_SIZE-1))
79 return ti;
82 /* thread information allocation */
83 #define alloc_thread_info(tsk) ((struct thread_info *) \
84 __get_free_pages(GFP_KERNEL, 1))
85 #define free_thread_info(ti) free_pages((unsigned long) (ti), 1)
86 #define put_thread_info(ti) put_task_struct((ti)->task)
88 #define PREEMPT_ACTIVE 0x4000000
91 * thread information flag bit numbers
93 #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
94 #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
95 #define TIF_SIGPENDING 2 /* signal pending */
96 #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
97 #define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling
98 TIF_NEED_RESCHED */
99 #define TIF_MEMDIE 5
101 /* as above, but as bit values */
102 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
103 #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
104 #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
105 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
106 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
108 #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
110 #else /* __ASSEMBLY__ */
112 /* how to get the thread information struct from ASM
113 usable only in supervisor mode */
114 .macro GET_THREAD_INFO reg
115 .if THREAD_SIZE & 0xffff0000
116 andhi \reg, sp, %hi(~(THREAD_SIZE-1))
117 .else
118 addi \reg, r0, %lo(~(THREAD_SIZE-1))
119 and \reg, \reg, sp
120 .endif
121 .endm
123 #endif /* __ASSEMBLY__ */
125 #endif /* __KERNEL__ */
127 #endif /* _ASM_THREAD_INFO_H */