.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2012 Regents of the University of California |
---|
3 | | - * |
---|
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. |
---|
7 | | - * |
---|
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. |
---|
12 | 4 | */ |
---|
13 | 5 | |
---|
14 | 6 | #ifndef _ASM_RISCV_PTRACE_H |
---|
.. | .. |
---|
20 | 12 | #ifndef __ASSEMBLY__ |
---|
21 | 13 | |
---|
22 | 14 | struct pt_regs { |
---|
23 | | - unsigned long sepc; |
---|
| 15 | + unsigned long epc; |
---|
24 | 16 | unsigned long ra; |
---|
25 | 17 | unsigned long sp; |
---|
26 | 18 | unsigned long gp; |
---|
.. | .. |
---|
52 | 44 | unsigned long t4; |
---|
53 | 45 | unsigned long t5; |
---|
54 | 46 | 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; |
---|
| 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; |
---|
61 | 53 | }; |
---|
62 | 54 | |
---|
63 | 55 | #ifdef CONFIG_64BIT |
---|
.. | .. |
---|
66 | 58 | #define REG_FMT "%08lx" |
---|
67 | 59 | #endif |
---|
68 | 60 | |
---|
69 | | -#define user_mode(regs) (((regs)->sstatus & SR_SPP) == 0) |
---|
| 61 | +#define user_mode(regs) (((regs)->status & SR_PP) == 0) |
---|
70 | 62 | |
---|
71 | 63 | |
---|
72 | 64 | /* Helpers for working with the instruction pointer */ |
---|
73 | | -#define GET_IP(regs) ((regs)->sepc) |
---|
74 | | -#define SET_IP(regs, val) (GET_IP(regs) = (val)) |
---|
75 | | - |
---|
76 | 65 | static inline unsigned long instruction_pointer(struct pt_regs *regs) |
---|
77 | 66 | { |
---|
78 | | - return GET_IP(regs); |
---|
| 67 | + return regs->epc; |
---|
79 | 68 | } |
---|
80 | 69 | static inline void instruction_pointer_set(struct pt_regs *regs, |
---|
81 | 70 | unsigned long val) |
---|
82 | 71 | { |
---|
83 | | - SET_IP(regs, val); |
---|
| 72 | + regs->epc = val; |
---|
84 | 73 | } |
---|
85 | 74 | |
---|
86 | 75 | #define profile_pc(regs) instruction_pointer(regs) |
---|
87 | 76 | |
---|
88 | 77 | /* 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)) |
---|
91 | | - |
---|
92 | 78 | static inline unsigned long user_stack_pointer(struct pt_regs *regs) |
---|
93 | 79 | { |
---|
94 | | - return GET_USP(regs); |
---|
| 80 | + return regs->sp; |
---|
95 | 81 | } |
---|
96 | 82 | static inline void user_stack_pointer_set(struct pt_regs *regs, |
---|
97 | 83 | unsigned long val) |
---|
98 | 84 | { |
---|
99 | | - SET_USP(regs, val); |
---|
| 85 | + regs->sp = val; |
---|
100 | 86 | } |
---|
101 | 87 | |
---|
102 | 88 | /* Helpers for working with the frame pointer */ |
---|
103 | | -#define GET_FP(regs) ((regs)->s0) |
---|
104 | | -#define SET_FP(regs, val) (GET_FP(regs) = (val)) |
---|
105 | | - |
---|
106 | 89 | static inline unsigned long frame_pointer(struct pt_regs *regs) |
---|
107 | 90 | { |
---|
108 | | - return GET_FP(regs); |
---|
| 91 | + return regs->s0; |
---|
109 | 92 | } |
---|
110 | 93 | static inline void frame_pointer_set(struct pt_regs *regs, |
---|
111 | 94 | unsigned long val) |
---|
112 | 95 | { |
---|
113 | | - SET_FP(regs, val); |
---|
| 96 | + regs->s0 = val; |
---|
| 97 | +} |
---|
| 98 | + |
---|
| 99 | +static inline unsigned long regs_return_value(struct pt_regs *regs) |
---|
| 100 | +{ |
---|
| 101 | + return regs->a0; |
---|
114 | 102 | } |
---|
115 | 103 | |
---|
116 | 104 | #endif /* __ASSEMBLY__ */ |
---|