#ifndef _M68K_PTRACE_H
#define _M68K_PTRACE_H

#define PT_D1	   0
#define PT_D2	   1
#define PT_D3	   2
#define PT_D4	   3
#define PT_D5	   4
#define PT_D6	   5
#define PT_D7	   6
#define PT_A0	   7
#define PT_A1	   8
#define PT_A2	   9
#define PT_A3	   10
#define PT_A4	   11
#define PT_A5	   12
#define PT_A6	   13
#define PT_D0	   14
#define PT_USP	   15
#define PT_ORIG_D0 16
#define PT_SR	   17
#define PT_PC	   18


/* this struct defines the way the registers are stored on the
   stack during a system call. */

struct pt_regs {
  long	d1;
  long	d2;
  long	d3;
  long	d4;
  long	d5;
  long	d6;
  long	d7;
  long	a0;
  long	a1;
  long	a2;
  long	a3;
  long	a4;
  long	a5;
  long	a6;
  long	d0;
  long	usp;
  long	orig_d0;
  short stkadj;
  short sr;
  long	pc;
  short fmtvec;
  short __fill;			/* to make it longword aligned */
};

#ifdef __KERNEL__

#ifndef PS_S
#define PS_S  (0x2000)
#define PS_M  (0x1000)
#endif

/* The only place this is called from arch-independent code is do_timer(); so
 * assume 'regs' points to a struct intframe */
#ifdef MASTER_STACK
#define user_mode(regs)														  \
	({	/* 'regs' really points to an int frame */							  \
		struct intframe *r = (struct intframe *)(regs);						  \
		if (r->format == 1)													  \
			/* in a throwaway stack frame, the S bit is always set, use frame \
			 * on the msp instead */										  \
			__asm__ __volatile__ ( "movec %/msp,%0" : "=d" (r) : );			  \
		!(r->sr & PS_S);													  \
	})
#else
#define user_mode(regs)														  \
	({	/* 'regs' really points to an int frame */							  \
		struct intframe *r = (struct intframe *)(regs);						  \
		!(r->sr & PS_S);													  \
	})
#endif

/* "Real" definition of user_mode(), working on struct pt_regs */
#define pt_user_mode(regs) (!((regs)->sr & PS_S))

/* called by do_timer(), so 'regs' is struct intframe */
#define instruction_pointer(regs) (((struct intframe *)regs)->pc)

extern void show_regs(struct pt_regs *);

#endif

#endif /* _M68K_PTRACE_H */
