686e6f5b28dd253ba5aa4883e318158bb888f9d2
[fw/openocd] / src / jtag / hla / hla_layout.c
1 /***************************************************************************
2  *   Copyright (C) 2011 by Mathias Kuester                                 *
3  *   Mathias Kuester <kesmtp@freenet.de>                                   *
4  *                                                                         *
5  *   Copyright (C) 2012 by Spencer Oliver                                  *
6  *   spen@spen-soft.co.uk                                                  *
7  *                                                                         *
8  *   This program is free software; you can redistribute it and/or modify  *
9  *   it under the terms of the GNU General Public License as published by  *
10  *   the Free Software Foundation; either version 2 of the License, or     *
11  *   (at your option) any later version.                                   *
12  *                                                                         *
13  *   This program is distributed in the hope that it will be useful,       *
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
16  *   GNU General Public License for more details.                          *
17  *                                                                         *
18  *   You should have received a copy of the GNU General Public License     *
19  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
20  ***************************************************************************/
21
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25
26 /* project specific includes */
27 #include <jtag/interface.h>
28 #include <transport/transport.h>
29 #include <helper/time_support.h>
30
31 #include <jtag/hla/hla_layout.h>
32 #include <jtag/hla/hla_tcl.h>
33 #include <jtag/hla/hla_transport.h>
34 #include <jtag/hla/hla_interface.h>
35
36 static int hl_layout_open(struct hl_interface_s *adapter)
37 {
38         int res;
39
40         LOG_DEBUG("hl_layout_open");
41
42         adapter->handle = NULL;
43
44         res = adapter->layout->api->open(&adapter->param, &adapter->handle);
45
46         if (res != ERROR_OK) {
47                 LOG_DEBUG("failed");
48                 return res;
49         }
50
51         return ERROR_OK;
52 }
53
54 static int hl_layout_close(struct hl_interface_s *adapter)
55 {
56         return ERROR_OK;
57 }
58
59 static const struct hl_layout hl_layouts[] = {
60 #if BUILD_HLADAPTER_STLINK
61         {
62          .name = "stlink",
63          .open = hl_layout_open,
64          .close = hl_layout_close,
65          .api = &stlink_usb_layout_api,
66          },
67 #endif
68 #if BUILD_HLADAPTER_ICDI
69         {
70          .name = "ti-icdi",
71          .open = hl_layout_open,
72          .close = hl_layout_close,
73          .api = &icdi_usb_layout_api,
74         },
75 #endif
76         {.name = NULL, /* END OF TABLE */ },
77 };
78
79 /** */
80 const struct hl_layout *hl_layout_get_list(void)
81 {
82         return hl_layouts;
83 }
84
85 int hl_layout_init(struct hl_interface_s *adapter)
86 {
87         LOG_DEBUG("hl_layout_init");
88
89         if (adapter->layout == NULL) {
90                 LOG_ERROR("no layout specified");
91                 return ERROR_FAIL;
92         }
93         return ERROR_OK;
94 }