Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | /* |
Mike Frysinger | 3750411 | 2010-01-22 09:11:20 -0500 | [diff] [blame] | 2 | * Copyright 2004-2010 Analog Devices Inc. |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 3 | * |
Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 4 | * Licensed under the GPL-2 or later. |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef _ASM_THREAD_INFO_H |
| 8 | #define _ASM_THREAD_INFO_H |
| 9 | |
| 10 | #include <asm/page.h> |
| 11 | #include <asm/entry.h> |
| 12 | #include <asm/l1layout.h> |
| 13 | #include <linux/compiler.h> |
| 14 | |
| 15 | #ifdef __KERNEL__ |
| 16 | |
| 17 | /* Thread Align Mask to reach to the top of the stack |
| 18 | * for any process |
| 19 | */ |
Mike Frysinger | 3750411 | 2010-01-22 09:11:20 -0500 | [diff] [blame] | 20 | #define ALIGN_PAGE_MASK 0xffffe000 |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 21 | |
Mike Frysinger | 12a7991 | 2007-07-25 10:25:29 +0800 | [diff] [blame] | 22 | /* |
| 23 | * Size of kernel stack for each process. This must be a power of 2... |
| 24 | */ |
FUJITA Tomonori | b69c49b | 2008-07-25 01:45:40 -0700 | [diff] [blame] | 25 | #define THREAD_SIZE_ORDER 1 |
Mike Frysinger | 12a7991 | 2007-07-25 10:25:29 +0800 | [diff] [blame] | 26 | #define THREAD_SIZE 8192 /* 2 pages */ |
Robin Getz | a45d575 | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 27 | #define STACK_WARN (THREAD_SIZE/8) |
Mike Frysinger | 12a7991 | 2007-07-25 10:25:29 +0800 | [diff] [blame] | 28 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 29 | #ifndef __ASSEMBLY__ |
| 30 | |
| 31 | typedef unsigned long mm_segment_t; |
| 32 | |
| 33 | /* |
| 34 | * low level task data. |
| 35 | * If you change this, change the TI_* offsets below to match. |
| 36 | */ |
| 37 | |
| 38 | struct thread_info { |
| 39 | struct task_struct *task; /* main task structure */ |
| 40 | struct exec_domain *exec_domain; /* execution domain */ |
| 41 | unsigned long flags; /* low level flags */ |
| 42 | int cpu; /* cpu we're on */ |
| 43 | int preempt_count; /* 0 => preemptable, <0 => BUG */ |
| 44 | mm_segment_t addr_limit; /* address limit */ |
| 45 | struct restart_block restart_block; |
Sonic Zhang | cc92b87 | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 46 | #ifndef CONFIG_SMP |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 47 | struct l1_scratch_task_info l1_task_info; |
Sonic Zhang | cc92b87 | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 48 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | /* |
| 52 | * macros/functions for gaining access to the thread information structure |
| 53 | */ |
| 54 | #define INIT_THREAD_INFO(tsk) \ |
| 55 | { \ |
| 56 | .task = &tsk, \ |
| 57 | .exec_domain = &default_exec_domain, \ |
| 58 | .flags = 0, \ |
| 59 | .cpu = 0, \ |
Mike Frysinger | 3750411 | 2010-01-22 09:11:20 -0500 | [diff] [blame] | 60 | .preempt_count = INIT_PREEMPT_COUNT, \ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 61 | .restart_block = { \ |
| 62 | .fn = do_no_restart_syscall, \ |
| 63 | }, \ |
| 64 | } |
| 65 | #define init_thread_info (init_thread_union.thread_info) |
| 66 | #define init_stack (init_thread_union.stack) |
| 67 | |
Robert P. J. Day | 18628e4 | 2008-04-24 09:02:00 +0800 | [diff] [blame] | 68 | /* Given a task stack pointer, you can find its corresponding |
| 69 | * thread_info structure just by masking it to the THREAD_SIZE |
| 70 | * boundary (currently 8K as you can see above). |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 71 | */ |
Robert P. J. Day | 18628e4 | 2008-04-24 09:02:00 +0800 | [diff] [blame] | 72 | __attribute_const__ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 73 | static inline struct thread_info *current_thread_info(void) |
| 74 | { |
| 75 | struct thread_info *ti; |
Mike Frysinger | 3750411 | 2010-01-22 09:11:20 -0500 | [diff] [blame] | 76 | __asm__("%0 = sp;" : "=da"(ti)); |
Mike Frysinger | 12a7991 | 2007-07-25 10:25:29 +0800 | [diff] [blame] | 77 | return (struct thread_info *)((long)ti & ~((long)THREAD_SIZE-1)); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 78 | } |
| 79 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 80 | #endif /* __ASSEMBLY__ */ |
| 81 | |
| 82 | /* |
| 83 | * Offsets in thread_info structure, used in assembly code |
| 84 | */ |
| 85 | #define TI_TASK 0 |
| 86 | #define TI_EXECDOMAIN 4 |
| 87 | #define TI_FLAGS 8 |
| 88 | #define TI_CPU 12 |
| 89 | #define TI_PREEMPT 16 |
| 90 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 91 | /* |
| 92 | * thread information flag bit numbers |
| 93 | */ |
| 94 | #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ |
Stephane Eranian | a583f1b | 2007-07-31 00:38:00 -0700 | [diff] [blame] | 95 | #define TIF_SIGPENDING 1 /* signal pending */ |
| 96 | #define TIF_NEED_RESCHED 2 /* rescheduling necessary */ |
Andreas Dilger | 0ddc932 | 2010-05-14 11:13:27 +0200 | [diff] [blame] | 97 | #define TIF_MEMDIE 4 /* is terminating due to OOM killer */ |
Stephane Eranian | a583f1b | 2007-07-31 00:38:00 -0700 | [diff] [blame] | 98 | #define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */ |
Mike Frysinger | 3750411 | 2010-01-22 09:11:20 -0500 | [diff] [blame] | 99 | #define TIF_IRQ_SYNC 7 /* sync pipeline stage */ |
| 100 | #define TIF_NOTIFY_RESUME 8 /* callback before returning to user */ |
Mike Frysinger | 600482c | 2010-02-17 10:44:22 +0000 | [diff] [blame] | 101 | #define TIF_SINGLESTEP 9 |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 102 | |
| 103 | /* as above, but as bit values */ |
| 104 | #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 105 | #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) |
| 106 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) |
Mike Frysinger | 3750411 | 2010-01-22 09:11:20 -0500 | [diff] [blame] | 107 | #define _TIF_IRQ_SYNC (1<<TIF_IRQ_SYNC) |
| 108 | #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) |
Mike Frysinger | 600482c | 2010-02-17 10:44:22 +0000 | [diff] [blame] | 109 | #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 110 | |
| 111 | #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */ |
| 112 | |
| 113 | #endif /* __KERNEL__ */ |
| 114 | |
| 115 | #endif /* _ASM_THREAD_INFO_H */ |