6e260abd870002c6267abd177f76eb00dcbc578a
[openocd.git] / src / target / breakpoints.h
1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17 ***************************************************************************/
18
19 #ifndef OPENOCD_TARGET_BREAKPOINTS_H
20 #define OPENOCD_TARGET_BREAKPOINTS_H
21
22 struct target;
23
24 enum breakpoint_type {
25 BKPT_HARD,
26 BKPT_SOFT,
27 };
28
29 enum watchpoint_rw {
30 WPT_READ = 0, WPT_WRITE = 1, WPT_ACCESS = 2
31 };
32
33 struct breakpoint {
34 uint32_t address;
35 uint32_t asid;
36 int length;
37 enum breakpoint_type type;
38 int set;
39 uint8_t *orig_instr;
40 struct breakpoint *next;
41 uint32_t unique_id;
42 int linked_BRP;
43 };
44
45 struct watchpoint {
46 uint32_t address;
47 uint32_t length;
48 uint32_t mask;
49 uint32_t value;
50 enum watchpoint_rw rw;
51 int set;
52 struct watchpoint *next;
53 int unique_id;
54 };
55
56 void breakpoint_clear_target(struct target *target);
57 int breakpoint_add(struct target *target,
58 uint32_t address, uint32_t length, enum breakpoint_type type);
59 int context_breakpoint_add(struct target *target,
60 uint32_t asid, uint32_t length, enum breakpoint_type type);
61 int hybrid_breakpoint_add(struct target *target,
62 uint32_t address, uint32_t asid, uint32_t length, enum breakpoint_type type);
63 void breakpoint_remove(struct target *target, uint32_t address);
64
65 struct breakpoint *breakpoint_find(struct target *target, uint32_t address);
66
67 void watchpoint_clear_target(struct target *target);
68 int watchpoint_add(struct target *target,
69 uint32_t address, uint32_t length,
70 enum watchpoint_rw rw, uint32_t value, uint32_t mask);
71 void watchpoint_remove(struct target *target, uint32_t address);
72
73 /* report type and address of just hit watchpoint */
74 int watchpoint_hit(struct target *target, enum watchpoint_rw *rw, uint32_t *address);
75
76 #endif /* OPENOCD_TARGET_BREAKPOINTS_H */