Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / riscv / include / asm / ptrace.h
blob2c5df945d43c9abfdfd197a61d8c92ce20e48133
1 /*
2 * Copyright (C) 2012 Regents of the University of California
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #ifndef _ASM_RISCV_PTRACE_H
15 #define _ASM_RISCV_PTRACE_H
17 #include <uapi/asm/ptrace.h>
18 #include <asm/csr.h>
20 #ifndef __ASSEMBLY__
22 struct pt_regs {
23 unsigned long sepc;
24 unsigned long ra;
25 unsigned long sp;
26 unsigned long gp;
27 unsigned long tp;
28 unsigned long t0;
29 unsigned long t1;
30 unsigned long t2;
31 unsigned long s0;
32 unsigned long s1;
33 unsigned long a0;
34 unsigned long a1;
35 unsigned long a2;
36 unsigned long a3;
37 unsigned long a4;
38 unsigned long a5;
39 unsigned long a6;
40 unsigned long a7;
41 unsigned long s2;
42 unsigned long s3;
43 unsigned long s4;
44 unsigned long s5;
45 unsigned long s6;
46 unsigned long s7;
47 unsigned long s8;
48 unsigned long s9;
49 unsigned long s10;
50 unsigned long s11;
51 unsigned long t3;
52 unsigned long t4;
53 unsigned long t5;
54 unsigned long t6;
55 /* Supervisor CSRs */
56 unsigned long sstatus;
57 unsigned long sbadaddr;
58 unsigned long scause;
59 /* a0 value before the syscall */
60 unsigned long orig_a0;
63 #ifdef CONFIG_64BIT
64 #define REG_FMT "%016lx"
65 #else
66 #define REG_FMT "%08lx"
67 #endif
69 #define user_mode(regs) (((regs)->sstatus & SR_SPP) == 0)
72 /* Helpers for working with the instruction pointer */
73 #define GET_IP(regs) ((regs)->sepc)
74 #define SET_IP(regs, val) (GET_IP(regs) = (val))
76 static inline unsigned long instruction_pointer(struct pt_regs *regs)
78 return GET_IP(regs);
80 static inline void instruction_pointer_set(struct pt_regs *regs,
81 unsigned long val)
83 SET_IP(regs, val);
86 #define profile_pc(regs) instruction_pointer(regs)
88 /* Helpers for working with the user stack pointer */
89 #define GET_USP(regs) ((regs)->sp)
90 #define SET_USP(regs, val) (GET_USP(regs) = (val))
92 static inline unsigned long user_stack_pointer(struct pt_regs *regs)
94 return GET_USP(regs);
96 static inline void user_stack_pointer_set(struct pt_regs *regs,
97 unsigned long val)
99 SET_USP(regs, val);
102 /* Helpers for working with the frame pointer */
103 #define GET_FP(regs) ((regs)->s0)
104 #define SET_FP(regs, val) (GET_FP(regs) = (val))
106 static inline unsigned long frame_pointer(struct pt_regs *regs)
108 return GET_FP(regs);
110 static inline void frame_pointer_set(struct pt_regs *regs,
111 unsigned long val)
113 SET_FP(regs, val);
116 #endif /* __ASSEMBLY__ */
118 #endif /* _ASM_RISCV_PTRACE_H */