OpenOCD
hla_layout.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /***************************************************************************
4  * Copyright (C) 2011 by Mathias Kuester *
5  * Mathias Kuester <kesmtp@freenet.de> *
6  * *
7  * Copyright (C) 2012 by Spencer Oliver *
8  * spen@spen-soft.co.uk *
9  ***************************************************************************/
10 
11 #ifdef HAVE_CONFIG_H
12 #include "config.h"
13 #endif
14 
15 /* project specific includes */
16 #include <jtag/interface.h>
17 #include <transport/transport.h>
18 #include <helper/time_support.h>
19 
20 #include <jtag/hla/hla_layout.h>
21 #include <jtag/hla/hla_tcl.h>
22 #include <jtag/hla/hla_transport.h>
23 #include <jtag/hla/hla_interface.h>
24 
26 {
27  int res;
28 
29  LOG_DEBUG("hl_layout_open");
30 
31  adapter->handle = NULL;
32 
33  res = adapter->layout->api->open(&adapter->param, &adapter->handle);
34 
35  if (res != ERROR_OK) {
36  LOG_DEBUG("failed");
37  return res;
38  }
39 
40  return ERROR_OK;
41 }
42 
44 {
45  return ERROR_OK;
46 }
47 
48 static const struct hl_layout hl_layouts[] = {
49 #if BUILD_HLADAPTER_STLINK
50  {
51  .name = "stlink",
52  .open = hl_layout_open,
53  .close = hl_layout_close,
54  .api = &stlink_usb_layout_api,
55  },
56 #endif
57 #if BUILD_HLADAPTER_ICDI
58  {
59  .name = "ti-icdi",
61  .close = hl_layout_close,
62  .api = &icdi_usb_layout_api,
63  },
64 #endif
65 #if BUILD_HLADAPTER_NULINK
66  {
67  .name = "nulink",
69  .close = hl_layout_close,
70  .api = &nulink_usb_layout_api,
71  },
72 #endif
73  {.name = NULL, /* END OF TABLE */ },
74 };
75 
77 const struct hl_layout *hl_layout_get_list(void)
78 {
79  return hl_layouts;
80 }
81 
83 {
84  LOG_DEBUG("hl_layout_init");
85 
86  if (!adapter->layout) {
87  LOG_ERROR("no layout specified");
88  return ERROR_FAIL;
89  }
90  return ERROR_OK;
91 }
static struct libusb_device_handle * adapter
Definition: ft232r.c:63
static const struct hl_layout hl_layouts[]
Definition: hla_layout.c:48
const struct hl_layout * hl_layout_get_list(void)
Definition: hla_layout.c:77
int hl_layout_init(struct hl_interface_s *adapter)
Definition: hla_layout.c:82
static int hl_layout_open(struct hl_interface_s *adapter)
Definition: hla_layout.c:25
static int hl_layout_close(struct hl_interface_s *adapter)
Definition: hla_layout.c:43
#define ERROR_FAIL
Definition: log.h:161
#define LOG_ERROR(expr ...)
Definition: log.h:123
#define LOG_DEBUG(expr ...)
Definition: log.h:109
#define ERROR_OK
Definition: log.h:155
int(* open)(struct hl_interface_param_s *param, void **handle)
Definition: hla_layout.h:29
char * name
Definition: hla_layout.h:122
struct hl_layout_api_s icdi_usb_layout_api
Definition: ti_icdi_usb.c:746
#define NULL
Definition: usb.h:16