blob: afb3a86263806ec830efde8d057767355e0f235e [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
Robin Getz96f10502009-09-24 14:11:24 +00002 * Copyright 2004-2009 Analog Devices Inc.
Bryan Wu1394f032007-05-06 14:50:22 -07003 *
Robin Getz96f10502009-09-24 14:11:24 +00004 * Licensed under the GPL-2 or later.
Bryan Wu1394f032007-05-06 14:50:22 -07005 */
6
7#ifndef _ASM_THREAD_INFO_H
8#define _ASM_THREAD_INFO_H
9
10#include <asm/page.h>
11#include <asm/entry.h>
12#include <asm/l1layout.h>
13#include <linux/compiler.h>
14
15#ifdef __KERNEL__
16
17/* Thread Align Mask to reach to the top of the stack
18 * for any process
19 */
20#define ALIGN_PAGE_MASK 0xffffe000
21
Mike Frysinger12a79912007-07-25 10:25:29 +080022/*
23 * Size of kernel stack for each process. This must be a power of 2...
24 */
FUJITA Tomonorib69c49b2008-07-25 01:45:40 -070025#define THREAD_SIZE_ORDER 1
Mike Frysinger12a79912007-07-25 10:25:29 +080026#define THREAD_SIZE 8192 /* 2 pages */
Robin Getza45d5752009-01-07 23:14:38 +080027#define STACK_WARN (THREAD_SIZE/8)
Mike Frysinger12a79912007-07-25 10:25:29 +080028
Bryan Wu1394f032007-05-06 14:50:22 -070029#ifndef __ASSEMBLY__
30
31typedef unsigned long mm_segment_t;
32
33/*
34 * low level task data.
35 * If you change this, change the TI_* offsets below to match.
36 */
37
38struct thread_info {
39 struct task_struct *task; /* main task structure */
40 struct exec_domain *exec_domain; /* execution domain */
41 unsigned long flags; /* low level flags */
42 int cpu; /* cpu we're on */
43 int preempt_count; /* 0 => preemptable, <0 => BUG */
44 mm_segment_t addr_limit; /* address limit */
45 struct restart_block restart_block;
Sonic Zhangcc92b872009-01-07 23:14:38 +080046#ifndef CONFIG_SMP
Bryan Wu1394f032007-05-06 14:50:22 -070047 struct l1_scratch_task_info l1_task_info;
Sonic Zhangcc92b872009-01-07 23:14:38 +080048#endif
Bryan Wu1394f032007-05-06 14:50:22 -070049};
50
51/*
52 * macros/functions for gaining access to the thread information structure
53 */
54#define INIT_THREAD_INFO(tsk) \
55{ \
56 .task = &tsk, \
57 .exec_domain = &default_exec_domain, \
58 .flags = 0, \
59 .cpu = 0, \
Peter Zijlstrac99e6ef2009-07-10 14:57:56 +020060 .preempt_count = INIT_PREEMPT_COUNT, \
Bryan Wu1394f032007-05-06 14:50:22 -070061 .restart_block = { \
62 .fn = do_no_restart_syscall, \
63 }, \
64}
65#define init_thread_info (init_thread_union.thread_info)
66#define init_stack (init_thread_union.stack)
67
Robert P. J. Day18628e42008-04-24 09:02:00 +080068/* Given a task stack pointer, you can find its corresponding
69 * thread_info structure just by masking it to the THREAD_SIZE
70 * boundary (currently 8K as you can see above).
Bryan Wu1394f032007-05-06 14:50:22 -070071 */
Robert P. J. Day18628e42008-04-24 09:02:00 +080072__attribute_const__
Bryan Wu1394f032007-05-06 14:50:22 -070073static inline struct thread_info *current_thread_info(void)
74{
75 struct thread_info *ti;
Robin Getz26fe19f2009-01-07 23:14:39 +080076 __asm__("%0 = sp;" : "=da"(ti) :
Bryan Wu1394f032007-05-06 14:50:22 -070077 );
Mike Frysinger12a79912007-07-25 10:25:29 +080078 return (struct thread_info *)((long)ti & ~((long)THREAD_SIZE-1));
Bryan Wu1394f032007-05-06 14:50:22 -070079}
80
Bryan Wu1394f032007-05-06 14:50:22 -070081#endif /* __ASSEMBLY__ */
82
83/*
84 * Offsets in thread_info structure, used in assembly code
85 */
86#define TI_TASK 0
87#define TI_EXECDOMAIN 4
88#define TI_FLAGS 8
89#define TI_CPU 12
90#define TI_PREEMPT 16
91
92#define PREEMPT_ACTIVE 0x4000000
93
94/*
95 * thread information flag bit numbers
96 */
97#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
Stephane Eraniana583f1b2007-07-31 00:38:00 -070098#define TIF_SIGPENDING 1 /* signal pending */
99#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
100#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
Bryan Wu1394f032007-05-06 14:50:22 -0700101 TIF_NEED_RESCHED */
Stephane Eraniana583f1b2007-07-31 00:38:00 -0700102#define TIF_MEMDIE 4
103#define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
104#define TIF_FREEZE 6 /* is freezing for suspend */
Philippe Gerum9bd50df2009-03-04 16:52:38 +0800105#define TIF_IRQ_SYNC 7 /* sync pipeline stage */
Bryan Wu1394f032007-05-06 14:50:22 -0700106
107/* as above, but as bit values */
108#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
Bryan Wu1394f032007-05-06 14:50:22 -0700109#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_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
113#define _TIF_FREEZE (1<<TIF_FREEZE)
Philippe Gerum9bd50df2009-03-04 16:52:38 +0800114#define _TIF_IRQ_SYNC (1<<TIF_IRQ_SYNC)
Bryan Wu1394f032007-05-06 14:50:22 -0700115
116#define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
117
118#endif /* __KERNEL__ */
119
120#endif /* _ASM_THREAD_INFO_H */