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