1 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 * Copyright (c) 2010 by David Brownell
5 * Copyright (C) 2011 Tomasz Boleslaw CEDRO (http://www.tomek.cedro.info)
8 #ifndef OPENOCD_TRANSPORT_TRANSPORT_H
9 #define OPENOCD_TRANSPORT_TRANSPORT_H
15 #include "helper/command.h"
18 * Wrapper for transport lifecycle operations.
20 * OpenOCD talks to targets through some kind of debugging
21 * or programming adapter, using some protocol that probably
22 * has target-specific aspects.
24 * A "transport" reflects electrical protocol to the target,
25 * e..g jtag, swd, spi, uart, ... NOT the messaging protocols
26 * layered over it (e.g. JTAG has eICE, CoreSight, Nexus, OnCE,
29 * In addition to the lifecycle operations packaged by this
30 * structure, a transport also involves an interface supported
31 * by debug adapters and used by components such as debug targets.
32 * For non-debug transports, there may be interfaces used to
33 * write to flash chips.
37 * Each transport has a unique name, used to select it
38 * from among the alternatives. Examples might include
39 * "jtag", * "swd", "AVR_ISP" and more.
44 * When a transport is selected, this method registers
45 * its commands and activates the transport (e.g. resets
48 * After those commands are registered, they will often
49 * be used for further configuration of the debug link.
51 int (*select)(struct command_context *ctx);
54 * server startup uses this method to validate transport
55 * configuration. (For example, with JTAG this interrogates
56 * the scan chain against the list of expected TAPs.)
58 int (*init)(struct command_context *ctx);
61 * Optional. If defined, allows transport to override target
62 * name prior to initialisation.
64 * @returns ERROR_OK on success, or an error code on failure.
66 int (*override_target)(const char **targetname);
69 * Transports are stored in a singly linked list.
71 struct transport *next;
74 int transport_register(struct transport *new_transport);
76 struct transport *get_current_transport(void);
78 int transport_register_commands(struct command_context *ctx);
80 COMMAND_HELPER(transport_list_parse, char ***vector);
82 int allow_transports(struct command_context *ctx, const char * const *vector);
84 bool transport_is_jtag(void);
85 bool transport_is_swd(void);
86 bool transport_is_dapdirect_jtag(void);
87 bool transport_is_dapdirect_swd(void);
88 bool transport_is_swim(void);
91 bool transport_is_hla(void);
93 static inline bool transport_is_hla(void)
99 #endif /* OPENOCD_TRANSPORT_TRANSPORT_H */