7e4977aba72a67f95b91cfca368c93558312bb2c
[fw/openocd] / src / target / armv7m_trace.h
1 /***************************************************************************
2  *   Copyright (C) 2015  Paul Fertser <fercerpav@gmail.com>                *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
16  ***************************************************************************/
17
18 #ifndef OPENOCD_TARGET_ARMV7M_TRACE_H
19 #define OPENOCD_TARGET_ARMV7M_TRACE_H
20
21 #include <helper/command.h>
22 #include <target/target.h>
23
24 /**
25  * @file
26  * Holds the interface to ITM and DWT configuration functions.
27  */
28
29 enum itm_ts_prescaler {
30         ITM_TS_PRESCALE1,       /**< no prescaling for the timestamp counter */
31         ITM_TS_PRESCALE4,       /**< refclock divided by 4 for the timestamp counter */
32         ITM_TS_PRESCALE16,      /**< refclock divided by 16 for the timestamp counter */
33         ITM_TS_PRESCALE64,      /**< refclock divided by 64 for the timestamp counter */
34 };
35
36 struct armv7m_trace_config {
37         /** Bitmask of currently enabled ITM stimuli */
38         uint32_t itm_ter[8];
39         /** Identifier for multi-source trace stream formatting */
40         unsigned int trace_bus_id;
41         /** Prescaler for the timestamp counter */
42         enum itm_ts_prescaler itm_ts_prescale;
43         /** Enable differential timestamps */
44         bool itm_diff_timestamps;
45         /** Enable async timestamps model */
46         bool itm_async_timestamps;
47         /** Enable synchronisation packet transmission (for sync port only) */
48         bool itm_synchro_packets;
49         /** Config ITM after target examine */
50         bool itm_deferred_config;
51 };
52
53 extern const struct command_registration armv7m_trace_command_handlers[];
54
55 /**
56  * Configure hardware accordingly to the current ITM target settings
57  */
58 int armv7m_trace_itm_config(struct target *target);
59
60 #endif /* OPENOCD_TARGET_ARMV7M_TRACE_H */