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 */
24 #define THREAD_SIZE_ORDER (2)
26 #define THREAD_SIZE_ORDER (1)
28 #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
32 #include <asm/processor.h>
35 typedef unsigned long mm_segment_t;
38 * low level task data that entry.S needs immediate access to
39 * - this struct should fit entirely inside of one cache line
40 * - if the members of this struct changes, the assembly constants
41 * in asm-offsets.c must be updated accordingly
42 * - thread_info is included in task_struct at an offset of 0. This means that
43 * tp points to both thread_info and task_struct.
46 unsigned long flags; /* low level flags */
47 int preempt_count; /* 0=>preemptible, <0=>BUG */
48 mm_segment_t addr_limit;
50 * These stack pointers are overwritten on every system call or
51 * exception. SP is also saved to the stack it can be recovered when
54 long kernel_sp; /* Kernel stack pointer */
55 long user_sp; /* User stack pointer */
60 * macros/functions for gaining access to the thread information structure
62 * preempt_count needs to be 1 initially, until the scheduler is functional.
64 #define INIT_THREAD_INFO(tsk) \
67 .preempt_count = INIT_PREEMPT_COUNT, \
68 .addr_limit = KERNEL_DS, \
71 #endif /* !__ASSEMBLY__ */
74 * thread information flags
75 * - these are process state flags that various assembly files may need to
77 * - pending work-to-be-done flags are in lowest half-word
78 * - other flags in upper half-word(s)
80 #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
81 #define TIF_NOTIFY_RESUME 1 /* callback before returning to user */
82 #define TIF_SIGPENDING 2 /* signal pending */
83 #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
84 #define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */
85 #define TIF_MEMDIE 5 /* is terminating due to OOM killer */
86 #define TIF_SYSCALL_TRACEPOINT 6 /* syscall tracepoint instrumentation */
88 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
89 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
90 #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
91 #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
93 #define _TIF_WORK_MASK \
94 (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | _TIF_NEED_RESCHED)
96 #endif /* _ASM_RISCV_THREAD_INFO_H */