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_transport.h>
22 #include <jtag/hla/hla_interface.h>
23 
24 static int hl_layout_open(struct hl_interface *adapter)
25 {
26  int res;
27 
28  LOG_DEBUG("hl_layout_open");
29 
30  adapter->handle = NULL;
31 
32  res = adapter->layout->api->open(&adapter->param, &adapter->handle);
33 
34  if (res != ERROR_OK) {
35  LOG_DEBUG("failed");
36  return res;
37  }
38 
39  return ERROR_OK;
40 }
41 
43 {
44  return ERROR_OK;
45 }
46 
47 static const struct hl_layout hl_layouts[] = {
48 #if BUILD_HLADAPTER_STLINK
49  {
50  .name = "stlink",
51  .open = hl_layout_open,
52  .close = hl_layout_close,
53  .api = &stlink_usb_layout_api,
54  },
55 #endif
56 #if BUILD_HLADAPTER_ICDI
57  {
58  .name = "ti-icdi",
60  .close = hl_layout_close,
61  .api = &icdi_usb_layout_api,
62  },
63 #endif
64 #if BUILD_HLADAPTER_NULINK
65  {
66  .name = "nulink",
68  .close = hl_layout_close,
69  .api = &nulink_usb_layout_api,
70  },
71 #endif
72  {.name = NULL, /* END OF TABLE */ },
73 };
74 
76 const struct hl_layout *hl_layout_get_list(void)
77 {
78  return hl_layouts;
79 }
80 
82 {
83  LOG_DEBUG("hl_layout_init");
84 
85  if (!adapter->layout) {
86  LOG_ERROR("no layout specified");
87  return ERROR_FAIL;
88  }
89  return ERROR_OK;
90 }
static struct libusb_device_handle * adapter
Definition: ft232r.c:63
static int hl_layout_close(struct hl_interface *adapter)
Definition: hla_layout.c:42
static const struct hl_layout hl_layouts[]
Definition: hla_layout.c:47
int hl_layout_init(struct hl_interface *adapter)
Definition: hla_layout.c:81
const struct hl_layout * hl_layout_get_list(void)
Definition: hla_layout.c:76
static int hl_layout_open(struct hl_interface *adapter)
Definition: hla_layout.c:24
#define ERROR_FAIL
Definition: log.h:170
#define LOG_ERROR(expr ...)
Definition: log.h:132
#define LOG_DEBUG(expr ...)
Definition: log.h:109
#define ERROR_OK
Definition: log.h:164
int(* open)(struct hl_interface_param *param, void **handle)
Definition: hla_layout.h:29
char * name
Definition: hla_layout.h:122
struct hl_layout_api icdi_usb_layout_api
Definition: ti_icdi_usb.c:746
#define NULL
Definition: usb.h:16