blob: 1a9e6ae0c5fd55e1324aad120a50016e4c1c6fb0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * include/asm-v850/thread_info.h -- v850 low-level thread information
3 *
4 * Copyright (C) 2002 NEC Corporation
5 * Copyright (C) 2002 Miles Bader <miles@gnu.org>
6 * Copyright (C) 2002 David Howells (dhowells@redhat.com)
7 * - Incorporating suggestions made by Linus Torvalds and Dave Miller
8 *
9 * This file is subject to the terms and conditions of the GNU General
10 * Public License. See the file COPYING in the main directory of this
11 * archive for more details.
12 *
13 * This file was derived from the PPC version, include/asm-ppc/thread_info.h
14 * which was adapted from the i386 version by Paul Mackerras
15 */
16
17#ifndef __V850_THREAD_INFO_H__
18#define __V850_THREAD_INFO_H__
19
20#ifdef __KERNEL__
21
22#ifndef __ASSEMBLY__
23
24/*
25 * low level task data.
26 * If you change this, change the TI_* offsets below to match.
27 */
28struct thread_info {
29 struct task_struct *task; /* main task structure */
30 struct exec_domain *exec_domain; /* execution domain */
31 unsigned long flags; /* low level flags */
32 int cpu; /* cpu we're on */
Jesper Juhldcd497f2005-06-23 00:09:07 -070033 int preempt_count; /* 0 => preemptable,
34 <0 => BUG */
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 struct restart_block restart_block;
36};
37
38#define INIT_THREAD_INFO(tsk) \
39{ \
40 .task = &tsk, \
41 .exec_domain = &default_exec_domain, \
42 .flags = 0, \
43 .cpu = 0, \
44 .preempt_count = 1, \
45 .restart_block = { \
46 .fn = do_no_restart_syscall, \
47 }, \
48}
49
50#define init_thread_info (init_thread_union.thread_info)
51#define init_stack (init_thread_union.stack)
52
53/*
54 * macros/functions for gaining access to the thread information structure
55 */
56
57/* thread information allocation */
58#define alloc_thread_info(tsk) ((struct thread_info *) \
59 __get_free_pages(GFP_KERNEL, 1))
60#define free_thread_info(ti) free_pages((unsigned long) (ti), 1)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
62#endif /* __ASSEMBLY__ */
63
64
65/*
66 * Offsets in thread_info structure, used in assembly code
67 */
68#define TI_TASK 0
69#define TI_EXECDOMAIN 4
70#define TI_FLAGS 8
71#define TI_CPU 12
72#define TI_PREEMPT 16
73
74#define PREEMPT_ACTIVE 0x4000000
75
76/*
77 * thread information flag bit numbers
78 */
79#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
Stephane Eraniana583f1b2007-07-31 00:38:00 -070080#define TIF_SIGPENDING 1 /* signal pending */
81#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
82#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 TIF_NEED_RESCHED */
Stephane Eraniana583f1b2007-07-31 00:38:00 -070084#define TIF_MEMDIE 4
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
86/* as above, but as bit values */
87#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
Linus Torvalds1da177e2005-04-16 15:20:36 -070088#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
89#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
90#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
91
92
93/* Size of kernel stack for each process. */
94#define THREAD_SIZE 0x2000
95
96/* The alignment of kernel threads, with thread_info structures at their
97 base. Thus, a pointer for a task's task structure can be derived from
98 its kernel stack pointer. */
99#define THREAD_ALIGNMENT THREAD_SIZE
100#define THREAD_MASK (-THREAD_ALIGNMENT)
101
102
103#ifdef __ASSEMBLY__
104
105/* Put a pointer to the current thread_info structure into REG. Note that
106 this definition requires THREAD_MASK to be representable as a signed
107 16-bit value. */
108#define GET_CURRENT_THREAD(reg) \
109 /* Use `addi' and then `and' instead of just `andi', because \
110 `addi' sign-extends the immediate value, whereas `andi' \
111 zero-extends it. */ \
112 addi THREAD_MASK, r0, reg; \
113 and sp, reg
114
115#else
116
117/* Return a pointer to the current thread_info structure. */
118static inline struct thread_info *current_thread_info (void)
119{
120 register unsigned long sp __asm__ ("sp");
121 return (struct thread_info *)(sp & THREAD_MASK);
122}
123
124#endif /* __ASSEMBLY__ */
125
126
127#endif /* __KERNEL__ */
128
129#endif /* __V850_THREAD_INFO_H__ */