Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * File: include/asm-blackfin/thread_info.h |
| 3 | * Based on: include/asm-m68knommu/thread_info.h |
| 4 | * Author: LG Soft India |
| 5 | * Copyright (C) 2004-2005 Analog Devices Inc. |
| 6 | * Created: Tue Sep 21 2004 |
| 7 | * Description: Blackfin low-level thread information |
| 8 | * Modified: |
| 9 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2, or (at your option) |
| 14 | * any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; see the file COPYING. |
| 23 | * If not, write to the Free Software Foundation, |
| 24 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 25 | */ |
| 26 | |
| 27 | #ifndef _ASM_THREAD_INFO_H |
| 28 | #define _ASM_THREAD_INFO_H |
| 29 | |
| 30 | #include <asm/page.h> |
| 31 | #include <asm/entry.h> |
| 32 | #include <asm/l1layout.h> |
| 33 | #include <linux/compiler.h> |
| 34 | |
| 35 | #ifdef __KERNEL__ |
| 36 | |
| 37 | /* Thread Align Mask to reach to the top of the stack |
| 38 | * for any process |
| 39 | */ |
| 40 | #define ALIGN_PAGE_MASK 0xffffe000 |
| 41 | |
Mike Frysinger | 12a7991 | 2007-07-25 10:25:29 +0800 | [diff] [blame] | 42 | /* |
| 43 | * Size of kernel stack for each process. This must be a power of 2... |
| 44 | */ |
FUJITA Tomonori | b69c49b | 2008-07-25 01:45:40 -0700 | [diff] [blame] | 45 | #define THREAD_SIZE_ORDER 1 |
Mike Frysinger | 12a7991 | 2007-07-25 10:25:29 +0800 | [diff] [blame] | 46 | #define THREAD_SIZE 8192 /* 2 pages */ |
Robin Getz | a45d575 | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 47 | #define STACK_WARN (THREAD_SIZE/8) |
Mike Frysinger | 12a7991 | 2007-07-25 10:25:29 +0800 | [diff] [blame] | 48 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 49 | #ifndef __ASSEMBLY__ |
| 50 | |
| 51 | typedef unsigned long mm_segment_t; |
| 52 | |
| 53 | /* |
| 54 | * low level task data. |
| 55 | * If you change this, change the TI_* offsets below to match. |
| 56 | */ |
| 57 | |
| 58 | struct thread_info { |
| 59 | struct task_struct *task; /* main task structure */ |
| 60 | struct exec_domain *exec_domain; /* execution domain */ |
| 61 | unsigned long flags; /* low level flags */ |
| 62 | int cpu; /* cpu we're on */ |
| 63 | int preempt_count; /* 0 => preemptable, <0 => BUG */ |
| 64 | mm_segment_t addr_limit; /* address limit */ |
| 65 | struct restart_block restart_block; |
Sonic Zhang | cc92b87 | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 66 | #ifndef CONFIG_SMP |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 67 | struct l1_scratch_task_info l1_task_info; |
Sonic Zhang | cc92b87 | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 68 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | /* |
| 72 | * macros/functions for gaining access to the thread information structure |
| 73 | */ |
| 74 | #define INIT_THREAD_INFO(tsk) \ |
| 75 | { \ |
| 76 | .task = &tsk, \ |
| 77 | .exec_domain = &default_exec_domain, \ |
| 78 | .flags = 0, \ |
| 79 | .cpu = 0, \ |
Peter Zijlstra | c99e6ef | 2009-07-10 14:57:56 +0200 | [diff] [blame^] | 80 | .preempt_count = INIT_PREEMPT_COUNT, \ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 81 | .restart_block = { \ |
| 82 | .fn = do_no_restart_syscall, \ |
| 83 | }, \ |
| 84 | } |
| 85 | #define init_thread_info (init_thread_union.thread_info) |
| 86 | #define init_stack (init_thread_union.stack) |
| 87 | |
Robert P. J. Day | 18628e4 | 2008-04-24 09:02:00 +0800 | [diff] [blame] | 88 | /* Given a task stack pointer, you can find its corresponding |
| 89 | * thread_info structure just by masking it to the THREAD_SIZE |
| 90 | * boundary (currently 8K as you can see above). |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 91 | */ |
Robert P. J. Day | 18628e4 | 2008-04-24 09:02:00 +0800 | [diff] [blame] | 92 | __attribute_const__ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 93 | static inline struct thread_info *current_thread_info(void) |
| 94 | { |
| 95 | struct thread_info *ti; |
Robin Getz | 26fe19f | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 96 | __asm__("%0 = sp;" : "=da"(ti) : |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 97 | ); |
Mike Frysinger | 12a7991 | 2007-07-25 10:25:29 +0800 | [diff] [blame] | 98 | return (struct thread_info *)((long)ti & ~((long)THREAD_SIZE-1)); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 99 | } |
| 100 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 101 | #endif /* __ASSEMBLY__ */ |
| 102 | |
| 103 | /* |
| 104 | * Offsets in thread_info structure, used in assembly code |
| 105 | */ |
| 106 | #define TI_TASK 0 |
| 107 | #define TI_EXECDOMAIN 4 |
| 108 | #define TI_FLAGS 8 |
| 109 | #define TI_CPU 12 |
| 110 | #define TI_PREEMPT 16 |
| 111 | |
| 112 | #define PREEMPT_ACTIVE 0x4000000 |
| 113 | |
| 114 | /* |
| 115 | * thread information flag bit numbers |
| 116 | */ |
| 117 | #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ |
Stephane Eranian | a583f1b | 2007-07-31 00:38:00 -0700 | [diff] [blame] | 118 | #define TIF_SIGPENDING 1 /* signal pending */ |
| 119 | #define TIF_NEED_RESCHED 2 /* rescheduling necessary */ |
| 120 | #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 121 | TIF_NEED_RESCHED */ |
Stephane Eranian | a583f1b | 2007-07-31 00:38:00 -0700 | [diff] [blame] | 122 | #define TIF_MEMDIE 4 |
| 123 | #define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */ |
| 124 | #define TIF_FREEZE 6 /* is freezing for suspend */ |
Philippe Gerum | 9bd50df | 2009-03-04 16:52:38 +0800 | [diff] [blame] | 125 | #define TIF_IRQ_SYNC 7 /* sync pipeline stage */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 126 | |
| 127 | /* as above, but as bit values */ |
| 128 | #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 129 | #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) |
| 130 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) |
| 131 | #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) |
| 132 | #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) |
| 133 | #define _TIF_FREEZE (1<<TIF_FREEZE) |
Philippe Gerum | 9bd50df | 2009-03-04 16:52:38 +0800 | [diff] [blame] | 134 | #define _TIF_IRQ_SYNC (1<<TIF_IRQ_SYNC) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 135 | |
| 136 | #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */ |
| 137 | |
| 138 | #endif /* __KERNEL__ */ |
| 139 | |
| 140 | #endif /* _ASM_THREAD_INFO_H */ |