]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | #ifndef _ASM_M32R_THREAD_INFO_H |
3 | #define _ASM_M32R_THREAD_INFO_H | |
4 | ||
5 | /* thread_info.h: m32r low-level thread information | |
6 | * | |
7 | * Copyright (C) 2002 David Howells (dhowells@redhat.com) | |
8 | * - Incorporating suggestions made by Linus Torvalds and Dave Miller | |
9 | * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org> | |
10 | */ | |
11 | ||
12 | #ifdef __KERNEL__ | |
13 | ||
14 | #ifndef __ASSEMBLY__ | |
15 | #include <asm/processor.h> | |
16 | #endif | |
17 | ||
18 | /* | |
19 | * low level task data that entry.S needs immediate access to | |
20 | * - this struct should fit entirely inside of one cache line | |
21 | * - this struct shares the supervisor stack pages | |
22 | * - if the contents of this structure are changed, the assembly constants must also be changed | |
23 | */ | |
24 | #ifndef __ASSEMBLY__ | |
25 | ||
26 | struct thread_info { | |
27 | struct task_struct *task; /* main task structure */ | |
1da177e4 LT |
28 | unsigned long flags; /* low level flags */ |
29 | unsigned long status; /* thread-synchronous flags */ | |
30 | __u32 cpu; /* current CPU */ | |
dcd497f9 | 31 | int preempt_count; /* 0 => preemptable, <0 => BUG */ |
1da177e4 LT |
32 | |
33 | mm_segment_t addr_limit; /* thread address space: | |
34 | 0-0xBFFFFFFF for user-thread | |
35 | 0-0xFFFFFFFF for kernel-thread | |
36 | */ | |
1da177e4 LT |
37 | |
38 | __u8 supervisor_stack[0]; | |
39 | }; | |
40 | ||
37f078ff | 41 | #endif /* !__ASSEMBLY__ */ |
1da177e4 | 42 | |
e6e9c540 TG |
43 | #define THREAD_SIZE (PAGE_SIZE << 1) |
44 | #define THREAD_SIZE_ORDER 1 | |
1da177e4 LT |
45 | /* |
46 | * macros/functions for gaining access to the thread information structure | |
1da177e4 LT |
47 | */ |
48 | #ifndef __ASSEMBLY__ | |
49 | ||
50 | #define INIT_THREAD_INFO(tsk) \ | |
51 | { \ | |
52 | .task = &tsk, \ | |
1da177e4 LT |
53 | .flags = 0, \ |
54 | .cpu = 0, \ | |
c99e6efe | 55 | .preempt_count = INIT_PREEMPT_COUNT, \ |
1da177e4 | 56 | .addr_limit = KERNEL_DS, \ |
1da177e4 LT |
57 | } |
58 | ||
59 | #define init_thread_info (init_thread_union.thread_info) | |
60 | #define init_stack (init_thread_union.stack) | |
61 | ||
1da177e4 LT |
62 | /* how to get the thread information struct from C */ |
63 | static inline struct thread_info *current_thread_info(void) | |
64 | { | |
65 | struct thread_info *ti; | |
66 | ||
67 | __asm__ __volatile__ ( | |
68 | "ldi %0, #%1 \n\t" | |
69 | "and %0, sp \n\t" | |
70 | : "=r" (ti) : "i" (~(THREAD_SIZE - 1)) | |
71 | ); | |
72 | ||
73 | return ti; | |
74 | } | |
75 | ||
1da177e4 LT |
76 | #define TI_FLAG_FAULT_CODE_SHIFT 28 |
77 | ||
78 | static inline void set_thread_fault_code(unsigned int val) | |
79 | { | |
80 | struct thread_info *ti = current_thread_info(); | |
81 | ti->flags = (ti->flags & (~0 >> (32 - TI_FLAG_FAULT_CODE_SHIFT))) | |
82 | | (val << TI_FLAG_FAULT_CODE_SHIFT); | |
83 | } | |
84 | ||
85 | static inline unsigned int get_thread_fault_code(void) | |
86 | { | |
87 | struct thread_info *ti = current_thread_info(); | |
88 | return ti->flags >> TI_FLAG_FAULT_CODE_SHIFT; | |
89 | } | |
90 | ||
1da177e4 LT |
91 | #endif |
92 | ||
93 | /* | |
94 | * thread information flags | |
95 | * - these are process state flags that various assembly files may need to access | |
96 | * - pending work-to-be-done flags are in LSW | |
97 | * - other flags in MSW | |
98 | */ | |
99 | #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ | |
a583f1b5 SE |
100 | #define TIF_SIGPENDING 1 /* signal pending */ |
101 | #define TIF_NEED_RESCHED 2 /* rescheduling necessary */ | |
102 | #define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */ | |
d0420c83 | 103 | #define TIF_NOTIFY_RESUME 5 /* callback before returning to user */ |
c37a3303 HT |
104 | #define TIF_RESTORE_SIGMASK 8 /* restore signal mask in do_signal() */ |
105 | #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */ | |
0ddc9324 | 106 | #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ |
1da177e4 LT |
107 | |
108 | #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) | |
1da177e4 LT |
109 | #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) |
110 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) | |
111 | #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) | |
d0420c83 | 112 | #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) |
c37a3303 | 113 | #define _TIF_USEDFPU (1<<TIF_USEDFPU) |
1da177e4 | 114 | |
d70745bb AV |
115 | #define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME) |
116 | #define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_SYSCALL_TRACE) | |
1da177e4 LT |
117 | |
118 | /* | |
119 | * Thread-synchronous status. | |
120 | * | |
121 | * This is different from the flags in that nobody else | |
122 | * ever touches our thread-synchronous status, so we don't | |
123 | * have to worry about atomic accesses. | |
124 | */ | |
125 | #define TS_USEDFPU 0x0001 /* FPU was used by this task this quantum (SMP) */ | |
126 | ||
127 | #endif /* __KERNEL__ */ | |
128 | ||
129 | #endif /* _ASM_M32R_THREAD_INFO_H */ |