]> git.sur5r.net Git - openocd/blob - src/transport/transport.h
configure: disable all drivers when zy1000 is enabled
[openocd] / src / transport / transport.h
1 /*
2  * Copyright (c) 2010 by David Brownell
3  * Copyright (C) 2011 Tomasz Boleslaw CEDRO (http://www.tomek.cedro.info)
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_TRANSPORT_TRANSPORT_H
20 #define OPENOCD_TRANSPORT_TRANSPORT_H
21
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25
26 #include "helper/command.h"
27
28 /**
29  * Wrapper for transport lifecycle operations.
30  *
31  * OpenOCD talks to targets through some kind of debugging
32  * or programming adapter, using some protocol that probably
33  * has target-specific aspects.
34  *
35  * A "transport" reflects electrical protocol to the target,
36  * e..g jtag, swd, spi, uart, ... NOT the messaging protocols
37  * layered over it (e.g. JTAG has eICE, CoreSight, Nexus, OnCE,
38  * and more).
39  *
40  * In addition to the lifecycle operations packaged by this
41  * structure, a transport also involves  an interface supported
42  * by debug adapters and used by components such as debug targets.
43  * For non-debug transports,  there may be interfaces used to
44  * write to flash chips.
45  */
46 struct transport {
47         /**
48          * Each transport has a unique name, used to select it
49          * from among the alternatives.  Examples might include
50          * "jtag", * "swd", "AVR_ISP" and more.
51          */
52         const char *name;
53
54         /**
55          * When a transport is selected, this method registers
56          * its commands and activates the transport (e.g. resets
57          * the link).
58          *
59          * After those commands are registered, they will often
60          * be used for further configuration of the debug link.
61          */
62         int (*select)(struct command_context *ctx);
63
64         /**
65          * server startup uses this method to validate transport
66          * configuration.  (For example, with JTAG this interrogates
67          * the scan chain against the list of expected TAPs.)
68          */
69         int (*init)(struct command_context *ctx);
70
71         /**
72          * Optional. If defined, allows transport to override target
73          * name prior to initialisation.
74          *
75          * @returns ERROR_OK on success, or an error code on failure.
76          */
77         int (*override_target)(const char **targetname);
78
79         /**
80          * Transports are stored in a singly linked list.
81          */
82         struct transport *next;
83 };
84
85 int transport_register(struct transport *new_transport);
86
87 struct transport *get_current_transport(void);
88
89 int transport_register_commands(struct command_context *ctx);
90
91 COMMAND_HELPER(transport_list_parse, char ***vector);
92
93 int allow_transports(struct command_context *ctx, const char * const *vector);
94
95 bool transports_are_declared(void);
96
97 bool transport_is_jtag(void);
98 bool transport_is_swd(void);
99
100 #if BUILD_HLADAPTER
101 bool transport_is_hla(void);
102 #else
103 static inline bool transport_is_hla(void)
104 {
105         return false;
106 }
107 #endif
108
109 #endif /* OPENOCD_TRANSPORT_TRANSPORT_H */