You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

111 lines
3.2 KiB

  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. * 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. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef OPENOCD_TRANSPORT_TRANSPORT_H
  17. #define OPENOCD_TRANSPORT_TRANSPORT_H
  18. #ifdef HAVE_CONFIG_H
  19. #include "config.h"
  20. #endif
  21. #include "helper/command.h"
  22. /**
  23. * Wrapper for transport lifecycle operations.
  24. *
  25. * OpenOCD talks to targets through some kind of debugging
  26. * or programming adapter, using some protocol that probably
  27. * has target-specific aspects.
  28. *
  29. * A "transport" reflects electrical protocol to the target,
  30. * e..g jtag, swd, spi, uart, ... NOT the messaging protocols
  31. * layered over it (e.g. JTAG has eICE, CoreSight, Nexus, OnCE,
  32. * and more).
  33. *
  34. * In addition to the lifecycle operations packaged by this
  35. * structure, a transport also involves an interface supported
  36. * by debug adapters and used by components such as debug targets.
  37. * For non-debug transports, there may be interfaces used to
  38. * write to flash chips.
  39. */
  40. struct transport {
  41. /**
  42. * Each transport has a unique name, used to select it
  43. * from among the alternatives. Examples might include
  44. * "jtag", * "swd", "AVR_ISP" and more.
  45. */
  46. const char *name;
  47. /**
  48. * When a transport is selected, this method registers
  49. * its commands and activates the transport (e.g. resets
  50. * the link).
  51. *
  52. * After those commands are registered, they will often
  53. * be used for further configuration of the debug link.
  54. */
  55. int (*select)(struct command_context *ctx);
  56. /**
  57. * server startup uses this method to validate transport
  58. * configuration. (For example, with JTAG this interrogates
  59. * the scan chain against the list of expected TAPs.)
  60. */
  61. int (*init)(struct command_context *ctx);
  62. /**
  63. * Optional. If defined, allows transport to override target
  64. * name prior to initialisation.
  65. *
  66. * @returns ERROR_OK on success, or an error code on failure.
  67. */
  68. int (*override_target)(const char **targetname);
  69. /**
  70. * Transports are stored in a singly linked list.
  71. */
  72. struct transport *next;
  73. };
  74. int transport_register(struct transport *new_transport);
  75. struct transport *get_current_transport(void);
  76. int transport_register_commands(struct command_context *ctx);
  77. COMMAND_HELPER(transport_list_parse, char ***vector);
  78. int allow_transports(struct command_context *ctx, const char * const *vector);
  79. bool transport_is_jtag(void);
  80. bool transport_is_swd(void);
  81. bool transport_is_dapdirect_jtag(void);
  82. bool transport_is_dapdirect_swd(void);
  83. bool transport_is_swim(void);
  84. #if BUILD_HLADAPTER
  85. bool transport_is_hla(void);
  86. #else
  87. static inline bool transport_is_hla(void)
  88. {
  89. return false;
  90. }
  91. #endif
  92. #endif /* OPENOCD_TRANSPORT_TRANSPORT_H */