Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 19 | struct task_struct; |
| 20 | struct exec_domain; |
| 21 | |
| 22 | struct 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 Skinnemoen | 2507bc1 | 2007-11-28 15:04:01 +0100 | [diff] [blame] | 28 | __u32 rar_saved; /* return address... */ |
| 29 | __u32 rsr_saved; /* ...and status register |
| 30 | saved by debug handler |
| 31 | when setting up |
| 32 | trampoline */ |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 33 | struct restart_block restart_block; |
| 34 | __u8 supervisor_stack[0]; |
| 35 | }; |
| 36 | |
| 37 | #define INIT_THREAD_INFO(tsk) \ |
| 38 | { \ |
| 39 | .task = &tsk, \ |
| 40 | .exec_domain = &default_exec_domain, \ |
| 41 | .flags = 0, \ |
| 42 | .cpu = 0, \ |
| 43 | .preempt_count = 1, \ |
| 44 | .restart_block = { \ |
| 45 | .fn = do_no_restart_syscall \ |
| 46 | } \ |
| 47 | } |
| 48 | |
| 49 | #define init_thread_info (init_thread_union.thread_info) |
| 50 | #define init_stack (init_thread_union.stack) |
| 51 | |
| 52 | /* |
| 53 | * Get the thread information struct from C. |
| 54 | * We do the usual trick and use the lower end of the stack for this |
| 55 | */ |
| 56 | static inline struct thread_info *current_thread_info(void) |
| 57 | { |
| 58 | unsigned long addr = ~(THREAD_SIZE - 1); |
| 59 | |
| 60 | asm("and %0, sp" : "=r"(addr) : "0"(addr)); |
| 61 | return (struct thread_info *)addr; |
| 62 | } |
| 63 | |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 64 | #define get_thread_info(ti) get_task_struct((ti)->task) |
| 65 | #define put_thread_info(ti) put_task_struct((ti)->task) |
| 66 | |
| 67 | #endif /* !__ASSEMBLY__ */ |
| 68 | |
| 69 | #define PREEMPT_ACTIVE 0x40000000 |
| 70 | |
| 71 | /* |
| 72 | * Thread information flags |
| 73 | * - these are process state flags that various assembly files may need to access |
| 74 | * - pending work-to-be-done flags are in LSW |
| 75 | * - other flags in MSW |
| 76 | */ |
| 77 | #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ |
Stephane Eranian | a583f1b | 2007-07-31 00:38:00 -0700 | [diff] [blame] | 78 | #define TIF_SIGPENDING 1 /* signal pending */ |
| 79 | #define TIF_NEED_RESCHED 2 /* rescheduling necessary */ |
| 80 | #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 81 | TIF_NEED_RESCHED */ |
Haavard Skinnemoen | 2507bc1 | 2007-11-28 15:04:01 +0100 | [diff] [blame] | 82 | #define TIF_BREAKPOINT 4 /* enter monitor mode on return */ |
| 83 | #define TIF_SINGLE_STEP 5 /* single step in progress */ |
Stephane Eranian | a583f1b | 2007-07-31 00:38:00 -0700 | [diff] [blame] | 84 | #define TIF_MEMDIE 6 |
| 85 | #define TIF_RESTORE_SIGMASK 7 /* restore signal mask in do_signal */ |
| 86 | #define TIF_CPU_GOING_TO_SLEEP 8 /* CPU is entering sleep 0 mode */ |
Haavard Skinnemoen | 02a00cf | 2008-02-24 13:51:38 +0100 | [diff] [blame] | 87 | #define TIF_FREEZE 29 |
Haavard Skinnemoen | 13b54a5 | 2007-11-27 13:50:45 +0100 | [diff] [blame] | 88 | #define TIF_DEBUG 30 /* debugging enabled */ |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 89 | #define TIF_USERSPACE 31 /* true if FS sets userspace */ |
| 90 | |
| 91 | #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 92 | #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) |
| 93 | #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) |
| 94 | #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 95 | #define _TIF_SINGLE_STEP (1 << TIF_SINGLE_STEP) |
| 96 | #define _TIF_MEMDIE (1 << TIF_MEMDIE) |
| 97 | #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) |
Hans-Christian Egtvedt | 19b7ce8 | 2007-02-26 13:50:43 +0100 | [diff] [blame] | 98 | #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP) |
Matt Helsley | 83224b0 | 2008-10-18 20:27:18 -0700 | [diff] [blame] | 99 | #define _TIF_FREEZE (1 << TIF_FREEZE) |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 100 | |
Haavard Skinnemoen | 702f22b | 2007-11-27 14:10:58 +0100 | [diff] [blame] | 101 | /* Note: The masks below must never span more than 16 bits! */ |
| 102 | |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 103 | /* work to do on interrupt/exception return */ |
Haavard Skinnemoen | 702f22b | 2007-11-27 14:10:58 +0100 | [diff] [blame] | 104 | #define _TIF_WORK_MASK \ |
| 105 | ((1 << TIF_SIGPENDING) \ |
| 106 | | (1 << TIF_NEED_RESCHED) \ |
| 107 | | (1 << TIF_POLLING_NRFLAG) \ |
| 108 | | (1 << TIF_BREAKPOINT) \ |
| 109 | | (1 << TIF_RESTORE_SIGMASK)) |
| 110 | |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 111 | /* work to do on any return to userspace */ |
Haavard Skinnemoen | 702f22b | 2007-11-27 14:10:58 +0100 | [diff] [blame] | 112 | #define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | (1 << TIF_SYSCALL_TRACE)) |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 113 | /* work to do on return from debug mode */ |
Haavard Skinnemoen | 2507bc1 | 2007-11-28 15:04:01 +0100 | [diff] [blame] | 114 | #define _TIF_DBGWORK_MASK (_TIF_WORK_MASK & ~(1 << TIF_BREAKPOINT)) |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 115 | |
| 116 | #endif /* __ASM_AVR32_THREAD_INFO_H */ |