1 /***************************************************************************
2 * Copyright (C) 2018 by Square, Inc. *
3 * Steven Stallion <stallion@squareup.com> *
4 * James Zhao <hjz@squareup.com> *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 ***************************************************************************/
20 #ifndef OPENOCD_TARGET_ESIRISC_JTAG_H
21 #define OPENOCD_TARGET_ESIRISC_JTAG_H
23 #include <helper/types.h>
24 #include <jtag/jtag.h>
26 /* TAP Instructions */
27 #define INSTR_IDCODE 0x8
28 #define INSTR_DEBUG 0x9
29 #define INSTR_BYPASS 0xf
30 #define INSTR_LENGTH 4
32 /* eSi-Debug Commands */
33 #define DEBUG_NOP 0x00
34 #define DEBUG_READ_BYTE 0x10
35 #define DEBUG_READ_HWORD 0x20
36 #define DEBUG_READ_WORD 0x30
37 #define DEBUG_WRITE_BYTE 0x60
38 #define DEBUG_WRITE_HWORD 0x70
39 #define DEBUG_WRITE_WORD 0x80
40 #define DEBUG_READ_REG 0xb0
41 #define DEBUG_WRITE_REG 0xc0
42 #define DEBUG_READ_CSR 0xd0
43 #define DEBUG_WRITE_CSR 0xe0
44 #define DEBUG_ENABLE_DEBUG 0xf0
45 #define DEBUG_DISABLE_DEBUG 0xf2
46 #define DEBUG_ASSERT_RESET 0xf4
47 #define DEBUG_DEASSERT_RESET 0xf6
48 #define DEBUG_BREAK 0xf8
49 #define DEBUG_CONTINUE 0xfa
50 #define DEBUG_FLUSH_CACHES 0xfc
53 #define EID_OVERFLOW 0x3d
54 #define EID_CANT_DEBUG 0x3e
58 #define STUFF_MARKER 0x55
66 bool esirisc_jtag_is_debug_active(struct esirisc_jtag *jtag_info);
67 bool esirisc_jtag_is_stopped(struct esirisc_jtag *jtag_info);
68 uint8_t esirisc_jtag_get_eid(struct esirisc_jtag *jtag_info);
70 int esirisc_jtag_read_byte(struct esirisc_jtag *jtag_info,
71 uint32_t address, uint8_t *data);
72 int esirisc_jtag_read_hword(struct esirisc_jtag *jtag_info,
73 uint32_t address, uint16_t *data);
74 int esirisc_jtag_read_word(struct esirisc_jtag *jtag_info,
75 uint32_t address, uint32_t *data);
77 int esirisc_jtag_write_byte(struct esirisc_jtag *jtag_info,
78 uint32_t address, uint8_t data);
79 int esirisc_jtag_write_hword(struct esirisc_jtag *jtag_info,
80 uint32_t address, uint16_t data);
81 int esirisc_jtag_write_word(struct esirisc_jtag *jtag_info,
82 uint32_t address, uint32_t data);
84 int esirisc_jtag_read_reg(struct esirisc_jtag *jtag_info,
85 uint8_t reg, uint32_t *data);
86 int esirisc_jtag_write_reg(struct esirisc_jtag *jtag_info,
87 uint8_t reg, uint32_t data);
89 int esirisc_jtag_read_csr(struct esirisc_jtag *jtag_info,
90 uint8_t bank, uint8_t csr, uint32_t *data);
91 int esirisc_jtag_write_csr(struct esirisc_jtag *jtag_info,
92 uint8_t bank, uint8_t csr, uint32_t data);
94 int esirisc_jtag_enable_debug(struct esirisc_jtag *jtag_info);
95 int esirisc_jtag_disable_debug(struct esirisc_jtag *jtag_info);
97 int esirisc_jtag_assert_reset(struct esirisc_jtag *jtag_info);
98 int esirisc_jtag_deassert_reset(struct esirisc_jtag *jtag_info);
100 int esirisc_jtag_break(struct esirisc_jtag *jtag_info);
101 int esirisc_jtag_continue(struct esirisc_jtag *jtag_info);
103 int esirisc_jtag_flush_caches(struct esirisc_jtag *jtag_info);
105 #endif /* OPENOCD_TARGET_ESIRISC_JTAG_H */