OpenOCD
esirisc_jtag.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 /***************************************************************************
4  * Copyright (C) 2018 by Square, Inc. *
5  * Steven Stallion <stallion@squareup.com> *
6  * James Zhao <hjz@squareup.com> *
7  ***************************************************************************/
8 
9 #ifndef OPENOCD_TARGET_ESIRISC_JTAG_H
10 #define OPENOCD_TARGET_ESIRISC_JTAG_H
11 
12 #include <helper/types.h>
13 #include <jtag/jtag.h>
14 
15 /* TAP Instructions */
16 #define INSTR_IDCODE 0x8
17 #define INSTR_DEBUG 0x9
18 #define INSTR_BYPASS 0xf
19 #define INSTR_LENGTH 4
20 
21 /* eSi-Debug Commands */
22 #define DEBUG_NOP 0x00
23 #define DEBUG_READ_BYTE 0x10
24 #define DEBUG_READ_HWORD 0x20
25 #define DEBUG_READ_WORD 0x30
26 #define DEBUG_WRITE_BYTE 0x60
27 #define DEBUG_WRITE_HWORD 0x70
28 #define DEBUG_WRITE_WORD 0x80
29 #define DEBUG_READ_REG 0xb0
30 #define DEBUG_WRITE_REG 0xc0
31 #define DEBUG_READ_CSR 0xd0
32 #define DEBUG_WRITE_CSR 0xe0
33 #define DEBUG_ENABLE_DEBUG 0xf0
34 #define DEBUG_DISABLE_DEBUG 0xf2
35 #define DEBUG_ASSERT_RESET 0xf4
36 #define DEBUG_DEASSERT_RESET 0xf6
37 #define DEBUG_BREAK 0xf8
38 #define DEBUG_CONTINUE 0xfa
39 #define DEBUG_FLUSH_CACHES 0xfc
40 
41 /* Exception IDs */
42 #define EID_OVERFLOW 0x3d
43 #define EID_CANT_DEBUG 0x3e
44 #define EID_NONE 0x3f
45 
46 /* Byte Stuffing */
47 #define STUFF_MARKER 0x55
48 #define PAD_BYTE 0xaa
49 
50 struct esirisc_jtag {
51  struct jtag_tap *tap;
52  uint8_t status;
53 };
54 
55 bool esirisc_jtag_is_debug_active(struct esirisc_jtag *jtag_info);
56 bool esirisc_jtag_is_stopped(struct esirisc_jtag *jtag_info);
57 uint8_t esirisc_jtag_get_eid(struct esirisc_jtag *jtag_info);
58 
59 int esirisc_jtag_read_byte(struct esirisc_jtag *jtag_info,
60  uint32_t address, uint8_t *data);
61 int esirisc_jtag_read_hword(struct esirisc_jtag *jtag_info,
62  uint32_t address, uint16_t *data);
63 int esirisc_jtag_read_word(struct esirisc_jtag *jtag_info,
64  uint32_t address, uint32_t *data);
65 
66 int esirisc_jtag_write_byte(struct esirisc_jtag *jtag_info,
67  uint32_t address, uint8_t data);
68 int esirisc_jtag_write_hword(struct esirisc_jtag *jtag_info,
69  uint32_t address, uint16_t data);
70 int esirisc_jtag_write_word(struct esirisc_jtag *jtag_info,
71  uint32_t address, uint32_t data);
72 
73 int esirisc_jtag_read_reg(struct esirisc_jtag *jtag_info,
74  uint8_t reg, uint32_t *data);
75 int esirisc_jtag_write_reg(struct esirisc_jtag *jtag_info,
76  uint8_t reg, uint32_t data);
77 
78 int esirisc_jtag_read_csr(struct esirisc_jtag *jtag_info,
79  uint8_t bank, uint8_t csr, uint32_t *data);
80 int esirisc_jtag_write_csr(struct esirisc_jtag *jtag_info,
81  uint8_t bank, uint8_t csr, uint32_t data);
82 
83 int esirisc_jtag_enable_debug(struct esirisc_jtag *jtag_info);
84 int esirisc_jtag_disable_debug(struct esirisc_jtag *jtag_info);
85 
86 int esirisc_jtag_assert_reset(struct esirisc_jtag *jtag_info);
87 int esirisc_jtag_deassert_reset(struct esirisc_jtag *jtag_info);
88 
89 int esirisc_jtag_break(struct esirisc_jtag *jtag_info);
90 int esirisc_jtag_continue(struct esirisc_jtag *jtag_info);
91 
92 int esirisc_jtag_flush_caches(struct esirisc_jtag *jtag_info);
93 
94 #endif /* OPENOCD_TARGET_ESIRISC_JTAG_H */
uint8_t csr
Definition: esirisc.c:136
uint8_t bank
Definition: esirisc.c:135
int esirisc_jtag_read_hword(struct esirisc_jtag *jtag_info, uint32_t address, uint16_t *data)
Definition: esirisc_jtag.c:265
int esirisc_jtag_read_csr(struct esirisc_jtag *jtag_info, uint8_t bank, uint8_t csr, uint32_t *data)
Definition: esirisc_jtag.c:429
int esirisc_jtag_deassert_reset(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:503
int esirisc_jtag_read_reg(struct esirisc_jtag *jtag_info, uint8_t reg, uint32_t *data)
Definition: esirisc_jtag.c:383
int esirisc_jtag_read_byte(struct esirisc_jtag *jtag_info, uint32_t address, uint8_t *data)
Definition: esirisc_jtag.c:237
int esirisc_jtag_write_byte(struct esirisc_jtag *jtag_info, uint32_t address, uint8_t data)
Definition: esirisc_jtag.c:321
int esirisc_jtag_continue(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:513
uint8_t esirisc_jtag_get_eid(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:224
int esirisc_jtag_flush_caches(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:518
bool esirisc_jtag_is_debug_active(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:214
int esirisc_jtag_disable_debug(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:493
int esirisc_jtag_write_csr(struct esirisc_jtag *jtag_info, uint8_t bank, uint8_t csr, uint32_t data)
Definition: esirisc_jtag.c:457
int esirisc_jtag_write_reg(struct esirisc_jtag *jtag_info, uint8_t reg, uint32_t data)
Definition: esirisc_jtag.c:409
int esirisc_jtag_read_word(struct esirisc_jtag *jtag_info, uint32_t address, uint32_t *data)
Definition: esirisc_jtag.c:293
bool esirisc_jtag_is_stopped(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:219
int esirisc_jtag_assert_reset(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:498
int esirisc_jtag_write_word(struct esirisc_jtag *jtag_info, uint32_t address, uint32_t data)
Definition: esirisc_jtag.c:362
int esirisc_jtag_write_hword(struct esirisc_jtag *jtag_info, uint32_t address, uint16_t data)
Definition: esirisc_jtag.c:341
int esirisc_jtag_enable_debug(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:488
int esirisc_jtag_break(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:508
The JTAG interface can be implemented with a software or hardware fifo.
struct jtag_tap * tap
Definition: esirisc_jtag.h:51
uint8_t status
Definition: esirisc_jtag.h:52
Definition: jtag.h:101
Definition: register.h:111