#ifndef _ASM_BSP_PTRACE_H_
#define _ASM_BSP_PTRACE_H_

#include <libdev/etiContext.h>

#ifdef __KERNEL__
typedef struct pt_regs {
    ctxContext  ctx;
} pt_regs;
#endif 

/* ptrace offsets for ctxExceptionContext (used by gdb) */
#define PT_EXC_OFFSET(_x_) ((unsigned)(&((ctxExceptionContext *)0)->_x_) >> 2)

/* shared system regs */
#define PT_SYS_TYPE    PT_EXC_OFFSET(header.u.s.type)
#define PT_SYS_PSW     PT_EXC_OFFSET(header.u.s.psw)
#define PT_SYS_PSE     PT_EXC_OFFSET(pse)
#define PT_SYS_EPCR0   PT_EXC_OFFSET(epcr0)
#define PT_SYS_EPCR1   PT_EXC_OFFSET(epcr1)
#define PT_SYS_EPCR2   PT_EXC_OFFSET(epcr2)
#define PT_SYS_EXCSP   PT_EXC_OFFSET(excSP)
#define PT_SYS_NONNMI  PT_EXC_OFFSET(nonNmi)

/* cluster general regs */
#define PT_CL0R0       PT_EXC_OFFSET(cl[0].r0)
#define PT_CL1R0       PT_EXC_OFFSET(cl[1].r0)
/* cluster plc/plv regs */
#define PT_CL0PLC      PT_EXC_OFFSET(cl[0].plc0[0])
#define PT_CL1PLC      PT_EXC_OFFSET(cl[1].plc0[0])
/* cluster system regs */
#define PT_CL0_SYS     PT_EXC_OFFSET(cl[0].ccr)
#define PT_CL1_SYS     PT_EXC_OFFSET(cl[1].ccr)

/* context offsets for etiSyscallContext.  Used by strace() */
#define PT_SYSCALL_OFFSET(_x_) ((unsigned)(&((ctxSyscallContext *)0)->_x_)>> 2)
#define PT_SYSCALL_ARG0   PT_SYSCALL_OFFSET(a0)
#define PT_SYSCALL_NUM    PT_SYSCALL_OFFSET(function_code)
#define PT_SYSCALL_RESULT PT_SYSCALL_OFFSET(result)
#define PT_SYSCALL_EPCR0  PT_SYSCALL_OFFSET(epcr0)

/* offsets for debug/breakpoint registers */
#define PT_DBG_BASE (sizeof(ctxContext) + 1)
#define PT_DBG_ASID    (PT_DBG_BASE + 0)
#define PT_DBG_EER     (PT_DBG_BASE + 1)
#define PT_DBG_IBRKA   (PT_DBG_BASE + 2)
#define PT_DBG_IBRKMSK (PT_DBG_BASE + 3)
#define PT_DBG_DBRKA   (PT_DBG_BASE + 4)
#define PT_DBG_DBRKMSK (PT_DBG_BASE + 5)
#define PT_DBG_CL0CEER (PT_DBG_BASE + 6)
#define PT_DBG_CL1CEER (PT_DBG_BASE + 7)
#define PT_DBG_MAX     PT_DBG_CL1CEER

#endif /* _ASM_BSP_PTRACE_H_ */
