blob: e608e056bb5301582b44b13d2bba9d9ccabfc23a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* thread_info.h: description
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 * Derived from include/asm-i386/thread_info.h
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#ifndef _ASM_THREAD_INFO_H
14#define _ASM_THREAD_INFO_H
15
16#ifdef __KERNEL__
17
18#ifndef __ASSEMBLY__
19#include <asm/processor.h>
20#endif
21
David Howells84e8cd62006-07-10 04:44:55 -070022#define THREAD_SIZE 8192
23
Linus Torvalds1da177e2005-04-16 15:20:36 -070024/*
25 * low level task data that entry.S needs immediate access to
26 * - this struct should fit entirely inside of one cache line
27 * - this struct shares the supervisor stack pages
28 * - if the contents of this structure are changed, the assembly constants must also be changed
29 */
30#ifndef __ASSEMBLY__
31
32struct thread_info {
33 struct task_struct *task; /* main task structure */
34 struct exec_domain *exec_domain; /* execution domain */
35 unsigned long flags; /* low level flags */
36 unsigned long status; /* thread-synchronous flags */
37 __u32 cpu; /* current CPU */
Jesper Juhldcd497f2005-06-23 00:09:07 -070038 int preempt_count; /* 0 => preemptable, <0 => BUG */
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40 mm_segment_t addr_limit; /* thread address space:
David Howells18793462009-04-10 01:48:01 +010041 * 0-0xBFFFFFFF for user-thead
42 * 0-0xFFFFFFFF for kernel-thread
43 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 struct restart_block restart_block;
45
46 __u8 supervisor_stack[0];
47};
48
49#else /* !__ASSEMBLY__ */
50
David Howells84e8cd62006-07-10 04:44:55 -070051#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
53#endif
54
David Howells8080f232005-11-28 13:43:51 -080055#define PREEMPT_ACTIVE 0x10000000
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
57/*
58 * macros/functions for gaining access to the thread information structure
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 */
60#ifndef __ASSEMBLY__
61
62#define INIT_THREAD_INFO(tsk) \
63{ \
64 .task = &tsk, \
65 .exec_domain = &default_exec_domain, \
66 .flags = 0, \
67 .cpu = 0, \
Peter Zijlstrac99e6ef2009-07-10 14:57:56 +020068 .preempt_count = INIT_PREEMPT_COUNT, \
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 .addr_limit = KERNEL_DS, \
70 .restart_block = { \
71 .fn = do_no_restart_syscall, \
72 }, \
73}
74
75#define init_thread_info (init_thread_union.thread_info)
76#define init_stack (init_thread_union.stack)
77
Linus Torvalds1da177e2005-04-16 15:20:36 -070078/* how to get the thread information struct from C */
79register struct thread_info *__current_thread_info asm("gr15");
80
81#define current_thread_info() ({ __current_thread_info; })
82
FUJITA Tomonorib69c49b2008-07-25 01:45:40 -070083#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
84
Linus Torvalds1da177e2005-04-16 15:20:36 -070085/* thread information allocation */
86#ifdef CONFIG_DEBUG_STACK_USAGE
87#define alloc_thread_info(tsk) \
88 ({ \
89 struct thread_info *ret; \
90 \
Mariusz Kozlowski33bbf952007-10-16 01:26:29 -070091 ret = kzalloc(THREAD_SIZE, GFP_KERNEL); \
92 \
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 ret; \
94 })
95#else
96#define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
97#endif
98
99#define free_thread_info(info) kfree(info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100
David Howells84e8cd62006-07-10 04:44:55 -0700101#endif /* __ASSEMBLY__ */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102
103/*
104 * thread information flags
105 * - these are process state flags that various assembly files may need to access
106 * - pending work-to-be-done flags are in LSW
107 * - other flags in MSW
108 */
109#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
David Howellsb7bab882009-06-11 13:05:14 +0100110#define TIF_NOTIFY_RESUME 1 /* callback before returning to user */
111#define TIF_SIGPENDING 2 /* signal pending */
112#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
113#define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */
Stephane Eraniana583f1b2007-07-31 00:38:00 -0700114#define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
116#define TIF_MEMDIE 17 /* OOM killer killed process */
Rafael J. Wysocki8a102ee2006-12-13 00:34:30 -0800117#define TIF_FREEZE 18 /* freezing for suspend */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
119#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
David Howellsb7bab882009-06-11 13:05:14 +0100120#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
122#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
123#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
David Howellsa411aee2006-01-18 17:43:59 -0800124#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
Rafael J. Wysocki8a102ee2006-12-13 00:34:30 -0800126#define _TIF_FREEZE (1 << TIF_FREEZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
128#define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
129#define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */
130
131/*
132 * Thread-synchronous status.
133 *
134 * This is different from the flags in that nobody else
135 * ever touches our thread-synchronous status, so we don't
136 * have to worry about atomic accesses.
137 */
138#define TS_USEDFPM 0x0001 /* FPU/Media was used by this task this quantum (SMP) */
139
140#endif /* __KERNEL__ */
141
142#endif /* _ASM_THREAD_INFO_H */