blob: 0f950845fad9df8f960d7640150a83cda22ffa38 [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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 unsigned long flags; /* low level flags */
35 unsigned long status; /* thread-synchronous flags */
36 __u32 cpu; /* current CPU */
Jesper Juhldcd497f2005-06-23 00:09:07 -070037 int preempt_count; /* 0 => preemptable, <0 => BUG */
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39 mm_segment_t addr_limit; /* thread address space:
David Howells18793462009-04-10 01:48:01 +010040 * 0-0xBFFFFFFF for user-thead
41 * 0-0xFFFFFFFF for kernel-thread
42 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
44 __u8 supervisor_stack[0];
45};
46
47#else /* !__ASSEMBLY__ */
48
David Howells84e8cd62006-07-10 04:44:55 -070049#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51#endif
52
Linus Torvalds1da177e2005-04-16 15:20:36 -070053/*
54 * macros/functions for gaining access to the thread information structure
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 */
56#ifndef __ASSEMBLY__
57
58#define INIT_THREAD_INFO(tsk) \
59{ \
60 .task = &tsk, \
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 .flags = 0, \
62 .cpu = 0, \
Peter Zijlstrac99e6ef2009-07-10 14:57:56 +020063 .preempt_count = INIT_PREEMPT_COUNT, \
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 .addr_limit = KERNEL_DS, \
Linus Torvalds1da177e2005-04-16 15:20:36 -070065}
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067/* how to get the thread information struct from C */
68register struct thread_info *__current_thread_info asm("gr15");
69
70#define current_thread_info() ({ __current_thread_info; })
71
David Howells84e8cd62006-07-10 04:44:55 -070072#endif /* __ASSEMBLY__ */
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74/*
75 * thread information flags
76 * - these are process state flags that various assembly files may need to access
77 * - pending work-to-be-done flags are in LSW
78 * - other flags in MSW
79 */
80#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
David Howellsb7bab882009-06-11 13:05:14 +010081#define TIF_NOTIFY_RESUME 1 /* callback before returning to user */
82#define TIF_SIGPENDING 2 /* signal pending */
83#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
84#define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */
Stephane Eraniana583f1b2007-07-31 00:38:00 -070085#define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
David Howells1e5ef912012-05-01 21:31:33 +010086#define TIF_MEMDIE 7 /* is terminating due to OOM killer */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
88#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
David Howellsb7bab882009-06-11 13:05:14 +010089#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
Linus Torvalds1da177e2005-04-16 15:20:36 -070090#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
91#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
92#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
Linus Torvalds1da177e2005-04-16 15:20:36 -070093
David Howells1e5ef912012-05-01 21:31:33 +010094/* work to do on interrupt/exception return */
95#define _TIF_WORK_MASK \
96 (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_SINGLESTEP)
97
98/* work to do on any return to u-space */
99#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_SYSCALL_TRACE)
100
101#if _TIF_ALLWORK_MASK >= 0x2000
102#error "_TIF_ALLWORK_MASK won't fit in an ANDI now (see entry.S)"
103#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
105/*
106 * Thread-synchronous status.
107 *
108 * This is different from the flags in that nobody else
109 * ever touches our thread-synchronous status, so we don't
110 * have to worry about atomic accesses.
111 */
112#define TS_USEDFPM 0x0001 /* FPU/Media was used by this task this quantum (SMP) */
113
114#endif /* __KERNEL__ */
115
116#endif /* _ASM_THREAD_INFO_H */