1 /* 2 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License version 2 as 6 * published by the Free Software Foundation. 7 * 8 * Vineetg: Oct 2009 9 * No need for ARC specific thread_info allocator (kmalloc/free). This is 10 * anyways one page allocation, thus slab alloc can be short-circuited and 11 * the generic version (get_free_page) would be loads better. 12 * 13 * Sameer Dhavale: Codito Technologies 2004 14 */ 15 16 #ifndef _ASM_THREAD_INFO_H 17 #define _ASM_THREAD_INFO_H 18 19 #include <asm/page.h> 20 21 #ifdef CONFIG_16KSTACKS 22 #define THREAD_SIZE_ORDER 1 23 #else 24 #define THREAD_SIZE_ORDER 0 25 #endif 26 27 #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) 28 29 #ifndef __ASSEMBLY__ 30 31 #include <linux/thread_info.h> 32 #include <asm/segment.h> 33 34 /* 35 * low level task data that entry.S needs immediate access to 36 * - this struct should fit entirely inside of one cache line 37 * - this struct shares the supervisor stack pages 38 * - if the contents of this structure are changed, the assembly constants 39 * must also be changed 40 */ 41 struct thread_info { 42 unsigned long flags; /* low level flags */ 43 int preempt_count; /* 0 => preemptable, <0 => BUG */ 44 struct task_struct *task; /* main task structure */ 45 mm_segment_t addr_limit; /* thread address space */ 46 struct exec_domain *exec_domain;/* execution domain */ 47 __u32 cpu; /* current CPU */ 48 unsigned long thr_ptr; /* TLS ptr */ 49 }; 50 51 /* 52 * macros/functions for gaining access to the thread information structure 53 * 54 * preempt_count needs to be 1 initially, until the scheduler is functional. 55 */ 56 #define INIT_THREAD_INFO(tsk) \ 57 { \ 58 .task = &tsk, \ 59 .exec_domain = &default_exec_domain, \ 60 .flags = 0, \ 61 .cpu = 0, \ 62 .preempt_count = INIT_PREEMPT_COUNT, \ 63 .addr_limit = KERNEL_DS, \ 64 } 65 66 #define init_thread_info (init_thread_union.thread_info) 67 #define init_stack (init_thread_union.stack) 68 69 static inline __attribute_const__ struct thread_info *current_thread_info(void) 70 { 71 register unsigned long sp asm("sp"); 72 return (struct thread_info *)(sp & ~(THREAD_SIZE - 1)); 73 } 74 75 #endif /* !__ASSEMBLY__ */ 76 77 /* 78 * thread information flags 79 * - these are process state flags that various assembly files may need to 80 * access 81 * - pending work-to-be-done flags are in LSW 82 * - other flags in MSW 83 */ 84 #define TIF_RESTORE_SIGMASK 0 /* restore sig mask in do_signal() */ 85 #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 86 #define TIF_SIGPENDING 2 /* signal pending */ 87 #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 88 #define TIF_SYSCALL_AUDIT 4 /* syscall auditing active */ 89 #define TIF_SYSCALL_TRACE 15 /* syscall trace active */ 90 91 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 92 #define TIF_MEMDIE 16 93 94 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 95 #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) 96 #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 97 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 98 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) 99 #define _TIF_MEMDIE (1<<TIF_MEMDIE) 100 101 /* work to do on interrupt/exception return */ 102 #define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \ 103 _TIF_NOTIFY_RESUME) 104 105 /* 106 * _TIF_ALLWORK_MASK includes SYSCALL_TRACE, but we don't need it. 107 * SYSCALL_TRACE is anways seperately/unconditionally tested right after a 108 * syscall, so all that reamins to be tested is _TIF_WORK_MASK 109 */ 110 111 #endif /* _ASM_THREAD_INFO_H */ 112