Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __ASM_SH_PTRACE_H |
| 2 | #define __ASM_SH_PTRACE_H |
| 3 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | /* |
| 5 | * Copyright (C) 1999, 2000 Niibe Yutaka |
| 6 | * |
| 7 | */ |
Paul Mundt | 33f242e | 2007-11-09 16:57:27 +0900 | [diff] [blame] | 8 | #if defined(__SH5__) || defined(CONFIG_SUPERH64) |
| 9 | struct pt_regs { |
| 10 | unsigned long long pc; |
| 11 | unsigned long long sr; |
| 12 | unsigned long long syscall_nr; |
| 13 | unsigned long long regs[63]; |
| 14 | unsigned long long tregs[8]; |
| 15 | unsigned long long pad[2]; |
| 16 | }; |
| 17 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | /* |
| 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 Mundt | 33f242e | 2007-11-09 16:57:27 +0900 | [diff] [blame] | 40 | #define REG_GBR 19 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | #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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | /* |
| 55 | * This struct defines the way the registers are stored on the |
| 56 | * kernel stack during a system call or other kernel entry. |
| 57 | */ |
| 58 | struct 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 | */ |
| 73 | struct 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 | }; |
| 89 | |
| 90 | #define PTRACE_GETDSPREGS 55 |
| 91 | #define PTRACE_SETDSPREGS 56 |
Paul Mundt | 33f242e | 2007-11-09 16:57:27 +0900 | [diff] [blame] | 92 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | |
| 94 | #ifdef __KERNEL__ |
Paul Mundt | 33f242e | 2007-11-09 16:57:27 +0900 | [diff] [blame] | 95 | #include <asm/addrspace.h> |
| 96 | |
| 97 | #define user_mode(regs) (((regs)->sr & 0x40000000)==0) |
Paul Mundt | 5a4f7c6 | 2007-11-20 18:08:06 +0900 | [diff] [blame] | 98 | #define instruction_pointer(regs) ((unsigned long)(regs)->pc) |
Paul Mundt | 33f242e | 2007-11-09 16:57:27 +0900 | [diff] [blame] | 99 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | extern void show_regs(struct pt_regs *); |
| 101 | |
Al Viro | 3cf0f4e | 2006-01-12 01:05:44 -0800 | [diff] [blame] | 102 | #ifdef CONFIG_SH_DSP |
| 103 | #define task_pt_regs(task) \ |
Al Viro | 308a792 | 2006-01-12 01:05:45 -0800 | [diff] [blame] | 104 | ((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE \ |
Al Viro | 3cf0f4e | 2006-01-12 01:05:44 -0800 | [diff] [blame] | 105 | - sizeof(struct pt_dspregs) - sizeof(unsigned long)) - 1) |
| 106 | #else |
| 107 | #define task_pt_regs(task) \ |
Al Viro | 308a792 | 2006-01-12 01:05:45 -0800 | [diff] [blame] | 108 | ((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE \ |
Al Viro | 3cf0f4e | 2006-01-12 01:05:44 -0800 | [diff] [blame] | 109 | - sizeof(unsigned long)) - 1) |
| 110 | #endif |
| 111 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | static inline unsigned long profile_pc(struct pt_regs *regs) |
| 113 | { |
| 114 | unsigned long pc = instruction_pointer(regs); |
| 115 | |
Paul Mundt | 33f242e | 2007-11-09 16:57:27 +0900 | [diff] [blame] | 116 | #ifdef P2SEG |
| 117 | if (pc >= P2SEG && pc < P3SEG) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | pc -= 0x20000000; |
Paul Mundt | 33f242e | 2007-11-09 16:57:27 +0900 | [diff] [blame] | 119 | #endif |
| 120 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | return pc; |
| 122 | } |
Paul Mundt | 33f242e | 2007-11-09 16:57:27 +0900 | [diff] [blame] | 123 | #endif /* __KERNEL__ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | |
| 125 | #endif /* __ASM_SH_PTRACE_H */ |