18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (C) 2013 Altera Corporation
38c2ecf20Sopenharmony_ci * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
48c2ecf20Sopenharmony_ci * Copyright (C) 2004 Microtronix Datacom Ltd
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * based on m68k asm/processor.h
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
98c2ecf20Sopenharmony_ci * License.  See the file "COPYING" in the main directory of this archive
108c2ecf20Sopenharmony_ci * for more details.
118c2ecf20Sopenharmony_ci */
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#ifndef _ASM_NIOS2_PTRACE_H
148c2ecf20Sopenharmony_ci#define _ASM_NIOS2_PTRACE_H
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#include <uapi/asm/ptrace.h>
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci/* This struct defines the way the registers are stored on the
198c2ecf20Sopenharmony_ci   stack during a system call.  */
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
228c2ecf20Sopenharmony_cistruct pt_regs {
238c2ecf20Sopenharmony_ci	unsigned long  r8;	/* r8-r15 Caller-saved GP registers */
248c2ecf20Sopenharmony_ci	unsigned long  r9;
258c2ecf20Sopenharmony_ci	unsigned long  r10;
268c2ecf20Sopenharmony_ci	unsigned long  r11;
278c2ecf20Sopenharmony_ci	unsigned long  r12;
288c2ecf20Sopenharmony_ci	unsigned long  r13;
298c2ecf20Sopenharmony_ci	unsigned long  r14;
308c2ecf20Sopenharmony_ci	unsigned long  r15;
318c2ecf20Sopenharmony_ci	unsigned long  r1;	/* Assembler temporary */
328c2ecf20Sopenharmony_ci	unsigned long  r2;	/* Retval LS 32bits */
338c2ecf20Sopenharmony_ci	unsigned long  r3;	/* Retval MS 32bits */
348c2ecf20Sopenharmony_ci	unsigned long  r4;	/* r4-r7 Register arguments */
358c2ecf20Sopenharmony_ci	unsigned long  r5;
368c2ecf20Sopenharmony_ci	unsigned long  r6;
378c2ecf20Sopenharmony_ci	unsigned long  r7;
388c2ecf20Sopenharmony_ci	unsigned long  orig_r2;	/* Copy of r2 ?? */
398c2ecf20Sopenharmony_ci	unsigned long  ra;	/* Return address */
408c2ecf20Sopenharmony_ci	unsigned long  fp;	/* Frame pointer */
418c2ecf20Sopenharmony_ci	unsigned long  sp;	/* Stack pointer */
428c2ecf20Sopenharmony_ci	unsigned long  gp;	/* Global pointer */
438c2ecf20Sopenharmony_ci	unsigned long  estatus;
448c2ecf20Sopenharmony_ci	unsigned long  ea;	/* Exception return address (pc) */
458c2ecf20Sopenharmony_ci	unsigned long  orig_r7;
468c2ecf20Sopenharmony_ci};
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci/*
498c2ecf20Sopenharmony_ci * This is the extended stack used by signal handlers and the context
508c2ecf20Sopenharmony_ci * switcher: it's pushed after the normal "struct pt_regs".
518c2ecf20Sopenharmony_ci */
528c2ecf20Sopenharmony_cistruct switch_stack {
538c2ecf20Sopenharmony_ci	unsigned long  r16;	/* r16-r23 Callee-saved GP registers */
548c2ecf20Sopenharmony_ci	unsigned long  r17;
558c2ecf20Sopenharmony_ci	unsigned long  r18;
568c2ecf20Sopenharmony_ci	unsigned long  r19;
578c2ecf20Sopenharmony_ci	unsigned long  r20;
588c2ecf20Sopenharmony_ci	unsigned long  r21;
598c2ecf20Sopenharmony_ci	unsigned long  r22;
608c2ecf20Sopenharmony_ci	unsigned long  r23;
618c2ecf20Sopenharmony_ci	unsigned long  fp;
628c2ecf20Sopenharmony_ci	unsigned long  gp;
638c2ecf20Sopenharmony_ci	unsigned long  ra;
648c2ecf20Sopenharmony_ci};
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci#define user_mode(regs)	(((regs)->estatus & ESTATUS_EU))
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci#define instruction_pointer(regs)	((regs)->ra)
698c2ecf20Sopenharmony_ci#define profile_pc(regs)		instruction_pointer(regs)
708c2ecf20Sopenharmony_ci#define user_stack_pointer(regs)	((regs)->sp)
718c2ecf20Sopenharmony_ciextern void show_regs(struct pt_regs *);
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#define current_pt_regs() \
748c2ecf20Sopenharmony_ci	((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE)\
758c2ecf20Sopenharmony_ci		- 1)
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci#define force_successful_syscall_return() (current_pt_regs()->orig_r2 = -1)
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ciint do_syscall_trace_enter(void);
808c2ecf20Sopenharmony_civoid do_syscall_trace_exit(void);
818c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */
828c2ecf20Sopenharmony_ci#endif /* _ASM_NIOS2_PTRACE_H */
83