Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2010 Tilera Corporation. All Rights Reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation, version 2. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, but |
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or |
| 11 | * NON INFRINGEMENT. See the GNU General Public License for |
| 12 | * more details. |
| 13 | */ |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 14 | #ifndef _ASM_TILE_PTRACE_H |
| 15 | #define _ASM_TILE_PTRACE_H |
| 16 | |
David Howells | df842f7 | 2012-10-09 09:47:47 +0100 | [diff] [blame] | 17 | #include <linux/compiler.h> |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 18 | |
| 19 | #ifndef __ASSEMBLY__ |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 20 | /* Benefit from consistent use of "long" on all chips. */ |
| 21 | typedef unsigned long pt_reg_t; |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 22 | #endif |
| 23 | |
David Howells | df842f7 | 2012-10-09 09:47:47 +0100 | [diff] [blame] | 24 | #include <uapi/asm/ptrace.h> |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 25 | |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 26 | #define PTRACE_O_MASK_TILE (PTRACE_O_TRACEMIGRATE) |
Chris Metcalf | 395e095 | 2012-12-13 11:34:45 -0500 | [diff] [blame] | 27 | #define PT_TRACE_MIGRATE PT_EVENT_FLAG(PTRACE_EVENT_MIGRATE) |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 28 | |
Chris Metcalf | 74fca9d | 2010-09-15 11:16:08 -0400 | [diff] [blame] | 29 | /* Flag bits in pt_regs.flags */ |
| 30 | #define PT_FLAGS_DISABLE_IRQ 1 /* on return to kernel, disable irqs */ |
| 31 | #define PT_FLAGS_CALLER_SAVES 2 /* caller-save registers are valid */ |
| 32 | #define PT_FLAGS_RESTORE_REGS 4 /* restore callee-save regs on return */ |
| 33 | |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 34 | #ifndef __ASSEMBLY__ |
| 35 | |
| 36 | #define instruction_pointer(regs) ((regs)->pc) |
| 37 | #define profile_pc(regs) instruction_pointer(regs) |
| 38 | |
| 39 | /* Does the process account for user or for system time? */ |
| 40 | #define user_mode(regs) (EX1_PL((regs)->ex1) == USER_PL) |
| 41 | |
| 42 | /* Fill in a struct pt_regs with the current kernel registers. */ |
| 43 | struct pt_regs *get_pt_regs(struct pt_regs *); |
| 44 | |
Chris Metcalf | 0707ad3 | 2010-06-25 17:04:17 -0400 | [diff] [blame] | 45 | /* Trace the current syscall. */ |
| 46 | extern void do_syscall_trace(void); |
| 47 | |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 48 | #define arch_has_single_step() (1) |
| 49 | |
| 50 | /* |
| 51 | * A structure for all single-stepper state. |
| 52 | * |
| 53 | * Also update defines in assembler section if it changes |
| 54 | */ |
| 55 | struct single_step_state { |
| 56 | /* the page to which we will write hacked-up bundles */ |
Chris Metcalf | 0707ad3 | 2010-06-25 17:04:17 -0400 | [diff] [blame] | 57 | void __user *buffer; |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 58 | |
| 59 | union { |
| 60 | int flags; |
| 61 | struct { |
| 62 | unsigned long is_enabled:1, update:1, update_reg:6; |
| 63 | }; |
| 64 | }; |
| 65 | |
| 66 | unsigned long orig_pc; /* the original PC */ |
| 67 | unsigned long next_pc; /* return PC if no branch (PC + 1) */ |
| 68 | unsigned long branch_next_pc; /* return PC if we did branch/jump */ |
| 69 | unsigned long update_value; /* value to restore to update_target */ |
| 70 | }; |
| 71 | |
| 72 | /* Single-step the instruction at regs->pc */ |
| 73 | extern void single_step_once(struct pt_regs *regs); |
| 74 | |
Chris Metcalf | 04f7a3f | 2011-02-28 13:08:32 -0500 | [diff] [blame] | 75 | /* Clean up after execve(). */ |
| 76 | extern void single_step_execve(void); |
| 77 | |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 78 | struct task_struct; |
| 79 | |
| 80 | extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, |
| 81 | int error_code); |
| 82 | |
| 83 | #ifdef __tilegx__ |
| 84 | /* We need this since sigval_t has a user pointer in it, for GETSIGINFO etc. */ |
| 85 | #define __ARCH_WANT_COMPAT_SYS_PTRACE |
| 86 | #endif |
| 87 | |
| 88 | #endif /* !__ASSEMBLY__ */ |
| 89 | |
| 90 | #define SINGLESTEP_STATE_MASK_IS_ENABLED 0x1 |
| 91 | #define SINGLESTEP_STATE_MASK_UPDATE 0x2 |
| 92 | #define SINGLESTEP_STATE_TARGET_LB 2 |
| 93 | #define SINGLESTEP_STATE_TARGET_UB 7 |
| 94 | |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 95 | #endif /* _ASM_TILE_PTRACE_H */ |