e989f66599a50a3a5c1264fa4ede4bb9992bb040
[fw/openocd] / src / jtag / hla / hla_layout.h
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, write to the                         *
20  *   Free Software Foundation, Inc.,                                       *
21  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.           *
22  ***************************************************************************/
23
24 #ifndef _HL_LAYOUT_H
25 #define _HL_LAYOUT_H
26
27 /** */
28 struct hl_interface_s;
29 struct hl_interface_param_s;
30
31 /** */
32 extern struct hl_layout_api_s stlink_usb_layout_api;
33 extern struct hl_layout_api_s icdi_usb_layout_api;
34
35 /** */
36 struct hl_layout_api_s {
37         /** */
38         int (*open) (struct hl_interface_param_s *param, void **handle);
39         /** */
40         int (*close) (void *handle);
41         /** */
42         int (*reset) (void *handle);
43         /** */
44         int (*assert_srst) (void *handle, int srst);
45         /** */
46         int (*run) (void *handle);
47         /** */
48         int (*halt) (void *handle);
49         /** */
50         int (*step) (void *handle);
51         /** */
52         int (*read_regs) (void *handle);
53         /** */
54         int (*read_reg) (void *handle, int num, uint32_t *val);
55         /** */
56         int (*write_reg) (void *handle, int num, uint32_t val);
57         /** */
58         int (*read_mem) (void *handle, uint32_t addr, uint32_t size,
59                         uint32_t count, uint8_t *buffer);
60         /** */
61         int (*write_mem) (void *handle, uint32_t addr, uint32_t size,
62                         uint32_t count, const uint8_t *buffer);
63         /** */
64         int (*write_debug_reg) (void *handle, uint32_t addr, uint32_t val);
65         /**
66          * Read the idcode of the target connected to the adapter
67          *
68          * If the adapter doesn't support idcode retrieval, this callback should
69          * store 0 to indicate a wildcard match.
70          *
71          * @param handle A pointer to the device-specific handle
72          * @param idcode Storage for the detected idcode
73          * @returns ERROR_OK on success, or an error code on failure.
74          */
75         int (*idcode) (void *handle, uint32_t *idcode);
76         /** */
77         int (*override_target) (const char *targetname);
78         /** */
79         int (*custom_command) (void *handle, const char *command);
80         /** */
81         int (*speed)(void *handle, int khz, bool query);
82         /** */
83         enum target_state (*state) (void *fd);
84 };
85
86 /** */
87 struct hl_layout {
88         /** */
89         char *name;
90         /** */
91         int (*open) (struct hl_interface_s *adapter);
92         /** */
93         int (*close) (struct hl_interface_s *adapter);
94         /** */
95         struct hl_layout_api_s *api;
96 };
97
98 /** */
99 const struct hl_layout *hl_layout_get_list(void);
100 /** */
101 int hl_layout_init(struct hl_interface_s *adapter);
102
103 #endif /* _HL_LAYOUT_H */