blob: d56afa99a5149c5a2504d3e7c472a940b9ab4930 [file] [log] [blame]
Haavard Skinnemoen5f97f7f2006-09-25 23:32:13 -07001/*
2 * Copyright (C) 2004-2006 Atmel Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8#ifndef __ASM_AVR32_THREAD_INFO_H
9#define __ASM_AVR32_THREAD_INFO_H
10
11#include <asm/page.h>
12
13#define THREAD_SIZE_ORDER 1
14#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
15
16#ifndef __ASSEMBLY__
17#include <asm/types.h>
18
19struct task_struct;
20struct exec_domain;
21
22struct thread_info {
23 struct task_struct *task; /* main task structure */
24 struct exec_domain *exec_domain; /* execution domain */
25 unsigned long flags; /* low level flags */
26 __u32 cpu;
27 __s32 preempt_count; /* 0 => preemptable, <0 => BUG */
Haavard Skinnemoen2507bc12007-11-28 15:04:01 +010028 __u32 rar_saved; /* return address... */
29 __u32 rsr_saved; /* ...and status register
30 saved by debug handler
31 when setting up
32 trampoline */
Haavard Skinnemoen5f97f7f2006-09-25 23:32:13 -070033 __u8 supervisor_stack[0];
34};
35
36#define INIT_THREAD_INFO(tsk) \
37{ \
38 .task = &tsk, \
39 .exec_domain = &default_exec_domain, \
40 .flags = 0, \
41 .cpu = 0, \
Peter Zijlstrac99e6ef2009-07-10 14:57:56 +020042 .preempt_count = INIT_PREEMPT_COUNT, \
Haavard Skinnemoen5f97f7f2006-09-25 23:32:13 -070043}
44
45#define init_thread_info (init_thread_union.thread_info)
46#define init_stack (init_thread_union.stack)
47
48/*
49 * Get the thread information struct from C.
50 * We do the usual trick and use the lower end of the stack for this
51 */
52static inline struct thread_info *current_thread_info(void)
53{
54 unsigned long addr = ~(THREAD_SIZE - 1);
55
56 asm("and %0, sp" : "=r"(addr) : "0"(addr));
57 return (struct thread_info *)addr;
58}
59
Haavard Skinnemoen5f97f7f2006-09-25 23:32:13 -070060#define get_thread_info(ti) get_task_struct((ti)->task)
61#define put_thread_info(ti) put_task_struct((ti)->task)
62
63#endif /* !__ASSEMBLY__ */
64
Haavard Skinnemoen5f97f7f2006-09-25 23:32:13 -070065/*
66 * Thread information flags
67 * - these are process state flags that various assembly files may need to access
68 * - pending work-to-be-done flags are in LSW
69 * - other flags in MSW
70 */
71#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
Stephane Eraniana583f1b2007-07-31 00:38:00 -070072#define TIF_SIGPENDING 1 /* signal pending */
73#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
Haavard Skinnemoen2507bc12007-11-28 15:04:01 +010074#define TIF_BREAKPOINT 4 /* enter monitor mode on return */
75#define TIF_SINGLE_STEP 5 /* single step in progress */
Andreas Dilger0ddc9322010-05-14 11:13:27 +020076#define TIF_MEMDIE 6 /* is terminating due to OOM killer */
Stephane Eraniana583f1b2007-07-31 00:38:00 -070077#define TIF_RESTORE_SIGMASK 7 /* restore signal mask in do_signal */
78#define TIF_CPU_GOING_TO_SLEEP 8 /* CPU is entering sleep 0 mode */
David Howellsd0420c82009-09-02 09:14:16 +010079#define TIF_NOTIFY_RESUME 9 /* callback before returning to user */
Haavard Skinnemoen13b54a52007-11-27 13:50:45 +010080#define TIF_DEBUG 30 /* debugging enabled */
Haavard Skinnemoen5f97f7f2006-09-25 23:32:13 -070081#define TIF_USERSPACE 31 /* true if FS sets userspace */
82
83#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
Haavard Skinnemoen5f97f7f2006-09-25 23:32:13 -070084#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
85#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
Al Viro971ceb12012-05-31 22:24:57 -040086#define _TIF_BREAKPOINT (1 << TIF_BREAKPOINT)
Haavard Skinnemoen5f97f7f2006-09-25 23:32:13 -070087#define _TIF_SINGLE_STEP (1 << TIF_SINGLE_STEP)
88#define _TIF_MEMDIE (1 << TIF_MEMDIE)
Hans-Christian Egtvedt19b7ce82007-02-26 13:50:43 +010089#define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
David Howellsd0420c82009-09-02 09:14:16 +010090#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
Haavard Skinnemoen5f97f7f2006-09-25 23:32:13 -070091
Haavard Skinnemoen702f22b2007-11-27 14:10:58 +010092/* Note: The masks below must never span more than 16 bits! */
93
Haavard Skinnemoen5f97f7f2006-09-25 23:32:13 -070094/* work to do on interrupt/exception return */
Haavard Skinnemoen702f22b2007-11-27 14:10:58 +010095#define _TIF_WORK_MASK \
Al Viro971ceb12012-05-31 22:24:57 -040096 (_TIF_SIGPENDING \
David Howellsd0420c82009-09-02 09:14:16 +010097 | _TIF_NOTIFY_RESUME \
Al Viro971ceb12012-05-31 22:24:57 -040098 | _TIF_NEED_RESCHED \
99 | _TIF_BREAKPOINT)
Haavard Skinnemoen702f22b2007-11-27 14:10:58 +0100100
Haavard Skinnemoen5f97f7f2006-09-25 23:32:13 -0700101/* work to do on any return to userspace */
Al Viro971ceb12012-05-31 22:24:57 -0400102#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_SYSCALL_TRACE)
Haavard Skinnemoen5f97f7f2006-09-25 23:32:13 -0700103/* work to do on return from debug mode */
Al Viro971ceb12012-05-31 22:24:57 -0400104#define _TIF_DBGWORK_MASK (_TIF_WORK_MASK & ~_TIF_BREAKPOINT)
Haavard Skinnemoen5f97f7f2006-09-25 23:32:13 -0700105
106#endif /* __ASM_AVR32_THREAD_INFO_H */