1*1583ca8aSDaniel Henrique Barboza /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
2*1583ca8aSDaniel Henrique Barboza /*
3*1583ca8aSDaniel Henrique Barboza  * Copyright (C) 2012 Regents of the University of California
4*1583ca8aSDaniel Henrique Barboza  */
5*1583ca8aSDaniel Henrique Barboza 
6*1583ca8aSDaniel Henrique Barboza #ifndef _ASM_RISCV_PTRACE_H
7*1583ca8aSDaniel Henrique Barboza #define _ASM_RISCV_PTRACE_H
8*1583ca8aSDaniel Henrique Barboza 
9*1583ca8aSDaniel Henrique Barboza #ifndef __ASSEMBLY__
10*1583ca8aSDaniel Henrique Barboza 
11*1583ca8aSDaniel Henrique Barboza #include <linux/types.h>
12*1583ca8aSDaniel Henrique Barboza 
13*1583ca8aSDaniel Henrique Barboza #define PTRACE_GETFDPIC		33
14*1583ca8aSDaniel Henrique Barboza 
15*1583ca8aSDaniel Henrique Barboza #define PTRACE_GETFDPIC_EXEC	0
16*1583ca8aSDaniel Henrique Barboza #define PTRACE_GETFDPIC_INTERP	1
17*1583ca8aSDaniel Henrique Barboza 
18*1583ca8aSDaniel Henrique Barboza /*
19*1583ca8aSDaniel Henrique Barboza  * User-mode register state for core dumps, ptrace, sigcontext
20*1583ca8aSDaniel Henrique Barboza  *
21*1583ca8aSDaniel Henrique Barboza  * This decouples struct pt_regs from the userspace ABI.
22*1583ca8aSDaniel Henrique Barboza  * struct user_regs_struct must form a prefix of struct pt_regs.
23*1583ca8aSDaniel Henrique Barboza  */
24*1583ca8aSDaniel Henrique Barboza struct user_regs_struct {
25*1583ca8aSDaniel Henrique Barboza 	unsigned long pc;
26*1583ca8aSDaniel Henrique Barboza 	unsigned long ra;
27*1583ca8aSDaniel Henrique Barboza 	unsigned long sp;
28*1583ca8aSDaniel Henrique Barboza 	unsigned long gp;
29*1583ca8aSDaniel Henrique Barboza 	unsigned long tp;
30*1583ca8aSDaniel Henrique Barboza 	unsigned long t0;
31*1583ca8aSDaniel Henrique Barboza 	unsigned long t1;
32*1583ca8aSDaniel Henrique Barboza 	unsigned long t2;
33*1583ca8aSDaniel Henrique Barboza 	unsigned long s0;
34*1583ca8aSDaniel Henrique Barboza 	unsigned long s1;
35*1583ca8aSDaniel Henrique Barboza 	unsigned long a0;
36*1583ca8aSDaniel Henrique Barboza 	unsigned long a1;
37*1583ca8aSDaniel Henrique Barboza 	unsigned long a2;
38*1583ca8aSDaniel Henrique Barboza 	unsigned long a3;
39*1583ca8aSDaniel Henrique Barboza 	unsigned long a4;
40*1583ca8aSDaniel Henrique Barboza 	unsigned long a5;
41*1583ca8aSDaniel Henrique Barboza 	unsigned long a6;
42*1583ca8aSDaniel Henrique Barboza 	unsigned long a7;
43*1583ca8aSDaniel Henrique Barboza 	unsigned long s2;
44*1583ca8aSDaniel Henrique Barboza 	unsigned long s3;
45*1583ca8aSDaniel Henrique Barboza 	unsigned long s4;
46*1583ca8aSDaniel Henrique Barboza 	unsigned long s5;
47*1583ca8aSDaniel Henrique Barboza 	unsigned long s6;
48*1583ca8aSDaniel Henrique Barboza 	unsigned long s7;
49*1583ca8aSDaniel Henrique Barboza 	unsigned long s8;
50*1583ca8aSDaniel Henrique Barboza 	unsigned long s9;
51*1583ca8aSDaniel Henrique Barboza 	unsigned long s10;
52*1583ca8aSDaniel Henrique Barboza 	unsigned long s11;
53*1583ca8aSDaniel Henrique Barboza 	unsigned long t3;
54*1583ca8aSDaniel Henrique Barboza 	unsigned long t4;
55*1583ca8aSDaniel Henrique Barboza 	unsigned long t5;
56*1583ca8aSDaniel Henrique Barboza 	unsigned long t6;
57*1583ca8aSDaniel Henrique Barboza };
58*1583ca8aSDaniel Henrique Barboza 
59*1583ca8aSDaniel Henrique Barboza struct __riscv_f_ext_state {
60*1583ca8aSDaniel Henrique Barboza 	__u32 f[32];
61*1583ca8aSDaniel Henrique Barboza 	__u32 fcsr;
62*1583ca8aSDaniel Henrique Barboza };
63*1583ca8aSDaniel Henrique Barboza 
64*1583ca8aSDaniel Henrique Barboza struct __riscv_d_ext_state {
65*1583ca8aSDaniel Henrique Barboza 	__u64 f[32];
66*1583ca8aSDaniel Henrique Barboza 	__u32 fcsr;
67*1583ca8aSDaniel Henrique Barboza };
68*1583ca8aSDaniel Henrique Barboza 
69*1583ca8aSDaniel Henrique Barboza struct __riscv_q_ext_state {
70*1583ca8aSDaniel Henrique Barboza 	__u64 f[64] __attribute__((aligned(16)));
71*1583ca8aSDaniel Henrique Barboza 	__u32 fcsr;
72*1583ca8aSDaniel Henrique Barboza 	/*
73*1583ca8aSDaniel Henrique Barboza 	 * Reserved for expansion of sigcontext structure.  Currently zeroed
74*1583ca8aSDaniel Henrique Barboza 	 * upon signal, and must be zero upon sigreturn.
75*1583ca8aSDaniel Henrique Barboza 	 */
76*1583ca8aSDaniel Henrique Barboza 	__u32 reserved[3];
77*1583ca8aSDaniel Henrique Barboza };
78*1583ca8aSDaniel Henrique Barboza 
79*1583ca8aSDaniel Henrique Barboza struct __riscv_ctx_hdr {
80*1583ca8aSDaniel Henrique Barboza 	__u32 magic;
81*1583ca8aSDaniel Henrique Barboza 	__u32 size;
82*1583ca8aSDaniel Henrique Barboza };
83*1583ca8aSDaniel Henrique Barboza 
84*1583ca8aSDaniel Henrique Barboza struct __riscv_extra_ext_header {
85*1583ca8aSDaniel Henrique Barboza 	__u32 __padding[129] __attribute__((aligned(16)));
86*1583ca8aSDaniel Henrique Barboza 	/*
87*1583ca8aSDaniel Henrique Barboza 	 * Reserved for expansion of sigcontext structure.  Currently zeroed
88*1583ca8aSDaniel Henrique Barboza 	 * upon signal, and must be zero upon sigreturn.
89*1583ca8aSDaniel Henrique Barboza 	 */
90*1583ca8aSDaniel Henrique Barboza 	__u32 reserved;
91*1583ca8aSDaniel Henrique Barboza 	struct __riscv_ctx_hdr hdr;
92*1583ca8aSDaniel Henrique Barboza };
93*1583ca8aSDaniel Henrique Barboza 
94*1583ca8aSDaniel Henrique Barboza union __riscv_fp_state {
95*1583ca8aSDaniel Henrique Barboza 	struct __riscv_f_ext_state f;
96*1583ca8aSDaniel Henrique Barboza 	struct __riscv_d_ext_state d;
97*1583ca8aSDaniel Henrique Barboza 	struct __riscv_q_ext_state q;
98*1583ca8aSDaniel Henrique Barboza };
99*1583ca8aSDaniel Henrique Barboza 
100*1583ca8aSDaniel Henrique Barboza struct __riscv_v_ext_state {
101*1583ca8aSDaniel Henrique Barboza 	unsigned long vstart;
102*1583ca8aSDaniel Henrique Barboza 	unsigned long vl;
103*1583ca8aSDaniel Henrique Barboza 	unsigned long vtype;
104*1583ca8aSDaniel Henrique Barboza 	unsigned long vcsr;
105*1583ca8aSDaniel Henrique Barboza 	unsigned long vlenb;
106*1583ca8aSDaniel Henrique Barboza 	void *datap;
107*1583ca8aSDaniel Henrique Barboza 	/*
108*1583ca8aSDaniel Henrique Barboza 	 * In signal handler, datap will be set a correct user stack offset
109*1583ca8aSDaniel Henrique Barboza 	 * and vector registers will be copied to the address of datap
110*1583ca8aSDaniel Henrique Barboza 	 * pointer.
111*1583ca8aSDaniel Henrique Barboza 	 */
112*1583ca8aSDaniel Henrique Barboza };
113*1583ca8aSDaniel Henrique Barboza 
114*1583ca8aSDaniel Henrique Barboza struct __riscv_v_regset_state {
115*1583ca8aSDaniel Henrique Barboza 	unsigned long vstart;
116*1583ca8aSDaniel Henrique Barboza 	unsigned long vl;
117*1583ca8aSDaniel Henrique Barboza 	unsigned long vtype;
118*1583ca8aSDaniel Henrique Barboza 	unsigned long vcsr;
119*1583ca8aSDaniel Henrique Barboza 	unsigned long vlenb;
120*1583ca8aSDaniel Henrique Barboza 	char vreg[];
121*1583ca8aSDaniel Henrique Barboza };
122*1583ca8aSDaniel Henrique Barboza 
123*1583ca8aSDaniel Henrique Barboza /*
124*1583ca8aSDaniel Henrique Barboza  * According to spec: The number of bits in a single vector register,
125*1583ca8aSDaniel Henrique Barboza  * VLEN >= ELEN, which must be a power of 2, and must be no greater than
126*1583ca8aSDaniel Henrique Barboza  * 2^16 = 65536bits = 8192bytes
127*1583ca8aSDaniel Henrique Barboza  */
128*1583ca8aSDaniel Henrique Barboza #define RISCV_MAX_VLENB (8192)
129*1583ca8aSDaniel Henrique Barboza 
130*1583ca8aSDaniel Henrique Barboza #endif /* __ASSEMBLY__ */
131*1583ca8aSDaniel Henrique Barboza 
132*1583ca8aSDaniel Henrique Barboza #endif /* _ASM_RISCV_PTRACE_H */
133