Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* thread_info.h: description |
| 2 | * |
| 3 | * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. |
| 4 | * Written by David Howells (dhowells@redhat.com) |
| 5 | * Derived from include/asm-i386/thread_info.h |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * as published by the Free Software Foundation; either version |
| 10 | * 2 of the License, or (at your option) any later version. |
| 11 | */ |
| 12 | |
| 13 | #ifndef _ASM_THREAD_INFO_H |
| 14 | #define _ASM_THREAD_INFO_H |
| 15 | |
| 16 | #ifdef __KERNEL__ |
| 17 | |
| 18 | #ifndef __ASSEMBLY__ |
| 19 | #include <asm/processor.h> |
| 20 | #endif |
| 21 | |
David Howells | 84e8cd6 | 2006-07-10 04:44:55 -0700 | [diff] [blame] | 22 | #define THREAD_SIZE 8192 |
| 23 | |
Amerigo Wang | 5ca7202 | 2011-03-29 14:05:12 +0100 | [diff] [blame] | 24 | #define __HAVE_ARCH_TASK_STRUCT_ALLOCATOR |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | /* |
| 27 | * low level task data that entry.S needs immediate access to |
| 28 | * - this struct should fit entirely inside of one cache line |
| 29 | * - this struct shares the supervisor stack pages |
| 30 | * - if the contents of this structure are changed, the assembly constants must also be changed |
| 31 | */ |
| 32 | #ifndef __ASSEMBLY__ |
| 33 | |
| 34 | struct thread_info { |
| 35 | struct task_struct *task; /* main task structure */ |
| 36 | struct exec_domain *exec_domain; /* execution domain */ |
| 37 | unsigned long flags; /* low level flags */ |
| 38 | unsigned long status; /* thread-synchronous flags */ |
| 39 | __u32 cpu; /* current CPU */ |
Jesper Juhl | dcd497f | 2005-06-23 00:09:07 -0700 | [diff] [blame] | 40 | int preempt_count; /* 0 => preemptable, <0 => BUG */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
| 42 | mm_segment_t addr_limit; /* thread address space: |
David Howells | 1879346 | 2009-04-10 01:48:01 +0100 | [diff] [blame] | 43 | * 0-0xBFFFFFFF for user-thead |
| 44 | * 0-0xFFFFFFFF for kernel-thread |
| 45 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | struct restart_block restart_block; |
| 47 | |
| 48 | __u8 supervisor_stack[0]; |
| 49 | }; |
| 50 | |
| 51 | #else /* !__ASSEMBLY__ */ |
| 52 | |
David Howells | 84e8cd6 | 2006-07-10 04:44:55 -0700 | [diff] [blame] | 53 | #include <asm/asm-offsets.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
| 55 | #endif |
| 56 | |
David Howells | 8080f23 | 2005-11-28 13:43:51 -0800 | [diff] [blame] | 57 | #define PREEMPT_ACTIVE 0x10000000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
| 59 | /* |
| 60 | * macros/functions for gaining access to the thread information structure |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | */ |
| 62 | #ifndef __ASSEMBLY__ |
| 63 | |
| 64 | #define INIT_THREAD_INFO(tsk) \ |
| 65 | { \ |
| 66 | .task = &tsk, \ |
| 67 | .exec_domain = &default_exec_domain, \ |
| 68 | .flags = 0, \ |
| 69 | .cpu = 0, \ |
Peter Zijlstra | c99e6ef | 2009-07-10 14:57:56 +0200 | [diff] [blame] | 70 | .preempt_count = INIT_PREEMPT_COUNT, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | .addr_limit = KERNEL_DS, \ |
| 72 | .restart_block = { \ |
| 73 | .fn = do_no_restart_syscall, \ |
| 74 | }, \ |
| 75 | } |
| 76 | |
| 77 | #define init_thread_info (init_thread_union.thread_info) |
| 78 | #define init_stack (init_thread_union.stack) |
| 79 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | /* how to get the thread information struct from C */ |
| 81 | register struct thread_info *__current_thread_info asm("gr15"); |
| 82 | |
| 83 | #define current_thread_info() ({ __current_thread_info; }) |
| 84 | |
FUJITA Tomonori | b69c49b | 2008-07-25 01:45:40 -0700 | [diff] [blame] | 85 | #define __HAVE_ARCH_THREAD_INFO_ALLOCATOR |
| 86 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | /* thread information allocation */ |
| 88 | #ifdef CONFIG_DEBUG_STACK_USAGE |
Eric Dumazet | b6a8401 | 2011-03-22 16:30:42 -0700 | [diff] [blame] | 89 | #define alloc_thread_info_node(tsk, node) \ |
| 90 | kzalloc_node(THREAD_SIZE, GFP_KERNEL, node) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | #else |
David Howells | 5ef9bdd | 2011-03-29 14:05:12 +0100 | [diff] [blame] | 92 | #define alloc_thread_info_node(tsk, node) \ |
Eric Dumazet | b6a8401 | 2011-03-22 16:30:42 -0700 | [diff] [blame] | 93 | kmalloc_node(THREAD_SIZE, GFP_KERNEL, node) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | #endif |
| 95 | |
| 96 | #define free_thread_info(info) kfree(info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | |
David Howells | 84e8cd6 | 2006-07-10 04:44:55 -0700 | [diff] [blame] | 98 | #endif /* __ASSEMBLY__ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | |
| 100 | /* |
| 101 | * thread information flags |
| 102 | * - these are process state flags that various assembly files may need to access |
| 103 | * - pending work-to-be-done flags are in LSW |
| 104 | * - other flags in MSW |
| 105 | */ |
| 106 | #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ |
David Howells | b7bab88 | 2009-06-11 13:05:14 +0100 | [diff] [blame] | 107 | #define TIF_NOTIFY_RESUME 1 /* callback before returning to user */ |
| 108 | #define TIF_SIGPENDING 2 /* signal pending */ |
| 109 | #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ |
| 110 | #define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */ |
Stephane Eranian | a583f1b | 2007-07-31 00:38:00 -0700 | [diff] [blame] | 111 | #define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ |
Andreas Dilger | 0ddc932 | 2010-05-14 11:13:27 +0200 | [diff] [blame] | 113 | #define TIF_MEMDIE 17 /* is terminating due to OOM killer */ |
Rafael J. Wysocki | 8a102ee | 2006-12-13 00:34:30 -0800 | [diff] [blame] | 114 | #define TIF_FREEZE 18 /* freezing for suspend */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | |
| 116 | #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) |
David Howells | b7bab88 | 2009-06-11 13:05:14 +0100 | [diff] [blame] | 117 | #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) |
| 119 | #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) |
| 120 | #define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP) |
David Howells | a411aee | 2006-01-18 17:43:59 -0800 | [diff] [blame] | 121 | #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) |
Rafael J. Wysocki | 8a102ee | 2006-12-13 00:34:30 -0800 | [diff] [blame] | 123 | #define _TIF_FREEZE (1 << TIF_FREEZE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | |
| 125 | #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */ |
| 126 | #define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */ |
| 127 | |
| 128 | /* |
| 129 | * Thread-synchronous status. |
| 130 | * |
| 131 | * This is different from the flags in that nobody else |
| 132 | * ever touches our thread-synchronous status, so we don't |
| 133 | * have to worry about atomic accesses. |
| 134 | */ |
| 135 | #define TS_USEDFPM 0x0001 /* FPU/Media was used by this task this quantum (SMP) */ |
| 136 | |
| 137 | #endif /* __KERNEL__ */ |
| 138 | |
| 139 | #endif /* _ASM_THREAD_INFO_H */ |