2 * Copyright (C) 2002 David Howells (dhowells@redhat.com)
3 * Copyright 2010 Tilera Corporation. All Rights Reserved.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation, version 2.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
12 * NON INFRINGEMENT. See the GNU General Public License for
16 #ifndef _ASM_TILE_THREAD_INFO_H
17 #define _ASM_TILE_THREAD_INFO_H
19 #include <asm/processor.h>
24 * Low level task data that assembly code needs immediate access to.
25 * The structure is placed at the bottom of the supervisor stack.
28 struct task_struct
*task
; /* main task structure */
29 unsigned long flags
; /* low level flags */
30 unsigned long status
; /* thread-synchronous flags */
31 __u32 homecache_cpu
; /* CPU we are homecached on */
32 __u32 cpu
; /* current CPU */
33 int preempt_count
; /* 0 => preemptable,
36 mm_segment_t addr_limit
; /* thread address space
37 (KERNEL_DS or USER_DS) */
38 struct single_step_state
*step_state
; /* single step state
40 int align_ctl
; /* controls unaligned access */
42 unsigned long unalign_jit_tmp
[4]; /* temp r0..r3 storage */
43 void __user
*unalign_jit_base
; /* unalign fixup JIT base */
45 bool in_backtrace
; /* currently doing backtrace? */
49 * macros/functions for gaining access to the thread information structure.
51 #define INIT_THREAD_INFO(tsk) \
56 .preempt_count = INIT_PREEMPT_COUNT, \
57 .addr_limit = KERNEL_DS, \
62 #endif /* !__ASSEMBLY__ */
65 #define THREAD_SIZE_ORDER (13 - PAGE_SHIFT)
67 #define THREAD_SIZE_ORDER (0)
69 #define THREAD_SIZE_PAGES (1 << THREAD_SIZE_ORDER)
71 #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
72 #define LOG2_THREAD_SIZE (PAGE_SHIFT + THREAD_SIZE_ORDER)
74 #define STACK_WARN (THREAD_SIZE/8)
78 void arch_release_thread_stack(unsigned long *stack
);
80 /* How to get the thread information struct from C. */
81 register unsigned long stack_pointer
__asm__("sp");
83 #define current_thread_info() \
84 ((struct thread_info *)(stack_pointer & -THREAD_SIZE))
86 /* Sit on a nap instruction until interrupted. */
87 extern void smp_nap(void);
89 /* Enable interrupts racelessly and nap forever: helper for arch_cpu_idle(). */
90 extern void _cpu_idle(void);
92 #else /* __ASSEMBLY__ */
95 * How to get the thread information struct from assembly.
96 * Note that we use different macros since different architectures
97 * have different semantics in their "mm" instruction and we would
98 * like to guarantee that the macro expands to exactly one instruction.
101 #define EXTRACT_THREAD_INFO(reg) mm reg, zero, LOG2_THREAD_SIZE, 63
103 #define GET_THREAD_INFO(reg) mm reg, sp, zero, LOG2_THREAD_SIZE, 31
106 #endif /* !__ASSEMBLY__ */
109 * Thread information flags that various assembly files may need to access.
110 * Keep flags accessed frequently in low bits, particular since it makes
111 * it easier to build constants in assembly.
113 #define TIF_SIGPENDING 0 /* signal pending */
114 #define TIF_NEED_RESCHED 1 /* rescheduling necessary */
115 #define TIF_SINGLESTEP 2 /* restore singlestep on return to
117 #define TIF_ASYNC_TLB 3 /* got an async TLB fault in kernel */
118 #define TIF_SYSCALL_TRACE 4 /* syscall trace active */
119 #define TIF_SYSCALL_AUDIT 5 /* syscall auditing active */
120 #define TIF_SECCOMP 6 /* secure computing */
121 #define TIF_MEMDIE 7 /* OOM killer at work */
122 #define TIF_NOTIFY_RESUME 8 /* callback before returning to user */
123 #define TIF_SYSCALL_TRACEPOINT 9 /* syscall tracepoint instrumentation */
124 #define TIF_POLLING_NRFLAG 10 /* idle is polling for TIF_NEED_RESCHED */
125 #define TIF_NOHZ 11 /* in adaptive nohz mode */
127 #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
128 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
129 #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
130 #define _TIF_ASYNC_TLB (1<<TIF_ASYNC_TLB)
131 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
132 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
133 #define _TIF_SECCOMP (1<<TIF_SECCOMP)
134 #define _TIF_MEMDIE (1<<TIF_MEMDIE)
135 #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
136 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
137 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
138 #define _TIF_NOHZ (1<<TIF_NOHZ)
140 /* Work to do as we loop to exit to user space. */
141 #define _TIF_WORK_MASK \
142 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
143 _TIF_ASYNC_TLB | _TIF_NOTIFY_RESUME)
145 /* Work to do on any return to user space. */
146 #define _TIF_ALLWORK_MASK \
147 (_TIF_WORK_MASK | _TIF_SINGLESTEP | _TIF_NOHZ)
149 /* Work to do at syscall entry. */
150 #define _TIF_SYSCALL_ENTRY_WORK \
151 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
153 /* Work to do at syscall exit. */
154 #define _TIF_SYSCALL_EXIT_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_TRACEPOINT)
157 * Thread-synchronous status.
159 * This is different from the flags in that nobody else
160 * ever touches our thread-synchronous status, so we don't
161 * have to worry about atomic accesses.
164 #define TS_COMPAT 0x0001 /* 32-bit compatibility mode */
167 #endif /* _ASM_TILE_THREAD_INFO_H */