d0ae18eab1751a85205d83d2a8f89e9c8473c70d
[fw/openocd] / src / jtag / swim.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 /*
4  * Copyright (C) 2020 by Antonio Borneo <borneo.antonio@gmail.com
5  */
6
7 /**
8  * @file
9  * This file implements support for STMicroelectronics debug protocol SWIM
10  * (Single Wire Interface Module).
11  */
12
13 #ifndef OPENOCD_JTAG_SWIM_H
14 #define OPENOCD_JTAG_SWIM_H
15
16 struct swim_driver {
17         /**
18          * Send SRST (system reset) command to target.
19          *
20          * @return ERROR_OK on success, else a fault code.
21          */
22         int (*srst)(void);
23
24         /**
25          * Read target memory through ROTF (read on-the-fly) command.
26          *
27          * @param addr Start address to read data from target memory.
28          * @param size Size in bytes of data units, 1, 2 or 4.
29          * @param count Number of units (size units, not bytes) to read.
30          * @param buffer Data buffer to receive data.
31          * @return ERROR_OK on success, else a fault code.
32          */
33         int (*read_mem)(uint32_t addr, uint32_t size, uint32_t count,
34                                         uint8_t *buffer);
35
36         /**
37          * Write target memory through WOTF (write on-the-fly) command.
38          *
39          * @param addr Start address to write data to target memory.
40          * @param size Size in bytes of data units, 1, 2 or 4.
41          * @param count Number of units (size units, not bytes) to write.
42          * @param buffer Data buffer to write.
43          * @return ERROR_OK on success, else a fault code.
44          */
45         int (*write_mem)(uint32_t addr, uint32_t size, uint32_t count,
46                                          const uint8_t *buffer);
47
48         /**
49          * Reconnect to the target.
50          * Should be reworked to be more generic and not linked to current
51          * implementation in stlink driver.
52          *
53          * @return ERROR_OK on success, else a fault code.
54          */
55         int (*reconnect)(void);
56 };
57
58 int swim_system_reset(void);
59 int swim_read_mem(uint32_t addr, uint32_t size, uint32_t count,
60                                   uint8_t *buffer);
61 int swim_write_mem(uint32_t addr, uint32_t size, uint32_t count,
62                                    const uint8_t *buffer);
63 int swim_reconnect(void);
64
65 #endif /* OPENOCD_JTAG_SWIM_H */