1 /* 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 5 * 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. 9 * 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. 14 */ 15 16 #ifndef _ASM_RISCV_THREAD_INFO_H 17 #define _ASM_RISCV_THREAD_INFO_H 18 19 #include <asm/page.h> 20 #include <linux/const.h> 21 22 /* thread information allocation */ 23 #define THREAD_SIZE_ORDER (1) 24 #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) 25 26 #ifndef __ASSEMBLY__ 27 28 #include <asm/processor.h> 29 #include <asm/csr.h> 30 31 typedef unsigned long mm_segment_t; 32 33 /* 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. 40 */ 41 struct thread_info { 42 unsigned long flags; /* low level flags */ 43 int preempt_count; /* 0=>preemptible, <0=>BUG */ 44 mm_segment_t addr_limit; 45 /* 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 48 * overwritten. 49 */ 50 long kernel_sp; /* Kernel stack pointer */ 51 long user_sp; /* User stack pointer */ 52 int cpu; 53 }; 54 55 /* 56 * macros/functions for gaining access to the thread information structure 57 * 58 * preempt_count needs to be 1 initially, until the scheduler is functional. 59 */ 60 #define INIT_THREAD_INFO(tsk) \ 61 { \ 62 .flags = 0, \ 63 .preempt_count = INIT_PREEMPT_COUNT, \ 64 .addr_limit = KERNEL_DS, \ 65 } 66 67 #endif /* !__ASSEMBLY__ */ 68 69 /* 70 * thread information flags 71 * - these are process state flags that various assembly files may need to 72 * access 73 * - pending work-to-be-done flags are in lowest half-word 74 * - other flags in upper half-word(s) 75 */ 76 #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 77 #define TIF_NOTIFY_RESUME 1 /* callback before returning to user */ 78 #define TIF_SIGPENDING 2 /* signal pending */ 79 #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 80 #define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */ 81 #define TIF_MEMDIE 5 /* is terminating due to OOM killer */ 82 #define TIF_SYSCALL_TRACEPOINT 6 /* syscall tracepoint instrumentation */ 83 84 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 85 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) 86 #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 87 #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) 88 89 #define _TIF_WORK_MASK \ 90 (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | _TIF_NEED_RESCHED) 91 92 #endif /* _ASM_RISCV_THREAD_INFO_H */ 93