2 * Copyright (C) 2009 Chen Liqin <liqin.chen@sunplusct.com>
3 * Copyright (C) 2012 Regents of the University of California
4 * Copyright (C) 2017 SiFive
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation, version 2.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #ifndef _ASM_RISCV_THREAD_INFO_H
17 #define _ASM_RISCV_THREAD_INFO_H
20 #include <linux/const.h>
22 /* thread information allocation */
23 #define THREAD_SIZE_ORDER (1)
24 #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
28 #include <asm/processor.h>
31 typedef unsigned long mm_segment_t;
34 * low level task data that entry.S needs immediate access to
35 * - this struct should fit entirely inside of one cache line
36 * - if the members of this struct changes, the assembly constants
37 * in asm-offsets.c must be updated accordingly
38 * - thread_info is included in task_struct at an offset of 0. This means that
39 * tp points to both thread_info and task_struct.
42 unsigned long flags; /* low level flags */
43 int preempt_count; /* 0=>preemptible, <0=>BUG */
44 mm_segment_t addr_limit;
46 * These stack pointers are overwritten on every system call or
47 * exception. SP is also saved to the stack it can be recovered when
50 long kernel_sp; /* Kernel stack pointer */
51 long user_sp; /* User stack pointer */
56 * macros/functions for gaining access to the thread information structure
58 * preempt_count needs to be 1 initially, until the scheduler is functional.
60 #define INIT_THREAD_INFO(tsk) \
63 .preempt_count = INIT_PREEMPT_COUNT, \
64 .addr_limit = KERNEL_DS, \
67 #define init_stack (init_thread_union.stack)
69 #endif /* !__ASSEMBLY__ */
72 * thread information flags
73 * - these are process state flags that various assembly files may need to
75 * - pending work-to-be-done flags are in lowest half-word
76 * - other flags in upper half-word(s)
78 #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
79 #define TIF_NOTIFY_RESUME 1 /* callback before returning to user */
80 #define TIF_SIGPENDING 2 /* signal pending */
81 #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
82 #define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */
83 #define TIF_MEMDIE 5 /* is terminating due to OOM killer */
84 #define TIF_SYSCALL_TRACEPOINT 6 /* syscall tracepoint instrumentation */
86 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
87 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
88 #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
89 #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
91 #define _TIF_WORK_MASK \
92 (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | _TIF_NEED_RESCHED)
94 #endif /* _ASM_RISCV_THREAD_INFO_H */