blob: 0494df6fca749b1fa41c0bfd14bb9e6bf3bd26eb [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* thread_info.h: PPC low-level thread information
2 * adapted from the i386 version by Paul Mackerras
3 *
4 * Copyright (C) 2002 David Howells (dhowells@redhat.com)
5 * - Incorporating suggestions made by Linus Torvalds and Dave Miller
6 */
7
8#ifndef _ASM_THREAD_INFO_H
9#define _ASM_THREAD_INFO_H
10
11#ifdef __KERNEL__
12
13#ifndef __ASSEMBLY__
14#include <linux/config.h>
15#include <linux/cache.h>
16#include <asm/processor.h>
17#include <asm/page.h>
18#include <linux/stringify.h>
19
20/*
21 * low level task data.
22 */
23struct thread_info {
24 struct task_struct *task; /* main task structure */
25 struct exec_domain *exec_domain; /* execution domain */
26 int cpu; /* cpu we're on */
Jesper Juhldcd497f2005-06-23 00:09:07 -070027 int preempt_count; /* 0 => preemptable, <0 => BUG */
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 struct restart_block restart_block;
29 /* set by force_successful_syscall_return */
30 unsigned char syscall_noerror;
31 /* low level flags - has atomic operations done on it */
32 unsigned long flags ____cacheline_aligned_in_smp;
33};
34
35/*
36 * macros/functions for gaining access to the thread information structure
37 *
38 * preempt_count needs to be 1 initially, until the scheduler is functional.
39 */
40#define INIT_THREAD_INFO(tsk) \
41{ \
42 .task = &tsk, \
43 .exec_domain = &default_exec_domain, \
44 .cpu = 0, \
45 .preempt_count = 1, \
46 .restart_block = { \
47 .fn = do_no_restart_syscall, \
48 }, \
49 .flags = 0, \
50}
51
52#define init_thread_info (init_thread_union.thread_info)
53#define init_stack (init_thread_union.stack)
54
55/* thread information allocation */
56
57#define THREAD_ORDER 2
58#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER)
59#define THREAD_SHIFT (PAGE_SHIFT + THREAD_ORDER)
60#ifdef CONFIG_DEBUG_STACK_USAGE
61#define alloc_thread_info(tsk) \
62 ({ \
63 struct thread_info *ret; \
64 \
65 ret = kmalloc(THREAD_SIZE, GFP_KERNEL); \
66 if (ret) \
67 memset(ret, 0, THREAD_SIZE); \
68 ret; \
69 })
70#else
71#define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
72#endif
73#define free_thread_info(ti) kfree(ti)
74#define get_thread_info(ti) get_task_struct((ti)->task)
75#define put_thread_info(ti) put_task_struct((ti)->task)
76
77/* how to get the thread information struct from C */
78static inline struct thread_info *current_thread_info(void)
79{
80 struct thread_info *ti;
81 __asm__("clrrdi %0,1,%1" : "=r"(ti) : "i" (THREAD_SHIFT));
82 return ti;
83}
84
85#endif /* __ASSEMBLY__ */
86
87#define PREEMPT_ACTIVE 0x10000000
88
89/*
90 * thread information flag bit numbers
91 */
92#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
93#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
94#define TIF_SIGPENDING 2 /* signal pending */
95#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
96#define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling
97 TIF_NEED_RESCHED */
98#define TIF_32BIT 5 /* 32 bit binary */
Anton Blanchard6dc2f0c2005-06-02 14:02:02 -070099/* #define SPARE 6 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100#define TIF_ABI_PENDING 7 /* 32/64 bit switch needed */
101#define TIF_SYSCALL_AUDIT 8 /* syscall auditing active */
102#define TIF_SINGLESTEP 9 /* singlestepping active */
103#define TIF_MEMDIE 10
104#define TIF_SECCOMP 11 /* secure computing */
105
106/* as above, but as bit values */
107#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
108#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
109#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
110#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
111#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
112#define _TIF_32BIT (1<<TIF_32BIT)
Anton Blanchard6dc2f0c2005-06-02 14:02:02 -0700113/* #define _SPARE (1<<SPARE) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
115#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
116#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
117#define _TIF_SECCOMP (1<<TIF_SECCOMP)
118#define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP)
119
120#define _TIF_USER_WORK_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | \
121 _TIF_NEED_RESCHED)
122
123#endif /* __KERNEL__ */
124
125#endif /* _ASM_THREAD_INFO_H */