Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | unsigned long flags; /* low level flags */ |
| 29 | unsigned long status; /* thread-synchronous flags */ |
| 30 | __u32 cpu; /* current CPU */ |
Jesper Juhl | dcd497f | 2005-06-23 00:09:07 -0700 | [diff] [blame] | 31 | int preempt_count; /* 0 => preemptable, <0 => BUG */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
| 33 | mm_segment_t addr_limit; /* thread address space: |
| 34 | 0-0xBFFFFFFF for user-thread |
| 35 | 0-0xFFFFFFFF for kernel-thread |
| 36 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
| 38 | __u8 supervisor_stack[0]; |
| 39 | }; |
| 40 | |
Richard Weinberger | 37f078f | 2015-04-03 18:20:58 +0200 | [diff] [blame] | 41 | #endif /* !__ASSEMBLY__ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
Thomas Gleixner | e6e9c54 | 2012-05-05 15:05:44 +0000 | [diff] [blame] | 43 | #define THREAD_SIZE (PAGE_SIZE << 1) |
| 44 | #define THREAD_SIZE_ORDER 1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | /* |
| 46 | * macros/functions for gaining access to the thread information structure |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | */ |
| 48 | #ifndef __ASSEMBLY__ |
| 49 | |
| 50 | #define INIT_THREAD_INFO(tsk) \ |
| 51 | { \ |
| 52 | .task = &tsk, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | .flags = 0, \ |
| 54 | .cpu = 0, \ |
Peter Zijlstra | c99e6ef | 2009-07-10 14:57:56 +0200 | [diff] [blame] | 55 | .preempt_count = INIT_PREEMPT_COUNT, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | .addr_limit = KERNEL_DS, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | } |
| 58 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | /* how to get the thread information struct from C */ |
| 60 | static inline struct thread_info *current_thread_info(void) |
| 61 | { |
| 62 | struct thread_info *ti; |
| 63 | |
| 64 | __asm__ __volatile__ ( |
| 65 | "ldi %0, #%1 \n\t" |
| 66 | "and %0, sp \n\t" |
| 67 | : "=r" (ti) : "i" (~(THREAD_SIZE - 1)) |
| 68 | ); |
| 69 | |
| 70 | return ti; |
| 71 | } |
| 72 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | #define TI_FLAG_FAULT_CODE_SHIFT 28 |
| 74 | |
| 75 | static inline void set_thread_fault_code(unsigned int val) |
| 76 | { |
| 77 | struct thread_info *ti = current_thread_info(); |
| 78 | ti->flags = (ti->flags & (~0 >> (32 - TI_FLAG_FAULT_CODE_SHIFT))) |
| 79 | | (val << TI_FLAG_FAULT_CODE_SHIFT); |
| 80 | } |
| 81 | |
| 82 | static inline unsigned int get_thread_fault_code(void) |
| 83 | { |
| 84 | struct thread_info *ti = current_thread_info(); |
| 85 | return ti->flags >> TI_FLAG_FAULT_CODE_SHIFT; |
| 86 | } |
| 87 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | #endif |
| 89 | |
| 90 | /* |
| 91 | * thread information flags |
| 92 | * - these are process state flags that various assembly files may need to access |
| 93 | * - pending work-to-be-done flags are in LSW |
| 94 | * - other flags in MSW |
| 95 | */ |
| 96 | #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ |
Stephane Eranian | a583f1b | 2007-07-31 00:38:00 -0700 | [diff] [blame] | 97 | #define TIF_SIGPENDING 1 /* signal pending */ |
| 98 | #define TIF_NEED_RESCHED 2 /* rescheduling necessary */ |
| 99 | #define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */ |
David Howells | d0420c8 | 2009-09-02 09:14:16 +0100 | [diff] [blame] | 100 | #define TIF_NOTIFY_RESUME 5 /* callback before returning to user */ |
Hirokazu Takata | c37a330 | 2007-09-12 17:51:35 +0900 | [diff] [blame] | 101 | #define TIF_RESTORE_SIGMASK 8 /* restore signal mask in do_signal() */ |
| 102 | #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */ |
Andreas Dilger | 0ddc932 | 2010-05-14 11:13:27 +0200 | [diff] [blame] | 103 | #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | |
| 105 | #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) |
| 107 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) |
| 108 | #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) |
David Howells | d0420c8 | 2009-09-02 09:14:16 +0100 | [diff] [blame] | 109 | #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) |
Hirokazu Takata | c37a330 | 2007-09-12 17:51:35 +0900 | [diff] [blame] | 110 | #define _TIF_USEDFPU (1<<TIF_USEDFPU) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | |
Al Viro | d70745b | 2012-05-31 22:25:28 -0400 | [diff] [blame] | 112 | #define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME) |
| 113 | #define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_SYSCALL_TRACE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
| 115 | /* |
| 116 | * Thread-synchronous status. |
| 117 | * |
| 118 | * This is different from the flags in that nobody else |
| 119 | * ever touches our thread-synchronous status, so we don't |
| 120 | * have to worry about atomic accesses. |
| 121 | */ |
| 122 | #define TS_USEDFPU 0x0001 /* FPU was used by this task this quantum (SMP) */ |
| 123 | |
| 124 | #endif /* __KERNEL__ */ |
| 125 | |
| 126 | #endif /* _ASM_M32R_THREAD_INFO_H */ |