Merge tag 'sched-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / riscv / include / asm / ptrace.h
blobee49f80c95337f948a3e6fbbb3b42fc20b8709a1
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (C) 2012 Regents of the University of California
4 */
6 #ifndef _ASM_RISCV_PTRACE_H
7 #define _ASM_RISCV_PTRACE_H
9 #include <uapi/asm/ptrace.h>
10 #include <asm/csr.h>
12 #ifndef __ASSEMBLY__
14 struct pt_regs {
15 unsigned long epc;
16 unsigned long ra;
17 unsigned long sp;
18 unsigned long gp;
19 unsigned long tp;
20 unsigned long t0;
21 unsigned long t1;
22 unsigned long t2;
23 unsigned long s0;
24 unsigned long s1;
25 unsigned long a0;
26 unsigned long a1;
27 unsigned long a2;
28 unsigned long a3;
29 unsigned long a4;
30 unsigned long a5;
31 unsigned long a6;
32 unsigned long a7;
33 unsigned long s2;
34 unsigned long s3;
35 unsigned long s4;
36 unsigned long s5;
37 unsigned long s6;
38 unsigned long s7;
39 unsigned long s8;
40 unsigned long s9;
41 unsigned long s10;
42 unsigned long s11;
43 unsigned long t3;
44 unsigned long t4;
45 unsigned long t5;
46 unsigned long t6;
47 /* Supervisor/Machine CSRs */
48 unsigned long status;
49 unsigned long badaddr;
50 unsigned long cause;
51 /* a0 value before the syscall */
52 unsigned long orig_a0;
55 #ifdef CONFIG_64BIT
56 #define REG_FMT "%016lx"
57 #else
58 #define REG_FMT "%08lx"
59 #endif
61 #define user_mode(regs) (((regs)->status & SR_PP) == 0)
64 /* Helpers for working with the instruction pointer */
65 static inline unsigned long instruction_pointer(struct pt_regs *regs)
67 return regs->epc;
69 static inline void instruction_pointer_set(struct pt_regs *regs,
70 unsigned long val)
72 regs->epc = val;
75 #define profile_pc(regs) instruction_pointer(regs)
77 /* Helpers for working with the user stack pointer */
78 static inline unsigned long user_stack_pointer(struct pt_regs *regs)
80 return regs->sp;
82 static inline void user_stack_pointer_set(struct pt_regs *regs,
83 unsigned long val)
85 regs->sp = val;
88 /* Helpers for working with the frame pointer */
89 static inline unsigned long frame_pointer(struct pt_regs *regs)
91 return regs->s0;
93 static inline void frame_pointer_set(struct pt_regs *regs,
94 unsigned long val)
96 regs->s0 = val;
99 static inline unsigned long regs_return_value(struct pt_regs *regs)
101 return regs->a0;
104 #endif /* __ASSEMBLY__ */
106 #endif /* _ASM_RISCV_PTRACE_H */