2 * Copyright (C) 2004-2006 Atmel Corporation
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.
8 #ifndef __ASM_AVR32_THREAD_INFO_H
9 #define __ASM_AVR32_THREAD_INFO_H
13 #define THREAD_SIZE_ORDER 1
14 #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
17 #include <asm/types.h>
23 struct task_struct
*task
; /* main task structure */
24 struct exec_domain
*exec_domain
; /* execution domain */
25 unsigned long flags
; /* low level flags */
27 __s32 preempt_count
; /* 0 => preemptable, <0 => BUG */
28 struct restart_block restart_block
;
29 __u8 supervisor_stack
[0];
32 #define INIT_THREAD_INFO(tsk) \
35 .exec_domain = &default_exec_domain, \
40 .fn = do_no_restart_syscall \
44 #define init_thread_info (init_thread_union.thread_info)
45 #define init_stack (init_thread_union.stack)
48 * Get the thread information struct from C.
49 * We do the usual trick and use the lower end of the stack for this
51 static inline struct thread_info
*current_thread_info(void)
53 unsigned long addr
= ~(THREAD_SIZE
- 1);
55 asm("and %0, sp" : "=r"(addr
) : "0"(addr
));
56 return (struct thread_info
*)addr
;
59 /* thread information allocation */
60 #define alloc_thread_info(ti) \
61 ((struct thread_info *) __get_free_pages(GFP_KERNEL, THREAD_SIZE_ORDER))
62 #define free_thread_info(ti) free_pages((unsigned long)(ti), 1)
63 #define get_thread_info(ti) get_task_struct((ti)->task)
64 #define put_thread_info(ti) put_task_struct((ti)->task)
66 #endif /* !__ASSEMBLY__ */
68 #define PREEMPT_ACTIVE 0x40000000
71 * Thread information flags
72 * - these are process state flags that various assembly files may need to access
73 * - pending work-to-be-done flags are in LSW
74 * - other flags in MSW
76 #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
77 #define TIF_SIGPENDING 1 /* signal pending */
78 #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
79 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
81 #define TIF_BREAKPOINT 4 /* true if we should break after return */
82 #define TIF_SINGLE_STEP 5 /* single step after next break */
84 #define TIF_RESTORE_SIGMASK 7 /* restore signal mask in do_signal */
85 #define TIF_CPU_GOING_TO_SLEEP 8 /* CPU is entering sleep 0 mode */
86 #define TIF_USERSPACE 31 /* true if FS sets userspace */
88 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
89 #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
90 #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
91 #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
92 #define _TIF_BREAKPOINT (1 << TIF_BREAKPOINT)
93 #define _TIF_SINGLE_STEP (1 << TIF_SINGLE_STEP)
94 #define _TIF_MEMDIE (1 << TIF_MEMDIE)
95 #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
96 #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
98 /* XXX: These two masks must never span more than 16 bits! */
99 /* work to do on interrupt/exception return */
100 #define _TIF_WORK_MASK 0x0000013e
101 /* work to do on any return to userspace */
102 #define _TIF_ALLWORK_MASK 0x0000013f
103 /* work to do on return from debug mode */
104 #define _TIF_DBGWORK_MASK 0x0000017e
106 #endif /* __ASM_AVR32_THREAD_INFO_H */