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 | |
| 22 | /* |
| 23 | * low level task data that entry.S needs immediate access to |
| 24 | * - this struct should fit entirely inside of one cache line |
| 25 | * - this struct shares the supervisor stack pages |
| 26 | * - if the contents of this structure are changed, the assembly constants must also be changed |
| 27 | */ |
| 28 | #ifndef __ASSEMBLY__ |
| 29 | |
| 30 | struct thread_info { |
| 31 | struct task_struct *task; /* main task structure */ |
| 32 | struct exec_domain *exec_domain; /* execution domain */ |
| 33 | unsigned long flags; /* low level flags */ |
| 34 | unsigned long status; /* thread-synchronous flags */ |
| 35 | __u32 cpu; /* current CPU */ |
Jesper Juhl | dcd497f | 2005-06-23 00:09:07 -0700 | [diff] [blame] | 36 | int preempt_count; /* 0 => preemptable, <0 => BUG */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
| 38 | mm_segment_t addr_limit; /* thread address space: |
| 39 | 0-0xBFFFFFFF for user-thead |
| 40 | 0-0xFFFFFFFF for kernel-thread |
| 41 | */ |
| 42 | struct restart_block restart_block; |
| 43 | |
| 44 | __u8 supervisor_stack[0]; |
| 45 | }; |
| 46 | |
| 47 | #else /* !__ASSEMBLY__ */ |
| 48 | |
| 49 | /* offsets into the thread_info struct for assembly code access */ |
| 50 | #define TI_TASK 0x00000000 |
| 51 | #define TI_EXEC_DOMAIN 0x00000004 |
| 52 | #define TI_FLAGS 0x00000008 |
| 53 | #define TI_STATUS 0x0000000C |
| 54 | #define TI_CPU 0x00000010 |
| 55 | #define TI_PRE_COUNT 0x00000014 |
| 56 | #define TI_ADDR_LIMIT 0x00000018 |
| 57 | #define TI_RESTART_BLOCK 0x0000001C |
| 58 | |
| 59 | #endif |
| 60 | |
| 61 | #define PREEMPT_ACTIVE 0x4000000 |
| 62 | |
| 63 | /* |
| 64 | * macros/functions for gaining access to the thread information structure |
| 65 | * |
| 66 | * preempt_count needs to be 1 initially, until the scheduler is functional. |
| 67 | */ |
| 68 | #ifndef __ASSEMBLY__ |
| 69 | |
| 70 | #define INIT_THREAD_INFO(tsk) \ |
| 71 | { \ |
| 72 | .task = &tsk, \ |
| 73 | .exec_domain = &default_exec_domain, \ |
| 74 | .flags = 0, \ |
| 75 | .cpu = 0, \ |
| 76 | .preempt_count = 1, \ |
| 77 | .addr_limit = KERNEL_DS, \ |
| 78 | .restart_block = { \ |
| 79 | .fn = do_no_restart_syscall, \ |
| 80 | }, \ |
| 81 | } |
| 82 | |
| 83 | #define init_thread_info (init_thread_union.thread_info) |
| 84 | #define init_stack (init_thread_union.stack) |
| 85 | |
| 86 | #ifdef CONFIG_SMALL_TASKS |
| 87 | #define THREAD_SIZE 4096 |
| 88 | #else |
| 89 | #define THREAD_SIZE 8192 |
| 90 | #endif |
| 91 | |
| 92 | /* how to get the thread information struct from C */ |
| 93 | register struct thread_info *__current_thread_info asm("gr15"); |
| 94 | |
| 95 | #define current_thread_info() ({ __current_thread_info; }) |
| 96 | |
| 97 | /* thread information allocation */ |
| 98 | #ifdef CONFIG_DEBUG_STACK_USAGE |
| 99 | #define alloc_thread_info(tsk) \ |
| 100 | ({ \ |
| 101 | struct thread_info *ret; \ |
| 102 | \ |
| 103 | ret = kmalloc(THREAD_SIZE, GFP_KERNEL); \ |
| 104 | if (ret) \ |
| 105 | memset(ret, 0, THREAD_SIZE); \ |
| 106 | ret; \ |
| 107 | }) |
| 108 | #else |
| 109 | #define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL) |
| 110 | #endif |
| 111 | |
| 112 | #define free_thread_info(info) kfree(info) |
| 113 | #define get_thread_info(ti) get_task_struct((ti)->task) |
| 114 | #define put_thread_info(ti) put_task_struct((ti)->task) |
| 115 | |
| 116 | #else /* !__ASSEMBLY__ */ |
| 117 | |
| 118 | #define THREAD_SIZE 8192 |
| 119 | |
| 120 | #endif |
| 121 | |
| 122 | /* |
| 123 | * thread information flags |
| 124 | * - these are process state flags that various assembly files may need to access |
| 125 | * - pending work-to-be-done flags are in LSW |
| 126 | * - other flags in MSW |
| 127 | */ |
| 128 | #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ |
| 129 | #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ |
| 130 | #define TIF_SIGPENDING 2 /* signal pending */ |
| 131 | #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ |
| 132 | #define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */ |
| 133 | #define TIF_IRET 5 /* return with iret */ |
| 134 | #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ |
| 135 | #define TIF_MEMDIE 17 /* OOM killer killed process */ |
| 136 | |
| 137 | #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) |
| 138 | #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) |
| 139 | #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) |
| 140 | #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) |
| 141 | #define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP) |
| 142 | #define _TIF_IRET (1 << TIF_IRET) |
| 143 | #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) |
| 144 | |
| 145 | #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */ |
| 146 | #define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */ |
| 147 | |
| 148 | /* |
| 149 | * Thread-synchronous status. |
| 150 | * |
| 151 | * This is different from the flags in that nobody else |
| 152 | * ever touches our thread-synchronous status, so we don't |
| 153 | * have to worry about atomic accesses. |
| 154 | */ |
| 155 | #define TS_USEDFPM 0x0001 /* FPU/Media was used by this task this quantum (SMP) */ |
| 156 | |
| 157 | #endif /* __KERNEL__ */ |
| 158 | |
| 159 | #endif /* _ASM_THREAD_INFO_H */ |