18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci* Copyright (C) 2020 Loongson Technology Corporation Limited
48c2ecf20Sopenharmony_ci*
58c2ecf20Sopenharmony_ci* Author: Hanlu Li <lihanlu@loongson.cn>
68c2ecf20Sopenharmony_ci*         Huacai Chen <chenhuacai@loongson.cn>
78c2ecf20Sopenharmony_ci*/
88c2ecf20Sopenharmony_ci#ifndef _UAPI_ASM_PTRACE_H
98c2ecf20Sopenharmony_ci#define _UAPI_ASM_PTRACE_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/types.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#ifndef __KERNEL__
148c2ecf20Sopenharmony_ci#include <stdint.h>
158c2ecf20Sopenharmony_ci#endif
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci/*
188c2ecf20Sopenharmony_ci * For PTRACE_{POKE,PEEK}USR. 0 - 31 are GPRs,
198c2ecf20Sopenharmony_ci * 32 is syscall's original ARG0, 33 is PC, 34 is BADVADDR.
208c2ecf20Sopenharmony_ci */
218c2ecf20Sopenharmony_ci#define GPR_BASE	0
228c2ecf20Sopenharmony_ci#define GPR_NUM		32
238c2ecf20Sopenharmony_ci#define GPR_END		(GPR_BASE + GPR_NUM - 1)
248c2ecf20Sopenharmony_ci#define ARG0		(GPR_END + 1)
258c2ecf20Sopenharmony_ci#define PC		(GPR_END + 2)
268c2ecf20Sopenharmony_ci#define BADVADDR	(GPR_END + 3)
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define NUM_FPU_REGS	32
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_cistruct user_pt_regs {
318c2ecf20Sopenharmony_ci	/* Main processor registers. */
328c2ecf20Sopenharmony_ci	unsigned long regs[32];
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci	/* Original syscall arg0. */
358c2ecf20Sopenharmony_ci	unsigned long orig_a0;
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci	/* Special CSR registers. */
388c2ecf20Sopenharmony_ci	unsigned long csr_era;
398c2ecf20Sopenharmony_ci	unsigned long csr_badv;
408c2ecf20Sopenharmony_ci	unsigned long reserved[10];
418c2ecf20Sopenharmony_ci} __attribute__((aligned(8)));
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_cistruct user_fp_state {
448c2ecf20Sopenharmony_ci	uint64_t fpr[32];
458c2ecf20Sopenharmony_ci	uint64_t fcc;
468c2ecf20Sopenharmony_ci	uint32_t fcsr;
478c2ecf20Sopenharmony_ci};
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_cistruct user_lsx_state {
508c2ecf20Sopenharmony_ci	/* 32 registers, 128 bits width per register. */
518c2ecf20Sopenharmony_ci	uint64_t vregs[32*2];
528c2ecf20Sopenharmony_ci};
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_cistruct user_lasx_state {
558c2ecf20Sopenharmony_ci	/* 32 registers, 256 bits width per register. */
568c2ecf20Sopenharmony_ci	uint64_t vregs[32*4];
578c2ecf20Sopenharmony_ci};
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci/*
608c2ecf20Sopenharmony_ci * This structure definition saves the LBT data structure,
618c2ecf20Sopenharmony_ci * the data comes from the task_struct structure, format is as follows:
628c2ecf20Sopenharmony_ci * regs[0]: thread.lbt.scr0
638c2ecf20Sopenharmony_ci * regs[1]: thread.lbt.scr1
648c2ecf20Sopenharmony_ci * regs[2]: thread.lbt.scr2
658c2ecf20Sopenharmony_ci * regs[3]: thread.lbt.scr3
668c2ecf20Sopenharmony_ci * regs[4]: thread.lbt.eflags
678c2ecf20Sopenharmony_ci * regs[5]: thread.fpu.ftop
688c2ecf20Sopenharmony_ci */
698c2ecf20Sopenharmony_cistruct user_lbt_state {
708c2ecf20Sopenharmony_ci	uint64_t regs[6];
718c2ecf20Sopenharmony_ci};
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci/* Read and write watchpoint registers.	 */
748c2ecf20Sopenharmony_ci#define NUM_WATCH_REGS 16
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_cienum pt_watch_style {
778c2ecf20Sopenharmony_ci	pt_watch_style_la32,
788c2ecf20Sopenharmony_ci	pt_watch_style_la64
798c2ecf20Sopenharmony_ci};
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_cistruct la32_watch_regs {
828c2ecf20Sopenharmony_ci	uint32_t addr;
838c2ecf20Sopenharmony_ci	uint32_t mask;
848c2ecf20Sopenharmony_ci	/* irw/irwsta/irwmask I R W bits.
858c2ecf20Sopenharmony_ci	 * bit 0 -- 1 if W bit is usable.
868c2ecf20Sopenharmony_ci	 * bit 1 -- 1 if R bit is usable.
878c2ecf20Sopenharmony_ci	 * bit 2 -- 1 if I bit is usable.
888c2ecf20Sopenharmony_ci	 */
898c2ecf20Sopenharmony_ci	uint8_t irw;
908c2ecf20Sopenharmony_ci	uint8_t irwstat;
918c2ecf20Sopenharmony_ci	uint8_t irwmask;
928c2ecf20Sopenharmony_ci} __attribute__((aligned(8)));
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_cistruct la64_watch_regs {
958c2ecf20Sopenharmony_ci	uint64_t addr;
968c2ecf20Sopenharmony_ci	uint64_t mask;
978c2ecf20Sopenharmony_ci	/* irw/irwsta/irwmask I R W bits.
988c2ecf20Sopenharmony_ci	 * bit 0 -- 1 if W bit is usable.
998c2ecf20Sopenharmony_ci	 * bit 1 -- 1 if R bit is usable.
1008c2ecf20Sopenharmony_ci	 * bit 2 -- 1 if I bit is usable.
1018c2ecf20Sopenharmony_ci	 */
1028c2ecf20Sopenharmony_ci	uint8_t irw;
1038c2ecf20Sopenharmony_ci	uint8_t irwstat;
1048c2ecf20Sopenharmony_ci	uint8_t irwmask;
1058c2ecf20Sopenharmony_ci} __attribute__((aligned(8)));
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_cistruct pt_watch_regs {
1088c2ecf20Sopenharmony_ci	int16_t max_valid;
1098c2ecf20Sopenharmony_ci	int16_t num_valid;
1108c2ecf20Sopenharmony_ci	enum pt_watch_style style;
1118c2ecf20Sopenharmony_ci	union {
1128c2ecf20Sopenharmony_ci		struct la32_watch_regs la32[NUM_WATCH_REGS];
1138c2ecf20Sopenharmony_ci		struct la64_watch_regs la64[NUM_WATCH_REGS];
1148c2ecf20Sopenharmony_ci	};
1158c2ecf20Sopenharmony_ci};
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci#define PTRACE_SYSEMU			0x1f
1188c2ecf20Sopenharmony_ci#define PTRACE_SYSEMU_SINGLESTEP	0x20
1198c2ecf20Sopenharmony_ci#define PTRACE_GET_WATCH_REGS		0xd0
1208c2ecf20Sopenharmony_ci#define PTRACE_SET_WATCH_REGS		0xd1
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci/* Watch irw/irwmask/irwstat bit definitions */
1238c2ecf20Sopenharmony_ci#define LA_WATCH_W		(1 << 0)
1248c2ecf20Sopenharmony_ci#define LA_WATCH_R		(1 << 1)
1258c2ecf20Sopenharmony_ci#define LA_WATCH_I		(1 << 2)
1268c2ecf20Sopenharmony_ci#define LA_WATCH_IRW	(LA_WATCH_W | LA_WATCH_R | LA_WATCH_I)
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci#endif /* _UAPI_ASM_PTRACE_H */
129