1 /* MN10300 Low-level thread information
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
12 #ifndef _ASM_THREAD_INFO_H
13 #define _ASM_THREAD_INFO_H
19 #define PREEMPT_ACTIVE 0x10000000
21 #ifdef CONFIG_4KSTACKS
22 #define THREAD_SIZE (4096)
24 #define THREAD_SIZE (8192)
27 #define STACK_WARN (THREAD_SIZE / 8)
30 * low level task data that entry.S needs immediate access to
31 * - this struct should fit entirely inside of one cache line
32 * - this struct shares the supervisor stack pages
33 * - if the contents of this structure are changed, the assembly constants
34 * must also be changed
42 struct task_struct
*task
; /* main task structure */
43 struct exec_domain
*exec_domain
; /* execution domain */
44 struct pt_regs
*frame
; /* current exception frame */
45 unsigned long flags
; /* low level flags */
46 __u32 cpu
; /* current CPU */
47 __s32 preempt_count
; /* 0 => preemptable, <0 => BUG */
49 mm_segment_t addr_limit
; /* thread address space:
50 0-0xBFFFFFFF for user-thead
51 0-0xFFFFFFFF for kernel-thread
53 struct restart_block restart_block
;
55 __u8 supervisor_stack
[0];
58 #define thread_info_to_uregs(ti) \
60 ((unsigned long)ti + THREAD_SIZE - sizeof(struct pt_regs)))
62 #else /* !__ASSEMBLY__ */
64 #ifndef __ASM_OFFSETS_H__
65 #include <asm/asm-offsets.h>
71 * macros/functions for gaining access to the thread information structure
75 #define INIT_THREAD_INFO(tsk) \
78 .exec_domain = &default_exec_domain, \
81 .preempt_count = INIT_PREEMPT_COUNT, \
82 .addr_limit = KERNEL_DS, \
84 .fn = do_no_restart_syscall, \
88 #define init_thread_info (init_thread_union.thread_info)
89 #define init_stack (init_thread_union.stack)
92 ((unsigned long) init_stack + THREAD_SIZE - sizeof(struct pt_regs)))
94 extern struct thread_info
*__current_ti
;
96 /* how to get the thread information struct from C */
97 static inline __attribute__((const))
98 struct thread_info
*current_thread_info(void)
100 struct thread_info
*ti
;
104 : "i" (~(THREAD_SIZE
- 1))
109 static inline __attribute__((const))
110 struct pt_regs
*current_frame(void)
112 return current_thread_info()->frame
;
115 /* how to get the current stack pointer from C */
116 static inline unsigned long current_stack_pointer(void)
119 asm("mov sp,%0; ":"=r" (sp
));
123 #define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
125 /* thread information allocation */
126 #ifdef CONFIG_DEBUG_STACK_USAGE
127 #define alloc_thread_info_node(tsk, node) \
128 kzalloc_node(THREAD_SIZE, GFP_KERNEL, node)
130 #define alloc_thread_info_node(tsk, node) \
131 kmalloc_node(THREAD_SIZE, GFP_KERNEL, node)
135 #define free_thread_info(ti) kfree((ti))
137 extern void free_thread_info(struct thread_info
*);
139 #define get_thread_info(ti) get_task_struct((ti)->task)
140 #define put_thread_info(ti) put_task_struct((ti)->task)
142 #else /* !__ASSEMBLY__ */
144 #ifndef __VMLINUX_LDS__
145 /* how to get the thread information struct from ASM */
146 .macro GET_THREAD_INFO reg
148 and -THREAD_SIZE
,\reg
154 * thread information flags
155 * - these are process state flags that various assembly files may need to
157 * - pending work-to-be-done flags are in LSW
158 * - other flags in MSW
160 #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
161 #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
162 #define TIF_SIGPENDING 2 /* signal pending */
163 #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
164 #define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */
165 #define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
166 #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
167 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
168 #define TIF_FREEZE 18 /* freezing for suspend */
170 #define _TIF_SYSCALL_TRACE +(1 << TIF_SYSCALL_TRACE)
171 #define _TIF_NOTIFY_RESUME +(1 << TIF_NOTIFY_RESUME)
172 #define _TIF_SIGPENDING +(1 << TIF_SIGPENDING)
173 #define _TIF_NEED_RESCHED +(1 << TIF_NEED_RESCHED)
174 #define _TIF_SINGLESTEP +(1 << TIF_SINGLESTEP)
175 #define _TIF_RESTORE_SIGMASK +(1 << TIF_RESTORE_SIGMASK)
176 #define _TIF_POLLING_NRFLAG +(1 << TIF_POLLING_NRFLAG)
177 #define _TIF_FREEZE +(1 << TIF_FREEZE)
179 #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
180 #define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */
182 #endif /* __KERNEL__ */
184 #endif /* _ASM_THREAD_INFO_H */