blob: 1a4fd9ab0ee1663ce4a4bdb86584be442c345dad [file] [log] [blame]
Chris Metcalf867e3592010-05-28 23:09:12 -04001/*
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 Metcalf867e3592010-05-28 23:09:12 -040014#ifndef _ASM_TILE_PTRACE_H
15#define _ASM_TILE_PTRACE_H
16
David Howellsdf842f72012-10-09 09:47:47 +010017#include <linux/compiler.h>
Chris Metcalf867e3592010-05-28 23:09:12 -040018
19#ifndef __ASSEMBLY__
Chris Metcalf867e3592010-05-28 23:09:12 -040020/* Benefit from consistent use of "long" on all chips. */
21typedef unsigned long pt_reg_t;
Chris Metcalf867e3592010-05-28 23:09:12 -040022#endif
23
David Howellsdf842f72012-10-09 09:47:47 +010024#include <uapi/asm/ptrace.h>
Chris Metcalf867e3592010-05-28 23:09:12 -040025
Chris Metcalf867e3592010-05-28 23:09:12 -040026#define PTRACE_O_MASK_TILE (PTRACE_O_TRACEMIGRATE)
27#define PT_TRACE_MIGRATE 0x00080000
28#define PT_TRACE_MASK_TILE (PT_TRACE_MIGRATE)
Chris Metcalf867e3592010-05-28 23:09:12 -040029
Chris Metcalf74fca9d2010-09-15 11:16:08 -040030/* Flag bits in pt_regs.flags */
31#define PT_FLAGS_DISABLE_IRQ 1 /* on return to kernel, disable irqs */
32#define PT_FLAGS_CALLER_SAVES 2 /* caller-save registers are valid */
33#define PT_FLAGS_RESTORE_REGS 4 /* restore callee-save regs on return */
34
Chris Metcalf867e3592010-05-28 23:09:12 -040035#ifndef __ASSEMBLY__
36
37#define instruction_pointer(regs) ((regs)->pc)
38#define profile_pc(regs) instruction_pointer(regs)
39
40/* Does the process account for user or for system time? */
41#define user_mode(regs) (EX1_PL((regs)->ex1) == USER_PL)
42
43/* Fill in a struct pt_regs with the current kernel registers. */
44struct pt_regs *get_pt_regs(struct pt_regs *);
45
Chris Metcalf0707ad32010-06-25 17:04:17 -040046/* Trace the current syscall. */
47extern void do_syscall_trace(void);
48
Chris Metcalf867e3592010-05-28 23:09:12 -040049#define arch_has_single_step() (1)
50
51/*
52 * A structure for all single-stepper state.
53 *
54 * Also update defines in assembler section if it changes
55 */
56struct single_step_state {
57 /* the page to which we will write hacked-up bundles */
Chris Metcalf0707ad32010-06-25 17:04:17 -040058 void __user *buffer;
Chris Metcalf867e3592010-05-28 23:09:12 -040059
60 union {
61 int flags;
62 struct {
63 unsigned long is_enabled:1, update:1, update_reg:6;
64 };
65 };
66
67 unsigned long orig_pc; /* the original PC */
68 unsigned long next_pc; /* return PC if no branch (PC + 1) */
69 unsigned long branch_next_pc; /* return PC if we did branch/jump */
70 unsigned long update_value; /* value to restore to update_target */
71};
72
73/* Single-step the instruction at regs->pc */
74extern void single_step_once(struct pt_regs *regs);
75
Chris Metcalf04f7a3f2011-02-28 13:08:32 -050076/* Clean up after execve(). */
77extern void single_step_execve(void);
78
Chris Metcalf867e3592010-05-28 23:09:12 -040079struct task_struct;
80
81extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
82 int error_code);
83
84#ifdef __tilegx__
85/* We need this since sigval_t has a user pointer in it, for GETSIGINFO etc. */
86#define __ARCH_WANT_COMPAT_SYS_PTRACE
87#endif
88
89#endif /* !__ASSEMBLY__ */
90
91#define SINGLESTEP_STATE_MASK_IS_ENABLED 0x1
92#define SINGLESTEP_STATE_MASK_UPDATE 0x2
93#define SINGLESTEP_STATE_TARGET_LB 2
94#define SINGLESTEP_STATE_TARGET_UB 7
95
Chris Metcalf867e3592010-05-28 23:09:12 -040096#endif /* _ASM_TILE_PTRACE_H */