1 /***************************************************************************
2 * Copyright (C) 2018 by Square, Inc. *
3 * Steven Stallion <stallion@squareup.com> *
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. *
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. *
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 ***************************************************************************/
19 #ifndef OPENOCD_TARGET_ESIRISC_TRACE_H
20 #define OPENOCD_TARGET_ESIRISC_TRACE_H
22 #include <helper/command.h>
23 #include <helper/types.h>
24 #include <target/target.h>
26 enum esirisc_trace_delay {
27 ESIRISC_TRACE_DELAY_NONE,
28 ESIRISC_TRACE_DELAY_START,
29 ESIRISC_TRACE_DELAY_STOP,
30 ESIRISC_TRACE_DELAY_BOTH,
33 enum esirisc_trace_format {
34 ESIRISC_TRACE_FORMAT_FULL,
35 ESIRISC_TRACE_FORMAT_BRANCH,
36 ESIRISC_TRACE_FORMAT_ICACHE,
39 enum esirisc_trace_id {
40 ESIRISC_TRACE_ID_EXECUTE,
41 ESIRISC_TRACE_ID_STALL,
42 ESIRISC_TRACE_ID_BRANCH,
43 ESIRISC_TRACE_ID_EXTENDED,
46 enum esirisc_trace_ext_id {
47 ESIRISC_TRACE_EXT_ID_EXCEPTION = 1,
48 ESIRISC_TRACE_EXT_ID_ERET,
49 ESIRISC_TRACE_EXT_ID_STOP,
50 ESIRISC_TRACE_EXT_ID_WAIT,
51 ESIRISC_TRACE_EXT_ID_MULTICYCLE,
52 ESIRISC_TRACE_EXT_ID_COUNT,
53 ESIRISC_TRACE_EXT_ID_PC,
54 ESIRISC_TRACE_EXT_ID_INDIRECT,
55 ESIRISC_TRACE_EXT_ID_END,
56 ESIRISC_TRACE_EXT_ID_END_PC,
59 enum esirisc_trace_trigger {
60 ESIRISC_TRACE_TRIGGER_NONE,
61 ESIRISC_TRACE_TRIGGER_PC,
62 ESIRISC_TRACE_TRIGGER_LOAD,
63 ESIRISC_TRACE_TRIGGER_STORE,
64 ESIRISC_TRACE_TRIGGER_EXCEPTION,
65 ESIRISC_TRACE_TRIGGER_ERET,
66 ESIRISC_TRACE_TRIGGER_WAIT,
67 ESIRISC_TRACE_TRIGGER_STOP,
68 ESIRISC_TRACE_TRIGGER_HIGH,
69 ESIRISC_TRACE_TRIGGER_LOW,
72 struct esirisc_trace {
73 target_addr_t buffer_start;
74 target_addr_t buffer_end;
78 enum esirisc_trace_format format;
81 enum esirisc_trace_trigger start_trigger;
85 enum esirisc_trace_trigger stop_trigger;
89 enum esirisc_trace_delay delay;
90 uint32_t delay_cycles;
93 extern const struct command_registration esirisc_trace_command_handlers[];
95 static inline uint32_t esirisc_trace_buffer_size(struct esirisc_trace *trace_info)
97 return trace_info->buffer_end - trace_info->buffer_start;
100 static inline bool esirisc_trace_is_fifo(struct esirisc_trace *trace_info)
102 return trace_info->buffer_start == trace_info->buffer_end;
105 #endif /* OPENOCD_TARGET_ESIRISC_TRACE_H */