Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2002 David Howells (dhowells@redhat.com) |
| 3 | * Copyright 2010 Tilera Corporation. All Rights Reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * as published by the Free Software Foundation, version 2. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but |
| 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or |
| 12 | * NON INFRINGEMENT. See the GNU General Public License for |
| 13 | * more details. |
| 14 | */ |
| 15 | |
| 16 | #ifndef _ASM_TILE_THREAD_INFO_H |
| 17 | #define _ASM_TILE_THREAD_INFO_H |
| 18 | |
| 19 | #include <asm/processor.h> |
| 20 | #include <asm/page.h> |
| 21 | #ifndef __ASSEMBLY__ |
| 22 | |
| 23 | /* |
| 24 | * Low level task data that assembly code needs immediate access to. |
| 25 | * The structure is placed at the bottom of the supervisor stack. |
| 26 | */ |
| 27 | struct thread_info { |
| 28 | struct task_struct *task; /* main task structure */ |
| 29 | struct exec_domain *exec_domain; /* execution domain */ |
| 30 | unsigned long flags; /* low level flags */ |
| 31 | unsigned long status; /* thread-synchronous flags */ |
| 32 | __u32 homecache_cpu; /* CPU we are homecached on */ |
| 33 | __u32 cpu; /* current CPU */ |
| 34 | int preempt_count; /* 0 => preemptable, |
| 35 | <0 => BUG */ |
| 36 | |
| 37 | mm_segment_t addr_limit; /* thread address space |
| 38 | (KERNEL_DS or USER_DS) */ |
| 39 | struct restart_block restart_block; |
| 40 | struct single_step_state *step_state; /* single step state |
| 41 | (if non-zero) */ |
| 42 | }; |
| 43 | |
| 44 | /* |
| 45 | * macros/functions for gaining access to the thread information structure. |
| 46 | */ |
| 47 | #define INIT_THREAD_INFO(tsk) \ |
| 48 | { \ |
| 49 | .task = &tsk, \ |
| 50 | .exec_domain = &default_exec_domain, \ |
| 51 | .flags = 0, \ |
| 52 | .cpu = 0, \ |
| 53 | .preempt_count = INIT_PREEMPT_COUNT, \ |
| 54 | .addr_limit = KERNEL_DS, \ |
| 55 | .restart_block = { \ |
| 56 | .fn = do_no_restart_syscall, \ |
| 57 | }, \ |
| 58 | .step_state = 0, \ |
| 59 | } |
| 60 | |
| 61 | #define init_thread_info (init_thread_union.thread_info) |
| 62 | #define init_stack (init_thread_union.stack) |
| 63 | |
| 64 | #endif /* !__ASSEMBLY__ */ |
| 65 | |
| 66 | #if PAGE_SIZE < 8192 |
| 67 | #define THREAD_SIZE_ORDER (13 - PAGE_SHIFT) |
| 68 | #else |
| 69 | #define THREAD_SIZE_ORDER (0) |
| 70 | #endif |
| 71 | |
| 72 | #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) |
| 73 | #define LOG2_THREAD_SIZE (PAGE_SHIFT + THREAD_SIZE_ORDER) |
| 74 | |
| 75 | #define STACK_WARN (THREAD_SIZE/8) |
| 76 | |
| 77 | #ifndef __ASSEMBLY__ |
| 78 | |
| 79 | /* How to get the thread information struct from C. */ |
| 80 | register unsigned long stack_pointer __asm__("sp"); |
| 81 | |
| 82 | #define current_thread_info() \ |
| 83 | ((struct thread_info *)(stack_pointer & -THREAD_SIZE)) |
| 84 | |
| 85 | #define __HAVE_ARCH_THREAD_INFO_ALLOCATOR |
| 86 | extern struct thread_info *alloc_thread_info(struct task_struct *task); |
| 87 | extern void free_thread_info(struct thread_info *info); |
| 88 | |
| 89 | /* Switch boot idle thread to a freshly-allocated stack and free old stack. */ |
| 90 | extern void cpu_idle_on_new_stack(struct thread_info *old_ti, |
| 91 | unsigned long new_sp, |
| 92 | unsigned long new_ss10); |
| 93 | |
| 94 | #else /* __ASSEMBLY__ */ |
| 95 | |
| 96 | /* how to get the thread information struct from ASM */ |
| 97 | #ifdef __tilegx__ |
| 98 | #define GET_THREAD_INFO(reg) move reg, sp; mm reg, zero, LOG2_THREAD_SIZE, 63 |
| 99 | #else |
| 100 | #define GET_THREAD_INFO(reg) mm reg, sp, zero, LOG2_THREAD_SIZE, 31 |
| 101 | #endif |
| 102 | |
| 103 | #endif /* !__ASSEMBLY__ */ |
| 104 | |
| 105 | #define PREEMPT_ACTIVE 0x10000000 |
| 106 | |
| 107 | /* |
| 108 | * Thread information flags that various assembly files may need to access. |
| 109 | * Keep flags accessed frequently in low bits, particular since it makes |
| 110 | * it easier to build constants in assembly. |
| 111 | */ |
| 112 | #define TIF_SIGPENDING 0 /* signal pending */ |
| 113 | #define TIF_NEED_RESCHED 1 /* rescheduling necessary */ |
| 114 | #define TIF_SINGLESTEP 2 /* restore singlestep on return to |
| 115 | user mode */ |
| 116 | #define TIF_ASYNC_TLB 3 /* got an async TLB fault in kernel */ |
| 117 | #define TIF_SYSCALL_TRACE 4 /* syscall trace active */ |
| 118 | #define TIF_SYSCALL_AUDIT 5 /* syscall auditing active */ |
| 119 | #define TIF_SECCOMP 6 /* secure computing */ |
| 120 | #define TIF_MEMDIE 7 /* OOM killer at work */ |
| 121 | |
| 122 | #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) |
| 123 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) |
| 124 | #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) |
| 125 | #define _TIF_ASYNC_TLB (1<<TIF_ASYNC_TLB) |
| 126 | #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) |
| 127 | #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) |
| 128 | #define _TIF_SECCOMP (1<<TIF_SECCOMP) |
| 129 | #define _TIF_MEMDIE (1<<TIF_MEMDIE) |
| 130 | |
| 131 | /* Work to do on any return to user space. */ |
| 132 | #define _TIF_ALLWORK_MASK \ |
| 133 | (_TIF_SIGPENDING|_TIF_NEED_RESCHED|_TIF_SINGLESTEP|_TIF_ASYNC_TLB) |
| 134 | |
| 135 | /* |
| 136 | * Thread-synchronous status. |
| 137 | * |
| 138 | * This is different from the flags in that nobody else |
| 139 | * ever touches our thread-synchronous status, so we don't |
| 140 | * have to worry about atomic accesses. |
| 141 | */ |
| 142 | #ifdef __tilegx__ |
| 143 | #define TS_COMPAT 0x0001 /* 32-bit compatibility mode */ |
| 144 | #endif |
| 145 | #define TS_POLLING 0x0004 /* in idle loop but not sleeping */ |
| 146 | #define TS_RESTORE_SIGMASK 0x0008 /* restore signal mask in do_signal */ |
| 147 | #define TS_EXEC_HASH_SET 0x0010 /* apply TS_EXEC_HASH_xxx flags */ |
| 148 | #define TS_EXEC_HASH_RO 0x0020 /* during exec, hash r/o segments */ |
| 149 | #define TS_EXEC_HASH_RW 0x0040 /* during exec, hash r/w segments */ |
| 150 | #define TS_EXEC_HASH_STACK 0x0080 /* during exec, hash the stack */ |
| 151 | #define TS_EXEC_HASH_FLAGS 0x00f0 /* mask for TS_EXEC_HASH_xxx flags */ |
| 152 | |
| 153 | #define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING) |
| 154 | |
| 155 | #ifndef __ASSEMBLY__ |
| 156 | #define HAVE_SET_RESTORE_SIGMASK 1 |
| 157 | static inline void set_restore_sigmask(void) |
| 158 | { |
| 159 | struct thread_info *ti = current_thread_info(); |
| 160 | ti->status |= TS_RESTORE_SIGMASK; |
| 161 | set_bit(TIF_SIGPENDING, &ti->flags); |
| 162 | } |
| 163 | #endif /* !__ASSEMBLY__ */ |
| 164 | |
| 165 | #endif /* _ASM_TILE_THREAD_INFO_H */ |