162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Copyright (C) 2013 Altera Corporation 362306a36Sopenharmony_ci * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch> 462306a36Sopenharmony_ci * Copyright (C) 2004 Microtronix Datacom Ltd 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * based on m68k asm/processor.h 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 962306a36Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 1062306a36Sopenharmony_ci * for more details. 1162306a36Sopenharmony_ci */ 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#ifndef _ASM_NIOS2_PTRACE_H 1462306a36Sopenharmony_ci#define _ASM_NIOS2_PTRACE_H 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci#include <uapi/asm/ptrace.h> 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci/* This struct defines the way the registers are stored on the 1962306a36Sopenharmony_ci stack during a system call. */ 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 2262306a36Sopenharmony_cistruct pt_regs { 2362306a36Sopenharmony_ci unsigned long r8; /* r8-r15 Caller-saved GP registers */ 2462306a36Sopenharmony_ci unsigned long r9; 2562306a36Sopenharmony_ci unsigned long r10; 2662306a36Sopenharmony_ci unsigned long r11; 2762306a36Sopenharmony_ci unsigned long r12; 2862306a36Sopenharmony_ci unsigned long r13; 2962306a36Sopenharmony_ci unsigned long r14; 3062306a36Sopenharmony_ci unsigned long r15; 3162306a36Sopenharmony_ci unsigned long r1; /* Assembler temporary */ 3262306a36Sopenharmony_ci unsigned long r2; /* Retval LS 32bits */ 3362306a36Sopenharmony_ci unsigned long r3; /* Retval MS 32bits */ 3462306a36Sopenharmony_ci unsigned long r4; /* r4-r7 Register arguments */ 3562306a36Sopenharmony_ci unsigned long r5; 3662306a36Sopenharmony_ci unsigned long r6; 3762306a36Sopenharmony_ci unsigned long r7; 3862306a36Sopenharmony_ci unsigned long orig_r2; /* Copy of r2 ?? */ 3962306a36Sopenharmony_ci unsigned long ra; /* Return address */ 4062306a36Sopenharmony_ci unsigned long fp; /* Frame pointer */ 4162306a36Sopenharmony_ci unsigned long sp; /* Stack pointer */ 4262306a36Sopenharmony_ci unsigned long gp; /* Global pointer */ 4362306a36Sopenharmony_ci unsigned long estatus; 4462306a36Sopenharmony_ci unsigned long ea; /* Exception return address (pc) */ 4562306a36Sopenharmony_ci unsigned long orig_r7; 4662306a36Sopenharmony_ci}; 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci/* 4962306a36Sopenharmony_ci * This is the extended stack used by signal handlers and the context 5062306a36Sopenharmony_ci * switcher: it's pushed after the normal "struct pt_regs". 5162306a36Sopenharmony_ci */ 5262306a36Sopenharmony_cistruct switch_stack { 5362306a36Sopenharmony_ci unsigned long r16; /* r16-r23 Callee-saved GP registers */ 5462306a36Sopenharmony_ci unsigned long r17; 5562306a36Sopenharmony_ci unsigned long r18; 5662306a36Sopenharmony_ci unsigned long r19; 5762306a36Sopenharmony_ci unsigned long r20; 5862306a36Sopenharmony_ci unsigned long r21; 5962306a36Sopenharmony_ci unsigned long r22; 6062306a36Sopenharmony_ci unsigned long r23; 6162306a36Sopenharmony_ci unsigned long fp; 6262306a36Sopenharmony_ci unsigned long gp; 6362306a36Sopenharmony_ci unsigned long ra; 6462306a36Sopenharmony_ci}; 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci#define user_mode(regs) (((regs)->estatus & ESTATUS_EU)) 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci#define instruction_pointer(regs) ((regs)->ra) 6962306a36Sopenharmony_ci#define profile_pc(regs) instruction_pointer(regs) 7062306a36Sopenharmony_ci#define user_stack_pointer(regs) ((regs)->sp) 7162306a36Sopenharmony_ciextern void show_regs(struct pt_regs *); 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci#define current_pt_regs() \ 7462306a36Sopenharmony_ci ((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE)\ 7562306a36Sopenharmony_ci - 1) 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci#define force_successful_syscall_return() (current_pt_regs()->orig_r2 = -1) 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ciint do_syscall_trace_enter(void); 8062306a36Sopenharmony_civoid do_syscall_trace_exit(void); 8162306a36Sopenharmony_ci#endif /* __ASSEMBLY__ */ 8262306a36Sopenharmony_ci#endif /* _ASM_NIOS2_PTRACE_H */ 83