18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci// Copyright (C) 2005-2017 Andes Technology Corporation
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#ifndef __ASM_NDS32_PTRACE_H
58c2ecf20Sopenharmony_ci#define __ASM_NDS32_PTRACE_H
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include <uapi/asm/ptrace.h>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci/*
108c2ecf20Sopenharmony_ci * If pt_regs.syscallno == NO_SYSCALL, then the thread is not executing
118c2ecf20Sopenharmony_ci * a syscall -- i.e., its most recent entry into the kernel from
128c2ecf20Sopenharmony_ci * userspace was not via syscall, or otherwise a tracer cancelled the
138c2ecf20Sopenharmony_ci * syscall.
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci * This must have the value -1, for ABI compatibility with ptrace etc.
168c2ecf20Sopenharmony_ci */
178c2ecf20Sopenharmony_ci#define NO_SYSCALL (-1)
188c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
198c2ecf20Sopenharmony_ci#include <linux/types.h>
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_cistruct pt_regs {
228c2ecf20Sopenharmony_ci	union {
238c2ecf20Sopenharmony_ci		struct user_pt_regs user_regs;
248c2ecf20Sopenharmony_ci		struct {
258c2ecf20Sopenharmony_ci			long uregs[26];
268c2ecf20Sopenharmony_ci			long fp;
278c2ecf20Sopenharmony_ci			long gp;
288c2ecf20Sopenharmony_ci			long lp;
298c2ecf20Sopenharmony_ci			long sp;
308c2ecf20Sopenharmony_ci			long ipc;
318c2ecf20Sopenharmony_ci#if defined(CONFIG_HWZOL)
328c2ecf20Sopenharmony_ci			long lb;
338c2ecf20Sopenharmony_ci			long le;
348c2ecf20Sopenharmony_ci			long lc;
358c2ecf20Sopenharmony_ci#else
368c2ecf20Sopenharmony_ci			long dummy[3];
378c2ecf20Sopenharmony_ci#endif
388c2ecf20Sopenharmony_ci			long syscallno;
398c2ecf20Sopenharmony_ci		};
408c2ecf20Sopenharmony_ci	};
418c2ecf20Sopenharmony_ci	long orig_r0;
428c2ecf20Sopenharmony_ci	long ir0;
438c2ecf20Sopenharmony_ci	long ipsw;
448c2ecf20Sopenharmony_ci	long pipsw;
458c2ecf20Sopenharmony_ci	long pipc;
468c2ecf20Sopenharmony_ci	long pp0;
478c2ecf20Sopenharmony_ci	long pp1;
488c2ecf20Sopenharmony_ci	long fucop_ctl;
498c2ecf20Sopenharmony_ci	long osp;
508c2ecf20Sopenharmony_ci};
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_cistatic inline bool in_syscall(struct pt_regs const *regs)
538c2ecf20Sopenharmony_ci{
548c2ecf20Sopenharmony_ci	return regs->syscallno != NO_SYSCALL;
558c2ecf20Sopenharmony_ci}
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_cistatic inline void forget_syscall(struct pt_regs *regs)
588c2ecf20Sopenharmony_ci{
598c2ecf20Sopenharmony_ci	regs->syscallno = NO_SYSCALL;
608c2ecf20Sopenharmony_ci}
618c2ecf20Sopenharmony_cistatic inline unsigned long regs_return_value(struct pt_regs *regs)
628c2ecf20Sopenharmony_ci{
638c2ecf20Sopenharmony_ci	return regs->uregs[0];
648c2ecf20Sopenharmony_ci}
658c2ecf20Sopenharmony_ciextern void show_regs(struct pt_regs *);
668c2ecf20Sopenharmony_ci/* Avoid circular header include via sched.h */
678c2ecf20Sopenharmony_cistruct task_struct;
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci#define arch_has_single_step()		(1)
708c2ecf20Sopenharmony_ci#define user_mode(regs)			(((regs)->ipsw & PSW_mskPOM) == 0)
718c2ecf20Sopenharmony_ci#define interrupts_enabled(regs)	(!!((regs)->ipsw & PSW_mskGIE))
728c2ecf20Sopenharmony_ci#define user_stack_pointer(regs)	((regs)->sp)
738c2ecf20Sopenharmony_ci#define instruction_pointer(regs)	((regs)->ipc)
748c2ecf20Sopenharmony_ci#define profile_pc(regs) 		instruction_pointer(regs)
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */
778c2ecf20Sopenharmony_ci#endif
78