flash/nor/at91samd: Use 32-bit register writes for ST-Link compat
[fw/openocd] / src / target / breakpoints.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 /***************************************************************************
4  *   Copyright (C) 2005 by Dominic Rath                                    *
5  *   Dominic.Rath@gmx.de                                                   *
6  ***************************************************************************/
7
8 #ifndef OPENOCD_TARGET_BREAKPOINTS_H
9 #define OPENOCD_TARGET_BREAKPOINTS_H
10
11 #include <stdint.h>
12
13 #include "helper/types.h"
14
15 struct target;
16
17 enum breakpoint_type {
18         BKPT_HARD,
19         BKPT_SOFT,
20 };
21
22 enum watchpoint_rw {
23         WPT_READ = 0, WPT_WRITE = 1, WPT_ACCESS = 2
24 };
25
26 struct breakpoint {
27         target_addr_t address;
28         uint32_t asid;
29         int length;
30         enum breakpoint_type type;
31         bool is_set;
32         unsigned int number;
33         uint8_t *orig_instr;
34         struct breakpoint *next;
35         uint32_t unique_id;
36         int linked_brp;
37 };
38
39 struct watchpoint {
40         target_addr_t address;
41         uint32_t length;
42         uint32_t mask;
43         uint32_t value;
44         enum watchpoint_rw rw;
45         bool is_set;
46         unsigned int number;
47         struct watchpoint *next;
48         int unique_id;
49 };
50
51 void breakpoint_clear_target(struct target *target);
52 int breakpoint_add(struct target *target,
53                 target_addr_t address, uint32_t length, enum breakpoint_type type);
54 int context_breakpoint_add(struct target *target,
55                 uint32_t asid, uint32_t length, enum breakpoint_type type);
56 int hybrid_breakpoint_add(struct target *target,
57                 target_addr_t address, uint32_t asid, uint32_t length, enum breakpoint_type type);
58 void breakpoint_remove(struct target *target, target_addr_t address);
59 void breakpoint_remove_all(struct target *target);
60
61 struct breakpoint *breakpoint_find(struct target *target, target_addr_t address);
62
63 static inline void breakpoint_hw_set(struct breakpoint *breakpoint, unsigned int hw_number)
64 {
65         breakpoint->is_set = true;
66         breakpoint->number = hw_number;
67 }
68
69 void watchpoint_clear_target(struct target *target);
70 int watchpoint_add(struct target *target,
71                 target_addr_t address, uint32_t length,
72                 enum watchpoint_rw rw, uint32_t value, uint32_t mask);
73 void watchpoint_remove(struct target *target, target_addr_t address);
74
75 /* report type and address of just hit watchpoint */
76 int watchpoint_hit(struct target *target, enum watchpoint_rw *rw,
77                 target_addr_t *address);
78
79 static inline void watchpoint_set(struct watchpoint *watchpoint, unsigned int number)
80 {
81         watchpoint->is_set = true;
82         watchpoint->number = number;
83 }
84
85 #endif /* OPENOCD_TARGET_BREAKPOINTS_H */