blob: 201d11ef211f1311152e911b10ff13ff6fff155b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __ASM_SH_PTRACE_H
2#define __ASM_SH_PTRACE_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004/*
5 * Copyright (C) 1999, 2000 Niibe Yutaka
6 *
7 */
Adrian Bunkf22ab812008-07-25 01:47:34 -07008#if defined(__SH5__)
Paul Mundt33f242e2007-11-09 16:57:27 +09009struct pt_regs {
10 unsigned long long pc;
11 unsigned long long sr;
Paul Mundtecd4ca52009-04-27 17:05:38 +090012 long long syscall_nr;
Paul Mundt33f242e2007-11-09 16:57:27 +090013 unsigned long long regs[63];
14 unsigned long long tregs[8];
15 unsigned long long pad[2];
16};
17#else
Linus Torvalds1da177e2005-04-16 15:20:36 -070018/*
19 * GCC defines register number like this:
20 * -----------------------------
21 * 0 - 15 are integer registers
22 * 17 - 22 are control/special registers
23 * 24 - 39 fp registers
24 * 40 - 47 xd registers
25 * 48 - fpscr register
26 * -----------------------------
27 *
28 * We follows above, except:
29 * 16 --- program counter (PC)
30 * 22 --- syscall #
31 * 23 --- floating point communication register
32 */
33#define REG_REG0 0
34#define REG_REG15 15
35
36#define REG_PC 16
37
38#define REG_PR 17
39#define REG_SR 18
Paul Mundt33f242e2007-11-09 16:57:27 +090040#define REG_GBR 19
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#define REG_MACH 20
42#define REG_MACL 21
43
44#define REG_SYSCALL 22
45
46#define REG_FPREG0 23
47#define REG_FPREG15 38
48#define REG_XFREG0 39
49#define REG_XFREG15 54
50
51#define REG_FPSCR 55
52#define REG_FPUL 56
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054/*
55 * This struct defines the way the registers are stored on the
56 * kernel stack during a system call or other kernel entry.
57 */
58struct pt_regs {
59 unsigned long regs[16];
60 unsigned long pc;
61 unsigned long pr;
62 unsigned long sr;
63 unsigned long gbr;
64 unsigned long mach;
65 unsigned long macl;
66 long tra;
67};
68
69/*
70 * This struct defines the way the DSP registers are stored on the
71 * kernel stack during a system call or other kernel entry.
72 */
73struct pt_dspregs {
74 unsigned long a1;
75 unsigned long a0g;
76 unsigned long a1g;
77 unsigned long m0;
78 unsigned long m1;
79 unsigned long a0;
80 unsigned long x0;
81 unsigned long x1;
82 unsigned long y0;
83 unsigned long y1;
84 unsigned long dsr;
85 unsigned long rs;
86 unsigned long re;
87 unsigned long mod;
88};
Paul Mundtdd762792008-12-10 20:14:15 +090089#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
Paul Mundt934135c2008-09-12 19:52:36 +090091#define PTRACE_GETREGS 12 /* General registers */
92#define PTRACE_SETREGS 13
93
94#define PTRACE_GETFPREGS 14 /* FPU registers */
95#define PTRACE_SETFPREGS 15
96
Paul Mundt3bc24a12008-05-19 13:40:12 +090097#define PTRACE_GETFDPIC 31 /* get the ELF fdpic loadmap address */
98
99#define PTRACE_GETFDPIC_EXEC 0 /* [addr] request the executable loadmap */
100#define PTRACE_GETFDPIC_INTERP 1 /* [addr] request the interpreter loadmap */
101
Paul Mundt934135c2008-09-12 19:52:36 +0900102#define PTRACE_GETDSPREGS 55 /* DSP registers */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103#define PTRACE_SETDSPREGS 56
104
Kieran Binghambe6514c2009-05-08 15:48:15 +0100105#define PT_TEXT_END_ADDR 240
106#define PT_TEXT_ADDR 244 /* &(struct user)->start_code */
107#define PT_DATA_ADDR 248 /* &(struct user)->start_data */
108#define PT_TEXT_LEN 252
109
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110#ifdef __KERNEL__
Paul Mundt33f242e2007-11-09 16:57:27 +0900111#include <asm/addrspace.h>
112
113#define user_mode(regs) (((regs)->sr & 0x40000000)==0)
Paul Mundt5a4f7c62007-11-20 18:08:06 +0900114#define instruction_pointer(regs) ((unsigned long)(regs)->pc)
Paul Mundt33f242e2007-11-09 16:57:27 +0900115
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116extern void show_regs(struct pt_regs *);
117
Paul Mundtc459dbf2008-07-30 19:09:31 +0900118/*
119 * These are defined as per linux/ptrace.h.
120 */
121struct task_struct;
122
123#define arch_has_single_step() (1)
124extern void user_enable_single_step(struct task_struct *);
125extern void user_disable_single_step(struct task_struct *);
126
Paul Mundt34d0b5a2009-12-28 17:53:47 +0900127struct perf_event;
128struct perf_sample_data;
129
130extern void ptrace_triggered(struct perf_event *bp, int nmi,
131 struct perf_sample_data *data, struct pt_regs *regs);
132
Al Viro3cf0f4e2006-01-12 01:05:44 -0800133#define task_pt_regs(task) \
Magnus Damm4f099eb2009-02-23 07:16:34 +0000134 ((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE) - 1)
Al Viro3cf0f4e2006-01-12 01:05:44 -0800135
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136static inline unsigned long profile_pc(struct pt_regs *regs)
137{
138 unsigned long pc = instruction_pointer(regs);
139
Paul Mundt33f242e2007-11-09 16:57:27 +0900140#ifdef P2SEG
141 if (pc >= P2SEG && pc < P3SEG)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 pc -= 0x20000000;
Paul Mundt33f242e2007-11-09 16:57:27 +0900143#endif
144
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 return pc;
146}
Paul Mundt33f242e2007-11-09 16:57:27 +0900147#endif /* __KERNEL__ */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148
149#endif /* __ASM_SH_PTRACE_H */