blob: 9b367ebe515d9675eb7c5f62cb7c0f4a38f81fdb [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/include/asm-arm26/thread_info.h
3 *
4 * Copyright (C) 2002 Russell King.
5 * Copyright (C) 2003 Ian Molton.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef __ASM_ARM_THREAD_INFO_H
12#define __ASM_ARM_THREAD_INFO_H
13
14#ifdef __KERNEL__
15
16#ifndef __ASSEMBLY__
17
18struct task_struct;
19struct exec_domain;
20
21#include <linux/compiler.h>
22#include <asm/fpstate.h>
23#include <asm/ptrace.h>
24#include <asm/types.h>
25
26typedef unsigned long mm_segment_t;
27
28struct cpu_context_save {
29 __u32 r4;
30 __u32 r5;
31 __u32 r6;
32 __u32 r7;
33 __u32 r8;
34 __u32 r9;
35 __u32 sl;
36 __u32 fp;
37 __u32 sp;
38 __u32 pc;
39};
40
41/*
42 * low level task data that entry.S needs immediate access to.
43 * We assume cpu_context follows immedately after cpu_domain.
44 */
45struct thread_info {
46 unsigned long flags; /* low level flags */
Jesper Juhldcd497f2005-06-23 00:09:07 -070047 int preempt_count; /* 0 => preemptable, <0 => bug */
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 mm_segment_t addr_limit; /* address limit */
49 struct task_struct *task; /* main task structure */
50 struct exec_domain *exec_domain; /* execution domain */
51 __u32 cpu; /* cpu */
52 struct cpu_context_save cpu_context; /* cpu context */
53 struct restart_block restart_block;
54 union fp_state fpstate;
55};
56
57#define INIT_THREAD_INFO(tsk) \
58{ \
59 .task &tsk, \
60 .exec_domain &default_exec_domain, \
61 .flags 0, \
62 .preempt_count 0, \
63 .addr_limit KERNEL_DS, \
64 .restart_block = { \
65 .fn = do_no_restart_syscall, \
66 }, \
67}
68
69#define init_thread_info (init_thread_union.thread_info)
70#define init_stack (init_thread_union.stack)
71
72/*
73 * how to get the thread information struct from C
74 */
75static inline struct thread_info *current_thread_info(void) __attribute_const__;
76
77static inline struct thread_info *current_thread_info(void)
78{
79 register unsigned long sp asm ("sp");
80 return (struct thread_info *)(sp & ~0x1fff);
81}
82
Adrian Bunk96419b72006-01-16 22:13:55 -080083#define THREAD_SIZE PAGE_SIZE
Al Viro7fdf0d72006-01-12 01:06:00 -080084#define task_pt_regs(task) ((struct pt_regs *)(task_stack_page(task) + THREAD_SIZE - 8) - 1)
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
86extern struct thread_info *alloc_thread_info(struct task_struct *task);
87extern void free_thread_info(struct thread_info *);
88
Linus Torvalds1da177e2005-04-16 15:20:36 -070089#define thread_saved_pc(tsk) \
Al Viro697102c2006-01-12 01:05:59 -080090 ((unsigned long)(pc_pointer(task_thread_info(tsk)->cpu_context.pc)))
Linus Torvalds1da177e2005-04-16 15:20:36 -070091#define thread_saved_fp(tsk) \
Al Viro697102c2006-01-12 01:05:59 -080092 ((unsigned long)(task_thread_info(tsk)->cpu_context.fp))
Linus Torvalds1da177e2005-04-16 15:20:36 -070093
94#else /* !__ASSEMBLY__ */
95
96#define TI_FLAGS 0
97#define TI_PREEMPT 4
98#define TI_ADDR_LIMIT 8
99#define TI_TASK 12
100#define TI_EXEC_DOMAIN 16
101#define TI_CPU 20
102#define TI_CPU_SAVE 24
103#define TI_RESTART_BLOCK 28
104#define TI_FPSTATE 68
105
106#endif
107
108#define PREEMPT_ACTIVE 0x04000000
109
110/*
111 * thread information flags:
112 * TIF_SYSCALL_TRACE - syscall trace active
113 * TIF_NOTIFY_RESUME - resumption notification requested
114 * TIF_SIGPENDING - signal pending
115 * TIF_NEED_RESCHED - rescheduling necessary
116 * TIF_USEDFPU - FPU was used by this task this quantum (SMP)
117 * TIF_POLLING_NRFLAG - true if poll_idle() is polling TIF_NEED_RESCHED
118 */
119#define TIF_NOTIFY_RESUME 0
120#define TIF_SIGPENDING 1
121#define TIF_NEED_RESCHED 2
122#define TIF_SYSCALL_TRACE 8
123#define TIF_USED_FPU 16
124#define TIF_POLLING_NRFLAG 17
125#define TIF_MEMDIE 18
126
127#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
128#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
129#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
130#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
131#define _TIF_USED_FPU (1 << TIF_USED_FPU)
132#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
133
134/*
135 * Change these and you break ASM code in entry-common.S
136 */
137#define _TIF_WORK_MASK 0x000000ff
138
139#endif /* __KERNEL__ */
140#endif /* __ASM_ARM_THREAD_INFO_H */