OpenOCD
transport.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 /*
4  * Copyright (c) 2010 by David Brownell
5  * Copyright (C) 2011 Tomasz Boleslaw CEDRO (http://www.tomek.cedro.info)
6  */
7 
8 #ifndef OPENOCD_TRANSPORT_TRANSPORT_H
9 #define OPENOCD_TRANSPORT_TRANSPORT_H
10 
11 #ifdef HAVE_CONFIG_H
12 #include "config.h"
13 #endif
14 
15 #include "helper/bits.h"
16 #include "helper/command.h"
17 #include "helper/list.h"
18 
19 #define TRANSPORT_JTAG BIT(0)
20 #define TRANSPORT_SWD BIT(1)
21 #define TRANSPORT_HLA_JTAG BIT(2)
22 #define TRANSPORT_HLA_SWD BIT(3)
23 #define TRANSPORT_DAPDIRECT_JTAG BIT(4)
24 #define TRANSPORT_DAPDIRECT_SWD BIT(5)
25 #define TRANSPORT_SWIM BIT(6)
26 
27 /* mask for valid ID */
28 #define TRANSPORT_VALID_MASK \
29  (TRANSPORT_JTAG | \
30  TRANSPORT_SWD | \
31  TRANSPORT_HLA_JTAG | \
32  TRANSPORT_HLA_SWD | \
33  TRANSPORT_DAPDIRECT_JTAG | \
34  TRANSPORT_DAPDIRECT_SWD | \
35  TRANSPORT_SWIM)
36 
55 struct transport {
60  unsigned int id;
61 
70  int (*select)(struct command_context *ctx);
71 
77  int (*init)(struct command_context *ctx);
78 
85  int (*override_target)(const char **targetname);
86 
90  struct list_head lh;
91 };
92 
93 int transport_register(struct transport *new_transport);
94 
95 struct transport *get_current_transport(void);
96 
97 const char *get_current_transport_name(void);
98 
99 const char *transport_name(unsigned int id);
100 
102 
103 int allow_transports(struct command_context *ctx, unsigned int transport_ids,
104  unsigned int transport_preferred_id);
105 
106 bool transport_is_jtag(void);
107 bool transport_is_swd(void);
108 bool transport_is_dapdirect_jtag(void);
109 bool transport_is_dapdirect_swd(void);
110 bool transport_is_swim(void);
111 
112 #if BUILD_HLADAPTER
113 bool transport_is_hla(void);
114 #else
115 static inline bool transport_is_hla(void)
116 {
117  return false;
118 }
119 #endif
120 
121 #endif /* OPENOCD_TRANSPORT_TRANSPORT_H */
Definition: list.h:41
Wrapper for transport lifecycle operations.
Definition: transport.h:55
int(* select)(struct command_context *ctx)
When a transport is selected, this method registers its commands and activates the transport (e....
Definition: transport.h:70
int(* override_target)(const char **targetname)
Optional.
Definition: transport.h:85
int(* init)(struct command_context *ctx)
server startup uses this method to validate transport configuration.
Definition: transport.h:77
unsigned int id
Each transport has a unique ID, used to select it from among the alternatives.
Definition: transport.h:60
struct list_head lh
Transports are stored in a linked list.
Definition: transport.h:90
bool transport_is_dapdirect_swd(void)
Returns true if the current debug session is using SWD as its transport.
bool transport_is_dapdirect_jtag(void)
Returns true if the current debug session is using JTAG as its transport.
bool transport_is_swim(void)
Definition: swim.c:150
int allow_transports(struct command_context *ctx, unsigned int transport_ids, unsigned int transport_preferred_id)
Called by debug adapter drivers, or affiliated Tcl config scripts, to declare the set of transports s...
Definition: transport.c:149
static bool transport_is_hla(void)
Definition: transport.h:115
bool transport_is_jtag(void)
Returns true if the current debug session is using JTAG as its transport.
Definition: jtag/core.c:1840
bool transport_is_swd(void)
Returns true if the current debug session is using SWD as its transport.
Definition: adi_v5_swd.c:773
const char * get_current_transport_name(void)
Definition: transport.c:258
int transport_register_commands(struct command_context *ctx)
Definition: transport.c:432
const char * transport_name(unsigned int id)
Definition: transport.c:86
struct transport * get_current_transport(void)
Returns the transport currently being used by this debug or programming session.
Definition: transport.c:252
int transport_register(struct transport *new_transport)
Registers a transport.
Definition: transport.c:211